Search in sources :

Example 1 with NeutronPortsNorthboundAction

use of org.apache.cloudstack.network.opendaylight.api.resources.NeutronPortsNorthboundAction in project cloudstack by apache.

the class NeutronRestApiIT method neutronListAllPorts.

@Test
public void neutronListAllPorts() throws NeutronRestApiException {
    URL url;
    try {
        url = new URL("http://178.237.34.233:8080");
        NeutronPortsNorthboundAction neutron = new NeutronPortsNorthboundAction(url, "admin", "admin");
        NeutronPortsList<NeutronPortWrapper> results = neutron.listAllPorts();
        Assert.assertNotNull(results);
        List<NeutronPortWrapper> networks = results.getPorts();
        Assert.assertNotNull(networks);
    } catch (MalformedURLException e) {
        Assert.fail("Should not fail here.");
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NeutronPortsNorthboundAction(org.apache.cloudstack.network.opendaylight.api.resources.NeutronPortsNorthboundAction) NeutronPortWrapper(org.apache.cloudstack.network.opendaylight.api.model.NeutronPortWrapper) URL(java.net.URL) Test(org.junit.Test)

Example 2 with NeutronPortsNorthboundAction

use of org.apache.cloudstack.network.opendaylight.api.resources.NeutronPortsNorthboundAction in project cloudstack by apache.

the class OpenDaylightControllerResource method executeRequest.

private Answer executeRequest(ConfigurePortCommand cmd) {
    NeutronPortsNorthboundAction configurePort = new NeutronPortsNorthboundAction(controllerUrl, controllerUsername, controllerPassword);
    NeutronPort newPort = new NeutronPort();
    // Configuration from the command
    newPort.setId(cmd.getPortId());
    newPort.setTenantId(cmd.getTennantId());
    newPort.setAdminStateUp(true);
    newPort.setName(cmd.getPortId().toString());
    newPort.setNetworkId(cmd.getNetworkId());
    newPort.setMacAddress(cmd.getMacAddress());
    newPort.setDeviceId(UUID.randomUUID());
    // Static valus
    newPort.setStatus("ACTIVE");
    newPort.setFixedIps(Collections.<String>emptyList());
    NeutronPortWrapper portWrapper = new NeutronPortWrapper();
    portWrapper.setPort(newPort);
    try {
        portWrapper = configurePort.createNeutronPort(portWrapper);
    } catch (NeutronRestApiException e) {
        s_logger.error("createPortCommand failed", e);
        return new ConfigurePortAnswer(cmd, e);
    }
    return new ConfigurePortAnswer(cmd, true, "Port " + portWrapper.getPort().getId().toString() + " created");
}
Also used : NeutronPort(org.apache.cloudstack.network.opendaylight.api.model.NeutronPort) NeutronPortsNorthboundAction(org.apache.cloudstack.network.opendaylight.api.resources.NeutronPortsNorthboundAction) NeutronRestApiException(org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException) ConfigurePortAnswer(org.apache.cloudstack.network.opendaylight.agent.responses.ConfigurePortAnswer) NeutronPortWrapper(org.apache.cloudstack.network.opendaylight.api.model.NeutronPortWrapper)

Aggregations

NeutronPortWrapper (org.apache.cloudstack.network.opendaylight.api.model.NeutronPortWrapper)2 NeutronPortsNorthboundAction (org.apache.cloudstack.network.opendaylight.api.resources.NeutronPortsNorthboundAction)2 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 ConfigurePortAnswer (org.apache.cloudstack.network.opendaylight.agent.responses.ConfigurePortAnswer)1 NeutronRestApiException (org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException)1 NeutronPort (org.apache.cloudstack.network.opendaylight.api.model.NeutronPort)1 Test (org.junit.Test)1