Search in sources :

Example 1 with PCISLOT

use of org.onosproject.openstacknetworking.api.Constants.PCISLOT in project onos by opennetworkinglab.

the class OpenstackDirectPortListCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackNetworkService service = get(OpenstackNetworkService.class);
    List<Port> ports = service.ports().stream().filter(port -> port.getvNicType().equals(DIRECT)).collect(Collectors.toList());
    print(FORMAT, "ID", "Network", "MAC", "FIXED IPs", "PCI Slot", "Interface");
    for (Port port : ports) {
        List<String> fixedIps = port.getFixedIps().stream().map(IP::getIpAddress).collect(Collectors.toList());
        Network osNet = service.network(port.getNetworkId());
        if (port.getVifType().equals(UNBOUND)) {
            print(FORMAT, port.getId(), deriveResourceName(osNet), port.getMacAddress(), fixedIps.isEmpty() ? "" : fixedIps, UNBOUND, UNBOUND);
        } else {
            print(FORMAT, port.getId(), deriveResourceName(osNet), port.getMacAddress(), fixedIps.isEmpty() ? "" : fixedIps, port.getProfile().containsKey(PCISLOT) ? port.getProfile().get(PCISLOT).toString() : "", getIntfNameFromPciAddress(port));
        }
    }
}
Also used : Network(org.openstack4j.model.network.Network) OpenstackNetworkingUtil.getIntfNameFromPciAddress(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress) PCISLOT(org.onosproject.openstacknetworking.api.Constants.PCISLOT) Collectors(java.util.stream.Collectors) AbstractShellCommand.get(org.onosproject.cli.AbstractShellCommand.get) Command(org.apache.karaf.shell.api.action.Command) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) List(java.util.List) DIRECT(org.onosproject.openstacknetworking.api.Constants.DIRECT) Service(org.apache.karaf.shell.api.action.lifecycle.Service) IP(org.openstack4j.model.network.IP) OpenstackNetworkingUtil.deriveResourceName(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName) Port(org.openstack4j.model.network.Port) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Port(org.openstack4j.model.network.Port) Network(org.openstack4j.model.network.Network)

Aggregations

List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Command (org.apache.karaf.shell.api.action.Command)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)1 AbstractShellCommand.get (org.onosproject.cli.AbstractShellCommand.get)1 DIRECT (org.onosproject.openstacknetworking.api.Constants.DIRECT)1 PCISLOT (org.onosproject.openstacknetworking.api.Constants.PCISLOT)1 OpenstackNetworkService (org.onosproject.openstacknetworking.api.OpenstackNetworkService)1 OpenstackNetworkingUtil.deriveResourceName (org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.deriveResourceName)1 OpenstackNetworkingUtil.getIntfNameFromPciAddress (org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress)1 IP (org.openstack4j.model.network.IP)1 Network (org.openstack4j.model.network.Network)1 Port (org.openstack4j.model.network.Port)1