use of com.cloud.network.nicira.NiciraNvpApi in project cloudstack by apache.
the class NiciraNvpRequestWrapperTest method testDeleteLogicalSwitchPortCommand.
@Test
public void testDeleteLogicalSwitchPortCommand() {
final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
final String logicalSwitchUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final String logicalSwitchPortUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final DeleteLogicalSwitchPortCommand command = new DeleteLogicalSwitchPortCommand(logicalSwitchUuid, logicalSwitchPortUuid);
when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
try {
doNothing().when(niciraNvpApi).deleteLogicalSwitchPort(command.getLogicalSwitchUuid(), command.getLogicalSwitchPortUuid());
} catch (final NiciraNvpApiException e) {
fail(e.getMessage());
}
final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, niciraNvpResource);
assertTrue(answer.getResult());
}
use of com.cloud.network.nicira.NiciraNvpApi in project cloudstack by apache.
the class NiciraNvpRequestWrapperTest method testUpdateLogicalSwitchPortCommand.
@Test
public void testUpdateLogicalSwitchPortCommand() {
final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
final NiciraNvpUtilities niciraNvpUtilities = Mockito.mock(NiciraNvpUtilities.class);
final VifAttachment vifAttachment = Mockito.mock(VifAttachment.class);
final String logicalSwitchPortUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final String logicalSwitchUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final String attachmentUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final String ownerName = "admin";
final String nicName = "eth0";
final UpdateLogicalSwitchPortCommand command = new UpdateLogicalSwitchPortCommand(logicalSwitchPortUuid, logicalSwitchUuid, attachmentUuid, ownerName, nicName);
when(niciraNvpResource.getNiciraNvpUtilities()).thenReturn(niciraNvpUtilities);
when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
try {
when(niciraNvpUtilities.createVifAttachment(attachmentUuid)).thenReturn(vifAttachment);
doNothing().when(niciraNvpApi).updateLogicalSwitchPortAttachment(logicalSwitchUuid, logicalSwitchPortUuid, vifAttachment);
} catch (final NiciraNvpApiException e) {
fail(e.getMessage());
}
final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, niciraNvpResource);
assertTrue(answer.getResult());
}
use of com.cloud.network.nicira.NiciraNvpApi in project cloudstack by apache.
the class NiciraNvpRequestWrapperTest method testCreateLogicalSwitchCommandWrapper.
@Test
public void testCreateLogicalSwitchCommandWrapper() {
final NiciraNvpApi niciraNvpApi = Mockito.mock(NiciraNvpApi.class);
final NiciraNvpUtilities niciraNvpUtilities = Mockito.mock(NiciraNvpUtilities.class);
final LogicalSwitch logicalSwitch = Mockito.mock(LogicalSwitch.class);
final String transportUuid = "d2e05a9e-7120-4487-a5fc-414ab36d9345";
final String transportType = "stt";
final String name = "logicalswitch";
final String ownerName = "owner";
final CreateLogicalSwitchCommand command = new CreateLogicalSwitchCommand(transportUuid, transportType, name, ownerName);
final String truncated = "lswitch-" + command.getName();
when(niciraNvpResource.getNiciraNvpUtilities()).thenReturn(niciraNvpUtilities);
when(niciraNvpUtilities.createLogicalSwitch()).thenReturn(logicalSwitch);
when(niciraNvpResource.truncate("lswitch-" + command.getName(), NiciraNvpResource.NAME_MAX_LEN)).thenReturn(truncated);
when(niciraNvpResource.getNiciraNvpApi()).thenReturn(niciraNvpApi);
try {
when(niciraNvpApi.createLogicalSwitch(logicalSwitch)).thenReturn(logicalSwitch);
when(logicalSwitch.getUuid()).thenReturn(transportUuid);
} catch (final NiciraNvpApiException e) {
fail(e.getMessage());
}
final NiciraNvpRequestWrapper wrapper = NiciraNvpRequestWrapper.getInstance();
assertNotNull(wrapper);
final Answer answer = wrapper.execute(command, niciraNvpResource);
assertTrue(answer.getResult());
}
use of com.cloud.network.nicira.NiciraNvpApi in project cloudstack by apache.
the class NiciraNvpDeleteLogicalRouterPortCommandWrapper method execute.
@Override
public Answer execute(DeleteLogicalRouterPortCommand command, NiciraNvpResource niciraNvpResource) {
final String logicalRouterUuid = command.getLogicalRouterUuid();
final String logicalRouterPortUuid = command.getLogicalRouterPortUuid();
final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
s_logger.debug("Deleting Logical Router Port " + logicalRouterPortUuid + " in Logical Router " + logicalRouterUuid);
try {
niciraNvpApi.deleteLogicalRouterPort(logicalRouterUuid, logicalRouterPortUuid);
return new DeleteLogicalRouterPortAnswer(command, true, "Logical Router Port " + logicalRouterPortUuid + " deleted");
} catch (NiciraNvpApiException e) {
final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
retryUtility.addRetry(command, NUM_RETRIES);
return retryUtility.retry(command, DeleteLogicalRouterPortAnswer.class, e);
}
}
use of com.cloud.network.nicira.NiciraNvpApi in project cloudstack by apache.
the class NiciraNvpDeleteLogicalSwitchCommandWrapper method execute.
@Override
public Answer execute(final DeleteLogicalSwitchCommand command, final NiciraNvpResource niciraNvpResource) {
try {
final NiciraNvpApi niciraNvpApi = niciraNvpResource.getNiciraNvpApi();
niciraNvpApi.deleteLogicalSwitch(command.getLogicalSwitchUuid());
return new DeleteLogicalSwitchAnswer(command, true, "Logicalswitch " + command.getLogicalSwitchUuid() + " deleted");
} catch (final NiciraNvpApiException e) {
final CommandRetryUtility retryUtility = niciraNvpResource.getRetryUtility();
retryUtility.addRetry(command, NUM_RETRIES);
return retryUtility.retry(command, DeleteLogicalSwitchAnswer.class, e);
}
}
Aggregations