Search in sources :

Example 1 with NetworkService

use of com.cloud.network.NetworkService in project cloudstack by apache.

the class AddNetworkServiceProviderCmdTest method testCreateProviderToPhysicalNetworkFailure.

@Test
public void testCreateProviderToPhysicalNetworkFailure() throws ResourceAllocationException {
    NetworkService networkService = Mockito.mock(NetworkService.class);
    addNetworkServiceProviderCmd._networkService = networkService;
    Mockito.when(networkService.addProviderToPhysicalNetwork(Matchers.anyLong(), Matchers.anyString(), Matchers.anyLong(), Matchers.anyList())).thenReturn(null);
    try {
        addNetworkServiceProviderCmd.create();
    } catch (ServerApiException exception) {
        Assert.assertEquals("Failed to add service provider entity to physical network", exception.getDescription());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) NetworkService(com.cloud.network.NetworkService) Test(org.junit.Test)

Example 2 with NetworkService

use of com.cloud.network.NetworkService in project cloudstack by apache.

the class AddIpToVmNicTest method testRemoveIpFromVmNicFailure.

@Test
public void testRemoveIpFromVmNicFailure() throws InsufficientAddressCapacityException {
    NetworkService networkService = Mockito.mock(NetworkService.class);
    RemoveIpFromVmNicCmd removeIpFromNic = Mockito.mock(RemoveIpFromVmNicCmd.class);
    Mockito.when(networkService.releaseSecondaryIpFromNic(Matchers.anyInt())).thenReturn(false);
    removeIpFromNic._networkService = networkService;
    successResponseGenerator = Mockito.mock(SuccessResponse.class);
    try {
        removeIpFromNic.execute();
    } catch (InvalidParameterValueException exception) {
        Assert.assertEquals("Failed to remove secondary  ip address for the nic", exception.getLocalizedMessage());
    }
}
Also used : SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) NetworkService(com.cloud.network.NetworkService) RemoveIpFromVmNicCmd(org.apache.cloudstack.api.command.user.vm.RemoveIpFromVmNicCmd) Test(org.junit.Test)

Example 3 with NetworkService

use of com.cloud.network.NetworkService in project cloudstack by apache.

the class AddIpToVmNicTest method testCreateFailure.

@Test
public void testCreateFailure() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    NetworkService networkService = Mockito.mock(NetworkService.class);
    AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
    Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.any())).thenReturn(null);
    ipTonicCmd._networkService = networkService;
    try {
        ipTonicCmd.execute();
    } catch (InsufficientAddressCapacityException e) {
        throw new InvalidParameterValueException("Allocating guest ip for nic failed");
    }
}
Also used : AddIpToVmNicCmd(org.apache.cloudstack.api.command.user.vm.AddIpToVmNicCmd) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) NetworkService(com.cloud.network.NetworkService) Test(org.junit.Test)

Example 4 with NetworkService

use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.

the class AddIpToVmNicTest method testRemoveIpFromVmNicSuccess.

@Test
public void testRemoveIpFromVmNicSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    final NetworkService networkService = Mockito.mock(NetworkService.class);
    final RemoveIpFromVmNicCmd removeIpFromNic = Mockito.mock(RemoveIpFromVmNicCmd.class);
    Mockito.when(networkService.releaseSecondaryIpFromNic(Matchers.anyInt())).thenReturn(true);
    removeIpFromNic._networkService = networkService;
    removeIpFromNic.execute();
}
Also used : NetworkService(com.cloud.network.NetworkService) RemoveIpFromVmNicCmd(com.cloud.api.command.user.vm.RemoveIpFromVmNicCmd) Test(org.junit.Test)

Example 5 with NetworkService

use of com.cloud.network.NetworkService in project cosmic by MissionCriticalCloud.

the class AddIpToVmNicTest method testCreateFailure.

@Test
public void testCreateFailure() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    final NetworkService networkService = Mockito.mock(NetworkService.class);
    final AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
    Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.anyString())).thenReturn(null);
    ipTonicCmd._networkService = networkService;
    try {
        ipTonicCmd.execute();
    } catch (final InsufficientAddressCapacityException e) {
        throw new InvalidParameterValueException("Allocating guest ip for nic failed");
    }
}
Also used : AddIpToVmNicCmd(com.cloud.api.command.user.vm.AddIpToVmNicCmd) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) NetworkService(com.cloud.network.NetworkService) Test(org.junit.Test)

Aggregations

NetworkService (com.cloud.network.NetworkService)12 Test (org.junit.Test)12 AddIpToVmNicCmd (com.cloud.api.command.user.vm.AddIpToVmNicCmd)2 RemoveIpFromVmNicCmd (com.cloud.api.command.user.vm.RemoveIpFromVmNicCmd)2 InsufficientAddressCapacityException (com.cloud.exception.InsufficientAddressCapacityException)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 ResourceAllocationException (com.cloud.exception.ResourceAllocationException)2 PhysicalNetworkServiceProvider (com.cloud.network.PhysicalNetworkServiceProvider)2 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)2 NicSecondaryIp (com.cloud.vm.NicSecondaryIp)2 AddIpToVmNicCmd (org.apache.cloudstack.api.command.user.vm.AddIpToVmNicCmd)2 RemoveIpFromVmNicCmd (org.apache.cloudstack.api.command.user.vm.RemoveIpFromVmNicCmd)2 ResponseGenerator (com.cloud.api.ResponseGenerator)1 ServerApiException (com.cloud.api.ServerApiException)1 NicSecondaryIpResponse (com.cloud.api.response.NicSecondaryIpResponse)1 SuccessResponse (com.cloud.api.response.SuccessResponse)1 ResponseGenerator (org.apache.cloudstack.api.ResponseGenerator)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1 NicSecondaryIpResponse (org.apache.cloudstack.api.response.NicSecondaryIpResponse)1 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)1