use of com.cloud.network.Network in project cloudstack by apache.
the class GloboDnsElementTest method testUpperCaseCharactersAreNotAllowed.
@Test(expected = InvalidParameterValueException.class)
public void testUpperCaseCharactersAreNotAllowed() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
Network network = mock(Network.class);
when(network.getDataCenterId()).thenReturn(zoneId);
when(network.getId()).thenReturn(1l);
NicProfile nic = new NicProfile();
VirtualMachineProfile vm = mock(VirtualMachineProfile.class);
when(vm.getHostName()).thenReturn("UPPERCASENAME");
when(vm.getType()).thenReturn(VirtualMachine.Type.User);
when(_datacenterDao.findById(zoneId)).thenReturn(mock(DataCenterVO.class));
DeployDestination dest = new DeployDestination();
ReservationContext context = new ReservationContextImpl(null, null, user);
_globodnsElement.prepare(network, nic, vm, dest, context);
}
use of com.cloud.network.Network in project cloudstack by apache.
the class NiciraNvpElementTest method implementSharedNetworkNumericalVlanIdWithoutL2GatewayService.
@Test(expected = CloudRuntimeException.class)
public void implementSharedNetworkNumericalVlanIdWithoutL2GatewayService() throws URISyntaxException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
final Network network = mock(Network.class);
when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
when(network.getBroadcastUri()).thenReturn(new URI("lswitch:aaaaa"));
when(network.getId()).thenReturn(NETWORK_ID);
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
when(network.getGuestType()).thenReturn(GuestType.Shared);
when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(true);
when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(niciraNvpDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
when(device.getId()).thenReturn(1L);
when(device.getHostId()).thenReturn(NICIRA_NVP_HOST_ID);
HostVO niciraNvpHost = mock(HostVO.class);
when(niciraNvpHost.getId()).thenReturn(NICIRA_NVP_HOST_ID);
when(hostDao.findById(NICIRA_NVP_HOST_ID)).thenReturn(niciraNvpHost);
final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Shared);
final DeployDestination dest = mock(DeployDestination.class);
final Domain dom = mock(Domain.class);
when(dom.getName()).thenReturn("domain");
final Account acc = mock(Account.class);
when(acc.getAccountName()).thenReturn("accountname");
final ReservationContext context = mock(ReservationContext.class);
when(context.getDomain()).thenReturn(dom);
when(context.getAccount()).thenReturn(acc);
//SHARED NETWORKS CASE 2
when(niciraNvpRouterMappingDao.existsMappingForNetworkId(NETWORK_ID)).thenReturn(false);
VlanVO vlanVO = mock(VlanVO.class);
when(vlanVO.getVlanTag()).thenReturn("111");
when(vlanDao.listVlansByNetworkId(NETWORK_ID)).thenReturn(Arrays.asList(new VlanVO[] { vlanVO }));
when(niciraNvpHost.getDetail("l2gatewayserviceuuid")).thenReturn(null);
element.implement(network, offering, dest, context);
}
use of com.cloud.network.Network in project cloudstack by apache.
the class NiciraNvpElementTest method implementSharedNetworkNumericalVlanIdTest.
@Test
public void implementSharedNetworkNumericalVlanIdTest() throws URISyntaxException, ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
// SHARED NETWORKS CASE 2: NUMERICAL VLAN ID
final Network network = mock(Network.class);
when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
when(network.getBroadcastUri()).thenReturn(new URI("lswitch:aaaaa"));
when(network.getId()).thenReturn(NETWORK_ID);
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
when(network.getGuestType()).thenReturn(GuestType.Shared);
when(networkModel.isProviderForNetwork(Provider.NiciraNvp, NETWORK_ID)).thenReturn(true);
when(ntwkSrvcDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NiciraNvp)).thenReturn(true);
final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
when(niciraNvpDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] { device }));
when(device.getId()).thenReturn(1L);
when(device.getHostId()).thenReturn(NICIRA_NVP_HOST_ID);
HostVO niciraNvpHost = mock(HostVO.class);
when(niciraNvpHost.getId()).thenReturn(NICIRA_NVP_HOST_ID);
when(hostDao.findById(NICIRA_NVP_HOST_ID)).thenReturn(niciraNvpHost);
final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Shared);
final DeployDestination dest = mock(DeployDestination.class);
final Domain dom = mock(Domain.class);
when(dom.getName()).thenReturn("domain");
final Account acc = mock(Account.class);
when(acc.getAccountName()).thenReturn("accountname");
final ReservationContext context = mock(ReservationContext.class);
when(context.getDomain()).thenReturn(dom);
when(context.getAccount()).thenReturn(acc);
//SHARED NETWORKS CASE 2
when(niciraNvpRouterMappingDao.existsMappingForNetworkId(NETWORK_ID)).thenReturn(false);
VlanVO vlanVO = mock(VlanVO.class);
when(vlanVO.getVlanTag()).thenReturn("111");
when(vlanDao.listVlansByNetworkId(NETWORK_ID)).thenReturn(Arrays.asList(new VlanVO[] { vlanVO }));
when(niciraNvpHost.getDetail("l2gatewayserviceuuid")).thenReturn("bbbb-bbbb-bbbb");
final ConfigureSharedNetworkVlanIdAnswer answer = mock(ConfigureSharedNetworkVlanIdAnswer.class);
when(answer.getResult()).thenReturn(true);
when(agentManager.easySend(eq(NICIRA_NVP_HOST_ID), (Command) any())).thenReturn(answer);
assertTrue(element.implement(network, offering, dest, context));
}
use of com.cloud.network.Network in project cloudstack by apache.
the class NiciraNvpGuestNetworkGuruTest method testDesignNoConnectivityInOffering.
@Test
public void testDesignNoConnectivityInOffering() {
final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long) any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT", "VXLAN" }));
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);
final DeploymentPlan plan = mock(DeploymentPlan.class);
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
assertTrue(designednetwork == null);
}
use of com.cloud.network.Network in project cloudstack by apache.
the class NiciraNvpGuestNetworkGuruTest method testDesignNoElementOnPhysicalNetwork.
@Test
public void testDesignNoElementOnPhysicalNetwork() {
final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long) any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "STT", "VXLAN" }));
when(physnet.getId()).thenReturn(NETWORK_ID);
mock(NiciraNvpDeviceVO.class);
when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NiciraNvpDeviceVO>emptyList());
final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
final DeploymentPlan plan = mock(DeploymentPlan.class);
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
assertTrue(designednetwork == null);
}
Aggregations