Search in sources :

Example 6 with AssociateMacToNetworkAnswer

use of com.cloud.agent.api.AssociateMacToNetworkAnswer in project cloudstack by apache.

the class BrocadeVcsGuestNetworkGuruTest method testReserveFail.

@Test
public void testReserveFail() throws InsufficientVirtualNetworkCapacityException, URISyntaxException, InsufficientAddressCapacityException {
    final NetworkVO network = mock(NetworkVO.class);
    when(network.getName()).thenReturn("testnetwork");
    when(network.getState()).thenReturn(State.Implementing);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getBroadcastUri()).thenReturn(new URI("vlan://14"));
    when(network.getDataCenterId()).thenReturn(NETWORK_ID);
    final NicProfile nic = mock(NicProfile.class);
    when(nic.getMacAddress()).thenReturn("macaddress");
    when(nic.getReservationStrategy()).thenReturn(ReservationStrategy.Start);
    final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
    final DeployDestination dest = mock(DeployDestination.class);
    final DataCenterVO dc = mock(DataCenterVO.class);
    when(dest.getDataCenter()).thenReturn(dc);
    when(dcdao.findById((long) anyInt())).thenReturn(dc);
    final HostVO brocadeHost = mock(HostVO.class);
    when(hostdao.findById(anyLong())).thenReturn(brocadeHost);
    when(brocadeHost.getId()).thenReturn(NETWORK_ID);
    when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(NETWORK_ID);
    final BrocadeVcsDeviceVO brocadeDevice = mock(BrocadeVcsDeviceVO.class);
    when(brocadeDevice.getHostId()).thenReturn(NETWORK_ID);
    final List<BrocadeVcsDeviceVO> devices = mock(List.class);
    when(devices.isEmpty()).thenReturn(true);
    when(vcsdao.listByPhysicalNetwork(anyLong())).thenReturn(devices);
    final Domain dom = mock(Domain.class);
    when(dom.getName()).thenReturn("domain");
    final Account acc = mock(Account.class);
    when(acc.getAccountName()).thenReturn("accountname");
    final ReservationContext res = mock(ReservationContext.class);
    when(res.getDomain()).thenReturn(dom);
    when(res.getAccount()).thenReturn(acc);
    final AssociateMacToNetworkAnswer answer = mock(AssociateMacToNetworkAnswer.class);
    when(answer.getResult()).thenReturn(true);
    when(agentmgr.easySend(eq(NETWORK_ID), (Command) any())).thenReturn(answer);
    guru.reserve(nic, network, vmProfile, dest, res);
    verify(agentmgr, times(0)).easySend(eq(NETWORK_ID), (Command) any());
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Account(com.cloud.user.Account) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) NicProfile(com.cloud.vm.NicProfile) URI(java.net.URI) HostVO(com.cloud.host.HostVO) BrocadeVcsDeviceVO(com.cloud.network.BrocadeVcsDeviceVO) ReservationContext(com.cloud.vm.ReservationContext) AssociateMacToNetworkAnswer(com.cloud.agent.api.AssociateMacToNetworkAnswer) DeployDestination(com.cloud.deploy.DeployDestination) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) Domain(com.cloud.domain.Domain) Test(org.junit.Test)

Aggregations

AssociateMacToNetworkAnswer (com.cloud.agent.api.AssociateMacToNetworkAnswer)6 Test (org.junit.Test)4 AssociateMacToNetworkCommand (com.cloud.agent.api.AssociateMacToNetworkCommand)3 HostVO (com.cloud.host.HostVO)3 BrocadeVcsDeviceVO (com.cloud.network.BrocadeVcsDeviceVO)3 DataCenterVO (com.cloud.dc.DataCenterVO)2 DeployDestination (com.cloud.deploy.DeployDestination)2 Domain (com.cloud.domain.Domain)2 BrocadeVcsApiException (com.cloud.network.brocade.BrocadeVcsApiException)2 NetworkVO (com.cloud.network.dao.NetworkVO)2 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)2 Account (com.cloud.user.Account)2 NicProfile (com.cloud.vm.NicProfile)2 ReservationContext (com.cloud.vm.ReservationContext)2 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)2 URI (java.net.URI)2 DataCenter (com.cloud.dc.DataCenter)1 InsufficientVirtualNetworkCapacityException (com.cloud.exception.InsufficientVirtualNetworkCapacityException)1 ArrayList (java.util.ArrayList)1