blob: 0667f2867cb0b689c0ecac9a00b3eed3c72d55dc [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
Ray Milkeyd84f89b2018-08-17 14:54:17 -070018import org.apache.karaf.shell.api.action.Command;
19import org.apache.karaf.shell.api.action.lifecycle.Service;
Thomas Vachuska5ca0f7a2017-11-28 16:27:22 -080020import org.onosproject.cli.AbstractShellCommand;
21import org.onosproject.net.driver.Driver;
22import org.onosproject.net.driver.DriverAdminService;
23import org.onosproject.net.driver.DriverProvider;
24
25import java.util.stream.Collectors;
26
27/**
28 * Lists device drivers.
29 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070030@Service
Thomas Vachuska5ca0f7a2017-11-28 16:27:22 -080031@Command(scope = "onos", name = "driver-providers",
32 description = "Lists device driver providers")
33public class DriverProvidersListCommand extends AbstractShellCommand {
34
35 private static final String FMT = "provider=%s, drivers=%s";
36
37 @Override
Ray Milkeyd84f89b2018-08-17 14:54:17 -070038 protected void doExecute() {
Thomas Vachuska5ca0f7a2017-11-28 16:27:22 -080039 DriverAdminService service = get(DriverAdminService.class);
40 service.getProviders().forEach(this::printDriverProvider);
41 }
42
43 private void printDriverProvider(DriverProvider provider) {
44 print(FMT, provider.getClass().getName(),
45 provider.getDrivers().stream()
46 .map(Driver::name)
47 .collect(Collectors.toSet()));
48 }
49
50}