Search in sources :

Example 1 with UNSUPPORTED_VENDOR

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

the class OpenstackDirectPortAddCommand method doExecute.

@Override
protected void doExecute() {
    OpenstackNetworkService osNetService = get(OpenstackNetworkService.class);
    OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
    DeviceService deviceService = get(DeviceService.class);
    Port port = osNetService.port(portId);
    if (port == null) {
        log.error("There's no port that matches the port ID {}", portId);
        return;
    }
    Optional<OpenstackNode> osNode = osNodeService.completeNodes(COMPUTE).stream().filter(node -> node.hostname().equals(port.getHostId())).findAny();
    if (!osNode.isPresent()) {
        log.error("There's no openstackNode that matches hostname {}", port.getHostId());
        return;
    }
    String intfName = getIntfNameFromPciAddress(port);
    if (intfName == null) {
        log.error("Failed to retrieve interface name from a port {}", portId);
        return;
    } else if (intfName.equals(UNSUPPORTED_VENDOR)) {
        return;
    }
    if (OpenstackNetworkingUtil.hasIntfAleadyInDevice(osNode.get().intgBridge(), intfName, deviceService)) {
        log.error("Interface {} is already added to the device {}", osNode.get().intgBridge());
        return;
    }
    log.info("Adding interface {} to the device {}..", intfName, osNode.get().intgBridge());
    osNodeService.addVfPort(osNode.get(), intfName);
}
Also used : UNSUPPORTED_VENDOR(org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode) OpenstackNetworkingUtil.getIntfNameFromPciAddress(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress) COMPUTE(org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE) OpenstackNetworkingUtil(org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil) DeviceService(org.onosproject.net.device.DeviceService) Argument(org.apache.karaf.shell.api.action.Argument) 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) Service(org.apache.karaf.shell.api.action.lifecycle.Service) Optional(java.util.Optional) Completion(org.apache.karaf.shell.api.action.Completion) Port(org.openstack4j.model.network.Port) OpenstackNodeService(org.onosproject.openstacknode.api.OpenstackNodeService) OpenstackNetworkService(org.onosproject.openstacknetworking.api.OpenstackNetworkService) Port(org.openstack4j.model.network.Port) DeviceService(org.onosproject.net.device.DeviceService) OpenstackNode(org.onosproject.openstacknode.api.OpenstackNode)

Aggregations

Optional (java.util.Optional)1 Argument (org.apache.karaf.shell.api.action.Argument)1 Command (org.apache.karaf.shell.api.action.Command)1 Completion (org.apache.karaf.shell.api.action.Completion)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 DeviceService (org.onosproject.net.device.DeviceService)1 UNSUPPORTED_VENDOR (org.onosproject.openstacknetworking.api.Constants.UNSUPPORTED_VENDOR)1 OpenstackNetworkService (org.onosproject.openstacknetworking.api.OpenstackNetworkService)1 OpenstackNetworkingUtil (org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil)1 OpenstackNetworkingUtil.getIntfNameFromPciAddress (org.onosproject.openstacknetworking.util.OpenstackNetworkingUtil.getIntfNameFromPciAddress)1 OpenstackNode (org.onosproject.openstacknode.api.OpenstackNode)1 COMPUTE (org.onosproject.openstacknode.api.OpenstackNode.NodeType.COMPUTE)1 OpenstackNodeService (org.onosproject.openstacknode.api.OpenstackNodeService)1 Port (org.openstack4j.model.network.Port)1