@@ -0,0 +1,2958 @@
+/*%0A * Copyright 2018-present Open Networking Foundation%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.onosproject.openstacknetworking.cli;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.fasterxml.jackson.databind.node.ArrayNode;%0Aimport com.google.common.collect.Lists;%0Aimport org.apache.karaf.shell.api.action.Command;%0Aimport org.apache.karaf.shell.api.action.lifecycle.Service;%0Aimport org.onosproject.cli.AbstractShellCommand;%0Aimport org.onosproject.openstacknetworking.api.OpenstackRouterService;%0Aimport org.openstack4j.model.network.RouterInterface;%0Aimport org.openstack4j.openstack.networking.domain.NeutronRouter;%0A%0Aimport java.util.List;%0A%0Aimport static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.modelEntityToJson;%0Aimport static org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.prettyJson;%0A%0A/**%0A * Lists Openstack router interfaces.%0A */%0A@Service%0A@Command(scope = %22onos%22, name = %22openstack-router-interfaces%22,%0A        description = %22Lists all OpenStack routers interfaces%22)%0Apublic class OpenstackRouterInterfaceListCommand extends AbstractShellCommand %7B%0A    private static final String FORMAT = %22%25-40s%25-40s%25-40s%25-40s%25-40s%22;%0A%0A    private final OpenstackRouterService routerService =%0A            AbstractShellCommand.get(OpenstackRouterService.class);%0A%0A    @Override%0A    protected void doExecute() %7B%0A        List%3CRouterInterface%3E routerInterfaces =%0A                Lists.newArrayList(routerService.routerInterfaces());%0A%0A        if (outputJson()) %7B%0A            print(%22%25s%22, json(routerInterfaces));%0A        %7D else %7B%0A            print(FORMAT, %22ID%22, %22RouterName%22, %22SubnetID%22, %22PortID%22, %22TenantID%22);%0A            for (RouterInterface routerInterface: routerInterfaces) %7B%0A                print(FORMAT, routerInterface.getId(),%0A                        routerService.router(routerInterface.getId()),%0A                        routerInterface.getSubnetId(),%0A                        routerInterface.getPortId(),%0A                        routerInterface.getTenantId());%0A            %7D%0A        %7D%0A    %7D%0A%0A    private String json(List%3CRouterInterface%3E routerInterfaces) %7B%0A        ObjectMapper mapper = new ObjectMapper();%0A        ArrayNode result = mapper.createArrayNode();%0A        for (RouterInterface routerInterface: routerInterfaces) %7B%0A            result.add(modelEntityToJson(routerInterface, NeutronRouter.class));%0A        %7D%0A        return prettyJson(mapper, result.toString());%0A    %7D%0A%7D

Add a CLI to list up openstack router interfaces