Package com.cloud.network.nicira

Examples of com.cloud.network.nicira.LogicalSwitch


    @Test
    public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
        _resource.configure("NiciraNvpResource", _parameters);

        LogicalSwitch ls = mock(LogicalSwitch.class);
        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenReturn(ls);

        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
        assertTrue(clsa.getResult());
View Full Code Here


    @Test
    public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
        _resource.configure("NiciraNvpResource", _parameters);

        LogicalSwitch ls = mock(LogicalSwitch.class);
        when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
        when(_nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException());

        CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String)_parameters.get("guid"), "stt", "loigicalswitch","owner");
        CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) _resource.executeRequest(clsc);
        assertFalse(clsa.getResult());
View Full Code Here

    @Override
    public void setAgentControl(IAgentControl agentControl) {
    }

    private Answer executeRequest(CreateLogicalSwitchCommand cmd, int numRetries) {
        LogicalSwitch logicalSwitch = new LogicalSwitch();
        logicalSwitch.setDisplay_name(truncate("lswitch-" + cmd.getName(), 40));
        logicalSwitch.setPort_isolation_enabled(false);

        // Set transport binding
        List<TransportZoneBinding> ltzb = new ArrayList<TransportZoneBinding>();
        ltzb.add(new TransportZoneBinding(cmd.getTransportUuid(), cmd.getTransportType()));
        logicalSwitch.setTransport_zones(ltzb);

        // Tags set to scope cs_account and account name
        List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
        tags.add(new NiciraNvpTag("cs_account",cmd.getOwnerName()));
        logicalSwitch.setTags(tags);

        try {
            logicalSwitch = _niciraNvpApi.createLogicalSwitch(logicalSwitch);
            return new CreateLogicalSwitchAnswer(cmd, true, "Logicalswitch " + logicalSwitch.getUuid() + " created", logicalSwitch.getUuid());
        } catch (NiciraNvpApiException e) {
            if (numRetries > 0) {
                return retry(cmd, --numRetries);
            }
            else {
View Full Code Here

TOP

Related Classes of com.cloud.network.nicira.LogicalSwitch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.