Search in sources :

Example 6 with CreateLogicalSwitchAnswer

use of com.cloud.legacymodel.communication.answer.CreateLogicalSwitchAnswer in project cosmic by MissionCriticalCloud.

the class NiciraNvpGuestNetworkGuruTest method testImplementURIException.

@Test
public void testImplementURIException() throws InsufficientVirtualNetworkCapacityException {
    final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
    when(physnetdao.findById((Long) any())).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT" }));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
    when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
    when(device.getId()).thenReturn(1L);
    final NetworkOffering offering = mock(NetworkOffering.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(offering.getGuestType()).thenReturn(GuestType.Isolated);
    when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(false);
    mock(DeploymentPlan.class);
    final NetworkVO network = mock(NetworkVO.class);
    when(network.getName()).thenReturn("testnetwork");
    when(network.getState()).thenReturn(Network.State.Implementing);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    final DeployDestination dest = mock(DeployDestination.class);
    final Zone zone = mock(Zone.class);
    when(dest.getZone()).thenReturn(zone);
    final HostVO niciraHost = mock(HostVO.class);
    when(hostdao.findById(anyLong())).thenReturn(niciraHost);
    when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
    when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
    when(niciraHost.getId()).thenReturn(NETWORK_ID);
    when(netmodel.findPhysicalNetworkId(anyLong(), (String) any(), (TrafficType) any())).thenReturn(NETWORK_ID);
    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 CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
    when(answer.getResult()).thenReturn(true);
    // when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
    when(agentmgr.easySend(eq(NETWORK_ID), (Command) any())).thenReturn(answer);
    final Network implementednetwork = guru.implement(network, offering, dest, res);
    assertTrue(implementednetwork == null);
    verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command) any());
}
Also used : Account(com.cloud.legacymodel.user.Account) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) CreateLogicalSwitchAnswer(com.cloud.legacymodel.communication.answer.CreateLogicalSwitchAnswer) NetworkOffering(com.cloud.offering.NetworkOffering) Zone(com.cloud.db.model.Zone) NiciraNvpDeviceVO(com.cloud.network.NiciraNvpDeviceVO) HostVO(com.cloud.host.HostVO) ReservationContext(com.cloud.vm.ReservationContext) DeployDestination(com.cloud.deploy.DeployDestination) Network(com.cloud.legacymodel.network.Network) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) Domain(com.cloud.legacymodel.domain.Domain) Test(org.junit.Test)

Example 7 with CreateLogicalSwitchAnswer

use of com.cloud.legacymodel.communication.answer.CreateLogicalSwitchAnswer in project cosmic by MissionCriticalCloud.

the class NiciraNvpResourceTest method testCreateLogicalSwitch.

@Test
public void testCreateLogicalSwitch() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final LogicalSwitch ls = mock(LogicalSwitch.class);
    when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
    when(nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenReturn(ls);
    final CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String) parameters.get("guid"), "stt", "loigicalswitch", "owner", null);
    final CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) resource.executeRequest(clsc);
    assertTrue(clsa.getResult());
    assertTrue("cccc".equals(clsa.getLogicalSwitchUuid()));
}
Also used : CreateLogicalSwitchAnswer(com.cloud.legacymodel.communication.answer.CreateLogicalSwitchAnswer) LogicalSwitch(com.cloud.network.nicira.LogicalSwitch) CreateLogicalSwitchCommand(com.cloud.legacymodel.communication.command.CreateLogicalSwitchCommand) Test(org.junit.Test)

Example 8 with CreateLogicalSwitchAnswer

use of com.cloud.legacymodel.communication.answer.CreateLogicalSwitchAnswer in project cosmic by MissionCriticalCloud.

the class NiciraNvpResourceTest method testCreateLogicalSwitchApiException.

@Test
public void testCreateLogicalSwitchApiException() throws ConfigurationException, NiciraNvpApiException {
    resource.configure("NiciraNvpResource", parameters);
    final LogicalSwitch ls = mock(LogicalSwitch.class);
    when(ls.getUuid()).thenReturn("cccc").thenReturn("cccc");
    when(nvpApi.createLogicalSwitch((LogicalSwitch) any())).thenThrow(new NiciraNvpApiException());
    final CreateLogicalSwitchCommand clsc = new CreateLogicalSwitchCommand((String) parameters.get("guid"), "stt", "loigicalswitch", "owner", null);
    final CreateLogicalSwitchAnswer clsa = (CreateLogicalSwitchAnswer) resource.executeRequest(clsc);
    assertFalse(clsa.getResult());
}
Also used : CreateLogicalSwitchAnswer(com.cloud.legacymodel.communication.answer.CreateLogicalSwitchAnswer) LogicalSwitch(com.cloud.network.nicira.LogicalSwitch) NiciraNvpApiException(com.cloud.network.nicira.NiciraNvpApiException) CreateLogicalSwitchCommand(com.cloud.legacymodel.communication.command.CreateLogicalSwitchCommand) Test(org.junit.Test)

Aggregations

CreateLogicalSwitchAnswer (com.cloud.legacymodel.communication.answer.CreateLogicalSwitchAnswer)8 Test (org.junit.Test)6 HostVO (com.cloud.host.HostVO)4 CreateLogicalSwitchCommand (com.cloud.legacymodel.communication.command.CreateLogicalSwitchCommand)4 NiciraNvpDeviceVO (com.cloud.network.NiciraNvpDeviceVO)4 NetworkVO (com.cloud.network.dao.NetworkVO)4 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)4 LogicalSwitch (com.cloud.network.nicira.LogicalSwitch)4 Zone (com.cloud.db.model.Zone)3 DeployDestination (com.cloud.deploy.DeployDestination)3 Domain (com.cloud.legacymodel.domain.Domain)3 Network (com.cloud.legacymodel.network.Network)3 Account (com.cloud.legacymodel.user.Account)3 NiciraNvpApiException (com.cloud.network.nicira.NiciraNvpApiException)3 NetworkOffering (com.cloud.offering.NetworkOffering)3 ReservationContext (com.cloud.vm.ReservationContext)3 NiciraNvpApi (com.cloud.network.nicira.NiciraNvpApi)1 NiciraNvpBindingConfig (com.cloud.network.nicira.NiciraNvpBindingConfig)1 NiciraNvpTag (com.cloud.network.nicira.NiciraNvpTag)1 NiciraNvpVxlanTransport (com.cloud.network.nicira.NiciraNvpVxlanTransport)1