blob: 3692c572b6ba25960041feebee65e956305b2f6d [file] [log] [blame]
Thomas Vachuska5ca0f7a2017-11-28 16:27:22 -08001/*
2 * Copyright 2015-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.cli.net;
17
18import org.apache.karaf.shell.commands.Command;
19import org.onosproject.cli.AbstractShellCommand;
20import org.onosproject.net.driver.Driver;
21import org.onosproject.net.driver.DriverAdminService;
22import org.onosproject.net.driver.DriverProvider;
23
24import java.util.stream.Collectors;
25
26/**
27 * Lists device drivers.
28 */
29@Command(scope = "onos", name = "driver-providers",
30 description = "Lists device driver providers")
31public class DriverProvidersListCommand extends AbstractShellCommand {
32
33 private static final String FMT = "provider=%s, drivers=%s";
34
35 @Override
36 protected void execute() {
37 DriverAdminService service = get(DriverAdminService.class);
38 service.getProviders().forEach(this::printDriverProvider);
39 }
40
41 private void printDriverProvider(DriverProvider provider) {
42 print(FMT, provider.getClass().getName(),
43 provider.getDrivers().stream()
44 .map(Driver::name)
45 .collect(Collectors.toSet()));
46 }
47
48}