Search in sources :

Example 31 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class VirtualRouterElementTest method testGetRouters3.

@Test
public void testGetRouters3() {
    Network network = new NetworkVO(3l, null, null, null, 1l, 1l, 1l, 1l, "d", "d", "d", null, 1l, 1l, null, true, null, true);
    mockDAOs((NetworkVO) network, testOffering);
    //alwyas return backup routers first when both master and backup need update.
    List<DomainRouterVO> routers = virtualRouterElement.getRouters(network);
    assertTrue(routers.size() == 4);
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) Network(com.cloud.network.Network) DomainRouterVO(com.cloud.vm.DomainRouterVO) Test(org.junit.Test)

Example 32 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class VirtualRouterElementTest method getResourceCountTest.

@Test
public void getResourceCountTest() {
    Network network = new NetworkVO(3l, null, null, null, 1l, 1l, 1l, 1l, "d", "d", "d", null, 1l, 1l, null, true, null, true);
    mockDAOs((NetworkVO) network, testOffering);
    int routers = virtualRouterElement.getResourceCount(network);
    assertTrue(routers == 4);
}
Also used : NetworkVO(com.cloud.network.dao.NetworkVO) Network(com.cloud.network.Network) Test(org.junit.Test)

Example 33 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class CreatePrivateNetworkTest method setup.

@Before
public void setup() throws Exception {
    MockitoAnnotations.initMocks(this);
    networkService._accountMgr = _accountMgr;
    networkService._networkOfferingDao = _networkOfferingDao;
    networkService._physicalNetworkDao = _physicalNetworkDao;
    networkService._dcDao = _dcDao;
    networkService._networksDao = _networkDao;
    networkService._networkMgr = _networkMgr;
    networkService._privateIpDao = _privateIpDao;
    Account account = new AccountVO("testaccount", 1, "networkdomain", (short) 0, UUID.randomUUID().toString());
    when(networkService._accountMgr.getAccount(anyLong())).thenReturn(account);
    NetworkOfferingVO ntwkOff = new NetworkOfferingVO("offer", "fakeOffer", TrafficType.Guest, true, true, null, null, false, null, null, GuestType.Isolated, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false);
    when(networkService._networkOfferingDao.findById(anyLong())).thenReturn(ntwkOff);
    List<NetworkOfferingVO> netofferlist = new ArrayList<NetworkOfferingVO>();
    netofferlist.add(ntwkOff);
    when(networkService._networkOfferingDao.listSystemNetworkOfferings()).thenReturn(netofferlist);
    PhysicalNetworkVO physicalNetwork = new PhysicalNetworkVO(1L, 1L, "2-5", "200", 1L, null, "testphysicalnetwork");
    when(networkService._physicalNetworkDao.findById(anyLong())).thenReturn(physicalNetwork);
    DataCenterVO dc = new DataCenterVO(1L, "hut", "op de hei", null, null, null, null, "10.1.1.0/24", "unreal.net", 1L, NetworkType.Advanced, null, null);
    when(networkService._dcDao.lockRow(anyLong(), anyBoolean())).thenReturn(dc);
    when(networkService._networksDao.getPrivateNetwork(anyString(), anyString(), eq(1L), eq(1L), anyLong())).thenReturn(null);
    Network net = new NetworkVO(1L, TrafficType.Guest, Mode.None, BroadcastDomainType.Vlan, 1L, 1L, 1L, 1L, "bla", "fake", "eet.net", GuestType.Isolated, 1L, 1L, ACLType.Account, false, 1L, false);
    when(networkService._networkMgr.createGuestNetwork(eq(ntwkOff.getId()), eq("bla"), eq("fake"), eq("10.1.1.1"), eq("10.1.1.0/24"), anyString(), anyString(), eq(account), anyLong(), eq(physicalNetwork), eq(physicalNetwork.getDataCenterId()), eq(ACLType.Account), anyBoolean(), eq(1L), anyString(), anyString(), anyBoolean(), anyString())).thenReturn(net);
    when(networkService._privateIpDao.findByIpAndSourceNetworkId(net.getId(), "10.1.1.2")).thenReturn(null);
    when(networkService._privateIpDao.findByIpAndSourceNetworkIdAndVpcId(eq(1L), anyString(), eq(1L))).thenReturn(null);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Account(com.cloud.user.Account) NetworkVO(com.cloud.network.dao.NetworkVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) AccountVO(com.cloud.user.AccountVO) Before(org.junit.Before)

Example 34 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class ConsoleProxyManagerTest method getDefaultNetworkForBasicSG.

@Test
public void getDefaultNetworkForBasicSG() {
    DataCenterVO dc = Mockito.mock(DataCenterVO.class);
    when(dc.getNetworkType()).thenReturn(NetworkType.Basic);
    when(dc.isSecurityGroupEnabled()).thenReturn(true);
    when(_dcDao.findById(Mockito.anyLong())).thenReturn(dc);
    NetworkVO network = Mockito.mock(NetworkVO.class);
    NetworkVO badNetwork = Mockito.mock(NetworkVO.class);
    when(_networkDao.listByZoneAndTrafficType(anyLong(), eq(TrafficType.Guest))).thenReturn(Collections.singletonList(network));
    when(_networkDao.listByZoneAndTrafficType(anyLong(), not(eq(TrafficType.Guest)))).thenReturn(Collections.singletonList(badNetwork));
    NetworkVO returnedNetwork = cpvmManager.getDefaultNetworkForBasicZone(dc);
    Assert.assertNotNull(returnedNetwork);
    Assert.assertEquals(network, returnedNetwork);
    Assert.assertNotEquals(badNetwork, returnedNetwork);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkVO(com.cloud.network.dao.NetworkVO) Test(org.junit.Test)

Example 35 with NetworkVO

use of com.cloud.network.dao.NetworkVO in project cloudstack by apache.

the class ConsoleProxyManagerTest method getDefaultNetworkForBasicSGWrongZoneType.

//also test invalid input
@Test(expected = CloudRuntimeException.class)
public void getDefaultNetworkForBasicSGWrongZoneType() {
    DataCenterVO dc = Mockito.mock(DataCenterVO.class);
    when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
    when(dc.isSecurityGroupEnabled()).thenReturn(true);
    when(_dcDao.findById(Mockito.anyLong())).thenReturn(dc);
    NetworkVO network = Mockito.mock(NetworkVO.class);
    NetworkVO badNetwork = Mockito.mock(NetworkVO.class);
    when(_networkDao.listByZoneAndTrafficType(anyLong(), eq(TrafficType.Guest))).thenReturn(Collections.singletonList(network));
    when(_networkDao.listByZoneAndTrafficType(anyLong(), not(eq(TrafficType.Guest)))).thenReturn(Collections.singletonList(badNetwork));
    cpvmManager.getDefaultNetworkForBasicZone(dc);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkVO(com.cloud.network.dao.NetworkVO) Test(org.junit.Test)

Aggregations

NetworkVO (com.cloud.network.dao.NetworkVO)230 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)108 ArrayList (java.util.ArrayList)79 Test (org.junit.Test)56 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)55 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)49 Account (com.cloud.user.Account)44 Network (com.cloud.network.Network)39 DataCenterVO (com.cloud.dc.DataCenterVO)35 DataCenter (com.cloud.dc.DataCenter)34 NicVO (com.cloud.vm.NicVO)33 NicProfile (com.cloud.vm.NicProfile)27 HostVO (com.cloud.host.HostVO)24 NetworkOffering (com.cloud.offering.NetworkOffering)24 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)22 ReservationContext (com.cloud.vm.ReservationContext)22 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)20 DeployDestination (com.cloud.deploy.DeployDestination)19 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)19 NetworkGuru (com.cloud.network.guru.NetworkGuru)19