Search in sources :

Example 21 with NuageVspDeviceVO

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

the class NuageVspElementTest method testApplyFWRules.

@Test
public void testApplyFWRules() throws Exception {
    final Network network = mock(Network.class);
    when(network.getUuid()).thenReturn("aaaaaa");
    when(network.getVpcId()).thenReturn(null);
    when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getDomainId()).thenReturn(NETWORK_ID);
    final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
    when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
    when(ntwkoffer.getEgressDefaultPolicy()).thenReturn(true);
    when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
    final HostVO host = mock(HostVO.class);
    when(host.getId()).thenReturn(NETWORK_ID);
    final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
    when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] { nuageVspDevice }));
    when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
    when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
    when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
    final Answer answer = mock(Answer.class);
    when(answer.getResult()).thenReturn(true);
    when(_agentManager.easySend(eq(NETWORK_ID), (Command) any())).thenReturn(answer);
    assertTrue(_nuageVspElement.applyFWRules(network, new ArrayList<FirewallRule>()));
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) DomainVO(com.cloud.domain.DomainVO) Answer(com.cloud.agent.api.Answer) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HostVO(com.cloud.host.HostVO) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 22 with NuageVspDeviceVO

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

the class NuageVspGuestNetworkGuruTest method testTrash.

@Test
public void testTrash() throws Exception {
    final NetworkVO network = mock(NetworkVO.class);
    when(network.getId()).thenReturn(NETWORK_ID);
    when(network.getUuid()).thenReturn("aaaaaa");
    when(network.getName()).thenReturn("trash");
    when(network.getDomainId()).thenReturn(NETWORK_ID);
    when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
    when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
    when(network.getDataCenterId()).thenReturn(NETWORK_ID);
    when(network.getVpcId()).thenReturn(null);
    when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
    final NetworkOfferingVO offering = mock(NetworkOfferingVO.class);
    when(offering.getId()).thenReturn(NETWORK_ID);
    when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
    when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(offering);
    final DomainVO domain = mock(DomainVO.class);
    when(domain.getUuid()).thenReturn("aaaaaa");
    when(_domainDao.findById(NETWORK_ID)).thenReturn(domain);
    final HostVO host = mock(HostVO.class);
    when(host.getId()).thenReturn(NETWORK_ID);
    final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
    when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[] { nuageVspDevice }));
    when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
    when(_nuageVspManager.getDnsDetails(network.getDataCenterId())).thenReturn(new ArrayList<String>());
    when(_nuageVspManager.getGatewaySystemIds()).thenReturn(new ArrayList<String>());
    assertTrue(_nuageVspGuestNetworkGuru.trash(network, offering));
}
Also used : NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) DomainVO(com.cloud.domain.DomainVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) HostVO(com.cloud.host.HostVO) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 23 with NuageVspDeviceVO

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

the class NuageVspGuestNetworkGuruTest method setUp.

@Before
public void setUp() throws Exception {
    _nuageVspGuestNetworkGuru = new NuageVspGuestNetworkGuru();
    super.setUp();
    _nuageVspGuestNetworkGuru._nuageVspEntityBuilder = _nuageVspEntityBuilder;
    final DataCenterVO dc = mock(DataCenterVO.class);
    when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
    when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
    when(_dataCenterDao.findById((Long) any())).thenReturn(dc);
    when(_configurationDao.getValue(NuageVspIsolatedNetworkDomainTemplateName.key())).thenReturn("IsolatedDomainTemplate");
    when(_configurationDao.getValue(NuageVspVpcDomainTemplateName.key())).thenReturn("VpcDomainTemplate");
    when(_configurationDao.getValue(NuageVspSharedNetworkDomainTemplateName.key())).thenReturn("SharedDomainTemplate");
    when(_physicalNetworkDao.findById(any(Long.class))).thenReturn(physnet);
    when(physnet.getIsolationMethods()).thenReturn(Arrays.asList("VSP"));
    when(physnet.getId()).thenReturn(NETWORK_ID);
    final HostVO host = mock(HostVO.class);
    when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
    when(host.getId()).thenReturn(NETWORK_ID);
    when(_agentManager.easySend(eq(NETWORK_ID), any(Command.class))).thenReturn(new Answer(null));
    when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
    final NuageVspDeviceVO device = mock(NuageVspDeviceVO.class);
    when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(device));
    when(device.getId()).thenReturn(1L);
    when(device.getHostId()).thenReturn(NETWORK_ID);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NuageVspDeviceVO(com.cloud.network.NuageVspDeviceVO) Answer(com.cloud.agent.api.Answer) Command(com.cloud.agent.api.Command) HostVO(com.cloud.host.HostVO) Before(org.junit.Before)

Aggregations

NuageVspDeviceVO (com.cloud.network.NuageVspDeviceVO)23 HostVO (com.cloud.host.HostVO)11 NuageTest (com.cloud.NuageTest)9 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)9 Test (org.junit.Test)9 DomainVO (com.cloud.domain.DomainVO)8 Answer (com.cloud.agent.api.Answer)7 SyncNuageVspCmsIdAnswer (com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer)7 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)7 ArrayList (java.util.ArrayList)6 Network (com.cloud.network.Network)5 PhysicalNetwork (com.cloud.network.PhysicalNetwork)5 SyncNuageVspCmsIdCommand (com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand)4 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)4 NuageVspDeviceResponse (com.cloud.api.response.NuageVspDeviceResponse)3 NetworkVO (com.cloud.network.dao.NetworkVO)3 Account (com.cloud.user.Account)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)3 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)2