Search in sources :

Example 11 with NetworkService

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

the class AddIpToVmNicTest method testRemoveIpFromVmNicSuccess.

@Test
public void testRemoveIpFromVmNicSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    NetworkService networkService = Mockito.mock(NetworkService.class);
    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(org.apache.cloudstack.api.command.user.vm.RemoveIpFromVmNicCmd) Test(org.junit.Test)

Example 12 with NetworkService

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

the class AddIpToVmNicTest method testCreateSuccess.

@Test
public void testCreateSuccess() throws ResourceAllocationException, ResourceUnavailableException, ConcurrentOperationException, InsufficientCapacityException {
    NetworkService networkService = Mockito.mock(NetworkService.class);
    AddIpToVmNicCmd ipTonicCmd = Mockito.mock(AddIpToVmNicCmd.class);
    NicSecondaryIp secIp = Mockito.mock(NicSecondaryIp.class);
    Mockito.when(networkService.allocateSecondaryGuestIP(Matchers.anyLong(), Matchers.any())).thenReturn(secIp);
    ipTonicCmd._networkService = networkService;
    responseGenerator = Mockito.mock(ResponseGenerator.class);
    NicSecondaryIpResponse ipres = Mockito.mock(NicSecondaryIpResponse.class);
    Mockito.when(responseGenerator.createSecondaryIPToNicResponse(secIp)).thenReturn(ipres);
    ipTonicCmd._responseGenerator = responseGenerator;
    ipTonicCmd.execute();
}
Also used : NicSecondaryIpResponse(org.apache.cloudstack.api.response.NicSecondaryIpResponse) AddIpToVmNicCmd(org.apache.cloudstack.api.command.user.vm.AddIpToVmNicCmd) ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) NicSecondaryIp(com.cloud.vm.NicSecondaryIp) 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