Search in sources :

Example 1 with NeutronNodesNorthboundAction

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

the class OpenDaylightControllerResource method executeRequest.

private Answer executeRequest(AddHypervisorCommand cmd) {
    NeutronNodesNorthboundAction nodeActions = new NeutronNodesNorthboundAction(controllerUrl, controllerUsername, controllerPassword);
    try {
        NeutronNodesList<NeutronNodeWrapper> nodes = nodeActions.listAllNodes();
        if (nodes.getNodes() != null) {
            for (NeutronNodeWrapper nodeWrapper : nodes.getNodes()) {
                NeutronNode node = nodeWrapper.getNode();
                if (node.getId().equals(cmd.getHostId())) {
                    return new AddHypervisorAnswer(cmd, true, "Hypervisor already connected");
                }
            }
        }
        // Not found in the existing node list, add it
        nodeActions.updateNeutronNodeV2("OVS", cmd.getHostId(), cmd.getIpAddress(), 6640);
    } catch (NeutronRestApiException e) {
        s_logger.error("Call to OpenDaylight failed", e);
        return new AddHypervisorAnswer(cmd, e);
    }
    return new AddHypervisorAnswer(cmd, true, "Hypervisor " + cmd.getHostId() + " added");
}
Also used : NeutronNodeWrapper(org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper) NeutronNode(org.apache.cloudstack.network.opendaylight.api.model.NeutronNode) NeutronNodesNorthboundAction(org.apache.cloudstack.network.opendaylight.api.resources.NeutronNodesNorthboundAction) NeutronRestApiException(org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException) AddHypervisorAnswer(org.apache.cloudstack.network.opendaylight.agent.responses.AddHypervisorAnswer)

Example 2 with NeutronNodesNorthboundAction

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

the class NeutronRestApiMock method neutronNodesFail.

@Test(expected = NeutronRestApiException.class)
public void neutronNodesFail() throws NeutronRestApiException {
    URL url;
    try {
        url = new URL("http://localhost:8080");
        NeutronNodesNorthboundAction neutron = new NeutronNodesNorthboundAction(url, "admin", "admin");
        neutron.listAllNodes();
    } catch (MalformedURLException e) {
        Assert.fail("Should not fail here.");
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NeutronNodesNorthboundAction(org.apache.cloudstack.network.opendaylight.api.resources.NeutronNodesNorthboundAction) URL(java.net.URL) Test(org.junit.Test)

Example 3 with NeutronNodesNorthboundAction

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

the class NeutronRestApiIT method neutronListAllNodes.

@Test
public void neutronListAllNodes() throws NeutronRestApiException {
    URL url;
    try {
        url = new URL("http://178.237.34.233:8080");
        NeutronNodesNorthboundAction neutron = new NeutronNodesNorthboundAction(url, "admin", "admin");
        NeutronNodesList<NeutronNodeWrapper> results = neutron.listAllNodes();
        Assert.assertNotNull(results);
    } catch (MalformedURLException e) {
        Assert.fail("Should not fail here.");
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NeutronNodeWrapper(org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper) NeutronNodesNorthboundAction(org.apache.cloudstack.network.opendaylight.api.resources.NeutronNodesNorthboundAction) URL(java.net.URL) Test(org.junit.Test)

Example 4 with NeutronNodesNorthboundAction

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

the class NeutronRestApiMock method neutronHTTPPutUriMethod.

/*
     * Test fails because there is no controller. It's used only to test that
     * the HTTP methods are correct.
     */
@Test(expected = NeutronRestApiException.class)
public void neutronHTTPPutUriMethod() throws NeutronRestApiException {
    URL url;
    try {
        url = new URL("http://localhost:8080");
        NeutronNodesNorthboundAction neutron = new NeutronNodesNorthboundAction(url, "admin", "admin");
        neutron.updateNeutronNodeV1("ca31aa7f-84c7-416d-bc00-1f84927367e0", "1.1.1.1.", 6400);
    } catch (MalformedURLException e) {
        Assert.fail("Should not fail here.");
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) NeutronNodesNorthboundAction(org.apache.cloudstack.network.opendaylight.api.resources.NeutronNodesNorthboundAction) URL(java.net.URL) Test(org.junit.Test)

Aggregations

NeutronNodesNorthboundAction (org.apache.cloudstack.network.opendaylight.api.resources.NeutronNodesNorthboundAction)4 MalformedURLException (java.net.MalformedURLException)3 URL (java.net.URL)3 Test (org.junit.Test)3 NeutronNodeWrapper (org.apache.cloudstack.network.opendaylight.api.model.NeutronNodeWrapper)2 AddHypervisorAnswer (org.apache.cloudstack.network.opendaylight.agent.responses.AddHypervisorAnswer)1 NeutronRestApiException (org.apache.cloudstack.network.opendaylight.api.NeutronRestApiException)1 NeutronNode (org.apache.cloudstack.network.opendaylight.api.model.NeutronNode)1