diff --git a/api/src/main/java/com/cloud/event/EventTypes.java b/api/src/main/java/com/cloud/event/EventTypes.java index f0e6ab69257..a30518aaf17 100644 --- a/api/src/main/java/com/cloud/event/EventTypes.java +++ b/api/src/main/java/com/cloud/event/EventTypes.java @@ -480,9 +480,6 @@ public class EventTypes { public static final String EVENT_EXTERNAL_OVS_CONTROLLER_DELETE = "PHYSICAL.OVSCONTROLLER.DELETE"; // external network mapping events - public static final String EVENT_EXTERNAL_VSP_VSD_ADD = "PHYSICAL.NUAGE.VSD.ADD"; - public static final String EVENT_EXTERNAL_VSP_VSD_UPDATE = "PHYSICAL.NUAGE.VSD.UPDATE"; - public static final String EVENT_EXTERNAL_VSP_VSD_DELETE = "PHYSICAL.NUAGE.VSD.DELETE"; // AutoScale public static final String EVENT_COUNTER_CREATE = "COUNTER.CREATE"; public static final String EVENT_COUNTER_DELETE = "COUNTER.DELETE"; @@ -924,8 +921,6 @@ public class EventTypes { entityEventDetails.put(EVENT_EXTERNAL_NVP_CONTROLLER_CONFIGURE, "NvpController"); // external network mapping events - entityEventDetails.put(EVENT_EXTERNAL_VSP_VSD_ADD, "NuageVsp"); - entityEventDetails.put(EVENT_EXTERNAL_VSP_VSD_DELETE, "NuageVsp"); // AutoScale entityEventDetails.put(EVENT_COUNTER_CREATE, AutoScaleCounter.class); diff --git a/api/src/main/java/com/cloud/network/Network.java b/api/src/main/java/com/cloud/network/Network.java index d9830810958..2aa241d7183 100644 --- a/api/src/main/java/com/cloud/network/Network.java +++ b/api/src/main/java/com/cloud/network/Network.java @@ -144,8 +144,6 @@ public interface Network extends ControlledEntity, StateObject, I // add new Ovs provider public static final Provider Ovs = new Provider("Ovs", false); public static final Provider Opendaylight = new Provider("Opendaylight", false); - // add Nuage Vsp Providers - public static final Provider NuageVsp = new Provider("NuageVsp", false); public static final Provider BrocadeVcs = new Provider("BrocadeVcs", false); // add GloboDns provider public static final Provider GloboDns = new Provider("GloboDns", true); diff --git a/api/src/main/java/com/cloud/network/Networks.java b/api/src/main/java/com/cloud/network/Networks.java index 06f4236eb7a..559a369b4d9 100644 --- a/api/src/main/java/com/cloud/network/Networks.java +++ b/api/src/main/java/com/cloud/network/Networks.java @@ -125,8 +125,8 @@ public class Networks { } } }, - UnDecided(null, null), OpenDaylight("opendaylight", String.class), - Vsp("vsp", String.class),; + UnDecided(null, null), + OpenDaylight("opendaylight", String.class); private final String scheme; private final Class type; diff --git a/client/pom.xml b/client/pom.xml index 06113bf378c..5c586358d03 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -213,11 +213,6 @@ cloud-plugin-network-vcs ${project.version} - - org.apache.cloudstack - cloud-plugin-network-vsp - ${project.version} - org.apache.cloudstack cloud-plugin-hypervisor-xenserver @@ -802,7 +797,7 @@ maven-antrun-plugin 1.7 - copy-systemvm diff --git a/engine/schema/src/main/resources/META-INF/db/create-default-role-api-mappings.sql b/engine/schema/src/main/resources/META-INF/db/create-default-role-api-mappings.sql index 57601fbde17..d814b0fc298 100644 --- a/engine/schema/src/main/resources/META-INF/db/create-default-role-api-mappings.sql +++ b/engine/schema/src/main/resources/META-INF/db/create-default-role-api-mappings.sql @@ -166,7 +166,6 @@ INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'getVMPassword', 'ALLOW', 143) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'getVirtualMachineUserData', 'ALLOW', 144) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'importLdapUsers', 'ALLOW', 145) ON DUPLICATE KEY UPDATE rule=rule; -INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'issueNuageVspResourceRequest', 'ALLOW', 146) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'ldapCreateAccount', 'ALLOW', 147) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'linkDomainToLdap', 'ALLOW', 148) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'listAccounts', 'ALLOW', 149) ON DUPLICATE KEY UPDATE rule=rule; @@ -479,7 +478,6 @@ INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getUploadParamsForVolume', 'ALLOW', 138) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getVMPassword', 'ALLOW', 139) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getVirtualMachineUserData', 'ALLOW', 140) ON DUPLICATE KEY UPDATE rule=rule; -INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'issueNuageVspResourceRequest', 'ALLOW', 141) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAccounts', 'ALLOW', 142) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAffinityGroupTypes', 'ALLOW', 143) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAffinityGroups', 'ALLOW', 144) ON DUPLICATE KEY UPDATE rule=rule; @@ -759,7 +757,6 @@ INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getUploadParamsForVolume', 'ALLOW', 116) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getVMPassword', 'ALLOW', 117) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getVirtualMachineUserData', 'ALLOW', 118) ON DUPLICATE KEY UPDATE rule=rule; -INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'issueNuageVspResourceRequest', 'ALLOW', 119) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAccounts', 'ALLOW', 120) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAffinityGroupTypes', 'ALLOW', 121) ON DUPLICATE KEY UPDATE rule=rule; INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAffinityGroups', 'ALLOW', 122) ON DUPLICATE KEY UPDATE rule=rule; diff --git a/engine/schema/src/main/resources/META-INF/db/schema-41120to41200-cleanup.sql b/engine/schema/src/main/resources/META-INF/db/schema-41120to41200-cleanup.sql index 82cbfad13ac..465c65c535d 100644 --- a/engine/schema/src/main/resources/META-INF/db/schema-41120to41200-cleanup.sql +++ b/engine/schema/src/main/resources/META-INF/db/schema-41120to41200-cleanup.sql @@ -25,3 +25,8 @@ DROP TABLE IF EXISTS `cloud`.`iam_group_policy_map`; DROP TABLE IF EXISTS `cloud`.`iam_group`; DROP TABLE IF EXISTS `cloud`.`iam_policy_permission`; DROP TABLE IF EXISTS `cloud`.`iam_policy`; + +-- Cleanup Nuage VSP +DELETE FROM `cloud`.`host` WHERE id in (SELECT vsp.host_id FROM `cloud`.`external_nuage_vsp_devices` vsp); +DROP TABLE IF EXISTS `cloud`.`external_nuage_vsp_devices`; +delete from `cloud`.`role_permissions` where rule = 'issueNuageVspResourceRequest'; diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 1cdc1f0d03b..ae6a6a2881b 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -2491,16 +2491,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } private void createVif(final LibvirtVMDef vm, final NicTO nic, final String nicAdapter, Map extraConfig) throws InternalErrorException, LibvirtException { - - if (nic.getType().equals(TrafficType.Guest) && nic.getBroadcastType().equals(BroadcastDomainType.Vsp)) { - String vrIp = nic.getBroadcastUri().getPath().substring(1); - vm.getMetaData().getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension(nic.getMac(), vrIp); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("NIC with MAC " + nic.getMac() + " and BroadcastDomainType " + nic.getBroadcastType() + " in network(" + nic.getGateway() + "/" + nic.getNetmask() - + ") is " + nic.getType() + " traffic type. So, vsp-vr-ip " + vrIp + " is set in the metadata"); - } - } if (vm.getDevices() == null) { s_logger.error("LibvirtVMDef object get devices with null result"); throw new InternalErrorException("LibvirtVMDef object get devices with null result"); diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java index 4f7732b9a3d..1b377834695 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDef.java @@ -26,8 +26,6 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import com.google.common.collect.Maps; - public class LibvirtVMDef { private static final Logger s_logger = Logger.getLogger(LibvirtVMDef.class); @@ -1665,28 +1663,6 @@ public class LibvirtVMDef { } } - public static class NuageExtensionDef { - private Map addresses = Maps.newHashMap(); - - public void addNuageExtension(String macAddress, String vrIp) { - addresses.put(macAddress, vrIp); - } - - @Override - public String toString() { - StringBuilder fsBuilder = new StringBuilder(); - fsBuilder.append("\n"); - for (Map.Entry address : addresses.entrySet()) { - fsBuilder.append(" \n"); - } - return fsBuilder.append("\n").toString(); - } - } - public static class RngDef { enum RngModel { VIRTIO("virtio"); diff --git a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java index ea4fd4a58fe..db3ee4dd350 100644 --- a/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java +++ b/plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java @@ -183,10 +183,6 @@ public class OvsVifDriver extends VifDriverBase { String brName = "OVSTunnel" + vnetId; s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + brName); intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps); - } else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vsp) { - intf.setVirtualPortInterfaceId(nic.getUuid()); - String brName = (trafficLabel != null && !trafficLabel.isEmpty()) ? _pifs.get(trafficLabel) : _pifs.get("private"); - intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps); } else { intf.defBridgeNet(_bridges.get("guest"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps); } diff --git a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java index 28f5389ba54..d0ba4dd68af 100644 --- a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java +++ b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/LibvirtVMDefTest.java @@ -292,23 +292,4 @@ public class LibvirtVMDefTest extends TestCase { "\n"; assertEquals(str, expected); } - - @Test - public void testMetadataDef() { - LibvirtVMDef.MetadataDef metadataDef = new LibvirtVMDef.MetadataDef(); - - metadataDef.getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension("mac1", "ip1"); - metadataDef.getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension("mac2", "ip2"); - - String xmlDef = metadataDef.toString(); - String expectedXml = "\n" + - "\n" + - " \n" + - " \n" + - "\n" + - "\n"; - - assertEquals(xmlDef, expectedXml); - } - } diff --git a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReplugNicCommandWrapperTest.java b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReplugNicCommandWrapperTest.java index c8b9e5c2f1d..9d47bfc94c0 100644 --- a/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReplugNicCommandWrapperTest.java +++ b/plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtReplugNicCommandWrapperTest.java @@ -56,6 +56,7 @@ import com.cloud.vm.VirtualMachine; @RunWith(PowerMockRunner.class) @PrepareForTest(value = {Script.class, MemStat.class}) public class LibvirtReplugNicCommandWrapperTest { + private static final String part_1 = "\n" + " i-85-285-VM\n" @@ -180,6 +181,7 @@ public class LibvirtReplugNicCommandWrapperTest { + "\n"; private static final String fullfile = part_1 + part_2 + part_3; + public static final String GUEST_BR = "guestbr0"; private LibvirtComputingResource res; private final Domain _domain = mock(Domain.class); @@ -213,7 +215,7 @@ public class LibvirtReplugNicCommandWrapperTest { BDDMockito.given(Script.findScript(anyString(), anyString())).willReturn("dummypath/tofile.sh"); Map pifs = new HashMap<>(); - pifs.put("alubr0", "alubr0"); + pifs.put(GUEST_BR, "eth0"); Map params = new HashMap<>(); params.put("libvirt.computing.resource", res); @@ -227,7 +229,7 @@ public class LibvirtReplugNicCommandWrapperTest { doReturn(helper).when(res).getLibvirtUtilitiesHelper(); doReturn(bridgeVifDriver).when(res).getVifDriver(eq(Networks.TrafficType.Guest), anyString()); - doReturn(ovsVifDriver).when(res).getVifDriver(Networks.TrafficType.Guest, "alubr0"); + doReturn(ovsVifDriver).when(res).getVifDriver(Networks.TrafficType.Guest, GUEST_BR); doReturn(bridgeVifDriver).when(res).getVifDriver(not(eq(Networks.TrafficType.Guest))); doReturn(Arrays.asList(bridgeVifDriver, ovsVifDriver)).when(res).getAllVifDrivers(); @@ -237,7 +239,6 @@ public class LibvirtReplugNicCommandWrapperTest { @Test public void testReplugNic() throws LibvirtException { - final String expectedDetachXml = "\n" + "\n" @@ -248,23 +249,29 @@ public class LibvirtReplugNicCommandWrapperTest { + "\n"; final String expectedAttachXml = "\n" - + "\n" + + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + + "\n" + + "\n" + + "" + "\n" + "
\n" + "\n"; final String expectedUpdateXml = "\n" - + "\n" + + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + + "\n" + + "\n" + + "" + "\n" + "
\n" + "\n"; @@ -272,9 +279,10 @@ public class LibvirtReplugNicCommandWrapperTest { final LibvirtReplugNicCommandWrapper wrapper = new LibvirtReplugNicCommandWrapper(); final NicTO nic = new NicTO(); nic.setType(Networks.TrafficType.Guest); - nic.setName("alubr0"); - nic.setBroadcastType(Networks.BroadcastDomainType.Vsp); + nic.setName(GUEST_BR); + nic.setBroadcastType(Networks.BroadcastDomainType.Vlan); nic.setMac("02:00:7c:98:00:02"); + nic.setBroadcastUri(Networks.BroadcastDomainType.Vlan.toUri(100)); final ReplugNicCommand command = new ReplugNicCommand(nic, "i-85-285-VM", VirtualMachine.Type.User); final Answer result = wrapper.execute(command, res); diff --git a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java index 37d27c855bc..22b878c2e0e 100644 --- a/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java +++ b/plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java @@ -1171,7 +1171,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD); vmConfigSpec.getDeviceChange().add(deviceConfigSpec); - setNuageVspVrIpInExtraConfig(vmConfigSpec.getExtraConfig(), nicTo, dvSwitchUuid); if (!vmMo.configureVm(vmConfigSpec)) { throw new Exception("Failed to configure devices when running PlugNicCommand"); } @@ -1252,7 +1251,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT); vmConfigSpec.getDeviceChange().add(deviceConfigSpec); - setNuageVspVrIpInExtraConfig(vmConfigSpec.getExtraConfig(), nicTo, dvSwitchUuid); if (!vmMo.configureVm(vmConfigSpec)) { throw new Exception("Failed to configure devices when running ReplugNicCommand"); } @@ -2632,36 +2630,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa newVal.setKey("nvp.iface-id." + nicNum); newVal.setValue(nicTo.getUuid()); extraOptions.add(newVal); - setNuageVspVrIpInExtraConfig(extraOptions, nicTo, nicUuidToDvSwitchUuid.get(nicTo.getUuid())); } nicNum++; } } - private static void setNuageVspVrIpInExtraConfig(List extraOptions, NicTO nicTo, String dvSwitchUuid) { - if (nicTo.getBroadcastType() != BroadcastDomainType.Vsp) { - return; - } - - OptionValue newVal; - if (nicTo.getType().equals(TrafficType.Guest) && dvSwitchUuid != null && nicTo.getGateway() != null && nicTo.getNetmask() != null) { - String vrIp = nicTo.getBroadcastUri().getPath().substring(1); - newVal = new OptionValue(); - newVal.setKey("vsp.vr-ip." + nicTo.getMac()); - newVal.setValue(vrIp); - extraOptions.add(newVal); - newVal = new OptionValue(); - newVal.setKey("vsp.dvswitch." + nicTo.getMac()); - newVal.setValue(dvSwitchUuid); - extraOptions.add(newVal); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("NIC with MAC " + nicTo.getMac() + " and BroadcastDomainType " + nicTo.getBroadcastType() + " in network(" + nicTo.getGateway() + "/" - + nicTo.getNetmask() + ") is " + nicTo.getType() + " traffic type. So, vsp-vr-ip is set in the extraconfig"); - } - } - } - private static void configCustomExtraOption(List extraOptions, VirtualMachineTO vmSpec) { // we no longer to validation anymore for (Map.Entry entry : vmSpec.getDetails().entrySet()) { diff --git a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index e1066b755e3..ff7b0a3ab53 100644 --- a/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -1225,14 +1225,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe // group VIF's & tunnel ports as part of tier // when bridge is setup for distributed routing vifr.otherConfig.put("cloudstack-network-id", nic.getNetworkUuid()); - - // Nuage Vsp needs Virtual Router IP to be passed in the otherconfig - // get the virtual router IP information from broadcast uri - final URI broadcastUri = nic.getBroadcastUri(); - if (broadcastUri != null && broadcastUri.getScheme().equalsIgnoreCase(Networks.BroadcastDomainType.Vsp.scheme())) { - final String path = broadcastUri.getPath(); - vifr.otherConfig.put("vsp-vr-ip", path.substring(1)); - } vifr.network = getNetwork(conn, nic); if (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) { @@ -2776,7 +2768,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe assert BroadcastDomainType.getSchemeValue(uri) == BroadcastDomainType.Vlan; final long vlan = Long.parseLong(BroadcastDomainType.getValue(uri)); return enableVlanNetwork(conn, vlan, network); - } else if (type == BroadcastDomainType.Native || type == BroadcastDomainType.LinkLocal || type == BroadcastDomainType.Vsp) { + } else if (type == BroadcastDomainType.Native || type == BroadcastDomainType.LinkLocal) { return network.getNetwork(); } else if (uri != null && type == BroadcastDomainType.Vswitch) { final String header = uri.toString().substring(Networks.BroadcastDomainType.Vswitch.scheme().length() + "://".length()); diff --git a/plugins/network-elements/nuage-vsp/pom.xml b/plugins/network-elements/nuage-vsp/pom.xml deleted file mode 100644 index 08deda93361..00000000000 --- a/plugins/network-elements/nuage-vsp/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - 4.0.0 - cloud-plugin-network-vsp - Apache CloudStack Plugin - Nuage VSP - - org.apache.cloudstack - cloudstack-plugins - 4.13.0.0-SNAPSHOT - ../../pom.xml - - - - nuage-vsp - http://cs.mv.nuagenetworks.net/releases/ - - - - 1.0.8 - - - - net.nuagenetworks.vsp - nuage-vsp-acs-client - ${nuage.vsp.client.version} - - - diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/CmdBuilder.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/CmdBuilder.java deleted file mode 100644 index 514afb6c331..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/CmdBuilder.java +++ /dev/null @@ -1,24 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api; - -public interface CmdBuilder { - T build(); -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/PingNuageVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/PingNuageVspCommand.java deleted file mode 100644 index c710ad5eaea..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/PingNuageVspCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.host.Host; - -public class PingNuageVspCommand extends PingCommand { - - private final boolean shouldAudit; - - public PingNuageVspCommand(Host.Type type, long id, boolean shouldAudit) { - super(type, id); - this.shouldAudit = shouldAudit; - } - - public boolean shouldAudit() { - return shouldAudit; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof PingNuageVspCommand)) return false; - - PingNuageVspCommand that = (PingNuageVspCommand) o; - - return super.equals(that) - && shouldAudit == that.shouldAudit; - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(shouldAudit) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/StartupVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/StartupVspCommand.java deleted file mode 100644 index 2e289fbb421..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/StartupVspCommand.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api; - -import com.cloud.host.Host; - -/** - * The super class implementations for equals and hashCode are acceptable because this class does not track any state - * in addition to the super class. - */ -public class StartupVspCommand extends StartupCommand { - - public StartupVspCommand() { - super(Host.Type.L2Networking); - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ApplyAclRuleVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ApplyAclRuleVspCommand.java deleted file mode 100644 index 4691355533a..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ApplyAclRuleVspCommand.java +++ /dev/null @@ -1,96 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.element; - -import java.util.List; -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class ApplyAclRuleVspCommand extends Command { - - private final VspAclRule.ACLType _aclType; - private final VspNetwork _network; - private final List _aclRules; - private final boolean _networkReset; - - public ApplyAclRuleVspCommand(VspAclRule.ACLType aclType, VspNetwork network, List aclRules, boolean networkReset) { - super(); - this._aclType = aclType; - this._network = network; - this._aclRules = aclRules; - this._networkReset = networkReset; - } - - public VspAclRule.ACLType getAclType() { - return _aclType; - } - - public VspNetwork getNetwork() { - return _network; - } - - public List getAclRules() { - return _aclRules; - } - - public boolean isNetworkReset() { - return _networkReset; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ApplyAclRuleVspCommand)) { - return false; - } - - ApplyAclRuleVspCommand that = (ApplyAclRuleVspCommand) o; - - return super.equals(that) - && _networkReset == that._networkReset - && Objects.equals(_aclType, that._aclType) - && Objects.equals(_network, that._network) - && Objects.equals(_aclRules, that._aclRules); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_aclType) - .append(_network) - .append(_networkReset) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ApplyStaticNatVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ApplyStaticNatVspCommand.java deleted file mode 100644 index b017dea91a5..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ApplyStaticNatVspCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.element; - -import java.util.List; -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class ApplyStaticNatVspCommand extends Command { - - private final VspNetwork _network; - private final List _staticNatDetails; - - public ApplyStaticNatVspCommand(VspNetwork network, List staticNatDetails) { - super(); - this._network = network; - this._staticNatDetails = staticNatDetails; - } - - public VspNetwork getNetwork() { - return _network; - } - - public List getStaticNatDetails() { - return _staticNatDetails; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ApplyStaticNatVspCommand)) { - return false; - } - - ApplyStaticNatVspCommand that = (ApplyStaticNatVspCommand) o; - - return super.equals(that) - && Objects.equals(_network, that._network) - && Objects.equals(_staticNatDetails, that._staticNatDetails); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_network) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ExtraDhcpOptionsVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ExtraDhcpOptionsVspCommand.java deleted file mode 100644 index 45f260182d7..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ExtraDhcpOptionsVspCommand.java +++ /dev/null @@ -1,86 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.element; - -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import org.apache.commons.lang.builder.HashCodeBuilder; - -import java.util.Map; -import java.util.Objects; - -import com.cloud.agent.api.Command; - -public class ExtraDhcpOptionsVspCommand extends Command { - private final VspNetwork network; - private final String nicUuid; - private final Map dhcpOptions; - - public ExtraDhcpOptionsVspCommand (VspNetwork network, String nicUuid, Map dhcpOptions) { - super(); - this.network = network; - this.nicUuid = nicUuid; - this.dhcpOptions = dhcpOptions; - } - - public VspNetwork getNetwork() { - return network; - } - - public String getNicUuid() { - return nicUuid; - } - - public Map getDhcpOptions() { - return dhcpOptions; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ExtraDhcpOptionsVspCommand)) { - return false; - } - - ExtraDhcpOptionsVspCommand that = (ExtraDhcpOptionsVspCommand) o; - - return super.equals(that) - && Objects.equals(network, that.network) - && Objects.equals(nicUuid, that.nicUuid) - && Objects.equals(dhcpOptions, that.dhcpOptions); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(nicUuid) - .append(network) - .append(dhcpOptions) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ImplementVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ImplementVspCommand.java deleted file mode 100644 index 37ec2bff4b6..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ImplementVspCommand.java +++ /dev/null @@ -1,104 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.element; - -import java.util.List; -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class ImplementVspCommand extends Command { - - private final VspNetwork _network; - private final List _ingressFirewallRules; - private final List _egressFirewallRules; - private final List _floatingIpUuids; - private final VspDhcpDomainOption _dhcpOption; - - public ImplementVspCommand(VspNetwork network, List ingressFirewallRules, - List egressFirewallRules, List floatingIpUuids, VspDhcpDomainOption dhcpOption) { - super(); - this._network = network; - this._ingressFirewallRules = ingressFirewallRules; - this._egressFirewallRules = egressFirewallRules; - this._floatingIpUuids = floatingIpUuids; - this._dhcpOption = dhcpOption; - } - - public VspNetwork getNetwork() { - return _network; - } - - public List getIngressFirewallRules() { - return _ingressFirewallRules; - } - - public List getEgressFirewallRules() { - return _egressFirewallRules; - } - - public List getFloatingIpUuids() { - return _floatingIpUuids; - } - - public VspDhcpDomainOption getDhcpOption() { - return _dhcpOption; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ImplementVspCommand)) { - return false; - } - - ImplementVspCommand that = (ImplementVspCommand) o; - - return super.equals(that) - && Objects.equals(_network, that._network) - && Objects.equals(_dhcpOption, that._dhcpOption) - && Objects.equals(_floatingIpUuids, that._floatingIpUuids) - && Objects.equals(_ingressFirewallRules, that._ingressFirewallRules) - && Objects.equals(_egressFirewallRules, that._egressFirewallRules); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_network) - .append(_dhcpOption) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ShutDownVpcVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ShutDownVpcVspCommand.java deleted file mode 100644 index 6c98238c944..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ShutDownVpcVspCommand.java +++ /dev/null @@ -1,107 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.element; - -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; -import com.cloud.network.manager.NuageVspManager; - -import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds; - -public class ShutDownVpcVspCommand extends Command { - - private final String _domainUuid; - private final String _vpcUuid; - private final String _domainTemplateName; - private final List _domainRouterUuids; - private final NetworkRelatedVsdIds _relatedVsdIds; - - public ShutDownVpcVspCommand(String domainUuid, String vpcUuid, String domainTemplateName, List domainRouterUuids, Map details) { - super(); - this._domainUuid = domainUuid; - this._vpcUuid = vpcUuid; - this._domainTemplateName = domainTemplateName; - this._domainRouterUuids = domainRouterUuids; - this._relatedVsdIds = new NetworkRelatedVsdIds.Builder() - .vsdDomainId(details.get(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID)) - .vsdZoneId(details.get(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID)) - .withVsdManaged(details.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED) != null && details.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED).equals("true")) - .build(); - } - - public String getDomainUuid() { - return _domainUuid; - } - - public String getVpcUuid() { - return _vpcUuid; - } - - public String getDomainTemplateName() { - return _domainTemplateName; - } - - public List getDomainRouterUuids() { - return _domainRouterUuids; - } - - public NetworkRelatedVsdIds getRelatedVsdIds() { - return _relatedVsdIds; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ShutDownVpcVspCommand)) { - return false; - } - if (!super.equals(o)) return false; - - ShutDownVpcVspCommand that = (ShutDownVpcVspCommand) o; - - return super.equals(that) - && Objects.equals(_domainUuid, that._domainUuid) - && Objects.equals(_vpcUuid, that._vpcUuid) - && Objects.equals(_domainTemplateName, that._domainTemplateName) - && Objects.equals(_domainRouterUuids, that._domainRouterUuids); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_domainUuid) - .append(_vpcUuid) - .append(_domainTemplateName) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ShutDownVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ShutDownVspCommand.java deleted file mode 100644 index 8406764adbf..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/element/ShutDownVspCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.element; - -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import org.apache.commons.lang.builder.ToStringBuilder; - -import com.cloud.agent.api.Command; - -public class ShutDownVspCommand extends Command { - - private final VspNetwork _network; - private final VspDhcpDomainOption _dhcpOptions; - - public ShutDownVspCommand(VspNetwork network, VspDhcpDomainOption dhcpOptions) { - super(); - this._network = network; - this._dhcpOptions = dhcpOptions; - } - - public VspNetwork getNetwork() { - return _network; - } - - public VspDhcpDomainOption getDhcpOptions() { - return _dhcpOptions; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ShutDownVspCommand)) { - return false; - } - - ShutDownVspCommand that = (ShutDownVspCommand) o; - - return super.equals(that) - && Objects.equals(_dhcpOptions, that._dhcpOptions) - && Objects.equals(_network, that._network); - } - - - - @Override - public int hashCode() { - return Objects.hash(_network, _dhcpOptions); - } - - public String toDetailString() { - return new ToStringBuilder(this) - .append("network", _network) - .append("dhcpOptions", _dhcpOptions) - .toString(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/DeallocateVmVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/DeallocateVmVspCommand.java deleted file mode 100644 index 327c0b5151b..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/DeallocateVmVspCommand.java +++ /dev/null @@ -1,90 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.guru; - -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspNic; -import net.nuage.vsp.acs.client.api.model.VspVm; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - - -public class DeallocateVmVspCommand extends Command { - - private final VspNetwork _network; - private final VspVm _vm; - private final VspNic _nic; - - public DeallocateVmVspCommand(VspNetwork network, VspVm vm, VspNic nic) { - super(); - this._network = network; - this._vm = vm; - this._nic = nic; - } - - public VspNetwork getNetwork() { - return this._network; - } - - public VspVm getVm() { - return this._vm; - } - - public VspNic getNic() { - return this._nic; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof DeallocateVmVspCommand)) { - return false; - } - - DeallocateVmVspCommand that = (DeallocateVmVspCommand) o; - - return super.equals(that) - && Objects.equals(_network, that._network) - && Objects.equals(_nic, that._nic) - && Objects.equals(_vm, that._vm); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_network) - .append(_vm) - .append(_nic) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/ImplementNetworkVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/ImplementNetworkVspCommand.java deleted file mode 100644 index 2f2d5fd98a2..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/ImplementNetworkVspCommand.java +++ /dev/null @@ -1,94 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.guru; - -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - -import com.cloud.agent.api.Command; - -public class ImplementNetworkVspCommand extends Command { - - private final VspNetwork _network; - private final VspDhcpDomainOption _dhcpOption; - private final boolean _isVsdManaged; - - public ImplementNetworkVspCommand(VspNetwork network, VspDhcpDomainOption dhcpOption, boolean isVsdManaged) { - super(); - this._network = network; - this._dhcpOption = dhcpOption; - this._isVsdManaged = isVsdManaged; - } - - public VspNetwork getNetwork() { - return _network; - } - - public VspDhcpDomainOption getDhcpOption() { - return _dhcpOption; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ImplementNetworkVspCommand)) { - return false; - } - - ImplementNetworkVspCommand that = (ImplementNetworkVspCommand) o; - - return super.equals(that) - && Objects.equals(_dhcpOption, that._dhcpOption) - && Objects.equals(_network, that._network); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_network) - .append(_dhcpOption) - .toHashCode(); - } - - public String toDetailString() { - return new ToStringBuilder(this) - .append("network", _network) - .append("dhcpOption", _dhcpOption) - .toString(); - } - - public boolean isVsdManaged() { - return _isVsdManaged; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/ReserveVmInterfaceVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/ReserveVmInterfaceVspCommand.java deleted file mode 100644 index 910d4ac7bf6..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/ReserveVmInterfaceVspCommand.java +++ /dev/null @@ -1,107 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.guru; - -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption; -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspNic; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; -import net.nuage.vsp.acs.client.api.model.VspVm; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class ReserveVmInterfaceVspCommand extends Command { - - private final VspNetwork _network; - private final VspVm _vm; - private final VspNic _nic; - private final VspStaticNat _staticNat; - private final VspDhcpVMOption _dhcpOption; - - public ReserveVmInterfaceVspCommand(VspNetwork network, VspVm vm, VspNic nic, VspStaticNat staticNat, VspDhcpVMOption dhcpOption) { - super(); - this._network = network; - this._vm = vm; - this._nic = nic; - this._staticNat = staticNat; - this._dhcpOption = dhcpOption; - } - - public VspNetwork getNetwork() { - return _network; - } - - public VspVm getVm() { - return _vm; - } - - public VspNic getNic() { - return _nic; - } - - public VspStaticNat getStaticNat() { - return _staticNat; - } - - public VspDhcpVMOption getDhcpOption() { - return _dhcpOption; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof ReserveVmInterfaceVspCommand)) { - return false; - } - - ReserveVmInterfaceVspCommand that = (ReserveVmInterfaceVspCommand) o; - - return super.equals(that) - && Objects.equals(_network, that._network) - && Objects.equals(_nic, that._nic) - && Objects.equals(_dhcpOption, that._dhcpOption) - && Objects.equals(_staticNat, that._staticNat) - && Objects.equals(_vm, that._vm); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_network) - .append(_vm) - .append(_nic) - .append(_staticNat) - .append(_dhcpOption) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/TrashNetworkVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/TrashNetworkVspCommand.java deleted file mode 100644 index 873b5c26fe0..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/TrashNetworkVspCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.guru; - -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class TrashNetworkVspCommand extends Command { - - private final VspNetwork _network; - - public TrashNetworkVspCommand(VspNetwork network) { - super(); - this._network = network; - } - - public VspNetwork getNetwork() { - return _network; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof TrashNetworkVspCommand)) { - return false; - } - - TrashNetworkVspCommand that = (TrashNetworkVspCommand) o; - - return super.equals(that) - && Objects.equals(_network, that._network); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_network) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/UpdateDhcpOptionVspCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/UpdateDhcpOptionVspCommand.java deleted file mode 100644 index c5ae11a21f3..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/guru/UpdateDhcpOptionVspCommand.java +++ /dev/null @@ -1,87 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.guru; - -import java.util.List; -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - -import com.cloud.agent.api.Command; - -public class UpdateDhcpOptionVspCommand extends Command { - - private final List _dhcpOptions; - private final VspNetwork _network; - - public UpdateDhcpOptionVspCommand(List dhcpOptions, VspNetwork network) { - this._dhcpOptions = dhcpOptions; - this._network = network; - } - - public List getDhcpOptions() { - return _dhcpOptions; - } - - public VspNetwork getNetwork() { - return _network; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof UpdateDhcpOptionVspCommand)) { - return false; - } - - UpdateDhcpOptionVspCommand that = (UpdateDhcpOptionVspCommand) o; - - return super.equals(that) - && Objects.equals(_network, that._network) - && Objects.equals(_dhcpOptions, that._dhcpOptions); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_network) - .toHashCode(); - } - - public String toDetailString() { - return new ToStringBuilder(this) - .append("network", _network) - .append("dhcpOptions", _dhcpOptions) - .toString(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/CleanUpDomainCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/CleanUpDomainCommand.java deleted file mode 100644 index 2229b61f813..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/CleanUpDomainCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import com.cloud.agent.api.Command; - -import com.google.common.base.Preconditions; -import net.nuage.vsp.acs.client.api.model.VspDomainCleanUp; -import org.apache.commons.lang.builder.HashCodeBuilder; - -import java.util.Objects; - -public class CleanUpDomainCommand extends Command { - - private final VspDomainCleanUp _domainCleanUp; - - public CleanUpDomainCommand(VspDomainCleanUp domainCleanUp) { - super(); - Preconditions.checkNotNull(domainCleanUp); - this._domainCleanUp = domainCleanUp; - } - - public VspDomainCleanUp getDomainCleanUp() { - return _domainCleanUp; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof CleanUpDomainCommand)) { - return false; - } - - CleanUpDomainCommand that = (CleanUpDomainCommand) o; - - return super.equals(that) - && Objects.equals(_domainCleanUp, that._domainCleanUp); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_domainCleanUp) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/EntityExistsCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/EntityExistsCommand.java deleted file mode 100644 index 8e8fd81dfd8..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/EntityExistsCommand.java +++ /dev/null @@ -1,85 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import java.util.Objects; - -import com.cloud.agent.api.Command; - -public class EntityExistsCommand extends Command { - - private transient Class _type; - private final String _className; - private final String _uuid; - - public EntityExistsCommand(Class type, String uuid) { - super(); - this._type = type; - this._className = type.getName(); - this._uuid = uuid; - } - - public Class getType() { - if (_type == null) { - try { - _type = (Class)Class.forName(_className); - } catch (ClassNotFoundException e) { - } - } - return _type; - } - - public String getUuid() { - return _uuid; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof EntityExistsCommand)) { - return false; - } - - EntityExistsCommand that = (EntityExistsCommand) o; - - return super.equals(that) - && Objects.equals(getType(), that.getType()) - && Objects.equals(_uuid, that._uuid); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(getType()) - .append(_uuid) - .toHashCode(); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/GetApiDefaultsAnswer.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/GetApiDefaultsAnswer.java deleted file mode 100644 index e52b0e39b2d..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/GetApiDefaultsAnswer.java +++ /dev/null @@ -1,70 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspApiDefaults; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Answer; - -public class GetApiDefaultsAnswer extends Answer { - - private VspApiDefaults _apiDefaults; - - public GetApiDefaultsAnswer(GetApiDefaultsCommand cmd, VspApiDefaults defaults) { - super(cmd); - this._apiDefaults = defaults; - } - - public GetApiDefaultsAnswer(GetApiDefaultsCommand cmd, Exception e) { - super(cmd, e); - } - - public VspApiDefaults getApiDefaults() { - return _apiDefaults; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof GetApiDefaultsAnswer)) { - return false; - } - - GetApiDefaultsAnswer that = (GetApiDefaultsAnswer) o; - - return super.equals(that) - && Objects.equals(_apiDefaults, that._apiDefaults); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_apiDefaults) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/GetApiDefaultsCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/GetApiDefaultsCommand.java deleted file mode 100644 index 3fca16a2420..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/GetApiDefaultsCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import com.cloud.agent.api.Command; - -/** - * The super class implementations for equals and hashCode are acceptable because this class does not track any state - * in addition to the super class. - */ -public class GetApiDefaultsCommand extends Command { - - public GetApiDefaultsCommand() { - super(); - } - - @Override - public boolean executeInSequence() { - return false; - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ImplementNetworkVspAnswer.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ImplementNetworkVspAnswer.java deleted file mode 100644 index 8cfb715743c..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ImplementNetworkVspAnswer.java +++ /dev/null @@ -1,53 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.guru.ImplementNetworkVspCommand; - -/** - * Created by sgoeminn on 3/24/17. - */ -public class ImplementNetworkVspAnswer extends Answer { - private NetworkRelatedVsdIds networkRelatedVsdIds; - - private VspNetwork vspNetwork; - - public ImplementNetworkVspAnswer(ImplementNetworkVspCommand command, VspNetwork vspNetwork, NetworkRelatedVsdIds networkRelatedVsdIds) { - super(command); - this.vspNetwork = vspNetwork; - this.networkRelatedVsdIds = networkRelatedVsdIds; - } - - public ImplementNetworkVspAnswer(ImplementNetworkVspCommand command, Exception e) { - super(command, e); - } - - public NetworkRelatedVsdIds getNetworkRelatedVsdIds() { - return networkRelatedVsdIds; - } - - public VspNetwork getVspNetwork() { - return vspNetwork; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ListVspDomainTemplatesAnswer.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ListVspDomainTemplatesAnswer.java deleted file mode 100644 index ec13d671857..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ListVspDomainTemplatesAnswer.java +++ /dev/null @@ -1,44 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import com.cloud.agent.api.Answer; -import net.nuage.vsp.acs.client.api.model.VspDomainTemplate; - -import java.util.List; - - -public class ListVspDomainTemplatesAnswer extends Answer { - private List domainTemplates; - - public ListVspDomainTemplatesAnswer(ListVspDomainTemplatesCommand command, List domainTemplates) { - super(command); - - this.domainTemplates = domainTemplates; - } - - public ListVspDomainTemplatesAnswer(ListVspDomainTemplatesCommand command, Exception e) { - super(command, e); - } - - public List getDomainTemplates() { - return domainTemplates; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ListVspDomainTemplatesCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ListVspDomainTemplatesCommand.java deleted file mode 100644 index e1740044cdf..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/ListVspDomainTemplatesCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import com.cloud.agent.api.Command; -import net.nuage.vsp.acs.client.api.model.VspDomain; - - -public class ListVspDomainTemplatesCommand extends Command { - private final VspDomain _domain; - private final String _name; - - public ListVspDomainTemplatesCommand(VspDomain domain, String name) { - this._domain = domain; - this._name = name; - } - - public VspDomain getDomain() { - return _domain; - } - - public String getName() { - return _name; - } - - @Override - public boolean executeInSequence() { - return false; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/SupportedApiVersionCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/SupportedApiVersionCommand.java deleted file mode 100644 index 6c57e852de9..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/SupportedApiVersionCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import java.util.Objects; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class SupportedApiVersionCommand extends Command { - - private final String _apiVersion; - - public SupportedApiVersionCommand(String apiVersion) { - super(); - this._apiVersion = apiVersion; - } - - public String getApiVersion() { - return _apiVersion; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof SupportedApiVersionCommand)) { - return false; - } - - SupportedApiVersionCommand that = (SupportedApiVersionCommand) o; - - return super.equals(that) - && Objects.equals(_apiVersion, that._apiVersion); - - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_apiVersion) - .toHashCode(); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/UpdateNuageVspDeviceCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/UpdateNuageVspDeviceCommand.java deleted file mode 100644 index d94ff701a97..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/manager/UpdateNuageVspDeviceCommand.java +++ /dev/null @@ -1,70 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.manager; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import java.util.Objects; - -import com.cloud.agent.api.Command; -import com.cloud.network.resource.NuageVspResourceConfiguration; - -public class UpdateNuageVspDeviceCommand extends Command { - - private final NuageVspResourceConfiguration configuration; - - public UpdateNuageVspDeviceCommand(NuageVspResourceConfiguration configuration) { - super(); - this.configuration = configuration; - } - - public NuageVspResourceConfiguration getConfiguration() { - return configuration; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof UpdateNuageVspDeviceCommand)) { - return false; - } - - UpdateNuageVspDeviceCommand that = (UpdateNuageVspDeviceCommand) o; - - return super.equals(that) - && Objects.equals(configuration, that.configuration); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(configuration) - .toHashCode(); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncDomainAnswer.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncDomainAnswer.java deleted file mode 100644 index 26d8ad417cd..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncDomainAnswer.java +++ /dev/null @@ -1,64 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.sync; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Answer; - -public class SyncDomainAnswer extends Answer { - - private final boolean _success; - - public SyncDomainAnswer(boolean success) { - super(); - this._success = success; - } - - public boolean getSuccess() { - return _success; - } - - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof SyncDomainAnswer)) { - return false; - } - - SyncDomainAnswer that = (SyncDomainAnswer) o; - - return super.equals(that) - && _success == that._success; - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_success) - .toHashCode(); - - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncDomainCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncDomainCommand.java deleted file mode 100644 index 024eaae7cca..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncDomainCommand.java +++ /dev/null @@ -1,84 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.sync; - -import java.util.Objects; - -import net.nuage.vsp.acs.client.api.model.VspDomain; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class SyncDomainCommand extends Command { - - public enum Type { ADD, REMOVE } - private final VspDomain _domain; - private final Type _action; - - public SyncDomainCommand(VspDomain domain, Type action) { - super(); - this._domain = domain; - this._action = action; - } - - public VspDomain getDomain() { - return _domain; - } - - public Type getAction() { - return _action; - } - - public boolean isToAdd() { - return Type.ADD.equals(_action); - } - - public boolean isToRemove() { - return Type.REMOVE.equals(_action); - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof SyncDomainCommand)) return false; - if (!super.equals(o)) return false; - - SyncDomainCommand that = (SyncDomainCommand) o; - - return super.equals(that) - && Objects.equals(_action, that._action) - && Objects.equals(_domain, that._domain); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_domain) - .append(_action) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncNuageVspCmsIdAnswer.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncNuageVspCmsIdAnswer.java deleted file mode 100644 index 98730fe7317..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncNuageVspCmsIdAnswer.java +++ /dev/null @@ -1,88 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.sync; - -import java.util.Objects; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; - -public class SyncNuageVspCmsIdAnswer extends Answer { - - private final boolean _success; - private final String _nuageVspCmsId; - private final SyncNuageVspCmsIdCommand.SyncType _syncType; - - public SyncNuageVspCmsIdAnswer(boolean success, String nuageVspCmsId, SyncNuageVspCmsIdCommand.SyncType syncType) { - super(); - this._success = success; - this._nuageVspCmsId = nuageVspCmsId; - this._syncType = syncType; - } - - public SyncNuageVspCmsIdAnswer(Command command, Exception e, SyncNuageVspCmsIdCommand.SyncType syncType) { - super(command, e); - this._nuageVspCmsId = null; - this._success = false; - this._syncType = syncType; - } - - public boolean getSuccess() { - return _success; - } - - public String getNuageVspCmsId() { - return _nuageVspCmsId; - } - - public SyncNuageVspCmsIdCommand.SyncType getSyncType() { - return _syncType; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof SyncNuageVspCmsIdAnswer)) { - return false; - } - - SyncNuageVspCmsIdAnswer that = (SyncNuageVspCmsIdAnswer) o; - - return super.equals(that) - && _success == that._success - && Objects.equals(_syncType, that._syncType) - && Objects.equals(_nuageVspCmsId, that._nuageVspCmsId); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_syncType) - .append(_nuageVspCmsId) - .append(_success) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncNuageVspCmsIdCommand.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncNuageVspCmsIdCommand.java deleted file mode 100644 index 40a0a455b45..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/agent/api/sync/SyncNuageVspCmsIdCommand.java +++ /dev/null @@ -1,75 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api.sync; - -import java.util.Objects; - -import org.apache.commons.lang.builder.HashCodeBuilder; - -import com.cloud.agent.api.Command; - -public class SyncNuageVspCmsIdCommand extends Command { - - public static enum SyncType { AUDIT, AUDIT_ONLY, REGISTER, UNREGISTER } - - private final SyncType _syncType; - private final String _nuageVspCmsId; - - public SyncNuageVspCmsIdCommand(SyncType syncType, String nuageVspCmsId) { - super(); - this._syncType = syncType; - this._nuageVspCmsId = nuageVspCmsId; - } - - public SyncType getSyncType() { - return _syncType; - } - - public String getNuageVspCmsId() { - return _nuageVspCmsId; - } - - @Override - public boolean executeInSequence() { - return false; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof SyncNuageVspCmsIdCommand)) return false; - if (!super.equals(o)) return false; - - SyncNuageVspCmsIdCommand that = (SyncNuageVspCmsIdCommand) o; - - return super.equals(that) - && Objects.equals(_syncType, that._syncType) - && Objects.equals(_nuageVspCmsId, that._nuageVspCmsId); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_syncType) - .append(_nuageVspCmsId) - .toHashCode(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/AddNuageVspDeviceCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/AddNuageVspDeviceCmd.java deleted file mode 100644 index 62a15ea5a77..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/AddNuageVspDeviceCmd.java +++ /dev/null @@ -1,182 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.api.response.NuageVspDeviceResponse; -import com.cloud.event.EventTypes; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.PhysicalNetworkResponse; -import org.apache.cloudstack.context.CallContext; - -import javax.inject.Inject; - -@APICommand(name = AddNuageVspDeviceCmd.APINAME, description = "Adds a Nuage VSP device", responseObject = NuageVspDeviceResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, - since = "4.5", - authorized = {RoleType.Admin}) -public class AddNuageVspDeviceCmd extends BaseAsyncCmd { - public static final String APINAME = "addNuageVspDevice"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = BaseCmd.CommandType.UUID, entityType = PhysicalNetworkResponse.class, - required = true, description = "the ID of the physical network in to which Nuage VSP is added") - private Long physicalNetworkId; - - @Parameter(name = VspConstants.NUAGE_VSP_API_PORT, type = CommandType.INTEGER, required = true, description = "the port to communicate to Nuage VSD") - private int port; - - @Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, required = true, description = "the hostname of the Nuage VSD") - private String hostName; - - @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "the user name of the CMS user in Nuage VSD") - private String userName; - - @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "the password of CMS user in Nuage VSD") - private String password; - - @Parameter(name = VspConstants.NUAGE_VSP_API_VERSION, type = CommandType.STRING, description = "the version of the API to use to communicate to Nuage VSD") - private String apiVersion; - - @Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_COUNT, type = CommandType.INTEGER, description = "the number of retries on failure to communicate to Nuage VSD") - private Integer apiRetryCount; - - @Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_INTERVAL, type = CommandType.LONG, description = "the time to wait after failure before retrying to communicate to Nuage VSD") - private Long apiRetryInterval; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getPhysicalNetworkId() { - return physicalNetworkId; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getHostName() { - return hostName; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } - - public String getUserName() { - return userName; - } - - public String getPassword() { - return password; - } - - public String getApiVersion() { - return apiVersion; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public Integer getApiRetryCount() { - return apiRetryCount; - } - - public void setApiRetryCount(int apiRetryCount) { - this.apiRetryCount = apiRetryCount; - } - - public Long getApiRetryInterval() { - return apiRetryInterval; - } - - public void setApiRetryInterval(long apiRetryInterval) { - this.apiRetryInterval = apiRetryInterval; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - NuageVspDeviceVO nuageVspDeviceVO = _nuageVspManager.addNuageVspDevice(this); - if (nuageVspDeviceVO != null) { - NuageVspDeviceResponse response = _nuageVspManager.createNuageVspDeviceResponse(nuageVspDeviceVO); - response.setObjectName("nuagevspdevice"); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nuage VSP device due to internal error."); - } - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override - public long getEntityOwnerId() { - return CallContext.current().getCallingAccount().getId(); - } - - @Override - public String getEventType() { - return EventTypes.EVENT_EXTERNAL_VSP_VSD_ADD; - } - - @Override - public String getEventDescription() { - return "Adding a Nuage VSD"; - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/AssociateNuageVspDomainTemplateCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/AssociateNuageVspDomainTemplateCmd.java deleted file mode 100644 index 9b36aaff735..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/AssociateNuageVspDomainTemplateCmd.java +++ /dev/null @@ -1,114 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import javax.inject.Inject; - -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.PhysicalNetworkResponse; -import org.apache.cloudstack.api.response.SuccessResponse; -import org.apache.cloudstack.api.response.VpcResponse; -import org.apache.cloudstack.api.response.ZoneResponse; -import org.apache.cloudstack.context.CallContext; - -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; - -@APICommand(name = AssociateNuageVspDomainTemplateCmd.APINAME, responseObject = SuccessResponse.class, - description = "associate a vpc with a domain template", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User}, - since = "4.11.0") -public class AssociateNuageVspDomainTemplateCmd extends BaseCmd { - static final String APINAME = "associateNuageVspDomainTemplate"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, required = true, description = "VPC ID") - private Long vpcId; - - - @Parameter(name = VspConstants.NUAGE_VSP_API_DOMAIN_TEMPLATE, type = CommandType.STRING, required = true, description = "the name of the domain template") - private String domainTemplate; - - @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the physical network ID") - private Long physicalNetworkId; - - @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the zone ID") - private Long zoneId; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getVpcId() { - return vpcId; - } - - public String getDomainTemplate() { return domainTemplate; } - - public Long getZoneId() { return zoneId; } - - public Long getPhysicalNetworkId() { return physicalNetworkId; } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - _nuageVspManager.associateNuageVspDomainTemplate(this); - SuccessResponse response = new SuccessResponse(getCommandName()); - response.setResponseName(getCommandName()); - response.setSuccess(true); - this.setResponseObject(response); - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override - public long getEntityOwnerId() { - return CallContext.current().getCallingAccount().getId(); - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/DeleteNuageVspDeviceCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/DeleteNuageVspDeviceCmd.java deleted file mode 100644 index 05a17d6734c..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/DeleteNuageVspDeviceCmd.java +++ /dev/null @@ -1,110 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.api.response.NuageVspDeviceResponse; -import com.cloud.event.EventTypes; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.SuccessResponse; -import org.apache.cloudstack.context.CallContext; - -import javax.inject.Inject; - -@APICommand(name = DeleteNuageVspDeviceCmd.APINAME, description = "delete a nuage vsp device", responseObject = SuccessResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, - since = "4.5", - authorized = {RoleType.Admin}) -public class DeleteNuageVspDeviceCmd extends BaseAsyncCmd { - public static final String APINAME = "deleteNuageVspDevice"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = VspConstants.NUAGE_VSP_DEVICE_ID, type = CommandType.UUID, entityType = NuageVspDeviceResponse.class, required = true, description = "Nuage device ID") - private Long nuageVspDeviceId; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getNuageVspDeviceId() { - return nuageVspDeviceId; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - boolean result = _nuageVspManager.deleteNuageVspDevice(this); - if (result) { - SuccessResponse response = new SuccessResponse(getCommandName()); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Nuage device."); - } - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override - public long getEntityOwnerId() { - return CallContext.current().getCallingAccount().getId(); - } - - @Override - public String getEventType() { - return EventTypes.EVENT_EXTERNAL_VSP_VSD_DELETE; - } - - @Override - public String getEventDescription() { - return "Deleting Nuage VSD"; - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/DisableNuageUnderlayVlanIpRangeCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/DisableNuageUnderlayVlanIpRangeCmd.java deleted file mode 100644 index bcc804c8da5..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/DisableNuageUnderlayVlanIpRangeCmd.java +++ /dev/null @@ -1,110 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.SuccessResponse; -import org.apache.cloudstack.api.response.VlanIpRangeResponse; -import org.apache.cloudstack.context.CallContext; - -import javax.inject.Inject; - -@APICommand(name = DisableNuageUnderlayVlanIpRangeCmd.APINAME, description = "disable Nuage underlay on vlan ip range", responseObject = SuccessResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, - since = "4.10", - authorized = {RoleType.Admin}) -public class DisableNuageUnderlayVlanIpRangeCmd extends BaseAsyncCmd { - public static final String APINAME = "disableNuageUnderlayVlanIpRange"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VlanIpRangeResponse.class, required = true, description = "VLAN IP Range ID") - private long vlanIpRangeId; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public long getVlanIpRangeId() { - return vlanIpRangeId; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - boolean result = _nuageVspManager.updateNuageUnderlayVlanIpRange(vlanIpRangeId, false); - if (result) { - SuccessResponse response = new SuccessResponse(getCommandName()); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable underlay, VLAN IP range is already pushed to the Nuage VSP device."); - } - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override - public long getEntityOwnerId() { - return CallContext.current().getCallingAccount().getId(); - } - - @Override - public String getEventType() { - return "VLAN.DISABLE.NUAGE.UNDERLAY"; - } - - @Override - public String getEventDescription() { - return "Disable VLAN IP range Nuage underlay"; - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/EnableNuageUnderlayVlanIpRangeCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/EnableNuageUnderlayVlanIpRangeCmd.java deleted file mode 100644 index b1eb9d73032..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/EnableNuageUnderlayVlanIpRangeCmd.java +++ /dev/null @@ -1,110 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.SuccessResponse; -import org.apache.cloudstack.api.response.VlanIpRangeResponse; -import org.apache.cloudstack.context.CallContext; - -import javax.inject.Inject; - -@APICommand(name = EnableNuageUnderlayVlanIpRangeCmd.APINAME, description = "enable Nuage underlay on vlan ip range", responseObject = SuccessResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, - since = "4.10", - authorized = {RoleType.Admin}) -public class EnableNuageUnderlayVlanIpRangeCmd extends BaseAsyncCmd { - public static final String APINAME = "enableNuageUnderlayVlanIpRange"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VlanIpRangeResponse.class, required = true, description = "VLAN IP Range ID") - private long vlanIpRangeId; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public long getVlanIpRangeId() { - return vlanIpRangeId; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - boolean result = _nuageVspManager.updateNuageUnderlayVlanIpRange(vlanIpRangeId, true); - if (result) { - SuccessResponse response = new SuccessResponse(getCommandName()); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable underlay, VLAN IP range is already pushed to the Nuage VSP device."); - } - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override - public long getEntityOwnerId() { - return CallContext.current().getCallingAccount().getId(); - } - - @Override - public String getEventType() { - return "VLAN.ENABLE.NUAGE.UNDERLAY"; - } - - @Override - public String getEventDescription() { - return "Enable VLAN IP range Nuage underlay"; - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageUnderlayVlanIpRangesCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageUnderlayVlanIpRangesCmd.java deleted file mode 100644 index 38bc788c37c..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageUnderlayVlanIpRangesCmd.java +++ /dev/null @@ -1,80 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.api.response.NuageVlanIpRangeResponse; -import com.cloud.dc.Vlan; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.Pair; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd; -import org.apache.cloudstack.api.response.ListResponse; - -import javax.inject.Inject; -import java.util.List; - -@APICommand(name = "listNuageUnderlayVlanIpRanges", description = "enable Nuage underlay on vlan ip range", responseObject = NuageVlanIpRangeResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, - since = "4.10", - authorized = {RoleType.Admin}) -public class ListNuageUnderlayVlanIpRangesCmd extends ListVlanIpRangesCmd { - public static final String APINAME = "listNuageUnderlayVlanIpRanges"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = VspConstants.NUAGE_VSP_API_UNDERLAY, type = CommandType.BOOLEAN, description = "true to list only underlay enabled, false if not, empty for all") - private Boolean underlay; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Boolean getUnderlay() { - return underlay; - } - - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() { - Pair, Integer> vlans = _mgr.searchForVlans(this); - ListResponse response = new ListResponse(); - List vlanIpRanges = _nuageVspManager.filterNuageVlanIpRanges(vlans.first(), underlay); - response.setResponses(vlanIpRanges); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspDevicesCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspDevicesCmd.java deleted file mode 100644 index d9f80e7856f..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspDevicesCmd.java +++ /dev/null @@ -1,111 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.api.response.NuageVspDeviceResponse; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.BaseListCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.ListResponse; -import org.apache.cloudstack.api.response.PhysicalNetworkResponse; - -import javax.inject.Inject; -import java.util.ArrayList; -import java.util.List; - -@APICommand(name = ListNuageVspDevicesCmd.APINAME, description = "Lists Nuage VSP devices", responseObject = NuageVspDeviceResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, - since = "4.5", - authorized = {RoleType.Admin}) -public class ListNuageVspDevicesCmd extends BaseListCmd { - public static final String APINAME = "listNuageVspDevices"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID") - private Long physicalNetworkId; - - @Parameter(name = VspConstants.NUAGE_VSP_DEVICE_ID, type = CommandType.UUID, entityType = NuageVspDeviceResponse.class, description = "the Nuage VSP device ID") - private Long nuageVspDeviceId; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getNuageVspDeviceId() { - return nuageVspDeviceId; - } - - public Long getPhysicalNetworkId() { - return physicalNetworkId; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - List nuageDevices = _nuageVspManager.listNuageVspDevices(this); - ListResponse response = new ListResponse(); - List nuageDevicesResponse = new ArrayList(); - - if (nuageDevices != null && !nuageDevices.isEmpty()) { - for (NuageVspDeviceVO nuageDeviceVO : nuageDevices) { - NuageVspDeviceResponse nuageDeviceResponse = _nuageVspManager.createNuageVspDeviceResponse(nuageDeviceVO); - nuageDevicesResponse.add(nuageDeviceResponse); - } - } - - response.setResponses(nuageDevicesResponse); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspDomainTemplatesCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspDomainTemplatesCmd.java deleted file mode 100644 index 8b000578a51..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspDomainTemplatesCmd.java +++ /dev/null @@ -1,120 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.api.response.NuageVspDomainTemplateResponse; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.BaseResponse; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.DomainResponse; -import org.apache.cloudstack.api.response.ListResponse; -import org.apache.cloudstack.api.response.PhysicalNetworkResponse; -import org.apache.cloudstack.api.response.ZoneResponse; - -import javax.inject.Inject; -import java.util.List; - -@APICommand(name = ListNuageVspDomainTemplatesCmd.APINAME, responseObject = BaseResponse.class, description = "Lists Nuage VSP domain templates", since = "4.11.0", responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User}) -public class ListNuageVspDomainTemplatesCmd extends BaseCmd { - static final String APINAME = "listNuageVspDomainTemplates"; - - @Inject - private NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, - description = "the domain ID") - private Long domainId; - - @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, - description = "the physical network ID") - private Long physicalNetworkId; - - @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, - description = "the zone ID") - private Long zoneId; - - @Parameter(name = ApiConstants.KEYWORD, type = CommandType.STRING, - description = "filters the domain templates which contain the keyword") - private String keyword; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public String getKeyword() { - return keyword; - } - - public Long getDomainId() { - return domainId; - } - - public Long getPhysicalNetworkId() { - return physicalNetworkId; - } - - public Long getZoneId() { return zoneId; } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - List responses = _nuageVspManager.listNuageVspDomainTemplates(this); - ListResponse response = new ListResponse<>(); - response.setResponses(responses); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException e) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override public long getEntityOwnerId() { - return 0; //not owned by anyone - } - -} - diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspGlobalDomainTemplateCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspGlobalDomainTemplateCmd.java deleted file mode 100644 index 902417020a0..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/ListNuageVspGlobalDomainTemplateCmd.java +++ /dev/null @@ -1,81 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import java.util.LinkedList; -import java.util.List; - -import javax.inject.Inject; - -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.BaseResponse; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.ListResponse; - -import com.cloud.api.response.NuageVspDomainTemplateResponse; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.NetworkRuleConflictException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.user.Account; -import com.cloud.utils.exception.CloudRuntimeException; - -@APICommand(name = ListNuageVspGlobalDomainTemplateCmd.APINAME, responseObject = BaseResponse.class, - description = "Lists Nuage VSP domain templates", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User}, - since = "4.11.0") -public class ListNuageVspGlobalDomainTemplateCmd extends BaseCmd { - static final String APINAME = "listNuageVspGlobalDomainTemplate"; - - @Inject - private NuageVspManager _nuageVspManager; - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { - try { - List responses = new LinkedList<>(); - NuageVspDomainTemplateResponse answer = new NuageVspDomainTemplateResponse(_nuageVspManager.NuageVspVpcDomainTemplateName.value(),_nuageVspManager.NuageVspVpcDomainTemplateName.value()); - responses.add(answer); - - ListResponse response = new ListResponse<>(); - response.setResponses(responses); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException e) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override public long getEntityOwnerId() { - return Account.ACCOUNT_ID_SYSTEM; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/UpdateNuageVspDeviceCmd.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/UpdateNuageVspDeviceCmd.java deleted file mode 100755 index 4197bd65a7d..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/UpdateNuageVspDeviceCmd.java +++ /dev/null @@ -1,182 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -import com.cloud.api.response.NuageVspDeviceResponse; -import com.cloud.event.EventTypes; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.exception.CloudRuntimeException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.APICommand; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.ApiErrorCode; -import org.apache.cloudstack.api.BaseAsyncCmd; -import org.apache.cloudstack.api.BaseCmd; -import org.apache.cloudstack.api.Parameter; -import org.apache.cloudstack.api.ServerApiException; -import org.apache.cloudstack.api.response.PhysicalNetworkResponse; -import org.apache.cloudstack.context.CallContext; - -import javax.inject.Inject; - -@APICommand(name = UpdateNuageVspDeviceCmd.APINAME, description = "Update a Nuage VSP device", responseObject = NuageVspDeviceResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, - since = "4.6", - authorized = {RoleType.Admin}) -public class UpdateNuageVspDeviceCmd extends BaseAsyncCmd { - public static final String APINAME = "updateNuageVspDevice"; - - @Inject - NuageVspManager _nuageVspManager; - - ///////////////////////////////////////////////////// - //////////////// API parameters ///////////////////// - ///////////////////////////////////////////////////// - - @Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = BaseCmd.CommandType.UUID, entityType = PhysicalNetworkResponse.class, - required = true, description = "the ID of the physical network in to which Nuage VSP is added") - private Long physicalNetworkId; - - @Parameter(name = VspConstants.NUAGE_VSP_API_PORT, type = CommandType.INTEGER, description = "the port to communicate to Nuage VSD") - private Integer port; - - @Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, description = "the hostname of the Nuage VSD") - private String hostName; - - @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = "the user name of the CMS user in Nuage VSD") - private String userName; - - @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, description = "the password of CMS user in Nuage VSD") - private String password; - - @Parameter(name = VspConstants.NUAGE_VSP_API_VERSION, type = CommandType.STRING, description = "the version of the API to use to communicate to Nuage VSD") - private String apiVersion; - - @Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_COUNT, type = CommandType.INTEGER, description = "the number of retries on failure to communicate to Nuage VSD") - private Integer apiRetryCount; - - @Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_INTERVAL, type = CommandType.LONG, description = "the time to wait after failure before retrying to communicate to Nuage VSD") - private Long apiRetryInterval; - - ///////////////////////////////////////////////////// - /////////////////// Accessors /////////////////////// - ///////////////////////////////////////////////////// - - public Long getPhysicalNetworkId() { - return physicalNetworkId; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public String getHostName() { - return hostName; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } - - public String getUserName() { - return userName; - } - - public String getPassword() { - return password; - } - - public String getApiVersion() { - return apiVersion; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public Integer getApiRetryCount() { - return apiRetryCount; - } - - public void setApiRetryCount(Integer apiRetryCount) { - this.apiRetryCount = apiRetryCount; - } - - public Long getApiRetryInterval() { - return apiRetryInterval; - } - - public void setApiRetryInterval(Long apiRetryInterval) { - this.apiRetryInterval = apiRetryInterval; - } - - ///////////////////////////////////////////////////// - /////////////// API Implementation/////////////////// - ///////////////////////////////////////////////////// - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { - try { - NuageVspDeviceVO nuageVspDeviceVO = _nuageVspManager.updateNuageVspDevice(this); - if (nuageVspDeviceVO != null) { - NuageVspDeviceResponse response = _nuageVspManager.createNuageVspDeviceResponse(nuageVspDeviceVO); - response.setObjectName("nuagevspdevice"); - response.setResponseName(getCommandName()); - this.setResponseObject(response); - } else { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nuage VSP device due to internal error."); - } - } catch (InvalidParameterValueException invalidParamExcp) { - throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage()); - } catch (CloudRuntimeException runtimeExcp) { - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage()); - } - } - - @Override - public String getCommandName() { - return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX; - } - - @Override - public long getEntityOwnerId() { - return CallContext.current().getCallingAccount().getId(); - } - - @Override - public String getEventType() { - return EventTypes.EVENT_EXTERNAL_VSP_VSD_UPDATE; - } - - @Override - public String getEventDescription() { - return "Updating a Nuage VSD"; - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/VspConstants.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/VspConstants.java deleted file mode 100644 index 5b226afe591..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/commands/VspConstants.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.commands; - -public class VspConstants { - public static final String NUAGE_VSP_DEVICE_ID = "vspdeviceid"; - public static final String NUAGE_VSP_DEVICE_NAME = "nuagedevicename"; - public static final String NUAGE_VSP_API_PORT = "port"; - public static final String NUAGE_VSP_API_VERSION = "apiversion"; - public static final String NUAGE_VSP_API_RETRY_COUNT = "retrycount"; - public static final String NUAGE_VSP_API_RETRY_INTERVAL = "retryinterval"; - public static final String NUAGE_VSP_API_METHOD = "method"; - public static final String NUAGE_VSP_API_RESOURCE = "resource"; - public static final String NUAGE_VSP_API_RESOURCE_ID = "resourceid"; - public static final String NUAGE_VSP_API_CHILD_RESOURCE = "childresource"; - public static final String NUAGE_VSP_API_RESOURCE_FILTER = "resourcefilter"; - public static final String NUAGE_VSP_API_RESOURCE_INFO = "resourceinfo"; - public static final String NUAGE_VSP_CMS_ID = "cmsid"; - public static final String NUAGE_VSP_API_UNDERLAY = "underlay"; - public static final String NUAGE_VSP_API_DOMAIN_TEMPLATE = "domaintemplate"; -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVlanIpRangeResponse.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVlanIpRangeResponse.java deleted file mode 100644 index cc3204d9709..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVlanIpRangeResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.response; - -import com.cloud.api.commands.VspConstants; -import com.cloud.dc.Vlan; -import com.cloud.serializer.Param; -import com.google.gson.annotations.SerializedName; -import org.apache.cloudstack.api.EntityReference; -import org.apache.cloudstack.api.response.VlanIpRangeResponse; - -@EntityReference(value = Vlan.class) -public class NuageVlanIpRangeResponse extends VlanIpRangeResponse { - @SerializedName(VspConstants.NUAGE_VSP_API_UNDERLAY) - @Param(description = "true if Nuage underlay enabled, false if not") - private boolean underlay; - - public void setUnderlay(boolean underlay) { - this.underlay = underlay; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspDeviceResponse.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspDeviceResponse.java deleted file mode 100644 index 346e28823f6..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspDeviceResponse.java +++ /dev/null @@ -1,111 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.response; - -import com.cloud.api.commands.VspConstants; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.serializer.Param; -import com.google.gson.annotations.SerializedName; -import org.apache.cloudstack.api.ApiConstants; -import org.apache.cloudstack.api.BaseResponse; -import org.apache.cloudstack.api.EntityReference; - -@EntityReference(value = NuageVspDeviceVO.class) -public class NuageVspDeviceResponse extends BaseResponse { - @SerializedName(VspConstants.NUAGE_VSP_DEVICE_ID) - @Param(description = "the device id of the Nuage VSD") - private String id; - - @SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) - @Param(description = "the ID of the physical network to which this Nuage VSP belongs to") - private String physicalNetworkId; - - @SerializedName(ApiConstants.PROVIDER) - @Param(description = "the service provider name corresponding to this Nuage VSP device") - private String providerName; - - @SerializedName(VspConstants.NUAGE_VSP_DEVICE_NAME) - @Param(description = "the name of the Nuage VSP device") - private String deviceName; - - @SerializedName(VspConstants.NUAGE_VSP_API_PORT) - @Param(description = "the port to communicate to Nuage VSD") - private int port; - - @SerializedName(ApiConstants.HOST_NAME) - @Param(description = "the hostname of the Nuage VSD") - private String hostName; - - @SerializedName(VspConstants.NUAGE_VSP_API_VERSION) - @Param(description = "the version of the API to use to communicate to Nuage VSD") - private String apiVersion; - - @SerializedName(VspConstants.NUAGE_VSP_API_RETRY_COUNT) - @Param(description = "the number of retries on failure to communicate to Nuage VSD") - private int apiRetryCount; - - @SerializedName(VspConstants.NUAGE_VSP_API_RETRY_INTERVAL) - @Param(description = "the time to wait after failure before retrying to communicate to Nuage VSD") - private long apiRetryInterval; - - @SerializedName(VspConstants.NUAGE_VSP_CMS_ID) - @Param(description = "the CMS ID generated by the Nuage VSD") - private String cmsId; - - public void setId(String vspDetailsId) { - this.id = vspDetailsId; - } - - public void setPhysicalNetworkId(String physicalNetworkId) { - this.physicalNetworkId = physicalNetworkId; - } - - public void setProviderName(String providerName) { - this.providerName = providerName; - } - - public void setDeviceName(String deviceName) { - this.deviceName = deviceName; - } - - public void setPort(int port) { - this.port = port; - } - - public void setHostName(String hostName) { - this.hostName = hostName; - } - - public void setApiVersion(String apiVersion) { - this.apiVersion = apiVersion; - } - - public void setApiRetryCount(int apiRetryCount) { - this.apiRetryCount = apiRetryCount; - } - - public void setApiRetryInterval(long apiRetryInterval) { - this.apiRetryInterval = apiRetryInterval; - } - - public void setCmsId(String cmsId) { - this.cmsId = cmsId; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspDomainTemplateResponse.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspDomainTemplateResponse.java deleted file mode 100644 index ce36e8e8ed8..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspDomainTemplateResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.response; - -import com.cloud.serializer.Param; -import org.apache.cloudstack.api.BaseResponse; - -public class NuageVspDomainTemplateResponse extends BaseResponse { - @Param(description = "the name of the domain template") - private String name; - - @Param(description = "the description of the domain template") - private String description; - - public NuageVspDomainTemplateResponse(String name, String description) { - this.name = name; - this.description = description; - this.setObjectName("domaintemplates"); - } - - public String getName() { - return name; - } - - public String getDescription() { - return description; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspResourceResponse.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspResourceResponse.java deleted file mode 100644 index 70024134a8f..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/api/response/NuageVspResourceResponse.java +++ /dev/null @@ -1,40 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.api.response; - -import com.cloud.api.commands.VspConstants; -import com.cloud.serializer.Param; -import com.google.gson.annotations.SerializedName; -import org.apache.cloudstack.api.BaseResponse; - -public class NuageVspResourceResponse extends BaseResponse { - @SerializedName(VspConstants.NUAGE_VSP_API_RESOURCE_INFO) - @Param(description = "the details of the Nuage VSP resource") - private String resourceInfo; - - public String getResourceInfo() { - return resourceInfo; - } - - public void setResourceInfo(String resourceInfo) { - this.resourceInfo = resourceInfo; - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/NuageVspDeviceVO.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/NuageVspDeviceVO.java deleted file mode 100644 index ad5a7eb2540..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/NuageVspDeviceVO.java +++ /dev/null @@ -1,97 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network; - -import org.apache.cloudstack.api.InternalIdentity; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; -import java.util.UUID; - -@Entity -@Table(name = "external_nuage_vsp_devices") -public class NuageVspDeviceVO implements InternalIdentity { - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private long id; - - @Column(name = "uuid") - private String uuid; - - @Column(name = "host_id") - private long hostId; - - @Column(name = "physical_network_id") - private long physicalNetworkId; - - @Column(name = "provider_name") - private String providerName; - - @Column(name = "device_name") - private String deviceName; - - public NuageVspDeviceVO() { - this.uuid = UUID.randomUUID().toString(); - } - - public NuageVspDeviceVO(long hostId, long physicalNetworkId, - String providerName, String deviceName){ - super(); - this.hostId = hostId; - this.physicalNetworkId = physicalNetworkId; - this.providerName = providerName; - this.deviceName = deviceName; - this.uuid = UUID.randomUUID().toString(); - } - - @Override - public long getId() { - return id; - } - - public String getUuid() { - return uuid; - } - - public long getHostId() { - return hostId; - } - - public long getPhysicalNetworkId() { - return physicalNetworkId; - } - - public String getProviderName() { - return providerName; - } - - public String getDeviceName() { - return deviceName; - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/dao/NuageVspDao.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/dao/NuageVspDao.java deleted file mode 100644 index aa795eb7b83..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/dao/NuageVspDao.java +++ /dev/null @@ -1,44 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.dao; - -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.utils.db.GenericDao; - -import java.util.List; - -public interface NuageVspDao extends GenericDao { - /** - * List all the Nuage Vsp devices added in to this physical network - * - * @param physicalNetworkId physical Network Id - * @return list of NuageVspDeviceVO for this physical network. - */ - List listByPhysicalNetwork(long physicalNetworkId); - - /** - * List all the Nuage Vsp devices by a specific host - * - * @param hostId host Id - * @return list of NuageVspDeviceVO for this host. - */ - List listByHost(long hostId); - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/dao/NuageVspDaoImpl.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/dao/NuageVspDaoImpl.java deleted file mode 100644 index d308fe18a4b..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/dao/NuageVspDaoImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.dao; - -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.utils.db.GenericDaoBase; -import com.cloud.utils.db.SearchBuilder; -import com.cloud.utils.db.SearchCriteria; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Component -public class NuageVspDaoImpl extends GenericDaoBase - implements NuageVspDao { - - private final SearchBuilder physicalNetworkIdSearch; - private final SearchBuilder hostIdSearch; - - public NuageVspDaoImpl() { - physicalNetworkIdSearch = createSearchBuilder(); - physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ); - physicalNetworkIdSearch.done(); - - hostIdSearch = createSearchBuilder(); - hostIdSearch.and("hostId", hostIdSearch.entity().getHostId(), SearchCriteria.Op.EQ); - hostIdSearch.done(); - } - - @Override - public List listByPhysicalNetwork(long physicalNetworkId) { - SearchCriteria sc = physicalNetworkIdSearch.create(); - sc.setParameters("physicalNetworkId", physicalNetworkId); - return search(sc, null); - } - - @Override - public List listByHost(long hostId) { - SearchCriteria sc = hostIdSearch.create(); - sc.setParameters("hostId", hostId); - return search(sc, null); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/element/NuageVspElement.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/element/NuageVspElement.java deleted file mode 100644 index b92e82731d9..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/element/NuageVspElement.java +++ /dev/null @@ -1,788 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.element; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.annotation.Nullable; -import javax.inject.Inject; -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; - -import com.google.common.base.Function; -import com.google.common.base.Preconditions; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; - -import org.apache.cloudstack.api.InternalIdentity; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import org.apache.cloudstack.network.ExternalNetworkDeviceManager; -import org.apache.cloudstack.resourcedetail.VpcDetailVO; -import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao; - -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.StartupCommand; -import com.cloud.agent.api.StartupVspCommand; -import com.cloud.agent.api.element.ApplyAclRuleVspCommand; -import com.cloud.agent.api.element.ApplyStaticNatVspCommand; -import com.cloud.agent.api.element.ExtraDhcpOptionsVspCommand; -import com.cloud.agent.api.element.ImplementVspCommand; -import com.cloud.agent.api.element.ShutDownVpcVspCommand; -import com.cloud.agent.api.element.ShutDownVspCommand; -import com.cloud.dc.Vlan; -import com.cloud.dc.VlanVO; -import com.cloud.dc.dao.VlanDao; -import com.cloud.dc.dao.VlanDetailsDao; -import com.cloud.deploy.DeployDestination; -import com.cloud.domain.Domain; -import com.cloud.domain.dao.DomainDao; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.exception.UnsupportedServiceException; -import com.cloud.host.Host; -import com.cloud.host.HostVO; -import com.cloud.network.Network; -import com.cloud.network.Network.Capability; -import com.cloud.network.Network.Provider; -import com.cloud.network.Network.Service; -import com.cloud.network.NetworkMigrationManager; -import com.cloud.network.NetworkModel; -import com.cloud.network.Networks; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.PublicIpAddress; -import com.cloud.network.dao.FirewallRulesCidrsDao; -import com.cloud.network.dao.FirewallRulesDao; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkServiceMapDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.network.manager.NuageVspManagerImpl; -import com.cloud.network.rules.FirewallRule; -import com.cloud.network.rules.FirewallRule.FirewallRuleType; -import com.cloud.network.rules.FirewallRuleVO; -import com.cloud.network.rules.StaticNat; -import com.cloud.network.vpc.NetworkACLItem; -import com.cloud.network.vpc.NetworkACLItemDao; -import com.cloud.network.vpc.NetworkACLItemVO; -import com.cloud.network.vpc.PrivateGateway; -import com.cloud.network.vpc.StaticRouteProfile; -import com.cloud.network.vpc.Vpc; -import com.cloud.network.vpc.VpcOfferingServiceMapVO; -import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; -import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.resource.ResourceManager; -import com.cloud.resource.ResourceStateAdapter; -import com.cloud.resource.ServerResource; -import com.cloud.resource.UnableDeleteHostException; -import com.cloud.server.ResourceTag; -import com.cloud.tags.dao.ResourceTagDao; -import com.cloud.util.NuageVspEntityBuilder; -import com.cloud.util.NuageVspUtil; -import com.cloud.utils.Pair; -import com.cloud.utils.component.AdapterBase; -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.utils.net.NetUtils; -import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.VirtualMachineProfile; -import com.cloud.vm.dao.DomainRouterDao; -import com.cloud.vm.dao.NicDao; - -public class NuageVspElement extends AdapterBase implements ConnectivityProvider, IpDeployer, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider, - DhcpServiceProvider, ResourceStateAdapter, VpcProvider, NetworkACLServiceProvider { - - private static final Logger s_logger = Logger.getLogger(NuageVspElement.class); - - private static final Map> capabilities = setCapabilities(); - - private static final Set REQUIRED_SERVICES = ImmutableSet.of( - Service.Connectivity, - Service.Dhcp - ); - private static final Set NUAGE_ONLY_SERVICES = ImmutableSet.of( - Service.SourceNat, - Service.StaticNat, - Service.Gateway - ); - private static final Set UNSUPPORTED_SERVICES = ImmutableSet.of( - Service.Vpn, - Service.Dns, - Service.PortForwarding, - Service.SecurityGroup - ); - private static final Set> ANY_REQUIRED_SERVICES = ImmutableSet.of( - new Pair<>(Service.SourceNat, Service.StaticNat) - ); - - - public static final ExternalNetworkDeviceManager.NetworkDevice NuageVspDevice = new ExternalNetworkDeviceManager.NetworkDevice("NuageVsp", Provider.NuageVsp.getName()); - - @Inject - ResourceManager _resourceMgr; - @Inject - NetworkModel _networkModel; - @Inject - NetworkServiceMapDao _ntwkSrvcDao; - @Inject - NetworkDao _networkDao; - @Inject - DomainDao _domainDao; - @Inject - IPAddressDao _ipAddressDao; - @Inject - VlanDao _vlanDao; - @Inject - VlanDetailsDao _vlanDetailsDao; - @Inject - NicDao _nicDao; - @Inject - VpcOfferingServiceMapDao _vpcOfferingSrvcDao; - @Inject - AgentManager _agentMgr; - @Inject - NetworkOfferingDao _ntwkOfferingDao; - @Inject - ConfigurationDao _configDao; - @Inject - NuageVspManager _nuageVspManager; - @Inject - FirewallRulesDao _firewallRulesDao; - @Inject - FirewallRulesCidrsDao _firewallRulesCidrsDao; - @Inject - PhysicalNetworkDao _physicalNetworkDao; - @Inject - NetworkACLItemDao _networkACLItemDao; - @Inject - NuageVspEntityBuilder _nuageVspEntityBuilder; - @Inject - VpcDetailsDao _vpcDetailsDao; - @Inject - DomainRouterDao _routerDao; - @Inject - ResourceTagDao _resourceTagDao; - - @Override - public boolean applyIps(Network network, List ipAddress, Set service) throws ResourceUnavailableException { - return false; - } - - @Override - public Map> getCapabilities() { - return capabilities; - } - - private static Map> setCapabilities() { - return ImmutableMap.>builder() - .put(Service.Connectivity, ImmutableMap.of( - Capability.NoVlan, "", - Capability.PublicAccess, "" - )) - .put(Service.Gateway, ImmutableMap.of()) - .put(Service.SourceNat, ImmutableMap.of( - Capability.SupportedSourceNatTypes, "perzone", - Capability.RedundantRouter, "false" - )) - .put(Service.StaticNat, ImmutableMap.of()) - .put(Service.SecurityGroup, ImmutableMap.of()) - .put(Service.Firewall, ImmutableMap.of( - Capability.TrafficStatistics, "per public ip", - Capability.SupportedProtocols, "tcp,udp,icmp", - Capability.SupportedEgressProtocols, "tcp,udp,icmp, all", - Capability.SupportedTrafficDirection, "ingress, egress", - Capability.MultipleIps, "true" - )) - .put(Service.Dhcp, ImmutableMap.of( - Capability.DhcpAccrossMultipleSubnets, "true", - Capability.ExtraDhcpOptions, "true" - )) - .put(Service.NetworkACL, ImmutableMap.of( - Capability.SupportedProtocols, "tcp,udp,icmp" - )) - .build(); - } - - @Override - public Provider getProvider() { - return Provider.NuageVsp; - } - - @Override - public boolean configure(String name, Map params) throws ConfigurationException { - super.configure(name, params); - _resourceMgr.registerResourceStateAdapter(name, this); - return true; - } - - @Override - public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, - ResourceUnavailableException, InsufficientCapacityException { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Entering NuageElement implement function for network " + network.getDisplayText() + " (state " + network.getState() + ")"); - } - - if (network.getVpcId() != null) { - return applyACLRulesForVpc(network, offering); - } - - if (!canHandle(network, offering, Service.Connectivity)) { - return false; - } - - if (network.getBroadcastUri() == null) { - s_logger.error("Nic has no broadcast Uri with the virtual router IP"); - return false; - } - - _nuageVspManager.updateBroadcastUri(network); - network = _networkDao.findById(network.getId()); - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network); - List ingressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Ingress); - List egressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Egress); - - List ips = _ipAddressDao.listStaticNatPublicIps(network.getId()); - List floatingIpUuids = new ArrayList(); - for (IPAddressVO ip : ips) { - floatingIpUuids.add(ip.getUuid()); - } - VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering); - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId()); - ImplementVspCommand cmd = new ImplementVspCommand(vspNetwork, ingressFirewallRules, egressFirewallRules, floatingIpUuids, vspDhcpOptions); - send(cmd, network); - - return true; - } - - private void send(Command cmd, Network network) - throws ResourceUnavailableException { - send(cmd, network.getPhysicalNetworkId(), Network.class, network); - } - - private void send(Command cmd, Vpc vpc) - throws ResourceUnavailableException { - send(cmd, getPhysicalNetworkId(vpc.getZoneId()), Vpc.class, vpc); - } - - - private void send(Command cmd, long physicalNetworkId, Class resourceClass, - R resource) - throws ResourceUnavailableException { - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(physicalNetworkId); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - if (isFailure(answer)) { - s_logger.error(cmd.getClass().getName() + " for " + resourceClass.getName() + " " + resource.getId() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); - if (hasFailureDetails(answer)) { - throw new ResourceUnavailableException(answer.getDetails(), resourceClass, resource.getId()); - } - } - } - - private boolean hasFailureDetails(Answer answer) { - return (null != answer) && (null != answer.getDetails()); - } - - private boolean isFailure(Answer answer) { - return answer == null || !answer.getResult(); - } - - private boolean applyACLRulesForVpc(Network network, NetworkOffering offering) throws ResourceUnavailableException { - List rules = _networkACLItemDao.listByACL(network.getNetworkACLId()); - if (_networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.NetworkACL)) { - applyACLRules(network, rules, true, false); - } - return true; - } - - private List getFirewallRulesToApply(final Network network, FirewallRule.TrafficType trafficType) { - List firewallRulesToApply = _firewallRulesDao.listByNetworkPurposeTrafficType(network.getId(), FirewallRule.Purpose.Firewall, trafficType); - List vspAclRulesToApply = Lists.newArrayListWithExpectedSize(firewallRulesToApply.size()); - - for (FirewallRuleVO rule : firewallRulesToApply) { - rule.setSourceCidrList(_firewallRulesCidrsDao.getSourceCidrs(rule.getId())); - VspAclRule vspAclRule = _nuageVspEntityBuilder.buildVspAclRule(rule, network); - vspAclRulesToApply.add(vspAclRule); - } - return vspAclRulesToApply; - } - - @Override - public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, - ResourceUnavailableException, InsufficientCapacityException { - if (!canHandle(network, Service.Connectivity)) { - return false; - } - - if (network.getBroadcastUri() == null) { - s_logger.error("Nic has no broadcast Uri with the virtual router IP"); - return false; - } - - return true; - } - - @Override - public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { - if (!canHandle(network, Service.Connectivity)) { - return false; - } - - if (network.getBroadcastUri() == null) { - s_logger.error("Nic has no broadcast Uri with the virtual router IP"); - return false; - } - - return true; - } - - @Override - public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException { - if (!canHandle(network, Service.Connectivity)) { - return false; - } - if (cleanup && isDnsSupportedByVR(network)) { - // The network is restarted, possibly the domain name is changed, update the dhcpOptions as soon as possible - NetworkOfferingVO networkOfferingVO = _ntwkOfferingDao.findById(network.getNetworkOfferingId()); - VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, networkOfferingVO); - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network); - - ShutDownVspCommand cmd = new ShutDownVspCommand(vspNetwork, vspDhcpOptions); - send(cmd, network); - } - return true; - } - - @Override - public boolean isReady(PhysicalNetworkServiceProvider provider) { - return true; - } - - @Override - public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { - return true; - } - - @Override - public boolean canEnableIndividualServices() { - return true; - } - - @Override - public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { - return canHandle(network, Service.Connectivity); - } - - @Override - public boolean verifyServicesCombination(Set services) { - Preconditions.checkNotNull(services); - final Sets.SetView missingServices = Sets.difference(REQUIRED_SERVICES, services); - final Sets.SetView unsupportedServices = Sets.intersection(UNSUPPORTED_SERVICES, services); - final Sets.SetView wantedServices = Sets.intersection(NUAGE_ONLY_SERVICES, new HashSet<>()); - - if (!missingServices.isEmpty()) { - throw new UnsupportedServiceException("Provider " + Provider.NuageVsp + " requires services: " + missingServices); - } - - if (!unsupportedServices.isEmpty()) { - // NuageVsp doesn't implement any of these services. - // So if these services are requested, we can't handle it. - s_logger.debug("Unable to support services combination. The services " + unsupportedServices + " are not supported by Nuage VSP."); - return false; - } - - if (!wantedServices.isEmpty()) { - throw new UnsupportedServiceException("Provider " + Provider.NuageVsp + " does not support services to be implemented by another provider: " + wantedServices); - } - - return true; - } - - protected boolean canHandle(Network network, Service service) { - NetworkOffering networkOffering = _ntwkOfferingDao.findById(network.getNetworkOfferingId()); - return canHandle(network, networkOffering, service); - } - - protected boolean canHandle(Network network, NetworkOffering networkOffering, Service service) { - if (network.getBroadcastDomainType() != Networks.BroadcastDomainType.Vsp) { - return false; - } - - if (!_networkModel.isProviderForNetwork(getProvider(), network.getId())) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp is not a provider for network " + network.getDisplayText()); - } - return false; - } - - if (service != null) { - if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, getProvider())) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp can't provide the " + service.getName() + " service on network " + network.getDisplayText()); - } - return false; - } - } - - if (service != Service.Connectivity - && !_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), Service.Connectivity, getProvider())) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as Connectivity provider"); - } - return false; - } - - if (service != Service.SourceNat - && networkOffering.getGuestType() == Network.GuestType.Isolated - && !_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, getProvider())) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as SourceNat provider"); - } - return false; - } - - if (networkOffering.isSpecifyVlan()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp doesn't support VLAN values for networks"); - } - return false; - } - - if (network.getVpcId() != null && !networkOffering.isPersistent()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp can't handle VPC tiers which use a network offering which are not persistent"); - } - return false; - } - - return true; - } - - @Override - public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, - InsufficientCapacityException, ResourceUnavailableException { - return true; - } - - @Override - public boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) - throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { - return true; - } - - private boolean isDnsSupportedByVR(Network network) { - return (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dns) && - ( _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VirtualRouter) || - _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter))); - } - - @Override - public boolean removeDhcpSupportForSubnet(Network network) throws ResourceUnavailableException { - return true; - } - - @Override - public boolean setExtraDhcpOptions(Network network, long nicId, Map dhcpOptions) { - if (network.isRollingRestart()) { - return true; - } - - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network); - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId()); - NicVO nic = _nicDao.findById(nicId); - - ExtraDhcpOptionsVspCommand extraDhcpOptionsVspCommand = new ExtraDhcpOptionsVspCommand(vspNetwork, nic.getUuid(), dhcpOptions); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), extraDhcpOptionsVspCommand); - if (isFailure(answer)) { - s_logger.error("[setExtraDhcpOptions] setting extra DHCP options for nic " + nic.getUuid() + " failed."); - return false; - } - - return true; - } - - @Override - public boolean applyStaticNats(Network config, List rules) throws ResourceUnavailableException { - List vspStaticNatDetails = new ArrayList(); - for (StaticNat staticNat : rules) { - IPAddressVO sourceNatIp = _ipAddressDao.findById(staticNat.getSourceIpAddressId()); - VlanVO sourceNatVlan = _vlanDao.findById(sourceNatIp.getVlanId()); - checkVlanUnderlayCompatibility(sourceNatVlan); - - if (!staticNat.isForRevoke()) { - final List firewallRules = _firewallRulesDao.listByIpAndNotRevoked(staticNat.getSourceIpAddressId()); - for (FirewallRuleVO firewallRule : firewallRules) { - _nuageVspEntityBuilder.buildVspAclRule(firewallRule, config, sourceNatIp); - } - } - - NicVO nicVO = _nicDao.findByIp4AddressAndNetworkId(staticNat.getDestIpAddress(), staticNat.getNetworkId()); - VspStaticNat vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(staticNat.isForRevoke(), sourceNatIp, sourceNatVlan, nicVO); - vspStaticNatDetails.add(vspStaticNat); - - - } - - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(config); - ApplyStaticNatVspCommand cmd = new ApplyStaticNatVspCommand(vspNetwork, vspStaticNatDetails); - send(cmd, - config); - - return true; - } - - private void checkVlanUnderlayCompatibility(VlanVO newVlan) throws ResourceUnavailableException { - List vlans = _vlanDao.listByZone(newVlan.getDataCenterId()); - if (CollectionUtils.isNotEmpty(vlans)) { - boolean newVlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, newVlan); - final String newCidr = NetUtils.getCidrFromGatewayAndNetmask(newVlan.getVlanGateway(), newVlan.getVlanNetmask()); - - for (VlanVO vlan : vlans) { - if (vlan.getId() == newVlan.getId()) continue; - - final String existingCidr = NetUtils.getCidrFromGatewayAndNetmask(vlan.getVlanGateway(), vlan.getVlanNetmask()); - - NetUtils.SupersetOrSubset supersetOrSubset = NetUtils.isNetowrkASubsetOrSupersetOfNetworkB(newCidr, existingCidr); - if (supersetOrSubset == NetUtils.SupersetOrSubset.sameSubnet) { - boolean vlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, vlan); - if (newVlanUnderlay != vlanUnderlay) { - throw new ResourceUnavailableException("Mixed values for the underlay flag for IP ranges in the same subnet is not supported", Vlan.class, newVlan.getId()); - } - break; - } - } - } - } - - @Override - public IpDeployer getIpDeployer(Network network) { - return this; - } - - @Override - public boolean applyFWRules(Network network, List rules) throws ResourceUnavailableException { - if (rules == null || rules.isEmpty()) { - return true; - } - - if (rules.size() == 1 && rules.iterator().next().getType().equals(FirewallRuleType.System)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Default ACL added by CS as system is ignored for network " + network.getName() + " with rule " + rules); - } - return true; - } - - s_logger.info("Applying " + rules.size() + " Firewall Rules for network " + network.getName()); - return applyACLRules(network, rules, false, false); - } - - protected boolean applyACLRules(final Network network, List rules, boolean isNetworkAcl, boolean networkReset) - throws ResourceUnavailableException { - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network); - List vspAclRules = Lists.transform(rules, new Function() { - @Nullable - @Override - public VspAclRule apply(@Nullable InternalIdentity input) { - if (input instanceof FirewallRule) { - return _nuageVspEntityBuilder.buildVspAclRule((FirewallRule) input, network); - } - return _nuageVspEntityBuilder.buildVspAclRule((NetworkACLItem) input); - } - }); - - VspAclRule.ACLType vspAclType = isNetworkAcl ? VspAclRule.ACLType.NetworkACL : VspAclRule.ACLType.Firewall; - ApplyAclRuleVspCommand cmd = new ApplyAclRuleVspCommand(vspAclType, vspNetwork, vspAclRules, networkReset); - send(cmd, - network); - return true; - } - - @Override - public boolean applyNetworkACLs(Network config, List rules) throws ResourceUnavailableException { - if (rules == null || rules.isEmpty()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("No rules to apply. So, delete all the existing ACL in VSP from Subnet with uuid " + config.getUuid()); - } - } else { - if (s_logger.isDebugEnabled()) { - s_logger.debug("New rules has to applied. So, delete all the existing ACL in VSP from Subnet with uuid " + config.getUuid()); - } - } - if (rules != null) { - s_logger.info("Applying " + rules.size() + " Network ACLs for network " + config.getName()); - applyACLRules(config, rules, true, rules.isEmpty()); - } - return true; - } - - @Override - public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException { - List vpcOfferingServices = _vpcOfferingSrvcDao.listByVpcOffId(vpc.getVpcOfferingId()); - Multimap supportedVpcServices = NuageVspManagerImpl.SUPPORTED_NUAGE_VSP_VPC_SERVICE_MAP; - for (VpcOfferingServiceMapVO vpcOfferingService : vpcOfferingServices) { - Network.Service service = Network.Service.getService(vpcOfferingService.getService()); - if (!supportedVpcServices.containsKey(service)) { - s_logger.warn(String.format("NuageVsp doesn't support service %s for VPCs", service.getName())); - return false; - } - - Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider()); - if (!supportedVpcServices.containsEntry(service, provider)) { - s_logger.warn(String.format("NuageVsp doesn't support provider %s for service %s for VPCs", provider.getName(), service.getName())); - return false; - } - } - - String globalDomainTemplate = _nuageVspManager.NuageVspVpcDomainTemplateName.value(); - if (StringUtils.isNotBlank(globalDomainTemplate) && !_nuageVspManager.checkIfDomainTemplateExist(vpc.getDomainId(),globalDomainTemplate,vpc.getZoneId(),null)) { - s_logger.warn("The global pre configured domain template does not exist on the VSD."); - throw new CloudRuntimeException("The global pre configured domain template does not exist on the VSD."); - } - - return true; - } - - @Override - public boolean shutdownVpc(Vpc vpc, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException { - if (vpc.getState().equals(Vpc.State.Inactive)) { - List routers = _routerDao.listByVpcId(vpc.getId()); - if (CollectionUtils.isEmpty(routers)) { - routers = _routerDao.listIncludingRemovedByVpcId(vpc.getId()); - } - - List domainRouterUuids = Lists.transform(routers, new Function() { - @Nullable - @Override - public String apply(@Nullable DomainRouterVO input) { - return input != null ? input.getUuid() : null; - } - }); - - Domain vpcDomain = _domainDao.findById(vpc.getDomainId()); - - String preConfiguredDomainTemplateName; - VpcDetailVO domainTemplateNameDetail = _vpcDetailsDao.findDetail(vpc.getId(), NuageVspManager.nuageDomainTemplateDetailName); - if (domainTemplateNameDetail != null) { - preConfiguredDomainTemplateName = domainTemplateNameDetail.getValue(); - } else { - preConfiguredDomainTemplateName = _configDao.getValue(NuageVspManager.NuageVspVpcDomainTemplateName.key()); - } - - Map vpcDetails = _vpcDetailsDao.listDetailsKeyPairs(vpc.getId(), false); - - cleanUpVpcCaching(vpc.getId()); - //related to migration caching - List vpcResourceDetails = _resourceTagDao.listByResourceUuid(vpc.getUuid()); - if (vpcResourceDetails != null) { - vpcResourceDetails.stream() - .filter(item -> item.getKey().equals(NetworkMigrationManager.MIGRATION)) - .findFirst() - .map(ResourceTag::getResourceId) - .ifPresent(this::cleanUpVpcCaching); - } - - ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand(vpcDomain.getUuid(), vpc.getUuid(), preConfiguredDomainTemplateName, domainRouterUuids, vpcDetails); - send(cmd, vpc); - } - return true; - } - - private void cleanUpVpcCaching(long vpcId) { - _vpcDetailsDao.removeDetail(vpcId, NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID); - _vpcDetailsDao.removeDetail(vpcId, NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID); - } - - private Long getPhysicalNetworkId(Long zoneId) { - Long guestPhysicalNetworkId = 0L; - List physicalNetworkList = _physicalNetworkDao.listByZone(zoneId); - for (PhysicalNetworkVO phyNtwk : physicalNetworkList) { - if (phyNtwk.getIsolationMethods().contains("VSP")) { - guestPhysicalNetworkId = phyNtwk.getId(); - break; - } - } - return guestPhysicalNetworkId; - } - - @Override - public boolean createPrivateGateway(PrivateGateway gateway) throws ConcurrentOperationException, ResourceUnavailableException { - return false; - } - - @Override - public boolean deletePrivateGateway(PrivateGateway privateGateway) throws ConcurrentOperationException, ResourceUnavailableException { - return false; - } - - @Override - public boolean applyStaticRoutes(Vpc vpc, List routes) throws ResourceUnavailableException { - return true; - } - - @Override - public boolean applyACLItemsToPrivateGw(PrivateGateway gateway, List rules) throws ResourceUnavailableException { - return false; - } - - @Override - public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) { - return null; - } - - @Override - public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map details, List hostTags) { - if (!(startup[0] instanceof StartupVspCommand)) { - return null; - } - host.setType(Host.Type.L2Networking); - return host; - } - - @Override - public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException { - if (!(host.getType() == Host.Type.L2Networking)) { - return null; - } - return new DeleteHostAnswer(true); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/guru/NuageVspGuestNetworkGuru.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/guru/NuageVspGuestNetworkGuru.java deleted file mode 100644 index 00b12839e26..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/guru/NuageVspGuestNetworkGuru.java +++ /dev/null @@ -1,874 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.guru; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.inject.Inject; - -import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds; -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption; -import net.nuage.vsp.acs.client.api.model.VspDomain; -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspNic; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; -import net.nuage.vsp.acs.client.api.model.VspVm; - -import org.apache.log4j.Logger; - -import com.google.common.base.Strings; -import com.google.common.collect.Iterables; -import com.google.common.collect.LinkedListMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService; -import org.apache.cloudstack.resourcedetail.VpcDetailVO; -import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao; - -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.guru.DeallocateVmVspCommand; -import com.cloud.agent.api.guru.ImplementNetworkVspCommand; -import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand; -import com.cloud.agent.api.guru.TrashNetworkVspCommand; -import com.cloud.agent.api.guru.UpdateDhcpOptionVspCommand; -import com.cloud.agent.api.manager.ImplementNetworkVspAnswer; -import com.cloud.configuration.ConfigurationManager; -import com.cloud.dc.DataCenter; -import com.cloud.dc.DataCenter.NetworkType; -import com.cloud.dc.DataCenterDetailVO; -import com.cloud.dc.VlanVO; -import com.cloud.dc.dao.DataCenterDetailsDao; -import com.cloud.dc.dao.VlanDetailsDao; -import com.cloud.deploy.DeployDestination; -import com.cloud.deploy.DeploymentPlan; -import com.cloud.domain.dao.DomainDao; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientAddressCapacityException; -import com.cloud.exception.InsufficientVirtualNetworkCapacityException; -import com.cloud.exception.UnsupportedServiceException; -import com.cloud.host.HostVO; -import com.cloud.network.Network; -import com.cloud.network.Network.GuestType; -import com.cloud.network.Network.State; -import com.cloud.network.NetworkProfile; -import com.cloud.network.Networks; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.PhysicalNetwork.IsolationMethod; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.NetworkDetailsDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.network.router.VirtualRouter; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.user.Account; -import com.cloud.user.AccountVO; -import com.cloud.user.dao.AccountDao; -import com.cloud.util.NuageVspEntityBuilder; -import com.cloud.util.NuageVspUtil; -import com.cloud.utils.StringUtils; -import com.cloud.utils.db.DB; -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.utils.net.Ip; -import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.Nic; -import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.VirtualMachineProfile; -import com.cloud.vm.dao.DomainRouterDao; -import com.cloud.vm.dao.VMInstanceDao; - -public class NuageVspGuestNetworkGuru extends GuestNetworkGuru implements NetworkGuruAdditionalFunctions { - public static final Logger s_logger = Logger.getLogger(NuageVspGuestNetworkGuru.class); - - @Inject - NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao; - @Inject - NetworkOfferingDao _ntwkOfferingDao; - @Inject - DomainDao _domainDao; - @Inject - AccountDao _accountDao; - @Inject - VMInstanceDao _vmInstanceDao; - @Inject - AgentManager _agentMgr; - @Inject - NuageVspManager _nuageVspManager; - @Inject - ConfigurationManager _configMgr; - @Inject - NuageVspEntityBuilder _nuageVspEntityBuilder; - @Inject - NetworkDetailsDao _networkDetailsDao; - @Inject - VpcDetailsDao _vpcDetailsDao; - @Inject - NetworkOrchestrationService _networkOrchestrationService; - @Inject - DataCenterDetailsDao _dcDetailsDao; - @Inject - VlanDetailsDao _vlanDetailsDao; - @Inject - private DomainRouterDao _routerDao; - - public NuageVspGuestNetworkGuru() { - super(); - _isolationMethods = new IsolationMethod[] {new IsolationMethod("VSP")}; - } - - @Override - public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) { - PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId()); - DataCenter dc = _dcDao.findById(plan.getDataCenterId()); - if (!canHandle(offering, dc.getNetworkType(), physnet)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Refusing to design network using network offering " + offering.getId() + (physnet != null ? " on physical network " + physnet.getId() : "")); - } - return null; - } - - NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner); - if (networkObject == null) { - return null; - } - - networkObject.setBroadcastDomainType(Networks.BroadcastDomainType.Vsp); - - if (userSpecified instanceof NetworkVO && userSpecified.getExternalId() != null) { - if (owner.getType() < Account.ACCOUNT_TYPE_ADMIN) { - throw new IllegalArgumentException("vsdManaged networks are only useable by admins."); - } - - if (!isUniqueReference(plan.getDataCenterId(), userSpecified.getExternalId())) { - s_logger.debug("Refusing to design network. VsdManaged network object already present in zone."); - return null; - } - } - - return networkObject; - } - - private boolean isUniqueReference(long dataCenterId, String vsdSubnetId) { - DataCenterDetailVO detail = _dcDetailsDao.findDetail(dataCenterId, vsdSubnetId); - return detail == null; - } - - private boolean isVsdManagedVpc(long vpcId) { - //Check if it's a vpc and if the vpc is already vsdManaged OR if it has 0 tiers - Map vpcDetails = _vpcDetailsDao.listDetailsKeyPairs(vpcId, false); - return vpcDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED) != null && vpcDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED).equals("true"); - } - - /** In case an externalId is specified, we get called here, and store the id the same way as cached data */ - @Override - public void finalizeNetworkDesign(long networkId, String vlanIdAsUUID) { - NetworkVO designedNetwork = _networkDao.findById(networkId); - String externalId = designedNetwork.getExternalId(); - boolean isVpc = designedNetwork.getVpcId() != null; - - if (isVpc && _networkDao.listByVpc(designedNetwork.getVpcId()).size() > 1) { - boolean isVsdManagedVpc = isVsdManagedVpc(designedNetwork.getVpcId()); - if (isVsdManagedVpc && externalId == null) { - throw new CloudRuntimeException("Refusing to design network. Network is vsdManaged but is part of a non vsd managed vpc."); - } else if (!isVsdManagedVpc && externalId != null) { - throw new CloudRuntimeException("Refusing to design network. Network is not vsdManaged but is part of a vsd managed vpc."); - } - } - - if (externalId == null) { - return; - } - - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(designedNetwork, externalId); - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(designedNetwork.getPhysicalNetworkId()); - - ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, null, true); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - if (answer == null || !answer.getResult()) { - s_logger.error("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); - if ((null != answer) && (null != answer.getDetails())) { - s_logger.error(answer.getDetails()); - } - throw new CloudRuntimeException("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); - } - - //check if the network does not violate the uuid cidr - ImplementNetworkVspAnswer implementAnswer = (ImplementNetworkVspAnswer) answer; - VspNetwork updatedVspNetwork = implementAnswer.getVspNetwork(); - NetworkVO forUpdate = _networkDao.createForUpdate(networkId); - - if (isVpc && (!designedNetwork.getCidr().equals(updatedVspNetwork.getCidr()) || !designedNetwork.getGateway().equals(updatedVspNetwork.getGateway()))) { - throw new CloudRuntimeException("Tier network does not match the VsdManaged subnet cidr or gateway."); - } else { - forUpdate.setCidr(updatedVspNetwork.getCidr()); - forUpdate.setGateway(updatedVspNetwork.getGateway()); - } - - saveNetworkAndVpcDetails(vspNetwork, implementAnswer.getNetworkRelatedVsdIds(), designedNetwork.getVpcId()); - saveNetworkDetail(networkId, NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID, externalId); - saveNetworkDetail(networkId, NuageVspManager.NETWORK_METADATA_VSD_MANAGED, "true"); - - forUpdate.setState(State.Allocated); - _networkDao.update(networkId, forUpdate); - } - - @Override - public Map listAdditionalNicParams(String nicUuid) { - return null; - } - - @Override - public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException { - long networkId = network.getId(); - network = _networkDao.acquireInLockTable(network.getId(), 1200); - if (network == null) { - throw new ConcurrentOperationException("Unable to acquire lock on network " + networkId); - } - - /* Check if an acl template is used in combination with a pre-configured DT. -> show an error if there is - Rollback of the network fails in core CS -> networkOrchestrator. */ - if(network.getVpcId() != null) { - VpcDetailVO detail = _vpcDetailsDao.findDetail(network.getVpcId(), NuageVspManager.nuageDomainTemplateDetailName); - if (detail != null && network.getNetworkACLId() != null) { - s_logger.error("Pre-configured DT are used in combination with ACL lists. Which is not supported."); - throw new IllegalArgumentException("CloudStack ACLs are not supported with Nuage Pre-configured Domain Template"); - } - - if(detail != null && !_nuageVspManager.checkIfDomainTemplateExist(network.getDomainId(),detail.getValue(),network.getDataCenterId(),null)){ - s_logger.error("The provided domain template does not exist on the VSD."); - throw new IllegalArgumentException("The provided domain template does not exist on the VSD anymore."); - } - } - - NetworkVO implemented = null; - try { - if (offering.getGuestType() == GuestType.Isolated && network.getState() != State.Implementing) { - throw new IllegalStateException("Network " + networkId + " is not in expected state Implementing, but is in state " + network.getState()); - } - - //Get the Account details and find the type - AccountVO networksAccount = _accountDao.findById(network.getAccountId()); - if (networksAccount.getType() == Account.ACCOUNT_TYPE_PROJECT) { - String errorMessage = "Networks created by account " + networksAccount.getAccountName() + " of type Project (" + Account.ACCOUNT_TYPE_PROJECT + ") " + - "are not yet supported by NuageVsp provider"; - s_logger.error(errorMessage); - throw new InsufficientVirtualNetworkCapacityException(errorMessage, Account.class, network.getAccountId()); - } - - //We don't support a shared network with UserData and multiple IP ranges at the same time. - checkMultipleSubnetsCombinedWithUseData(network); - - long dcId = dest.getDataCenter().getId(); - //Get physical network id - Long physicalNetworkId = network.getPhysicalNetworkId(); - //Physical network id can be null in Guest Network in Basic zone, so locate the physical network - if (physicalNetworkId == null) { - physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType()); - } - - implemented = new NetworkVO(network.getId(), network, network.getNetworkOfferingId(), network.getGuruName(), network.getDomainId(), network.getAccountId(), - network.getRelated(), network.getName(), network.getDisplayText(), network.getNetworkDomain(), network.getGuestType(), network.getDataCenterId(), - physicalNetworkId, network.getAclType(), network.getSpecifyIpRanges(), network.getVpcId(), offering.isRedundantRouter(), network.getExternalId()); - implemented.setUuid(network.getUuid()); - implemented.setState(State.Allocated); - if (network.getGateway() != null) { - implemented.setGateway(network.getGateway()); - } - if (network.getCidr() != null) { - implemented.setCidr(network.getCidr()); - } - - implemented.setBroadcastUri(_nuageVspManager.calculateBroadcastUri(implemented)); - implemented.setBroadcastDomainType(Networks.BroadcastDomainType.Vsp); - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(implemented); - - if (vspNetwork.isShared()) { - Boolean previousUnderlay= null; - for (VlanVO vlan : _vlanDao.listVlansByNetworkId(networkId)) { - boolean underlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, vlan); - if (previousUnderlay == null || underlay == previousUnderlay) { - previousUnderlay = underlay; - } else { - throw new CloudRuntimeException("Mixed values for the underlay flag for IP ranges in the same subnet is not supported"); - } - } - if (previousUnderlay != null) { - vspNetwork = new VspNetwork.Builder().fromObject(vspNetwork) - .vlanUnderlay(previousUnderlay) - .build(); - } - } - - boolean implementSucceeded = implement(network.getVpcId(), physicalNetworkId, vspNetwork, implemented, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering)); - - if (!implementSucceeded) { - return null; - } - - if (StringUtils.isNotBlank(vspNetwork.getDomainTemplateName())) { - if (network.getVpcId() != null) { - saveVpcDetail(network.getVpcId(), NuageVspManager.nuageDomainTemplateDetailName, vspNetwork.getDomainTemplateName()); - } else { - saveNetworkDetail(implemented.getId(), NuageVspManager.nuageDomainTemplateDetailName, vspNetwork.getDomainTemplateName()); - } - } - - String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId(); - s_logger.info("Implemented OK, network " + implemented.getUuid() + " in tenant " + tenantId + " linked to " + implemented.getBroadcastUri()); - } finally { - _networkDao.releaseFromLockTable(network.getId()); - } - return implemented; - } - - private boolean implement(Long vpcId, long physicalNetworkId, VspNetwork vspNetwork, NetworkVO implemented, VspDhcpDomainOption vspDhcpDomainOption) { - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(physicalNetworkId); - final boolean isVsdManaged = vspNetwork.getNetworkRelatedVsdIds() - .getVsdSubnetId() - .isPresent(); - if (isVsdManaged) { - //Implement cmd was already send in design step. - _dcDetailsDao.persist(implemented.getDataCenterId(), vspNetwork.getNetworkRelatedVsdIds().getVsdSubnetId().orElseThrow(() -> new CloudRuntimeException("Managed but no subnetId. How can this happen?")), implemented.getUuid()); - return true; - } - - ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpDomainOption, false); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - if (answer == null || !answer.getResult()) { - s_logger.error("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); - if ((null != answer) && (null != answer.getDetails())) { - s_logger.error(answer.getDetails()); - } - return false; - } - - ImplementNetworkVspAnswer implementAnswer = (ImplementNetworkVspAnswer) answer; - saveNetworkAndVpcDetails(vspNetwork, implementAnswer.getNetworkRelatedVsdIds(), vpcId); - return true; - } - - private void saveNetworkAndVpcDetails(VspNetwork vspNetwork, NetworkRelatedVsdIds networkRelatedVsdIds, Long vpcId) { - if (!vspNetwork.isShared() && !vspNetwork.getNetworkRelatedVsdIds().equals(networkRelatedVsdIds)) { - Map networkDetails = constructNetworkDetails(networkRelatedVsdIds, vspNetwork.isVpc()); - - long networkId = vspNetwork.getId(); - - for (Map.Entry networkDetail : networkDetails.entrySet()) { - saveNetworkDetail(vspNetwork.getId(), networkDetail.getKey(), networkDetail.getValue()); - } - - if(vspNetwork.isVpc()) { - Map vpcDetails = constructVpcDetails(networkRelatedVsdIds); - - for (Map.Entry vpcDetail : vpcDetails.entrySet()) { - saveVpcDetail(vpcId, vpcDetail.getKey(), vpcDetail.getValue()); - } - } - } - } - - private void saveVpcDetail(Long vpcId, String key, String value) { - _vpcDetailsDao.addDetail(vpcId, key, value, false); - } - - private void saveNetworkDetail(long networkId, String key, String value) { - _networkDetailsDao.addDetail(networkId, key, value, false); - } - - private static Map constructNetworkDetails(NetworkRelatedVsdIds networkRelatedVsdIds, boolean isVpc) { - Map networkDetails = Maps.newHashMap(); - - if (!isVpc) { - networkRelatedVsdIds.getVsdDomainId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID, v)); - networkRelatedVsdIds.getVsdZoneId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID, v)); - } - networkRelatedVsdIds.getVsdSubnetId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID, v)); - - return networkDetails; - } - - private static Map constructVpcDetails(NetworkRelatedVsdIds networkRelatedVsdIds) { - Map vpcDetails = Maps.newHashMap(); - - networkRelatedVsdIds.getVsdDomainId().ifPresent(v -> vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID, v)); - networkRelatedVsdIds.getVsdZoneId().ifPresent(v -> vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID, v)); - if (networkRelatedVsdIds.isVsdManaged()) { - vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_MANAGED, "true"); - } - - return vpcDetails; - } - - - @Override - public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { - if (vm.getType() != VirtualMachine.Type.DomainRouter && _nuageVspEntityBuilder.usesVirtualRouter(network.getNetworkOfferingId())) { - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network); - if (nic != null && nic.getRequestedIPv4() != null && nic.getRequestedIPv4().equals(vspNetwork.getVirtualRouterIp())) { - DataCenter dc = _dcDao.findById(network.getDataCenterId()); - s_logger.error("Unable to acquire requested Guest IP address " + nic.getRequestedIPv4() + " because it is reserved for the VR in network " + network); - throw new InsufficientVirtualNetworkCapacityException("Unable to acquire requested Guest IP address " + nic.getRequestedIPv4() + " because it is reserved " + - "for the VR in network " + network, DataCenter.class,dc.getId()); - } - } - - return super.allocate(network, nic, vm); - } - - @Override - public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) - throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException { - boolean lockedNetwork = lockNetworkForUserVm(network, vm); - if (lockedNetwork && s_logger.isDebugEnabled()) { - s_logger.debug("Locked network " + network.getId() + " for creation of user VM " + vm.getInstanceName()); - } - - try { - //We don't support a shared network with UserData and multiple IP ranges at the same time. - checkMultipleSubnetsCombinedWithUseData(network); - - if (s_logger.isDebugEnabled()) { - s_logger.debug("Handling reserve() call back to with Create a new VM or add an interface to existing VM in network " + network.getName()); - } - - DataCenter dc = _dcDao.findById(network.getDataCenterId()); - AccountVO neworkAccountDetails = _accountDao.findById(network.getAccountId()); - if (neworkAccountDetails.getType() == Account.ACCOUNT_TYPE_PROJECT) { - throw new InsufficientVirtualNetworkCapacityException("CS project support is not yet implemented in NuageVsp", DataCenter.class, dc.getId()); - } - - if (Strings.isNullOrEmpty(network.getBroadcastUri().getPath()) || !network.getBroadcastUri().getPath().startsWith("/")) { - throw new IllegalStateException("The broadcast URI path " + network.getBroadcastUri() + " is empty or in an incorrect format."); - } - - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId()); - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(vm.getVirtualMachine().getDomainId(), network); - - boolean vrAddedToNuage = vm.getType() == VirtualMachine.Type.DomainRouter && vspNetwork.getVirtualRouterIp() - .equals("null"); - if (vrAddedToNuage) { - //In case a VR is added due to upgrade network offering - recalculate the broadcast uri before using it. - _nuageVspManager.updateBroadcastUri(network); - network = _networkDao.findById(network.getId()); - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(vm.getVirtualMachine().getDomainId(), network, null); - } - - if (vspNetwork.isShared()) { - vspNetwork = _nuageVspEntityBuilder.updateVspNetworkByPublicIp(vspNetwork, network, nic.getIPv4Address()); - - if (VirtualMachine.Type.DomainRouter.equals(vm.getType()) && !nic.getIPv4Address().equals(vspNetwork.getVirtualRouterIp())) { - if(s_logger.isDebugEnabled()) { - s_logger.debug("VR got spawned with a different IP, releasing the previously allocated public IP " + nic.getIPv4Address()); - } - IPAddressVO oldIpAddress = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), nic.getIPv4Address()); - _ipAddressDao.unassignIpAddress(oldIpAddress.getId()); - _ipAddressDao.mark(network.getDataCenterId(), new Ip(vspNetwork.getVirtualRouterIp())); - } else if (VirtualMachine.Type.User.equals(vm.getType()) && nic.getIPv4Address().equals(vspNetwork.getVirtualRouterIp())) { - s_logger.error("Deploying a user VM with the same IP as the VR is not allowed."); - throw new InsufficientVirtualNetworkCapacityException("Deploying a user VM with the same IP " + nic.getIPv4Address() + " as the VR is not allowed.", - Network.class, network.getId()); - } - - // Make sure the shared network is present - NetworkOffering offering = _ntwkOfferingDao.findById(network.getNetworkOfferingId()); - if (!implement(network.getVpcId(), network.getPhysicalNetworkId(), vspNetwork, null, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering))) { - s_logger.error("Failed to implement shared network " + network.getUuid() + " under domain " + context.getDomain().getUuid()); - throw new InsufficientVirtualNetworkCapacityException("Failed to implement shared network " + network.getUuid() + " under domain " + - context.getDomain().getUuid(), Network.class, network.getId()); - } - } - - // Set flags for dhcp options - boolean networkHasDns = networkHasDns(network); - - Map networkHasDnsCache = Maps.newHashMap(); - networkHasDnsCache.put(network.getId(), networkHasDns); - - // Determine if dhcp options of the other nics in the network need to be updated - if (vm.getType() == VirtualMachine.Type.DomainRouter && network.getState() != State.Implementing) { - updateDhcpOptionsForExistingVms(network, nuageVspHost, vspNetwork, networkHasDns, networkHasDnsCache); - //update the extra DHCP options - - } - // Update broadcast Uri to enable VR ip update - if (!network.getBroadcastUri().getPath().substring(1).equals(vspNetwork.getVirtualRouterIp())) { - NetworkVO networkToUpdate = _networkDao.findById(network.getId()); - String broadcastUriStr = networkToUpdate.getUuid() + "/" + vspNetwork.getVirtualRouterIp(); - networkToUpdate.setBroadcastUri(Networks.BroadcastDomainType.Vsp.toUri(broadcastUriStr)); - _networkDao.update(network.getId(), networkToUpdate); - if (network instanceof NetworkVO) { - ((NetworkVO) network).setBroadcastUri(networkToUpdate.getBroadcastUri()); - } - } - - nic.setBroadcastUri(network.getBroadcastUri()); - nic.setIsolationUri(network.getBroadcastUri()); - - VspVm vspVm = _nuageVspEntityBuilder.buildVspVm(vm.getVirtualMachine(), network); - - if (vm.isRollingRestart()) { - ((NetworkVO)network).setRollingRestart(true); - } else { - //NicProfile does not contain the NIC UUID. We need this information to set it in the VMInterface and VPort - //that we create in VSP - NicVO nicFromDb = _nicDao.findById(nic.getId()); - IPAddressVO staticNatIp = _ipAddressDao.findByVmIdAndNetworkId(network.getId(), vm.getId()); - VspNic vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb.getUuid(), nic); - VspStaticNat vspStaticNat = null; - if (staticNatIp != null) { - VlanVO staticNatVlan = _vlanDao.findById(staticNatIp.getVlanId()); - vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(null, staticNatIp, staticNatVlan, vspNic); - } - - boolean defaultHasDns = getDefaultHasDns(networkHasDnsCache, nicFromDb); - VspDhcpVMOption dhcpOption = _nuageVspEntityBuilder.buildVmDhcpOption(nicFromDb, defaultHasDns, networkHasDns); - ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat, dhcpOption); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - - if (answer == null || !answer.getResult()) { - s_logger.error("ReserveVmInterfaceNuageVspCommand failed for NIC " + nic.getId() + " attached to VM " + vm.getId() + " in network " + network.getId()); - if ((null != answer) && (null != answer.getDetails())) { - s_logger.error(answer.getDetails()); - } - throw new InsufficientVirtualNetworkCapacityException("Failed to reserve VM in Nuage VSP.", Network.class, network.getId()); - } - } - - if (vspVm.getDomainRouter() == Boolean.TRUE) { - nic.setIPv4Address(vspVm.getDomainRouterIp()); - } - - } finally { - if (network != null && lockedNetwork) { - _networkDao.releaseFromLockTable(network.getId()); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Unlocked network " + network.getId() + " for creation of user VM " + vm.getInstanceName()); - } - } - } - } - - private void updateExtraDhcpOptionsForExistingVm(Network network, Nic nic) { - _networkOrchestrationService.configureExtraDhcpOptions(network, nic.getId()); - } - - private void updateDhcpOptionsForExistingVms(Network network, HostVO nuageVspHost, VspNetwork vspNetwork, boolean networkHasDns, Map networkHasDnsCache) - throws InsufficientVirtualNetworkCapacityException { - // Update dhcp options if a VR is added when we are not initiating the network - if(s_logger.isDebugEnabled()) { - s_logger.debug(String.format("DomainRouter is added to an existing network: %s in state: %s", network.getName(), network.getState())); - } - - List userNics = _nicDao.listByNetworkId(network.getId()); - LinkedListMultimap dhcpOptionsPerDomain = LinkedListMultimap.create(); - - for (Iterator iterator = userNics.iterator(); iterator.hasNext(); ) { - NicVO userNic = iterator.next(); - if (userNic.getVmType() == VirtualMachine.Type.DomainRouter || userNic.getState() != Nic.State.Reserved) { - iterator.remove(); - continue; - } - - VMInstanceVO userVm = _vmInstanceDao.findById(userNic.getInstanceId()); - boolean defaultHasDns = getDefaultHasDns(networkHasDnsCache, userNic); - VspDhcpVMOption dhcpOption = _nuageVspEntityBuilder.buildVmDhcpOption(userNic, defaultHasDns, networkHasDns); - dhcpOptionsPerDomain.put(userVm.getDomainId(), dhcpOption); - } - - for (Long domainId : dhcpOptionsPerDomain.keySet()) { - VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(_domainDao.findById(domainId)); - VspNetwork vspNetworkForDomain = new VspNetwork.Builder().fromObject(vspNetwork).domain(vspDomain).build(); - List dhcpOptions = dhcpOptionsPerDomain.get(domainId); - UpdateDhcpOptionVspCommand cmd = new UpdateDhcpOptionVspCommand(dhcpOptions, vspNetworkForDomain); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - - if (answer == null || !answer.getResult()) { - s_logger.error("UpdateDhcpOptionVspCommand failed at \"reserve\" for network " + vspNetwork.getName() + " under domain " + vspNetwork.getVspDomain().getName()); - if ((null != answer) && (null != answer.getDetails())) { - s_logger.error(answer.getDetails()); - } - throw new InsufficientVirtualNetworkCapacityException("Failed to reserve VM in Nuage VSP.", Network.class, network.getId()); - } - } - - for (NicVO userNic : userNics) { - updateExtraDhcpOptionsForExistingVm(network, userNic); - } - } - - - private boolean isServiceProvidedByVR(Network network, Network.Service service ) { - return (_networkModel.areServicesSupportedInNetwork(network.getId(), service) && - ( _networkModel.isProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.VirtualRouter) || - _networkModel.isProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.VPCVirtualRouter))); - } - - private void checkMultipleSubnetsCombinedWithUseData(Network network) { - if (isServiceProvidedByVR(network, Network.Service.UserData)) { - List vlanVOs = _vlanDao.listVlansByNetworkId(network.getId()); - if (vlanVOs.stream() - .map(VlanVO::getVlanGateway) - .distinct() - .count() > 1) { - s_logger.error("NuageVsp provider does not support multiple subnets in combination with user data. Network: " + network + ", vlans: " + vlanVOs); - throw new UnsupportedServiceException("NuageVsp provider does not support multiple subnets in combination with user data."); - } - } - } - - @Override - protected boolean canHandle(NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) { - if (networkType == NetworkType.Advanced - && isMyTrafficType(offering.getTrafficType()) - && isMyIsolationMethod(physicalNetwork) - && (offering.getGuestType() == GuestType.Isolated || offering.getGuestType() == GuestType.Shared) - && hasRequiredServices(offering)) { - if (_configMgr.isOfferingForVpc(offering) && !offering.isPersistent()) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp can't handle VPC tiers which use a network offering which are not persistent"); - } - return false; - } else if (offering.getGuestType() == GuestType.Shared) { - List supportedSharedNetworkServices = Lists.newArrayList(Network.Service.Connectivity.getName(), Network.Service.Dhcp.getName(), Network.Service.UserData.getName()); - List offeringServices = _ntwkOfferingSrvcDao.listServicesForNetworkOffering(offering.getId()); - if (!supportedSharedNetworkServices.containsAll(offeringServices)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("We only support " + Iterables.toString(supportedSharedNetworkServices) + " services for shared networks"); - } - return false; - } - } - return true; - } else { - if (s_logger.isTraceEnabled()) { - s_logger.trace("We only take care of networks in zone of type " + NetworkType.Advanced + " without VLAN"); - } - return false; - } - } - - private boolean hasRequiredServices(NetworkOffering networkOffering) { - final Map> serviceProviderMap = _networkModel.getNetworkOfferingServiceProvidersMap(networkOffering.getId()); - - if (!serviceProviderMap.get(Network.Service.Connectivity).contains(Network.Provider.NuageVsp)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as Connectivity provider"); - } - return false; - } - - if (networkOffering.getGuestType() == GuestType.Isolated - && !serviceProviderMap.get(Network.Service.SourceNat).contains(Network.Provider.NuageVsp)) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as SourceNat provider"); - } - return false; - } - return true; - } - - @Override - @DB - public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) { - boolean lockedNetwork = lockNetworkForUserVm(network, vm); - if (lockedNetwork && s_logger.isDebugEnabled()) { - s_logger.debug("Locked network " + network.getId() + " for deallocation of user VM " + vm.getInstanceName()); - } - - try { - final VirtualMachine virtualMachine = vm.getVirtualMachine(); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Handling deallocate() call back, which is called when a VM is destroyed or interface is removed, " + "to delete VM Interface with IP " - + nic.getIPv4Address() + " from a VM " + vm.getInstanceName() + " with state " + virtualMachine - .getState()); - } - - NicVO nicFromDb = _nicDao.findById(nic.getId()); - - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(virtualMachine - .getDomainId(), network); - VspVm vspVm = _nuageVspEntityBuilder.buildVspVm(virtualMachine, network); - VspNic vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb.getUuid(), nic); - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId()); - - DeallocateVmVspCommand cmd = new DeallocateVmVspCommand(vspNetwork, vspVm, vspNic); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - if (answer == null || !answer.getResult()) { - s_logger.error("DeallocateVmNuageVspCommand for VM " + vm.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); - if ((null != answer) && (null != answer.getDetails())) { - s_logger.error(answer.getDetails()); - } - } - - // In case of shared network, when a User VM is spawned with the same IP as the VR, and it gets cleaned up, make sure we do not release the public IP - // because it is still allocated for the VR. - if (vspNetwork.isShared() && VirtualMachine.Type.User.equals(vm.getType()) && nic.getIPv4Address().equals(vspNetwork.getVirtualRouterIp())) { - nic.deallocate(); - } else { - super.deallocate(network, nic, vm); - } - - if (virtualMachine.getType() == VirtualMachine.Type.DomainRouter) { - final List routers = _routerDao.listByNetworkAndRole(network.getId(), VirtualRouter.Role.VIRTUAL_ROUTER); - final DomainRouterVO otherRouter = routers.stream() - .filter(r -> r.getId() != vm.getId()) - .findFirst() - .orElse(null); - - if (otherRouter != null) { - nicFromDb = _nicDao.findByNtwkIdAndInstanceId(network.getId(), otherRouter.getId()); - vspVm = _nuageVspEntityBuilder.buildVspVm(otherRouter, network); - vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb); - - VspDhcpVMOption dhcpOption = _nuageVspEntityBuilder.buildVmDhcpOption(nicFromDb, false, false); - ReserveVmInterfaceVspCommand reserveCmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, null, dhcpOption); - - answer = _agentMgr.easySend(nuageVspHost.getId(), reserveCmd); - if (answer == null || !answer.getResult()) { - s_logger.error("DeallocateVmNuageVspCommand for VM " + vm.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname")); - if ((null != answer) && (null != answer.getDetails())) { - s_logger.error(answer.getDetails()); - } - } - } - - } - } finally { - if (network != null && lockedNetwork) { - _networkDao.releaseFromLockTable(network.getId()); - if (s_logger.isDebugEnabled()) { - s_logger.debug("Unlocked network " + network.getId() + " for deallocation of user VM " + vm.getInstanceName()); - } - } - } - } - - private boolean lockNetworkForUserVm(Network network, VirtualMachineProfile vm) { - if (!vm.getVirtualMachine().getType().isUsedBySystem()) { - long networkId = network.getId(); - network = _networkDao.acquireInLockTable(network.getId(), 1200); - if (network == null) { - throw new ConcurrentOperationException("Unable to acquire lock on network " + networkId); - } - return true; - } - return false; - } - - @Override - public void shutdown(NetworkProfile profile, NetworkOffering offering) { - super.shutdown(profile, offering); - } - - @Override - public boolean trash(Network network, NetworkOffering offering) { - long networkId = network.getId(); - network = _networkDao.acquireInLockTable(networkId, 1200); - if (network == null) { - throw new ConcurrentOperationException("Unable to acquire lock on network " + networkId); - } - - try { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Handling trash() call back to delete the network " + network.getName() + " with uuid " + network.getUuid() + " from VSP"); - } - - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network); - - boolean networkMigrationCopy = network.getRelated() != network.getId(); - - if (networkMigrationCopy) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Network " + network.getName() + " is a copy of a migrated network. Cleaning up network details of related network."); - } - cleanUpNetworkCaching(network.getRelated()); - } - cleanUpNetworkCaching(network.getId()); - - //Clean up VSD managed subnet caching - if (vspNetwork.getNetworkRelatedVsdIds().isVsdManaged()) { - final long dataCenterId = network.getDataCenterId(); - vspNetwork.getNetworkRelatedVsdIds().getVsdSubnetId().ifPresent(subnetId -> { - _dcDetailsDao.removeDetail(dataCenterId, subnetId); - }); - } - - HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId()); - TrashNetworkVspCommand cmd = new TrashNetworkVspCommand(vspNetwork); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - if (answer == null || !answer.getResult()) { - s_logger.error("TrashNetworkNuageVspCommand for network " + network.getUuid() + " failed"); - if ((null != answer) && (null != answer.getDetails())) { - s_logger.error(answer.getDetails()); - } - return false; - } - } finally { - _networkDao.releaseFromLockTable(network.getId()); - } - return super.trash(network, offering); - } - - private void cleanUpNetworkCaching(long id) { - _networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID); - _networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID); - _networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID); - _networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_MANAGED); - } - - private boolean networkHasDns(Network network) { - - if (network != null) { - List dnsProviders = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(network.getNetworkOfferingId(), Network.Service.Dns); - return dnsProviders.contains(Network.Provider.VirtualRouter.getName()) - || dnsProviders.contains(Network.Provider.VPCVirtualRouter.getName()); - - } - - return false; - } - - private boolean getDefaultHasDns(Map cache, Nic nic) { - Long networkId = nic.isDefaultNic() - ? Long.valueOf(nic.getNetworkId()) - : getDefaultNetwork(nic.getInstanceId()); - - Boolean hasDns = cache.computeIfAbsent(networkId, k -> networkHasDns(_networkDao.findById(networkId))); - return hasDns; - } - - private Long getDefaultNetwork(long vmId) { - NicVO defaultNic = _nicDao.findDefaultNicForVM(vmId); - if (defaultNic != null) return defaultNic.getNetworkId(); - return null; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/AbstractListener.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/AbstractListener.java deleted file mode 100644 index 648e0f781e5..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/AbstractListener.java +++ /dev/null @@ -1,91 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.manager; - -import com.cloud.agent.Listener; -import com.cloud.agent.api.AgentControlAnswer; -import com.cloud.agent.api.AgentControlCommand; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.StartupCommand; -import com.cloud.exception.ConnectionException; -import com.cloud.host.Host; -import com.cloud.host.Status; - -/** - * Created by maximusf on 7/19/17. - */ -abstract class AbstractListener implements Listener { - - @Override - public boolean processAnswers(long agentId, long seq, Answer[] answers) { - return true; - } - - @Override - public boolean processCommands(long agentId, long seq, Command[] commands) { - return true; - } - - @Override - public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) { - return null; - } - - @Override - public void processHostAdded(long hostId) { - - } - - @Override - public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException { - - } - - @Override - public boolean processDisconnect(long agentId, Status state) { - return true; - } - - @Override - public void processHostAboutToBeRemoved(long hostId) { - - } - - @Override - public void processHostRemoved(long hostId, long clusterId) { - - } - - @Override - public boolean isRecurring() { - return false; - } - - @Override - public int getTimeout() { - return 0; - } - - @Override - public boolean processTimeout(long agentId, long seq) { - return true; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/NuageVspManager.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/NuageVspManager.java deleted file mode 100644 index 1fe9b40170f..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/NuageVspManager.java +++ /dev/null @@ -1,173 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.manager; - -import java.net.URI; -import java.util.List; - -import org.apache.cloudstack.framework.config.ConfigKey; -import org.apache.cloudstack.framework.config.ConfigKey.Scope; - -import com.cloud.agent.api.manager.EntityExistsCommand; -import com.cloud.api.commands.AddNuageVspDeviceCmd; -import com.cloud.api.commands.AssociateNuageVspDomainTemplateCmd; -import com.cloud.api.commands.DeleteNuageVspDeviceCmd; -import com.cloud.api.commands.ListNuageVspDevicesCmd; -import com.cloud.api.commands.ListNuageVspDomainTemplatesCmd; -import com.cloud.api.commands.UpdateNuageVspDeviceCmd; -import com.cloud.api.response.NuageVlanIpRangeResponse; -import com.cloud.api.response.NuageVspDeviceResponse; -import com.cloud.dc.Vlan; -import com.cloud.api.response.NuageVspDomainTemplateResponse; -import com.cloud.exception.InsufficientVirtualNetworkCapacityException; -import com.cloud.host.HostVO; -import com.cloud.network.Network; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.utils.component.PluggableService; - - - -public interface NuageVspManager extends PluggableService { - - String nuageVPCOfferingName = "Nuage VSP VPC Offering"; - - String nuageVPCOfferingDisplayText = "Nuage VSP VPC Offering"; - - String nuageDomainTemplateDetailName = "domainTemplateName"; - - String nuageUnderlayVlanIpRangeDetailKey = "nuage.underlay"; - - ConfigKey NuageVspConfigDns = new ConfigKey(Boolean.class, "nuagevsp.configure.dns", "Advanced", "true", - "Defines if NuageVsp plugin needs to configure DNS setting for a VM or not. True will configure the DNS and false will not configure the DNS settings", true, - Scope.Global, null); - - ConfigKey NuageVspDnsExternal = new ConfigKey( - Boolean.class, - "nuagevsp.dns.external", - "Advanced", - "true", - "Defines if NuageVsp plugin needs to configure either internal or external DNS server configured during Zone provisioning. " - + "Value true uses the external DNS and value false uses the internal DNS to configure in the VM. But, this flag depends on " - + "nuagevsp.configure.dns. Only if nuagevsp.configure.dns is set to true, DNS server will be configured in the VM. " - + "If nuagevsp.configure.dns is false, DNS server will not be configured in the VM. Default value for this flag is true", - true, Scope.Global, null); - - ConfigKey NuageVspConfigGateway = new ConfigKey(String.class, "nuagevsp.configure.gateway.systemid", "Advanced", "", - "Defines the systemID of the gateway configured in VSP", true, Scope.Global, null); - - ConfigKey NuageVspSharedNetworkDomainTemplateName = new ConfigKey(String.class, "nuagevsp.sharedntwk.domaintemplate.name", - "Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for shared networks", true, Scope.Global, null); - - ConfigKey NuageVspVpcDomainTemplateName = new ConfigKey(String.class, "nuagevsp.vpc.domaintemplate.name", - "Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for VPCs", true, Scope.Global, null); - - ConfigKey NuageVspIsolatedNetworkDomainTemplateName = new ConfigKey(String.class, "nuagevsp.isolatedntwk.domaintemplate.name", - "Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for isolated networks", true, Scope.Global, null); - - String NETWORK_METADATA_VSD_DOMAIN_ID = "vsdDomainId"; - - String NETWORK_METADATA_VSD_ZONE_ID = "vsdZoneId"; - - String NETWORK_METADATA_VSD_SUBNET_ID = "vsdSubnetId"; - - String NETWORK_METADATA_VSD_MANAGED = "isVsdManaged"; - - String CMSID_CONFIG_KEY = "nuagevsp.cms.id"; - - String NUAGE_VSP_ISOLATION = "VSP"; - - NuageVspDeviceVO addNuageVspDevice(AddNuageVspDeviceCmd cmd); - - NuageVspDeviceVO updateNuageVspDevice(UpdateNuageVspDeviceCmd cmd); - - NuageVspDeviceResponse createNuageVspDeviceResponse(NuageVspDeviceVO nuageVspDeviceVO); - - boolean deleteNuageVspDevice(DeleteNuageVspDeviceCmd cmd); - - List listNuageVspDevices(ListNuageVspDevicesCmd cmd); - - List getDnsDetails(long dataCenterId); - - List getGatewaySystemIds(); - - HostVO getNuageVspHost(long physicalNetworkId); - - boolean updateNuageUnderlayVlanIpRange(long vlanIpRangeId, boolean enabled); - - List filterNuageVlanIpRanges(List vlanIpRanges, Boolean underlay); - - List listNuageVspDomainTemplates(ListNuageVspDomainTemplatesCmd cmd); - - List listNuageVspDomainTemplates(long domainId, String keyword, Long zoneId, Long physicalNetworkId); - - /** - * Associates a Nuage Vsp domain template with a - * @param cmd Associate cmd which contains all the data - */ - void associateNuageVspDomainTemplate(AssociateNuageVspDomainTemplateCmd cmd); - - /** - * Queries the VSD to check if the entity provided in the entityCmd exists on the VSD - * @param cmd entityCommand which contains the ACS class of the entity and the UUID - * @param hostId the hostId of the VSD - * @return true if an entity exists with the UUI on the VSD, otherwise false. - */ - boolean entityExist(EntityExistsCommand cmd, Long hostId); - - /** - * Sets the preconfigured domain template for a given network - * @param network the network for which we want to set the domain template - * @param domainTemplateName the domain template name we want to use - */ - void setPreConfiguredDomainTemplateName(Network network, String domainTemplateName); - - /** - * Returns the current pre configured domain template for a given network - * @param network the network for which we want the domain template name - * @return the domain template name - */ - String getPreConfiguredDomainTemplateName(Network network); - - /** - * Checks if a given domain template exists or not on the VSD. - * @param domainId Id of the domain to search in. - * @param domainTemplate The name of the domain template for which we need to query the VSD. - * @param zoneId zoneId OR PhysicalNetworkId needs to be provided. - * @param physicalNetworkId zoneId OR PhysicalNetworkId needs to be provided. - * @return true if the domain template exists on the VSD else false if it does not exist on the VSD - */ - boolean checkIfDomainTemplateExist(Long domainId, String domainTemplate, Long zoneId, Long physicalNetworkId); - - /** - * calculates the new broadcast uri of a network and persists it in the database - * @param network the network for which you want to calculate the broadcast uri - * @throws InsufficientVirtualNetworkCapacityException in case there is no free ip that can be used as the VR ip. - */ - void updateBroadcastUri(Network network) throws InsufficientVirtualNetworkCapacityException; - - /** - * Calculates the broadcast uri based on the network and the offering of the given network - * @param network the network for which you want to calculate the broadcast uri - * @return the calculated broadcast uri - * @throws InsufficientVirtualNetworkCapacityException in case there is no free ip that can be used as the VR ip. - */ - URI calculateBroadcastUri(Network network) throws InsufficientVirtualNetworkCapacityException; - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/NuageVspManagerImpl.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/NuageVspManagerImpl.java deleted file mode 100644 index d5f9acba702..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/manager/NuageVspManagerImpl.java +++ /dev/null @@ -1,1408 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.manager; - -import static com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand.SyncType; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.TreeSet; -import java.util.UUID; -import java.util.stream.Collectors; - -import javax.annotation.Nonnull; -import javax.inject.Inject; -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.api.NuageVspPluginClientLoader; -import net.nuage.vsp.acs.client.api.model.VspApiDefaults; -import net.nuage.vsp.acs.client.api.model.VspDomain; -import net.nuage.vsp.acs.client.api.model.VspDomainCleanUp; -import net.nuage.vsp.acs.client.api.model.VspDomainTemplate; -import net.nuage.vsp.acs.client.api.model.VspHost; -import net.nuage.vsp.acs.client.common.NuageVspApiVersion; -import net.nuage.vsp.acs.client.common.NuageVspConstants; -import net.nuage.vsp.acs.client.common.model.Pair; -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; - -import com.google.common.base.MoreObjects; -import com.google.common.base.Strings; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; - -import org.apache.cloudstack.api.ResponseGenerator; -import org.apache.cloudstack.context.CallContext; -import org.apache.cloudstack.framework.config.ConfigKey; -import org.apache.cloudstack.framework.config.Configurable; -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; -import org.apache.cloudstack.framework.config.impl.ConfigurationVO; -import org.apache.cloudstack.framework.messagebus.MessageBus; -import org.apache.cloudstack.network.ExternalNetworkDeviceManager; -import org.apache.cloudstack.resourcedetail.VpcDetailVO; -import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao; - -import com.cloud.agent.AgentManager; -import com.cloud.agent.Listener; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.PingNuageVspCommand; -import com.cloud.agent.api.manager.CleanUpDomainCommand; -import com.cloud.agent.api.manager.EntityExistsCommand; -import com.cloud.agent.api.manager.GetApiDefaultsAnswer; -import com.cloud.agent.api.manager.GetApiDefaultsCommand; -import com.cloud.agent.api.manager.ListVspDomainTemplatesAnswer; -import com.cloud.agent.api.manager.ListVspDomainTemplatesCommand; -import com.cloud.agent.api.manager.SupportedApiVersionCommand; -import com.cloud.agent.api.manager.UpdateNuageVspDeviceCommand; -import com.cloud.agent.api.sync.SyncDomainCommand; -import com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer; -import com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand; -import com.cloud.api.ApiDBUtils; -import com.cloud.api.commands.AddNuageVspDeviceCmd; -import com.cloud.api.commands.AssociateNuageVspDomainTemplateCmd; -import com.cloud.api.commands.DeleteNuageVspDeviceCmd; -import com.cloud.api.commands.DisableNuageUnderlayVlanIpRangeCmd; -import com.cloud.api.commands.EnableNuageUnderlayVlanIpRangeCmd; -import com.cloud.api.commands.ListNuageUnderlayVlanIpRangesCmd; -import com.cloud.api.commands.ListNuageVspDevicesCmd; -import com.cloud.api.commands.ListNuageVspDomainTemplatesCmd; -import com.cloud.api.commands.ListNuageVspGlobalDomainTemplateCmd; -import com.cloud.api.commands.UpdateNuageVspDeviceCmd; -import com.cloud.api.response.NuageVlanIpRangeResponse; -import com.cloud.api.response.NuageVspDeviceResponse; -import com.cloud.api.response.NuageVspDomainTemplateResponse; -import com.cloud.dc.DataCenterVO; -import com.cloud.dc.Vlan; -import com.cloud.dc.VlanDetailsVO; -import com.cloud.dc.VlanVO; -import com.cloud.dc.dao.DataCenterDao; -import com.cloud.dc.dao.VlanDao; -import com.cloud.dc.dao.VlanDetailsDao; -import com.cloud.domain.Domain; -import com.cloud.domain.DomainVO; -import com.cloud.domain.dao.DomainDao; -import com.cloud.exception.InsufficientVirtualNetworkCapacityException; -import com.cloud.exception.InvalidParameterValueException; -import com.cloud.host.DetailVO; -import com.cloud.host.Host; -import com.cloud.host.HostVO; -import com.cloud.host.Status; -import com.cloud.host.dao.HostDao; -import com.cloud.host.dao.HostDetailsDao; -import com.cloud.network.Network; -import com.cloud.network.NetworkModel; -import com.cloud.network.Networks; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.network.PhysicalNetwork; -import com.cloud.network.PhysicalNetworkServiceProvider; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkDetailVO; -import com.cloud.network.dao.NetworkDetailsDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.NuageVspDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderVO; -import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.network.resource.NuageVspResourceConfiguration; -import com.cloud.network.vpc.VpcOffering; -import com.cloud.network.vpc.VpcOfferingServiceMapVO; -import com.cloud.network.vpc.VpcOfferingVO; -import com.cloud.network.vpc.VpcVO; -import com.cloud.network.vpc.dao.VpcDao; -import com.cloud.network.vpc.dao.VpcOfferingDao; -import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao; -import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.resource.ResourceManager; -import com.cloud.resource.ResourceState; -import com.cloud.user.DomainManager; -import com.cloud.util.NuageVspEntityBuilder; -import com.cloud.util.NuageVspUtil; -import com.cloud.utils.component.ManagerBase; -import com.cloud.utils.db.DB; -import com.cloud.utils.db.Transaction; -import com.cloud.utils.db.TransactionCallback; -import com.cloud.utils.db.TransactionCallbackNoReturn; -import com.cloud.utils.db.TransactionStatus; -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.utils.fsm.StateListener; -import com.cloud.utils.fsm.StateMachine2; -import com.cloud.utils.net.NetUtils; -import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.dao.NicDao; -import com.cloud.vm.dao.VMInstanceDao; - -public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager, Configurable, StateListener { - - private static final Logger s_logger = Logger.getLogger(NuageVspManagerImpl.class); - - public static final Multimap DEFAULT_NUAGE_VSP_VPC_SERVICE_MAP; - public static final Multimap SUPPORTED_NUAGE_VSP_VPC_SERVICE_MAP; - private static final ConfigKey[] NUAGE_VSP_CONFIG_KEYS = new ConfigKey[] { NuageVspConfigDns, NuageVspDnsExternal, NuageVspConfigGateway, - NuageVspSharedNetworkDomainTemplateName, NuageVspVpcDomainTemplateName, NuageVspIsolatedNetworkDomainTemplateName }; - - - @Inject - ResourceManager _resourceMgr; - @Inject - HostDetailsDao _hostDetailsDao; - @Inject - HostDao _hostDao; - @Inject - PhysicalNetworkDao _physicalNetworkDao; - @Inject - PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao; - @Inject - NetworkDao _networkDao; - @Inject - NetworkDetailsDao _networkDetailsDao; - @Inject - VpcOfferingDao _vpcOffDao; - @Inject - VpcOfferingServiceMapDao _vpcOffSvcMapDao; - @Inject - VpcDao _vpcDao; - @Inject - private VpcDetailsDao _vpcDetailsDao; - @Inject - NuageVspDao _nuageVspDao; - @Inject - DataCenterDao _dataCenterDao; - @Inject - ConfigurationDao _configDao; - @Inject - AgentManager _agentMgr; - @Inject - private DomainDao _domainDao; - @Inject - NetworkOfferingDao _networkOfferingDao; - @Inject - NetworkOfferingServiceMapDao _networkOfferingServiceMapDao; - @Inject - NuageVspEntityBuilder _nuageVspEntityBuilder; - @Inject - VlanDao _vlanDao; - @Inject - VlanDetailsDao _vlanDetailsDao; - @Inject - ResponseGenerator _responseGenerator; - @Inject - MessageBus _messageBus; - @Inject - VMInstanceDao _vmInstanceDao; - @Inject - NicDao _nicDao; - @Inject - NetworkModel _networkModel; - - static { - Set nuageVspProviders = ImmutableSet.of(Network.Provider.NuageVsp); - Set vrProviders = ImmutableSet.of(Network.Provider.VPCVirtualRouter); - Set defaultLbProviders = ImmutableSet.of(Network.Provider.InternalLbVm); - Set supportedLbProviders = ImmutableSet.of(Network.Provider.InternalLbVm); - Set supportedUserDataProviders = ImmutableSet.of(Network.Provider.VPCVirtualRouter, Network.Provider.ConfigDrive); - - DEFAULT_NUAGE_VSP_VPC_SERVICE_MAP = ImmutableMultimap.builder() - .putAll(Network.Service.Connectivity, nuageVspProviders) - .putAll(Network.Service.Gateway, nuageVspProviders) - .putAll(Network.Service.Dhcp, nuageVspProviders) - .putAll(Network.Service.StaticNat, nuageVspProviders) - .putAll(Network.Service.SourceNat, nuageVspProviders) - .putAll(Network.Service.NetworkACL, nuageVspProviders) - .putAll(Network.Service.UserData, vrProviders) - .putAll(Network.Service.Lb, defaultLbProviders) - .putAll(Network.Service.Dns, vrProviders) - .build(); - - Multimap builder = HashMultimap.create(DEFAULT_NUAGE_VSP_VPC_SERVICE_MAP); - builder.putAll(Network.Service.UserData, supportedUserDataProviders); - builder.putAll(Network.Service.Lb, supportedLbProviders); - - SUPPORTED_NUAGE_VSP_VPC_SERVICE_MAP = ImmutableMultimap.copyOf(builder); - } - - private Listener _nuageVspResourceListener; - - @Override - public List> getCommands() { - return Lists.>newArrayList( - AddNuageVspDeviceCmd.class, - DeleteNuageVspDeviceCmd.class, - UpdateNuageVspDeviceCmd.class, - ListNuageVspDevicesCmd.class, - - DisableNuageUnderlayVlanIpRangeCmd.class, - EnableNuageUnderlayVlanIpRangeCmd.class, - ListNuageUnderlayVlanIpRangesCmd.class, - - ListNuageVspDomainTemplatesCmd.class, - ListNuageVspGlobalDomainTemplateCmd.class, - AssociateNuageVspDomainTemplateCmd.class - ); - } - - @Override - public NuageVspDeviceVO addNuageVspDevice(AddNuageVspDeviceCmd cmd) { - final NuageVspResource resource = new NuageVspResource(); - final String deviceName = Network.Provider.NuageVsp.getName(); - ExternalNetworkDeviceManager.NetworkDevice networkDevice = ExternalNetworkDeviceManager.NetworkDevice.getNetworkDevice(deviceName); - final Long physicalNetworkId = cmd.getPhysicalNetworkId(); - PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); - if (physicalNetwork == null) { - throw new InvalidParameterValueException("Could not find phyical network with ID: " + physicalNetworkId); - } - long zoneId = physicalNetwork.getDataCenterId(); - - final PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(), - networkDevice.getNetworkServiceProvder()); - if (ntwkSvcProvider == null) { - throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() + " is not enabled in the physical network: " - + physicalNetworkId + "to add this device"); - } else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) { - throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() + " is in shutdown state in the physical network: " - + physicalNetworkId + "to add this device"); - } - - if (_nuageVspDao.listByPhysicalNetwork(physicalNetworkId).size() != 0) { - throw new CloudRuntimeException("A NuageVsp device is already configured on this physical network"); - } - - // While the default VSD port is 8443, clustering via HAProxy will go over port 443 (CLOUD-58) - int port = cmd.getPort() > 0 ? cmd.getPort() : 443; - - try { - String apiVersion = null; - - String cmsUserPasswordBase64 = NuageVspUtil.encodePassword(cmd.getPassword()); - - NuageVspResourceConfiguration resourceConfiguration = new NuageVspResourceConfiguration() - .guid(UUID.randomUUID().toString()) - .zoneId(String.valueOf(physicalNetwork.getDataCenterId())) - .hostName(cmd.getHostName()) - .cmsUser(cmd.getUserName()) - .cmsUserPassword(cmsUserPasswordBase64) - .port(String.valueOf(port)) - .apiVersion(NuageVspApiVersion.CURRENT.toString()) - .retryCount(NuageVspConstants.DEFAULT_API_RETRY_COUNT.toString()) - .retryInterval(NuageVspConstants.DEFAULT_API_RETRY_INTERVAL.toString()) - .apiRelativePath("/nuage"); - - VspHost vspHost = resourceConfiguration.buildVspHost(); - NuageVspPluginClientLoader clientLoader = NuageVspPluginClientLoader.getClientLoader(vspHost); - VspApiDefaults apiDefaults = clientLoader.getNuageVspManagerClient().getApiDefaults(); - - - if (StringUtils.isNotBlank(cmd.getApiVersion())){ - apiVersion = cmd.getApiVersion(); - if (!clientLoader.getNuageVspManagerClient().isSupportedApiVersion(apiVersion)){ - throw new CloudRuntimeException("Unsupported API version : " + cmd.getApiVersion()); - } - } else { - List supportedVsdVersions = clientLoader.getNuageVspManagerClient().getSupportedVersionList(); - supportedVsdVersions.retainAll(Arrays.asList(NuageVspApiVersion.SUPPORTED_VERSIONS)); - - if(supportedVsdVersions.isEmpty()) { - throw new CloudRuntimeException("No supported API version found!"); - } - - supportedVsdVersions.sort(Comparator.reverseOrder()); - apiVersion = supportedVsdVersions.get(0).toString(); - } - - - String retryCount = String.valueOf(MoreObjects.firstNonNull(cmd.getApiRetryCount(), apiDefaults.getRetryCount())); - String retryInterval = String.valueOf(MoreObjects.firstNonNull(cmd.getApiRetryInterval(), apiDefaults.getRetryInterval())); - - resourceConfiguration - .apiVersion(apiVersion) - .apiRelativePath("/nuage/api/" + apiVersion) - .retryCount(retryCount) - .retryInterval(retryInterval); - Map hostDetails = resourceConfiguration.build(); - resource.configure("Nuage VSD - " + cmd.getHostName(), Maps.newHashMap(hostDetails)); - - - Host host = _resourceMgr.addHost(zoneId, resource, Host.Type.L2Networking, hostDetails); - if (host == null) { - throw new CloudRuntimeException("Failed to add Nuage Vsp Device due to internal error."); - } - - NuageVspDeviceVO nuageVspDevice = new NuageVspDeviceVO(host.getId(), physicalNetworkId, ntwkSvcProvider.getProviderName(), deviceName); - _nuageVspDao.persist(nuageVspDevice); - - DetailVO detail = new DetailVO(host.getId(), "nuagevspdeviceid", String.valueOf(nuageVspDevice.getId())); - _hostDetailsDao.persist(detail); - - NuageVspDeviceVO matchingNuageVspDevice = findMatchingNuageVspDevice(nuageVspDevice); - String cmsId; - if (matchingNuageVspDevice != null) { - cmsId = findNuageVspCmsIdForDeviceOrHost(matchingNuageVspDevice.getId(), matchingNuageVspDevice.getHostId()); - } else { - SyncNuageVspCmsIdCommand syncCmd = new SyncNuageVspCmsIdCommand(SyncType.REGISTER, null); - SyncNuageVspCmsIdAnswer answer = (SyncNuageVspCmsIdAnswer) _agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd); - if (answer != null && answer.getSuccess()) { - cmsId = answer.getNuageVspCmsId(); - } else { - throw new CloudRuntimeException("Failed to register CMS ID"); - } - } - - host = findNuageVspHost(nuageVspDevice.getHostId()); - registerNewNuageVspDevice(host.getId(), cmsId); - - resourceConfiguration.nuageVspCmsId(cmsId); - resource.configure(cmd.getHostName(), Maps.newHashMap(resourceConfiguration.build())); - - if (matchingNuageVspDevice == null) { - auditDomainsOnVsp((HostVO) host, true); - } - - return nuageVspDevice; - } catch (ConfigurationException e) { - s_logger.error("Failed to configure Nuage VSD resource " + cmd.getHostName(), e); - throw new CloudRuntimeException("Failed to configure Nuage VSD resource " + cmd.getHostName(), e); - } catch (NuageVspException ee) { - s_logger.error("Failed to add Nuage VSP device " + cmd.getHostName(), ee); - throw new CloudRuntimeException("Failed to add Nuage VSP device " + cmd.getHostName(), ee); - } - } - - @Override - public NuageVspDeviceVO updateNuageVspDevice(UpdateNuageVspDeviceCmd command) { - NuageVspResource resource = new NuageVspResource(); - final String deviceName = Network.Provider.NuageVsp.getName(); - ExternalNetworkDeviceManager.NetworkDevice networkDevice = ExternalNetworkDeviceManager.NetworkDevice.getNetworkDevice(deviceName); - final Long physicalNetworkId = command.getPhysicalNetworkId(); - PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); - if (physicalNetwork == null) { - throw new InvalidParameterValueException("Could not find phyical network with ID: " + physicalNetworkId); - } - - final PhysicalNetworkServiceProviderVO ntwkSvcProvider = _physicalNetworkServiceProviderDao.findByServiceProvider(physicalNetwork.getId(), - networkDevice.getNetworkServiceProvder()); - if (ntwkSvcProvider == null) { - throw new CloudRuntimeException("Network Service Provider: " + networkDevice.getNetworkServiceProvder() + " is not enabled in the physical network: " - + physicalNetworkId + "to add this device"); - } - if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) { - throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() + " is in shutdown state in the physical network: " - + physicalNetworkId + "to add this device"); - } - - HostVO nuageVspHost = null; - NuageVspDeviceVO nuageVspDevice = null; - List nuageVspDevices = _nuageVspDao.listByPhysicalNetwork(physicalNetworkId); - if (nuageVspDevices == null || nuageVspDevices.isEmpty()) { - throw new CloudRuntimeException("Nuage VSD is not configured on physical network " + physicalNetworkId); - } else { - nuageVspDevice = nuageVspDevices.iterator().next(); - nuageVspHost = _hostDao.findById(nuageVspDevice.getHostId()); - _hostDao.loadDetails(nuageVspHost); - } - - boolean resourceConfigurationChanged = false; - NuageVspResourceConfiguration resourceConfiguration = NuageVspResourceConfiguration.fromConfiguration(nuageVspHost.getDetails()); - if (!Strings.isNullOrEmpty(command.getHostName()) && - !command.getHostName().equals(resourceConfiguration.hostName())) { - resourceConfiguration.hostName(command.getHostName()); - resourceConfigurationChanged = true; - } - - if (!Strings.isNullOrEmpty(command.getUserName()) && - !command.getUserName().equals(resourceConfiguration.cmsUser())) { - resourceConfiguration.cmsUser(command.getUserName()); - resourceConfigurationChanged = true; - } - - if (!Strings.isNullOrEmpty(command.getPassword())) { - String encodedNewPassword = NuageVspUtil.encodePassword(command.getPassword()); - if (!encodedNewPassword.equals(resourceConfiguration.cmsUserPassword())) { - resourceConfiguration.cmsUserPassword(encodedNewPassword); - resourceConfigurationChanged = true; - } - } - - if (command.getPort() != null && - command.getPort() != Integer.parseInt(resourceConfiguration.port())) { - resourceConfiguration.port(String.valueOf(command.getPort())); - resourceConfigurationChanged = true; - } - - String apiVersion = MoreObjects.firstNonNull(command.getApiVersion(), resourceConfiguration.apiVersion()); - NuageVspApiVersion apiVersionObj = NuageVspApiVersion.fromString(apiVersion); - NuageVspApiVersion apiVersionCurrent = null; - try { - apiVersionCurrent = resourceConfiguration.getApiVersion(); - } catch (ConfigurationException e){ - throw new CloudRuntimeException("Current version is not configured correctly"); - } - - - if(command.getApiVersion() != null){ - if(apiVersionObj.compareTo(apiVersionCurrent) < 0) { - throw new CloudRuntimeException("Downgrading is not supported"); - } - - GetApiDefaultsCommand apiDefaultsCmd = new GetApiDefaultsCommand(); - GetApiDefaultsAnswer apiDefaultsAnswer = (GetApiDefaultsAnswer) _agentMgr.easySend(nuageVspHost.getId(), apiDefaultsCmd); - - SupportedApiVersionCommand supportedApiVersionCmd = new SupportedApiVersionCommand(apiVersion); - Answer supportedApiVersionAnswer = _agentMgr.easySend(nuageVspHost.getId(), supportedApiVersionCmd); - - if (!supportedApiVersionAnswer.getResult()) { - throw new CloudRuntimeException("Incorrect API version: Nuage plugin only supports " + apiDefaultsAnswer.getApiDefaults().getVersion()); - } - - String apiRelativePath = "/nuage/api/" + apiVersion; - if (!apiRelativePath.equals(resourceConfiguration.apiRelativePath())) { - resourceConfiguration.apiVersion(apiVersion); - resourceConfiguration.apiRelativePath(apiRelativePath); - resourceConfigurationChanged = true; - } - - } - - if (command.getApiRetryCount() != null && resourceConfiguration.retryCount() != null) { - final int retryCount = Integer.parseInt(resourceConfiguration.retryCount()); - if (command.getApiRetryCount() != retryCount) { - resourceConfiguration.retryCount(String.valueOf(command.getApiRetryCount())); - resourceConfigurationChanged = true; - } - } - - if (command.getApiRetryInterval() != null && resourceConfiguration.retryInterval() != null) { - final int apiRetryInterval = Integer.parseInt(resourceConfiguration.retryInterval()); - if (command.getApiRetryInterval() != apiRetryInterval) { - resourceConfiguration.retryInterval(String.valueOf(command.getApiRetryInterval())); - resourceConfigurationChanged = true; - } - } - - if (!resourceConfigurationChanged) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("No change in the NuageVsp device parameters. None of the NuageVsp device parameters are modified"); - } - return nuageVspDevice; - } - - Map config = resourceConfiguration.build(); - try { - resource.validate(config); - - UpdateNuageVspDeviceCommand cmd = new UpdateNuageVspDeviceCommand(resourceConfiguration); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - if (answer == null || !answer.getResult()) { - s_logger.error("UpdateNuageVspDeviceCommand failed"); - if ((null != answer) && (null != answer.getDetails())) { - throw new CloudRuntimeException(answer.getDetails()); - } - } - - _hostDetailsDao.persist(nuageVspDevice.getHostId(), config); - } catch (ConfigurationException e) { - throw new CloudRuntimeException("Failed to update Nuage VSP device " + nuageVspDevice.getId() + " with parameters " + resourceConfiguration, e); - } - return nuageVspDevice; - } - - @Override - public NuageVspDeviceResponse createNuageVspDeviceResponse(NuageVspDeviceVO nuageVspDeviceVO) { - HostVO nuageVspHost = _hostDao.findById(nuageVspDeviceVO.getHostId()); - _hostDao.loadDetails(nuageVspHost); - - NuageVspResourceConfiguration resourceConfiguration = NuageVspResourceConfiguration.fromConfiguration(nuageVspHost.getDetails()); - NuageVspDeviceResponse response = new NuageVspDeviceResponse(); - response.setDeviceName(nuageVspDeviceVO.getDeviceName()); - PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(nuageVspDeviceVO.getPhysicalNetworkId()); - if (pnw != null) { - response.setPhysicalNetworkId(pnw.getUuid()); - } - response.setId(nuageVspDeviceVO.getUuid()); - response.setProviderName(nuageVspDeviceVO.getProviderName()); - response.setHostName(resourceConfiguration.hostName()); - response.setPort(Integer.parseInt(resourceConfiguration.port())); - String apiRelativePath = resourceConfiguration.apiRelativePath(); - response.setApiVersion(apiRelativePath.substring(apiRelativePath.lastIndexOf('/') + 1)); - response.setApiRetryCount(Integer.parseInt(resourceConfiguration.retryCount())); - response.setApiRetryInterval(Long.parseLong(resourceConfiguration.retryInterval())); - response.setCmsId(resourceConfiguration.nuageVspCmsId()); - response.setObjectName("nuagevspdevice"); - return response; - } - - @Override - public boolean deleteNuageVspDevice(DeleteNuageVspDeviceCmd cmd) { - Long nuageDeviceId = cmd.getNuageVspDeviceId(); - NuageVspDeviceVO nuageVspDevice = _nuageVspDao.findById(nuageDeviceId); - if (nuageVspDevice == null) { - throw new InvalidParameterValueException("Could not find a Nuage Vsp device with id " + nuageDeviceId); - } - - // Find the physical network we work for - Long physicalNetworkId = nuageVspDevice.getPhysicalNetworkId(); - PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); - if (physicalNetwork != null) { - // Lets see if there are networks that use us - // Find the nuage networks on this physical network - List networkList = _networkDao.listByPhysicalNetwork(physicalNetworkId); - - // Networks with broadcast type lswitch are ours - for (NetworkVO network : networkList) { - if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Vsp) { - if ((network.getState() != Network.State.Shutdown) && (network.getState() != Network.State.Destroy)) { - throw new CloudRuntimeException("This Nuage Vsp device can not be deleted as there are one or more logical networks provisioned by Cloudstack."); - } - } - } - } - - NuageVspDeviceVO matchingNuageVspDevice = findMatchingNuageVspDevice(nuageVspDevice); - - String nuageVspCmsId = findNuageVspCmsIdForDeviceOrHost(nuageVspDevice.getId(), nuageVspDevice.getHostId()); - if (matchingNuageVspDevice == null) { - HostVO host = findNuageVspHost(nuageVspDevice.getHostId()); - if (!auditDomainsOnVsp(host, false)) { - return false; - } - - SyncNuageVspCmsIdCommand syncCmd = new SyncNuageVspCmsIdCommand(SyncType.UNREGISTER, nuageVspCmsId); - SyncNuageVspCmsIdAnswer answer = (SyncNuageVspCmsIdAnswer) _agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd); - if (answer == null || !answer.getSuccess()) { - return false; - } - } - - removeLegacyNuageVspDeviceCmsId(nuageVspDevice.getId()); - - HostVO nuageHost = _hostDao.findById(nuageVspDevice.getHostId()); - Long hostId = nuageHost.getId(); - - nuageHost.setResourceState(ResourceState.Maintenance); - _hostDao.update(hostId, nuageHost); - _resourceMgr.deleteHost(hostId, false, false); - - _nuageVspDao.remove(nuageDeviceId); - return true; - } - - private NuageVspDeviceVO findMatchingNuageVspDevice(NuageVspDeviceVO nuageVspDevice) { - DetailVO nuageVspDeviceHost = _hostDetailsDao.findDetail(nuageVspDevice.getHostId(), "hostname"); - String nuageVspDeviceHostName = (nuageVspDeviceHost != null) ? nuageVspDeviceHost.getValue(): null; - - List otherNuageVspDevices = _nuageVspDao.listAll(); - for (NuageVspDeviceVO otherNuageVspDevice : otherNuageVspDevices) { - if (otherNuageVspDevice.getId() == nuageVspDevice.getId()) continue; - - DetailVO otherNuageVspDeviceHostName = _hostDetailsDao.findDetail(otherNuageVspDevice.getHostId(), "hostname"); - if (otherNuageVspDeviceHostName != null && nuageVspDeviceHostName.equals(otherNuageVspDeviceHostName.getValue())) { - return otherNuageVspDevice; - } - } - return null; - } - - @Override - public List listNuageVspDevices(ListNuageVspDevicesCmd cmd) { - Long physicalNetworkId = cmd.getPhysicalNetworkId(); - Long nuageVspDeviceId = cmd.getNuageVspDeviceId(); - List responseList = new ArrayList(); - - if (physicalNetworkId == null && nuageVspDeviceId == null) { - throw new InvalidParameterValueException("Either physical network Id or Nuage device Id must be specified"); - } - - if (nuageVspDeviceId != null) { - NuageVspDeviceVO nuageVspDevice = _nuageVspDao.findById(nuageVspDeviceId); - if (nuageVspDevice == null) { - throw new InvalidParameterValueException("Could not find Nuage Vsp device with id: " + nuageVspDeviceId); - } - responseList.add(nuageVspDevice); - } else { - PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); - if (physicalNetwork == null) { - throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId); - } - responseList = _nuageVspDao.listByPhysicalNetwork(physicalNetworkId); - } - - return responseList; - } - - private void registerNewNuageVspDevice(long hostId, String cmsId) { - DetailVO detail = new DetailVO(hostId, "nuagevspcmsid", cmsId); - _hostDetailsDao.persist(detail); - } - - @Deprecated - private void removeLegacyNuageVspDeviceCmsId(long deviceId) { - ConfigurationVO cmsIdConfig = _configDao.findByName(CMSID_CONFIG_KEY); - if (cmsIdConfig != null) { - if (!cmsIdConfig.getValue().contains(";") && cmsIdConfig.getValue().startsWith(deviceId + ":")) { - _configDao.update(CMSID_CONFIG_KEY, "Advanced", ""); - } else { - String newValue = cmsIdConfig.getValue().replace(String.format("(^|;)%d:[0-9a-f\\-]+;?", deviceId), ";"); - _configDao.update(CMSID_CONFIG_KEY, "Advanced", newValue); - } - } - } - - public boolean executeSyncCmsId(NuageVspDeviceVO nuageVspDevice, SyncType syncType) { - NuageVspDeviceVO matchingNuageVspDevice = findMatchingNuageVspDevice(nuageVspDevice); - if (syncType == SyncType.REGISTER && matchingNuageVspDevice != null) { - String cmsId = findNuageVspCmsIdForDeviceOrHost(matchingNuageVspDevice.getId(), matchingNuageVspDevice.getHostId()); - registerNewNuageVspDevice(nuageVspDevice.getHostId(), cmsId); - return true; - } - - String cmsId = findNuageVspCmsIdForDeviceOrHost(nuageVspDevice.getId(), nuageVspDevice.getHostId()); - - SyncNuageVspCmsIdCommand syncCmd = new SyncNuageVspCmsIdCommand(syncType, cmsId); - SyncNuageVspCmsIdAnswer answer = (SyncNuageVspCmsIdAnswer) _agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd); - if (answer != null) { - if (answer.getSuccess()) { - if (syncType == SyncType.REGISTER || answer.getSyncType() == SyncType.REGISTER) { - registerNewNuageVspDevice(nuageVspDevice.getHostId(), answer.getNuageVspCmsId()); - } else if (syncType == SyncType.UNREGISTER) { - removeLegacyNuageVspDeviceCmsId(nuageVspDevice.getId()); - } - } else if (syncType == SyncType.AUDIT || syncType == SyncType.AUDIT_ONLY) { - s_logger.fatal("Nuage VSP Device with ID " + nuageVspDevice.getId() + " is configured with an unknown CMS ID!"); - } - } - - return answer != null && answer.getSuccess(); - } - - void auditHost(long hostId) { - Host host = _hostDao.findById(hostId); - auditHost((HostVO)host); - } - - void auditHost(HostVO host) { - if (host == null) return; - - _hostDao.loadDetails(host); - - boolean validateDomains = true; - List nuageVspDevices = _nuageVspDao.listByHost(host.getId()); - if (!CollectionUtils.isEmpty(nuageVspDevices)) { - for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) { - String nuageVspCmsId = findNuageVspCmsIdForDeviceOrHost(nuageVspDevice.getId(), nuageVspDevice.getHostId()); - SyncNuageVspCmsIdCommand syncCmd = new SyncNuageVspCmsIdCommand(SyncType.AUDIT, nuageVspCmsId); - SyncNuageVspCmsIdAnswer answer = (SyncNuageVspCmsIdAnswer) _agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd); - - if (answer != null && !answer.getSuccess()) { - s_logger.error("Nuage VSP Device with ID " + nuageVspDevice.getId() + " is configured with an unknown CMS ID!"); - validateDomains = false; - } else if (answer != null && answer.getSyncType() == SyncType.REGISTER) { - registerNewNuageVspDevice(nuageVspDevice.getHostId(), answer.getNuageVspCmsId()); - } - } - } - - if (validateDomains) { - auditDomainsOnVsp(host, true); - } - } - - private boolean auditDomainsOnVsp(HostVO host, boolean add) { - List nuageVspDevices = _nuageVspDao.listByHost(host.getId()); - if (CollectionUtils.isEmpty(nuageVspDevices)) { - return true; - } - - final SyncDomainCommand.Type action = add ? SyncDomainCommand.Type.ADD : SyncDomainCommand.Type.REMOVE; - - _hostDao.loadDetails(host); - List allDomains = _domainDao.listAll(); - for (DomainVO domain : allDomains) { - if (action == SyncDomainCommand.Type.REMOVE) { - VspDomainCleanUp vspDomainCleanUp = _nuageVspEntityBuilder.buildVspDomainCleanUp(domain); - CleanUpDomainCommand cmd = new CleanUpDomainCommand(vspDomainCleanUp); - Answer answer = _agentMgr.easySend(host.getId(), cmd); - if (!answer.getResult()) { - return false; - } - } - - VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain); - SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, action); - Answer answer = _agentMgr.easySend(host.getId(), cmd); - if (!answer.getResult()) { - return false; - } - } - return true; - } - - private String findNuageVspCmsIdForDeviceOrHost(long deviceId, long hostId) { - String cmsId = findNuageVspCmsIdForHostDevice(hostId); - if(cmsId == null) { - cmsId = findNuageVspCmsIdForDevice(deviceId); - - if (cmsId != null) { - // Upgrade - registerNewNuageVspDevice(hostId, cmsId); - removeLegacyNuageVspDeviceCmsId(deviceId); - } - } - - return cmsId; - } - - private String findNuageVspCmsIdForHostDevice(long hostId) { - final DetailVO cmsIdDetailVO = _hostDetailsDao.findDetail(hostId, "nuagevspcmsid"); - if (cmsIdDetailVO != null) { - return cmsIdDetailVO.getValue(); - } - return null; - } - - @Deprecated - private String findNuageVspCmsIdForDevice(long deviceId) { - ConfigurationVO cmsIdConfig = _configDao.findByName(CMSID_CONFIG_KEY); - if(cmsIdConfig != null) { - String configValue = cmsIdConfig.getValue(); - if (!Strings.isNullOrEmpty(configValue)) { - String[] configuredNuageVspDevices = configValue.split(";"); - for (String configuredNuageVspDevice : configuredNuageVspDevices) { - if (configuredNuageVspDevice.startsWith(deviceId + ":")) { - String[] split = configuredNuageVspDevice.split(":"); - if (split.length != 2 || (split.length > 1 && Strings.isNullOrEmpty(split[1]))) { - throw new IllegalArgumentException("The configured CMS ID for Nuage VSP device " + deviceId + " is in an incorrect format"); - } - return split[1]; - } - } - } - } - return null; - } - - public List getDnsDetails(long dataCenterId) { - Boolean configureDns = Boolean.valueOf(_configDao.getValue(NuageVspManager.NuageVspConfigDns.key())); - if (!configureDns) { - return Lists.newArrayList(); - } - - Boolean configureExternalDns = Boolean.valueOf(_configDao.getValue(NuageVspManager.NuageVspDnsExternal.key())); - DataCenterVO dc = _dataCenterDao.findById(dataCenterId); - List dnsServers = new ArrayList(); - if (configureExternalDns) { - if (!Strings.isNullOrEmpty(dc.getDns1())) { - dnsServers.add(dc.getDns1()); - } - if (!Strings.isNullOrEmpty(dc.getDns2())) { - dnsServers.add(dc.getDns2()); - } - } else { - if (!Strings.isNullOrEmpty(dc.getInternalDns1())) { - dnsServers.add(dc.getInternalDns1()); - } - if (!Strings.isNullOrEmpty(dc.getInternalDns2())) { - dnsServers.add(dc.getInternalDns2()); - } - } - return dnsServers; - } - - public List getGatewaySystemIds() { - String gatewaySystemIds = String.valueOf(_configDao.getValue(NuageVspManager.NuageVspConfigGateway.key())); - if (!Strings.isNullOrEmpty(gatewaySystemIds)) { - return Lists.newArrayList(gatewaySystemIds.split(",")); - } - return Lists.newArrayList(); - } - - - @Override - public List listNuageVspDomainTemplates(ListNuageVspDomainTemplatesCmd cmd){ - long domainId; - - if (cmd.getDomainId() != null) { - domainId = cmd.getDomainId(); - } else { - domainId = CallContext.current().getCallingAccount().getDomainId(); - } - - return listNuageVspDomainTemplates(domainId, cmd.getKeyword(), cmd.getZoneId(), cmd.getPhysicalNetworkId()); - } - - @Override - public List listNuageVspDomainTemplates(long domainId, String keyword, Long zoneId, Long passedPhysicalNetworkId) { - Optional physicalNetworkId; - Domain domain = _domainDao.findById(domainId); - VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain); - - if (passedPhysicalNetworkId != null) { - physicalNetworkId = Optional.of(passedPhysicalNetworkId); - } else if (zoneId != null) { - physicalNetworkId = Optional.ofNullable(getPhysicalNetworkBasedOnZone(zoneId)); - } else { - throw new InvalidParameterValueException("No zoneid or physicalnetworkid specified."); - } - - if (!physicalNetworkId.isPresent()) { - return new LinkedList<>(); - } - - Long hostId = getNuageVspHostId(physicalNetworkId.get()); - if (hostId == null) { - return new LinkedList<>(); - } - - ListVspDomainTemplatesCommand agentCmd = new ListVspDomainTemplatesCommand(vspDomain, keyword); - ListVspDomainTemplatesAnswer answer = (ListVspDomainTemplatesAnswer) _agentMgr.easySend(hostId, agentCmd); - List domainTemplates = answer.getDomainTemplates(); - - return domainTemplates.stream() - .map(NuageVspManagerImpl::createDomainTemplateResponse) - .collect(Collectors.toList()); - } - - private static NuageVspDomainTemplateResponse createDomainTemplateResponse(VspDomainTemplate dt) { - return new NuageVspDomainTemplateResponse(dt.getName(), dt.getDescription()); - } - - /** - * Returns the PhysicalNetworkId based on a zoneId - * @param zoneId != null, the zone id for which we need to retrieve the PhysicalNetworkId - * @return the physical network id if it's found otherwise null - */ - private Long getPhysicalNetworkBasedOnZone(Long zoneId){ - - Long physicalNetworkId = null; - List physicalNetworkVOs = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, Networks.TrafficType.Guest); - for (PhysicalNetworkVO physicalNetwok : physicalNetworkVOs) { - if (physicalNetwok.getIsolationMethods().contains(NUAGE_VSP_ISOLATION)) { - physicalNetworkId = physicalNetwok.getId(); - break; - } - } - return physicalNetworkId; - } - - @Override - public void associateNuageVspDomainTemplate(AssociateNuageVspDomainTemplateCmd cmd){ - VpcVO vpc = _vpcDao.findById(cmd.getVpcId()); - Long physicalNetworkId; - if (cmd.getPhysicalNetworkId() != null) { - physicalNetworkId = cmd.getPhysicalNetworkId(); - } else if (cmd.getZoneId() != null) { - physicalNetworkId = getPhysicalNetworkBasedOnZone(cmd.getZoneId()); - } else { - throw new InvalidParameterValueException("No zoneid or physicalnetworkid specified."); - } - - EntityExistsCommand entityCmd = new EntityExistsCommand(VpcVO.class, vpc.getUuid()); - boolean exists = entityExist(entityCmd, physicalNetworkId); - if (exists) { - throw new CloudRuntimeException("Failed to associate domain template, VPC is already pushed to the Nuage VSP device."); - } - - if (!checkIfDomainTemplateExist(vpc.getDomainId(), cmd.getDomainTemplate(), cmd.getZoneId(), cmd.getPhysicalNetworkId())) { - throw new InvalidParameterValueException("Could not find a Domain Template with name: " + cmd.getDomainTemplate()); - } - setPreConfiguredDomainTemplateName(cmd.getVpcId(), cmd.getDomainTemplate()); - } - - @Override - public boolean checkIfDomainTemplateExist(Long domainId, String domainTemplate, Long zoneId, Long physicalNetworkId){ - List domainTemplateList = listNuageVspDomainTemplates(domainId, domainTemplate, zoneId, physicalNetworkId); - if (domainTemplateList != null) { - for (NuageVspDomainTemplateResponse val : domainTemplateList) { - if (val.getName().equals(domainTemplate)) { - return true; - } - } - } - return false; - } - - @Override - public void updateBroadcastUri(Network network) throws InsufficientVirtualNetworkCapacityException { - NetworkVO updatedNetwork = _networkDao.createForUpdate(network.getId()); - URI broadcastUri = calculateBroadcastUri(network); - if (!broadcastUri.equals(network.getBroadcastUri())) { - updatedNetwork.setBroadcastUri(broadcastUri); - _networkDao.update(network.getId(), updatedNetwork); - } - } - - @Override - public URI calculateBroadcastUri(Network network) throws InsufficientVirtualNetworkCapacityException { - String vrIp = calculateVirtualRouterIp(network); - return Networks.BroadcastDomainType.Vsp.toUri(network.getUuid() + "/" + vrIp); - } - - private boolean usesVirtualRouter(long networkOfferingId) { - return _networkOfferingServiceMapDao.isProviderForNetworkOffering(networkOfferingId, Network.Provider.VirtualRouter) || - _networkOfferingServiceMapDao.isProviderForNetworkOffering(networkOfferingId, Network.Provider.VPCVirtualRouter); - } - - private String calculateVirtualRouterIp(Network network) - throws InsufficientVirtualNetworkCapacityException { - if (!usesVirtualRouter(network.getNetworkOfferingId())) { - return null; - } - - List> ipAddressRanges = - network.getGuestType() == Network.GuestType.Shared ? getSharedIpAddressRanges(network.getId()) : getIpAddressRanges(network); - - //check if a vr might be present already or not? CLOUD-1216 - before we always picked .2 - List vrs =_vmInstanceDao.listNonRemovedVmsByTypeAndNetwork(network.getId(), VirtualMachine.Type.DomainRouter); - - for (VMInstanceVO vr : vrs) { - return _nicDao.listByVmIdAndNicIdAndNtwkId(vr.getId(), null, network.getId()).get(0).getIPv4Address(); - } - - ensureIpCapacity(network, ipAddressRanges); - - if(network.getGuestType() == Network.GuestType.Shared) { - return ipAddressRanges.stream() - .sorted(Comparator.comparingLong(p -> NetUtils.ip2Long(p.getLeft()))) - .findFirst() - .map(Pair::getLeft) - .orElseThrow(() -> new IllegalArgumentException("Shared network without ip ranges? How can this happen?")); - } - - Network networkToCheck; - if (isMigratingNetwork(network)) { - networkToCheck = _networkDao.findById(network.getRelated()); - } else { - networkToCheck = network; - } - - Long freeIp = _networkModel.getAvailableIps(networkToCheck, null) - .stream() - .findFirst() - .orElseThrow(() -> new InsufficientVirtualNetworkCapacityException("There is no free ip available for the VirtualRouter.", - Network.class, - network.getId())); - - return NetUtils.long2Ip(freeIp); - } - - private List> getSharedIpAddressRanges(long networkId) { - List vlans = _vlanDao.listVlansByNetworkId(networkId); - List> ipAddressRanges = Lists.newArrayList(); - for (VlanVO vlan : vlans) { - Pair ipAddressRange = NuageVspUtil.getIpAddressRange(vlan); - if (ipAddressRange != null) { - ipAddressRanges.add(ipAddressRange); - } - } - return ipAddressRanges; - } - - private List> getIpAddressRanges(Network network) { - List> ipAddressRanges = Lists.newArrayList(); - String subnet = NetUtils.getCidrSubNet(network.getCidr()); - String netmask = NetUtils.getCidrNetmask(network.getCidr()); - long cidrSize = NetUtils.getCidrSize(netmask); - Set allIPsInCidr = NetUtils.getAllIpsFromCidr(subnet, cidrSize, new HashSet()); - if (allIPsInCidr == null || !(allIPsInCidr instanceof TreeSet)) { - throw new IllegalStateException("The IPs in CIDR for subnet " + subnet + " where null or returned in a non-ordered set."); - } - - Iterator ipIterator = allIPsInCidr.iterator(); - long ip = ipIterator.next(); - long gatewayIp = NetUtils.ip2Long(network.getGateway()); - String lastIp = NetUtils.getIpRangeEndIpFromCidr(subnet, cidrSize); - if (gatewayIp == ip) { - ip = ipIterator.next(); - ipAddressRanges.add(Pair.of(NetUtils.long2Ip(ip), lastIp)); - } else if (!network.getGateway().equals(lastIp)) { - ipAddressRanges.add(Pair.of(NetUtils.long2Ip(ip), NetUtils.long2Ip(gatewayIp - 1))); - ipAddressRanges.add(Pair.of(NetUtils.long2Ip(gatewayIp + 1), lastIp)); - } else { - ipAddressRanges.add(Pair.of(NetUtils.long2Ip(ip), NetUtils.long2Ip(gatewayIp - 1))); - } - - return ipAddressRanges; - } - - private void ensureIpCapacity(Network network, List> ipAddressRanges) throws InsufficientVirtualNetworkCapacityException { - long ipCount = ipAddressRanges.stream() - .mapToLong(this::getIpCount) - .sum(); - - if (ipCount == 0) { - throw new InsufficientVirtualNetworkCapacityException("VSP allocates an IP for VirtualRouter." + " But no ip address ranges are specified", Network.class, - network.getId()); - } else if (ipCount < 3) { - throw new InsufficientVirtualNetworkCapacityException("VSP allocates an IP for VirtualRouter." + " So, subnet should have atleast minimum 3 hosts", Network.class, - network.getId()); - } - } - - private boolean isMigratingNetwork(Network network) { - return network.getRelated() != network.getId(); - } - - private long getIpCount(Pair ipAddressRange) { - return NetUtils.ip2Long(ipAddressRange.getRight()) - NetUtils.ip2Long(ipAddressRange.getLeft()) + 1; - } - - @Override - public boolean entityExist(EntityExistsCommand cmd, Long physicalNetworkId){ - Long hostId = getNuageVspHostId(physicalNetworkId); - if (hostId == null) { - throw new CloudRuntimeException("There is no Nuage VSP device configured on physical network " + physicalNetworkId); - } - - Answer answer = _agentMgr.easySend(hostId, cmd); - if (answer != null) { - return answer.getResult(); - } - throw new CloudRuntimeException("No answer received from the client"); - } - - /** - * Sets the preconfigured domain template of a vpc to the given value. - * @param vpcId - * @param domainTemplateName - */ - private void setPreConfiguredDomainTemplateName(long vpcId, String domainTemplateName) { - //remove the previous nuageDomainTemplate if it is present. - if (_vpcDetailsDao.findDetail(vpcId, NuageVspManager.nuageDomainTemplateDetailName) != null) { - _vpcDetailsDao.removeDetail(vpcId, NuageVspManager.nuageDomainTemplateDetailName); - } - VpcDetailVO vpcDetail = new VpcDetailVO(vpcId, NuageVspManager.nuageDomainTemplateDetailName, domainTemplateName, false); - _vpcDetailsDao.persist(vpcDetail); - } - - @Override - public void setPreConfiguredDomainTemplateName(Network network, String domainTemplateName) { - - if (network.getVpcId() != null) { - setPreConfiguredDomainTemplateName(network.getVpcId(), domainTemplateName); - } else { - NetworkDetailVO networkDetail = new NetworkDetailVO(network.getId(), NuageVspManager.nuageDomainTemplateDetailName, domainTemplateName, false); - _networkDetailsDao.persist(networkDetail); - } - } - - @Override - public String getPreConfiguredDomainTemplateName(Network network) { - - if (network.getVpcId() != null) { - VpcDetailVO domainTemplateNetworkDetail = _vpcDetailsDao.findDetail(network.getVpcId(), NuageVspManager.nuageDomainTemplateDetailName); - if (domainTemplateNetworkDetail != null) { - return domainTemplateNetworkDetail.getValue(); - } - - return NuageVspVpcDomainTemplateName.value(); - } else { - NetworkDetailVO domainTemplateNetworkDetail = _networkDetailsDao.findDetail(network.getId(), NuageVspManager.nuageDomainTemplateDetailName); - if (domainTemplateNetworkDetail != null) { - return domainTemplateNetworkDetail.getValue(); - } - - if (network.getGuestType() == Network.GuestType.Shared) { - return NuageVspSharedNetworkDomainTemplateName.value(); - } - - return NuageVspIsolatedNetworkDomainTemplateName.value(); - } - } - - @Override - public HostVO getNuageVspHost(long physicalNetworkId) { - HostVO nuageVspHost; - List nuageVspDevices = _nuageVspDao.listByPhysicalNetwork(physicalNetworkId); - if (CollectionUtils.isEmpty(nuageVspDevices)) { - // Perhaps another physical network is passed from within the same zone, find the VSP physical network in that case - PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId); - List physicalNetworksInZone = _physicalNetworkDao.listByZone(physicalNetwork.getDataCenterId()); - for (PhysicalNetworkVO physicalNetworkInZone : physicalNetworksInZone) { - if (physicalNetworkInZone.getIsolationMethods().contains(NUAGE_VSP_ISOLATION)) { - nuageVspDevices = _nuageVspDao.listByPhysicalNetwork(physicalNetworkInZone.getId()); - break; - } - } - } - - if (CollectionUtils.isNotEmpty(nuageVspDevices)) { - NuageVspDeviceVO config = nuageVspDevices.iterator().next(); - nuageVspHost = _hostDao.findById(config.getHostId()); - _hostDao.loadDetails(nuageVspHost); - } else { - throw new CloudRuntimeException("There is no Nuage VSP device configured on physical network " + physicalNetworkId); - } - return nuageVspHost; - } - - @Override - public boolean updateNuageUnderlayVlanIpRange(long vlanIpRangeId, boolean enabled) { - VlanVO staticNatVlan = _vlanDao.findById(vlanIpRangeId); - HostVO nuageVspHost = getNuageVspHost(staticNatVlan.getPhysicalNetworkId()); - EntityExistsCommand cmd = new EntityExistsCommand(Vlan.class, staticNatVlan.getUuid()); - Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd); - if (answer != null && !answer.getResult()) { - _vlanDetailsDao.addDetail(staticNatVlan.getId(), NuageVspManager.nuageUnderlayVlanIpRangeDetailKey, String.valueOf(enabled), false); - return true; - } - - return false; - } - - @Override - public List filterNuageVlanIpRanges(List vlanIpRanges, Boolean underlay) { - List nuageVlanIpRanges = Lists.newArrayList(); - for (Vlan vlanIpRange : vlanIpRanges) { - NuageVlanIpRangeResponse nuageVlanIpRange = (NuageVlanIpRangeResponse) _responseGenerator.createVlanIpRangeResponse(NuageVlanIpRangeResponse.class, vlanIpRange); - - VlanDetailsVO nuageUnderlayDetail = _vlanDetailsDao.findDetail(vlanIpRange.getId(), NuageVspManager.nuageUnderlayVlanIpRangeDetailKey); - boolean underlayEnabled = nuageUnderlayDetail != null && nuageUnderlayDetail.getValue().equalsIgnoreCase(String.valueOf(true)); - nuageVlanIpRange.setUnderlay(underlayEnabled); - if (underlay == null || underlayEnabled == underlay) { - nuageVlanIpRanges.add(nuageVlanIpRange); - } - nuageVlanIpRange.setObjectName("nuagevlaniprange"); - } - return nuageVlanIpRanges; - } - - @Override - public boolean preStateTransitionEvent(Status oldState, Status.Event event, Status newState, Host host, boolean status, Object opaque) { - return true; - } - - @Override - public boolean postStateTransitionEvent(StateMachine2.Transition transition, Host vo, boolean status, Object opaque) { - // Whenever a Nuage VSP Host comes up, check if all CS domains are present and check if the CMS ID is valid - if (transition.getToState() == Status.Up && vo instanceof HostVO) { - auditHost((HostVO) vo); - } - return true; - } - - @Override - public boolean configure(String name, Map params) throws ConfigurationException { - initMessageBusListeners(); - initNuageVspResourceListeners(); - initNuageVspVpcOffering(); - Status.getStateMachine().registerListener(this); - return true; - } - - @DB - private void initMessageBusListeners() { - // Create corresponding enterprise and profile in VSP when creating a CS Domain - _messageBus.subscribe(DomainManager.MESSAGE_ADD_DOMAIN_EVENT, (senderAddress, subject, args) -> { - Long domainId = (Long) args; - Domain domain = _domainDao.findById(domainId); - - try { - _domainDao.acquireInLockTable(domain.getId()); - - List nuageVspDevices = _nuageVspDao.listAll(); - for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) { - VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain); - SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.ADD); - _agentMgr.easySend(nuageVspDevice.getHostId(), cmd); - } - } finally { - _domainDao.releaseFromLockTable(domain.getId()); - } - }); - - // Clean up corresponding resources in VSP when deleting a CS Domain - _messageBus.subscribe(DomainManager.MESSAGE_PRE_REMOVE_DOMAIN_EVENT, (senderAddress, subject, args) -> { - DomainVO domain = (DomainVO) args; - List nuageVspDevices = _nuageVspDao.listAll(); - for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) { - VspDomainCleanUp vspDomainCleanUp = _nuageVspEntityBuilder.buildVspDomainCleanUp(domain); - CleanUpDomainCommand cmd = new CleanUpDomainCommand(vspDomainCleanUp); - _agentMgr.easySend(nuageVspDevice.getHostId(), cmd); - } - }); - - // Delete corresponding enterprise and profile in VSP when deleting a CS Domain - _messageBus.subscribe(DomainManager.MESSAGE_REMOVE_DOMAIN_EVENT, (senderAddress, subject, args) -> { - DomainVO domain = (DomainVO) args; - List nuageVspDevices = _nuageVspDao.listAll(); - for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) { - VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain); - SyncDomainCommand syncCmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.REMOVE); - _agentMgr.easySend(nuageVspDevice.getHostId(), syncCmd); - } - }); - } - - private class NuageVspResourceListener extends AbstractListener { - @Override - public boolean processCommands(long agentId, long seq, Command[] commands) { - if (commands != null && commands.length == 1) { - Command command = commands[0]; - if (command instanceof PingNuageVspCommand) { - PingNuageVspCommand pingNuageVspCommand = (PingNuageVspCommand)command; - if (pingNuageVspCommand.shouldAudit()) { - auditHost(pingNuageVspCommand.getHostId()); - } - } - } - return true; - } - } - - @DB - private void initNuageVspResourceListeners() { - _agentMgr.registerForHostEvents(new NuageVspResourceListener(), false, true, false); - } - - private Long getNuageVspHostId(long physicalNetworkId) { - List nuageVspDevices = _nuageVspDao.listByPhysicalNetwork(physicalNetworkId); - if (nuageVspDevices != null && (!nuageVspDevices.isEmpty())) { - NuageVspDeviceVO config = nuageVspDevices.iterator().next(); - return config.getHostId(); - } - - return null; - } - - @DB - private void initNuageVspVpcOffering() { - //configure default Nuage VSP vpc offering - Transaction.execute(new TransactionCallbackNoReturn() { - @Override - public void doInTransactionWithoutResult(TransactionStatus status) { - VpcOffering offering = _vpcOffDao.findByUniqueName(nuageVPCOfferingName); - if (offering == null) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Creating default Nuage VPC offering " + nuageVPCOfferingName); - } - - createVpcOffering(nuageVPCOfferingName, nuageVPCOfferingDisplayText, DEFAULT_NUAGE_VSP_VPC_SERVICE_MAP, true, VpcOffering.State.Enabled, null); - } else { - updateVpcOffering(offering, DEFAULT_NUAGE_VSP_VPC_SERVICE_MAP); - } - } - }); - } - - @DB - protected VpcOffering createVpcOffering(final String name, final String displayText, final Multimap svcProviderMap, final boolean isDefault, - final VpcOffering.State state, final Long serviceOfferingId) { - return Transaction.execute((TransactionCallback)status -> createVpcOfferingInTransaction(name, displayText, svcProviderMap, isDefault, state, serviceOfferingId)); - } - - private VpcOffering createVpcOfferingInTransaction(String name, String displayText, Multimap svcProviderMap, boolean isDefault, - VpcOffering.State state, Long serviceOfferingId) { - // create vpc offering object - VpcOfferingVO offering = new VpcOfferingVO(name, displayText, isDefault, serviceOfferingId, false, false); - - if (state != null) { - offering.setState(state); - } - if (s_logger.isDebugEnabled()) { - s_logger.debug(String.format("Adding vpc offering %s", offering)); - } - offering = _vpcOffDao.persist(offering); - // populate services and providers - if (svcProviderMap != null) { - for (Map.Entry entry : svcProviderMap.entries()) { - Network.Service service = entry.getKey(); - Network.Provider provider = entry.getValue(); - - VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider); - _vpcOffSvcMapDao.persist(offService); - if (s_logger.isTraceEnabled()) { - s_logger.trace(String.format("Added service for the vpc offering: %s with provider %s", offService, provider.getName())); - } - } - } - - return offering; - } - - @DB - protected void updateVpcOffering(final VpcOffering offering, final Multimap svcProviderMap) { - Transaction.execute((TransactionCallback)status -> updateVpcOfferingInTransaction(offering, svcProviderMap)); - } - - @Nonnull - private VpcOffering updateVpcOfferingInTransaction(VpcOffering offering, Multimap svcProviderMap) { - if (s_logger.isDebugEnabled()) { - s_logger.debug(String.format("Updating vpc offering %s", offering)); - } - - List currentVpcOfferingServices = _vpcOffSvcMapDao.listByVpcOffId(offering.getId()); - Multimap currentSvcProviderMap = HashMultimap.create(); - for (VpcOfferingServiceMapVO vpcOfferingService : currentVpcOfferingServices) { - Network.Service service = Network.Service.getService(vpcOfferingService.getService()); - Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider()); - currentSvcProviderMap.put(service, provider); - } - - for (Map.Entry entry : svcProviderMap.entries()) { - Network.Service service = entry.getKey(); - Network.Provider provider = entry.getValue(); - - if (!currentSvcProviderMap.containsEntry(service, provider)) { - VpcOfferingServiceMapVO offService = new VpcOfferingServiceMapVO(offering.getId(), service, provider); - _vpcOffSvcMapDao.persist(offService); - if (s_logger.isDebugEnabled()) { - s_logger.debug(String.format("Added service for the vpc offering: %s", offService)); - } - } - - } - - return offering; - } - - private HostVO findNuageVspHost(long hostId) { - HostVO host = _hostDao.findById(hostId); - _hostDao.loadDetails(host); - return host; - } - - @Override - public String getConfigComponentName() { - return NuageVspManager.class.getSimpleName(); - } - - @Override - public ConfigKey[] getConfigKeys() { - return Arrays.copyOf(NUAGE_VSP_CONFIG_KEYS, NUAGE_VSP_CONFIG_KEYS.length); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspRequestWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspRequestWrapper.java deleted file mode 100644 index 2a0e0bf3eed..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspRequestWrapper.java +++ /dev/null @@ -1,78 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.resource; - -import java.util.Hashtable; -import java.util.Set; - -import org.reflections.Reflections; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.RequestWrapper; -import com.cloud.resource.ServerResource; - -public class NuageVspRequestWrapper extends RequestWrapper { - - private static NuageVspRequestWrapper instance; - - @SuppressWarnings("rawtypes") - private final static Set> baseSet; - - static { - Reflections baseWrappers = new Reflections("com.cloud.network.vsp.resource.wrapper"); - baseSet = baseWrappers.getSubTypesOf(CommandWrapper.class); - instance = new NuageVspRequestWrapper(); - } - - private NuageVspRequestWrapper() { - init(); - } - - @SuppressWarnings("rawtypes") - private void init() { - // NuageVspResource commands - final Hashtable, CommandWrapper> vspCommands = processAnnotations(baseSet); - - resources.put(NuageVspResource.class, vspCommands); - } - - public static NuageVspRequestWrapper getInstance() { - return instance; - } - - @SuppressWarnings("rawtypes") - @Override - public Answer execute(final Command command, final ServerResource serverResource) { - final Class resourceClass = serverResource.getClass(); - - final Hashtable, CommandWrapper> resourceCommands = retrieveResource(command, resourceClass); - - CommandWrapper commandWrapper = retrieveCommands(command.getClass(), resourceCommands); - - while (commandWrapper == null) { - //Could not find the command in the given resource, will traverse the family tree. - commandWrapper = retryWhenAllFails(command, resourceClass, resourceCommands); - } - - return commandWrapper.execute(command, serverResource); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspResource.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspResource.java deleted file mode 100644 index 74b9c1d6f09..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspResource.java +++ /dev/null @@ -1,310 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.resource; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; -import com.google.common.base.Strings; - -import net.nuage.vsp.acs.client.api.NuageVspAclClient; -import net.nuage.vsp.acs.client.api.NuageVspApiClient; -import net.nuage.vsp.acs.client.api.NuageVspElementClient; -import net.nuage.vsp.acs.client.api.NuageVspGuruClient; -import net.nuage.vsp.acs.client.api.NuageVspManagerClient; -import net.nuage.vsp.acs.client.api.NuageVspPluginClientLoader; -import net.nuage.vsp.acs.client.api.model.VspHost; -import net.nuage.vsp.acs.client.common.RequestType; -import net.nuage.vsp.acs.client.common.model.NuageVspEntity; -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.IAgentControl; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.PingCommand; -import com.cloud.agent.api.PingNuageVspCommand; -import com.cloud.agent.api.StartupCommand; -import com.cloud.agent.api.StartupVspCommand; -import com.cloud.host.Host; -import com.cloud.resource.ServerResource; -import com.cloud.utils.component.ManagerBase; -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.utils.mgmt.JmxUtil; - -public class NuageVspResource extends ManagerBase implements ServerResource, VspStatisticsMBean { - private static final Logger s_logger = Logger.getLogger(NuageVspResource.class); - - private String _guid; - private String _zoneId; - private String _hostName; - private boolean _shouldAudit = true; - - private VspHost _vspHost; - - private static final String NUAGE_VSP_PLUGIN_ERROR_MESSAGE = "Nuage Vsp plugin client is not installed"; - protected NuageVspPluginClientLoader _clientLoader; - - public VspHost validate(Map params) throws ConfigurationException { - return validate(NuageVspResourceConfiguration.fromConfiguration(params)); - } - - public VspHost validate(NuageVspResourceConfiguration configuration) throws ConfigurationException { - configuration.validate(); - - VspHost newVspHost = configuration.buildVspHost(); - - - if (!newVspHost.getApiVersion().isSupported()) { - s_logger.warn(String.format("[UPGRADE] API version %s of Nuage Vsp Device %s should be updated.", newVspHost.getApiVersion(), configuration.hostName())); - } - - _guid = configuration.guid(); - _zoneId = configuration.zoneId(); - _hostName = configuration.hostName(); - _name = configuration.name(); - - try { - final NuageVspPluginClientLoader clientLoader = getClientLoader(newVspHost); - clientLoader.getNuageVspApiClient().login(); - - _vspHost = newVspHost; - _clientLoader = clientLoader; - } catch (NuageVspException e) { - s_logger.error(e.getMessage(), e); - throw new CloudRuntimeException(e.getMessage(), e); - } - - return _vspHost; - } - - @Override - public long getVSDStatistics() { - return _clientLoader.getNuageVspStatistics().getVsdCount(); - } - - - @Override - public long getVsdStatisticsByEntityType(String entity) { - try { - NuageVspEntity nuageVspEntity = NuageVspEntity.valueOf(entity); - return _clientLoader.getNuageVspStatistics().getVsdCount(nuageVspEntity); - } catch (IllegalArgumentException e) { - return -1; - } - } - - @Override - public long getVsdStatisticsByRequestType(String requestType) { - try { - RequestType requestTypeValue = RequestType.valueOf(requestType); - return _clientLoader.getNuageVspStatistics().getVsdCount(requestTypeValue); - } catch (IllegalArgumentException e) { - return -1; - } - - } - - @Override - public long getVsdStatisticsByEntityAndRequestType(String entity, String requestType) { - try { - RequestType requestTypeValue = RequestType.valueOf(requestType); - NuageVspEntity nuageVspEntity = NuageVspEntity.valueOf(entity); - return _clientLoader.getNuageVspStatistics().getVsdCount(nuageVspEntity, requestTypeValue); - } catch (IllegalArgumentException e) { - return -1; - } - } - - private static Map convertHashMap(Map map) { - return map.entrySet() - .stream() - .collect(Collectors.toMap( - e -> e.getKey().toString(), - Map.Entry::getValue) - ); - } - - @Override - public Map> getVsdStatisticsReport() { - return _clientLoader.getNuageVspStatistics() - .getVsdCountReport() - .entrySet().stream() - .collect(Collectors.toMap( - e -> e.getKey().toString(), - e -> convertHashMap(e.getValue()) - )); - } - - @Override - public boolean configure(String name, Map params) throws ConfigurationException { - if(super.configure(name, params)) { - validate(params); - } - return true; - } - - protected void login() throws ConfigurationException, NuageVspException { - getNuageVspApiClient().login(); - } - - protected NuageVspPluginClientLoader getClientLoader(VspHost vspHost) { - return NuageVspPluginClientLoader.getClientLoader(vspHost); - } - - @Override - public boolean start() { - try { - JmxUtil.registerMBean("NuageVspResource", _name, new VspStatisticsMBeanImpl(this)); - } catch (Exception e) { - s_logger.warn("Unable to initialize statistics Mbean", e); - } - - return true; - - } - - @Override - public boolean stop() { - - try { - JmxUtil.unregisterMBean("NuageVspResource", _name); - } catch (Exception e) { - s_logger.warn("Unable to stop NuageVspResource", e); - } - - return true; - } - - @Override - public Host.Type getType() { - return Host.Type.L2Networking; - } - - @Override - public StartupCommand[] initialize() { - StartupVspCommand sc = new StartupVspCommand(); - sc.setGuid(_guid); - sc.setName(_name); - sc.setDataCenter(_zoneId); - sc.setPod(""); - sc.setPrivateIpAddress(""); - sc.setStorageIpAddress(""); - sc.setVersion(NuageVspResource.class.getPackage().getImplementationVersion()); - return new StartupCommand[] {sc}; - } - - @Override - public PingCommand getCurrentStatus(long id) { - if (Strings.isNullOrEmpty(_vspHost.getRestRelativePath())) { - s_logger.error("Refusing to ping Nuage VSD because the resource configuration is missing the relative path information"); - _shouldAudit = true; - return null; - } - - if (Strings.isNullOrEmpty(_vspHost.getCmsUserLogin()) || Strings.isNullOrEmpty(_vspHost.getCmsUserPassword())) { - s_logger.error("Refusing to ping Nuage VSD because the resource configuration is missing the CMS user information"); - _shouldAudit = true; - return null; - } - - try { - login(); - } catch (NuageVspException | ConfigurationException e) { - s_logger.error("Failed to ping to Nuage VSD on " + _name + " as user " +_vspHost.getCmsUserLogin(), e); - _shouldAudit = true; - return null; - } - PingNuageVspCommand pingNuageVspCommand = new PingNuageVspCommand(Host.Type.L2Networking, id, _shouldAudit); - _shouldAudit = false; - return pingNuageVspCommand; - } - - public boolean getStatus() { - try { - login(); - return true; - } catch (NuageVspException | ConfigurationException e) { - s_logger.error("Failed to ping to Nuage VSD on " + _name + " as user " +_vspHost.getCmsUserLogin(), e); - return false; - } - } - - @Override - public Answer executeRequest(final Command cmd) { - final NuageVspRequestWrapper wrapper = NuageVspRequestWrapper.getInstance(); - try { - return wrapper.execute(cmd, this); - } catch (final Exception e) { - if (s_logger.isDebugEnabled()) { - s_logger.debug("Received unsupported command " + cmd.toString(), e); - } - return Answer.createUnsupportedCommandAnswer(cmd); - } - } - - @Override - public void disconnected() { - } - - @Override - public IAgentControl getAgentControl() { - return null; - } - - @Override - public void setAgentControl(IAgentControl agentControl) { - } - - protected void assertNuageVspClientsLoaded() throws ConfigurationException { - if (_clientLoader == null) { - throw new ConfigurationException(NUAGE_VSP_PLUGIN_ERROR_MESSAGE); - } - } - - public NuageVspApiClient getNuageVspApiClient() throws ConfigurationException { - assertNuageVspClientsLoaded(); - return _clientLoader.getNuageVspApiClient(); - - } - - public NuageVspGuruClient getNuageVspGuruClient() throws ConfigurationException { - assertNuageVspClientsLoaded(); - return _clientLoader.getNuageVspGuruClient(); - } - - public NuageVspAclClient getNuageVspAclClient() throws ConfigurationException { - assertNuageVspClientsLoaded(); - return _clientLoader.getNuageVspAclClient(); - } - - public NuageVspElementClient getNuageVspElementClient() throws ConfigurationException { - assertNuageVspClientsLoaded(); - return _clientLoader.getNuageVspElementClient(); - } - - public NuageVspManagerClient getNuageVspManagerClient() throws ConfigurationException { - assertNuageVspClientsLoaded(); - return _clientLoader.getNuageVspManagerClient(); - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspResourceConfiguration.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspResourceConfiguration.java deleted file mode 100644 index 71d7390a668..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/NuageVspResourceConfiguration.java +++ /dev/null @@ -1,360 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.resource; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.api.model.NuageVspUser; -import net.nuage.vsp.acs.client.api.model.VspHost; -import net.nuage.vsp.acs.client.common.NuageVspApiVersion; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; - -import com.google.common.base.Preconditions; - -import com.cloud.util.NuageVspUtil; - -public class NuageVspResourceConfiguration { - private static final String NAME = "name"; - private static final String GUID = "guid"; - private static final String ZONE_ID = "zoneid"; - private static final String HOST_NAME = "hostname"; - private static final String CMS_USER = "cmsuser"; - private static final String CMS_USER_PASSWORD = "cmsuserpass"; - private static final String PORT = "port"; - private static final String API_VERSION = "apiversion"; - private static final String API_RELATIVE_PATH = "apirelativepath"; - private static final String RETRY_COUNT = "retrycount"; - private static final String RETRY_INTERVAL = "retryinterval"; - private static final String NUAGE_VSP_CMS_ID = "nuagevspcmsid"; - - private static final String CMS_USER_ENTEPRISE_NAME = "CSP"; - - private String _name; - private String _guid; - private String _zoneId; - private String _hostName; - private String _cmsUser; - private String _cmsUserPassword; - private String _port; - private String _apiVersion; - private String _apiRelativePath; - private String _retryCount; - private String _retryInterval; - private String _nuageVspCmsId; - - public String name() { - return _name; - } - - public String guid() { - return this._guid; - } - - public NuageVspResourceConfiguration guid(String guid) { - this._guid = guid; - return this; - } - - public String zoneId() { - return this._zoneId; - } - - public NuageVspResourceConfiguration zoneId(String zoneId) { - this._zoneId = zoneId; - return this; - } - - public String hostName() { - return this._hostName; - } - - public NuageVspResourceConfiguration hostName(String hostName) { - this._hostName = hostName; - this._name = "Nuage VSD - " + _hostName; - return this; - } - - public String cmsUser() { - return this._cmsUser; - } - - public NuageVspResourceConfiguration cmsUser(String cmsUser) { - this._cmsUser = cmsUser; - return this; - } - - public String cmsUserPassword() { - return this._cmsUserPassword; - } - - public NuageVspResourceConfiguration cmsUserPassword(String cmsUserPassword) { - this._cmsUserPassword = cmsUserPassword; - return this; - } - - public String port() { - return this._port; - } - - public NuageVspResourceConfiguration port(String port) { - this._port = port; - return this; - } - - public String apiVersion() { - return this._apiVersion; - } - - public NuageVspResourceConfiguration apiVersion(String apiVersion) { - this._apiVersion = apiVersion; - return this; - } - - public String apiRelativePath() { - return this._apiRelativePath; - } - - public NuageVspResourceConfiguration apiRelativePath(String apiRelativePath) { - this._apiRelativePath = apiRelativePath; - return this; - } - - public String retryCount() { - return this._retryCount; - } - - public NuageVspResourceConfiguration retryCount(String retryCount) { - this._retryCount = retryCount; - return this; - } - - public String retryInterval() { - return this._retryInterval; - } - - public NuageVspResourceConfiguration retryInterval(String retryInterval) { - this._retryInterval = retryInterval; - return this; - } - - public String nuageVspCmsId() { - return this._nuageVspCmsId; - } - - public NuageVspResourceConfiguration nuageVspCmsId(String nuageVspCmsId) { - this._nuageVspCmsId = nuageVspCmsId; - return this; - } - - public String getRootPath(){ - return "https://" + _hostName + ":" + _port + "/nuage"; - } - - public String getApiPath() { - return "https://" + _hostName + ":" + _port + "/nuage/api/" + _apiVersion; - } - - public NuageVspApiVersion getApiVersion() throws ConfigurationException { - try { - if(_apiVersion != null) { - return NuageVspApiVersion.fromString(_apiVersion); - } - return null; - } catch (IllegalArgumentException e) { - throw new ConfigurationException("Incorrect API version"); - } - } - - public Map build() { - Map map = new HashMap<>(); - putIfPresent(map, GUID, _guid); - putIfPresent(map, ZONE_ID, _zoneId); - putIfPresent(map, HOST_NAME, _hostName); - putIfPresent(map, CMS_USER, _cmsUser); - putIfPresent(map, CMS_USER_PASSWORD, _cmsUserPassword); - putIfPresent(map, PORT, _port); - putIfPresent(map, API_VERSION, _apiVersion); - putIfPresent(map, API_RELATIVE_PATH, _apiRelativePath); - putIfPresent(map, RETRY_COUNT, _retryCount); - putIfPresent(map, RETRY_INTERVAL, _retryInterval); - putIfPresent(map, NUAGE_VSP_CMS_ID, _nuageVspCmsId); - return map; - } - - private void putIfPresent(Map map, String key, String value) { - Preconditions.checkNotNull(map); - Preconditions.checkNotNull(key); - - if (value != null) { - map.put(key, value); - } - } - - public static NuageVspResourceConfiguration fromConfiguration(Map configuration) { - return new NuageVspResourceConfiguration() - .guid((String)configuration.get(GUID)) - .zoneId((String)configuration.get(ZONE_ID)) - .hostName((String)configuration.get(HOST_NAME)) - .cmsUser((String)configuration.get(CMS_USER)) - .cmsUserPassword((String)configuration.get(CMS_USER_PASSWORD)) - .port((String)configuration.get(PORT)) - .apiVersion((String)configuration.get(API_VERSION)) - .apiRelativePath((String)configuration.get(API_RELATIVE_PATH)) - .retryCount((String)configuration.get(RETRY_COUNT)) - .retryInterval((String)configuration.get(RETRY_INTERVAL)) - .nuageVspCmsId((String)configuration.get(NUAGE_VSP_CMS_ID)); - } - - private void verifyNotNull(String name, String value) throws ConfigurationException { - if (value == null) { - throw new ConfigurationException("Unable to find " + name); - } - } - - private void verifyNotEmpty(String name, String value) throws ConfigurationException { - if (StringUtils.isEmpty(value)) { - throw new ConfigurationException("Unable to find " + name); - } - } - - private int verifyInRange(String name, String value, int min, int max) throws ConfigurationException { - verifyNotEmpty(name, value); - - int parsedValue; - try { - parsedValue = Integer.parseInt(value); - } catch (NumberFormatException ex) { - throw new ConfigurationException(name + " has to be between " + min + " and " + max); - } - if ((parsedValue < min) || (parsedValue > max)) { - throw new ConfigurationException(name + " has to be between " + min + " and " + max); - } - return parsedValue; - } - - public void validate() throws ConfigurationException { - verifyNotNull("name", _name); - verifyNotNull("guid", _guid); - verifyNotNull("zone", _zoneId); - verifyNotNull("hostname", _hostName); - verifyNotNull("CMS username", _cmsUser); - verifyNotNull("CMS password", _cmsUserPassword); - verifyNotEmpty("API version", _apiVersion); - - try { - NuageVspApiVersion.fromString(_apiVersion); - } catch(IllegalArgumentException e) { - throw new ConfigurationException("Incorrect API version"); - } - - verifyNotEmpty("number of retries", _retryCount); - verifyNotEmpty("retry interval", _retryInterval); - } - - public int parseRetryCount() throws ConfigurationException { - return verifyInRange("Number of retries", _retryCount, 1, 10); - } - - public int parseRetryInterval() throws ConfigurationException { - return verifyInRange("Retry interval", _retryInterval, 1, 10000); - } - - public VspHost buildVspHost() throws ConfigurationException { - return new VspHost.Builder() - .cmsUser(new NuageVspUser(CMS_USER_ENTEPRISE_NAME, _cmsUser, NuageVspUtil.decodePassword(_cmsUserPassword))) - .apiVersion(getApiVersion()) - .restRelativePath(getApiPath()) - .rootPath(getRootPath()) - .nuageVspCmsId(_nuageVspCmsId) - .noofRetry(parseRetryCount()) - .retryInterval(parseRetryInterval()) - .build(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - - if (!(o instanceof NuageVspResourceConfiguration)) { - return false; - } - - NuageVspResourceConfiguration that = (NuageVspResourceConfiguration) o; - - return super.equals(that) - && Objects.equals(_name, that._name) - && Objects.equals(_guid, that._guid) - && Objects.equals(_zoneId, that._zoneId) - && Objects.equals(_hostName, that._hostName) - && Objects.equals(_cmsUser, that._cmsUser) - && Objects.equals(_cmsUserPassword, that._cmsUserPassword) - && Objects.equals(_port, that._port) - && Objects.equals(_apiVersion, that._apiVersion) - && Objects.equals(_apiRelativePath, that._apiRelativePath) - && Objects.equals(_retryCount, that._retryCount) - && Objects.equals(_retryInterval, that._retryInterval) - && Objects.equals(_nuageVspCmsId, that._nuageVspCmsId); - } - - @Override - public int hashCode() { - return new HashCodeBuilder() - .appendSuper(super.hashCode()) - .append(_name) - .append(_guid) - .append(_zoneId) - .append(_hostName) - .append(_cmsUser) - .append(_cmsUserPassword) - .append(_port) - .append(_apiVersion) - .append(_apiRelativePath) - .append(_retryCount) - .append(_retryInterval) - .append(_nuageVspCmsId) - .toHashCode(); - } - - @Override public String toString() { - return new ToStringBuilder(this) - .append("_name", _name) - .append("_guid", _guid) - .append("_zoneId", _zoneId) - .append("_hostName", _hostName) - .append("_cmsUser", _cmsUser) - .append("_cmsUserPassword", _cmsUserPassword) - .append("_port", _port) - .append("_apiVersion", _apiVersion) - .append("_apiRelativePath", _apiRelativePath) - .append("_retryCount", _retryCount) - .append("_retryInterval", _retryInterval) - .append("_nuageVspCmsId", _nuageVspCmsId) - .toString(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/VspStatisticsMBean.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/VspStatisticsMBean.java deleted file mode 100644 index 55072ec6650..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/VspStatisticsMBean.java +++ /dev/null @@ -1,66 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.resource; - -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; - -import com.cloud.utils.mgmt.ManagementBean; - -/** - * Created by sgoeminn on 1/24/17. - */ -public interface VspStatisticsMBean extends ManagementBean { - - /** - * Returns the global count of all the VSD calls since start up - * @return - */ - long getVSDStatistics(); - - /** - * Returns the count of all the vsd calls where the entityType is equal to the entity - * @param entity - * @return - */ - long getVsdStatisticsByEntityType(String entity); - - /** - * Returns the count of all the vsd calls where the requestType is equal to the requestType - * @param requestType - * @return - */ - long getVsdStatisticsByRequestType(String requestType); - - /** - * Returns the count of all the vsd calls where the EntityType is equal to the entity - * and the RequestType is equal to the requestType string. - * @param entity - * @param requestType - * @return - */ - long getVsdStatisticsByEntityAndRequestType(String entity, String requestType); - - /** - * Returns the count of all VSD calls with EntityType entity and RequestType type - * @return - */ - Map> getVsdStatisticsReport(); -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/VspStatisticsMBeanImpl.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/VspStatisticsMBeanImpl.java deleted file mode 100644 index 7e3de561db1..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/resource/VspStatisticsMBeanImpl.java +++ /dev/null @@ -1,66 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.resource; - -import javax.management.StandardMBean; -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; - -/** - * Created by sgoeminn on 1/24/17. - */ -public class VspStatisticsMBeanImpl extends StandardMBean implements VspStatisticsMBean{ - private VspStatisticsMBean _delegate; - - public VspStatisticsMBeanImpl(VspStatisticsMBean nuageVspResource) { - super(VspStatisticsMBean.class, false); - _delegate = nuageVspResource; - } - - @Override - public long getVSDStatistics() { - return _delegate.getVSDStatistics(); - } - - @Override - public long getVsdStatisticsByEntityType(String entity) { - return _delegate.getVsdStatisticsByEntityType(entity); - } - - @Override - public long getVsdStatisticsByRequestType(String requestType) { - return _delegate.getVsdStatisticsByRequestType(requestType); - } - - @Override - public long getVsdStatisticsByEntityAndRequestType(String entity, String requestType) { - return _delegate.getVsdStatisticsByEntityAndRequestType(entity, requestType); - } - - @Override - public Map> getVsdStatisticsReport() { - return _delegate.getVsdStatisticsReport(); - } - - @Override - public String getName() { - return _delegate.getName(); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApiSupportCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApiSupportCommandWrapper.java deleted file mode 100644 index 1e84e20515e..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApiSupportCommandWrapper.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.manager.SupportedApiVersionCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = SupportedApiVersionCommand.class) -public final class NuageVspApiSupportCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(SupportedApiVersionCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - return nuageVspResource.getNuageVspManagerClient().isSupportedApiVersion(cmd.getApiVersion()); - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, SupportedApiVersionCommand cmd) { - return stringBuilder.append("Check if API version ").append(cmd.getApiVersion()).append(" is supported"); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApplyAclRulesCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApplyAclRulesCommandWrapper.java deleted file mode 100644 index 42499c4f788..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApplyAclRulesCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.element.ApplyAclRuleVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ApplyAclRuleVspCommand.class) -public final class NuageVspApplyAclRulesCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(ApplyAclRuleVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspElementClient().applyAclRules(cmd.getAclType(), cmd.getNetwork(), cmd.getAclRules(), cmd.isNetworkReset()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, ApplyAclRuleVspCommand cmd) { - return stringBuilder.append("Applied ACL Rule to network mapping " + cmd.getNetwork().getUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApplyStaticNatCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApplyStaticNatCommandWrapper.java deleted file mode 100644 index 81fbdef4548..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspApplyStaticNatCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.element.ApplyStaticNatVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ApplyStaticNatVspCommand.class) -public final class NuageVspApplyStaticNatCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(ApplyStaticNatVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspElementClient().applyStaticNats(cmd.getNetwork(), cmd.getStaticNatDetails()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, ApplyStaticNatVspCommand cmd) { - return stringBuilder.append("Applied Static NAT to network mapping ").append(cmd.getNetwork().getUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCheckHealthCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCheckHealthCommandWrapper.java deleted file mode 100644 index d66fc1b5441..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCheckHealthCommandWrapper.java +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.CheckHealthCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = CheckHealthCommand.class) -public class NuageVspCheckHealthCommandWrapper extends NuageVspCommandWrapper { - - @Override - public boolean executeNuageVspCommand(CheckHealthCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - return nuageVspResource.getStatus(); - } - - @Override - public StringBuilder fillDetail(StringBuilder stringBuilder, CheckHealthCommand cmd) { - return stringBuilder.append("Check Health"); - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCleanupDomainCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCleanupDomainCommandWrapper.java deleted file mode 100644 index 273a719211d..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCleanupDomainCommandWrapper.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.manager.CleanUpDomainCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = CleanUpDomainCommand.class) -public final class NuageVspCleanupDomainCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(CleanUpDomainCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - return nuageVspResource.getNuageVspManagerClient().cleanUpDomain(cmd.getDomainCleanUp()); - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, CleanUpDomainCommand cmd) { - return stringBuilder.append("Clean Domain ").append(cmd.getDomainCleanUp().getUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCommandWrapper.java deleted file mode 100644 index 3e3c4a12c44..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspCommandWrapper.java +++ /dev/null @@ -1,57 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import net.nuage.vsp.acs.client.exception.NuageVspUnsupportedRequestException; -import org.apache.log4j.Logger; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.UnsupportedAnswer; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.CommandWrapper; - -public abstract class NuageVspCommandWrapper extends CommandWrapper { - - private static final Logger s_logger = Logger.getLogger(NuageVspResource.class); - - @Override - public final Answer execute(final T command, final NuageVspResource nuageVspResource) { - try { - boolean success = executeNuageVspCommand(command, nuageVspResource); - String detail = fillDetail(new StringBuilder(), command).append(" on ").append(nuageVspResource.getName()).toString(); - return new Answer(command, success, detail); - } catch (NuageVspUnsupportedRequestException e) { - s_logger.error("Failure during " + command + " on " + nuageVspResource.getName(), e); - return new UnsupportedAnswer(command, e.getMessage()); //New Exception so there is no stacktrace showed in the UI when changing ACL lists. - } catch (Exception e) { - s_logger.error("Failure during " + command + " on " + nuageVspResource.getName(), e); - return new Answer(command, e); - } - } - - public abstract boolean executeNuageVspCommand(final T command, final NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException; - - public abstract StringBuilder fillDetail(final StringBuilder stringBuilder, final T command); -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspDeallocateVmInterfaceCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspDeallocateVmInterfaceCommandWrapper.java deleted file mode 100644 index 21256531365..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspDeallocateVmInterfaceCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.guru.DeallocateVmVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = DeallocateVmVspCommand.class) -public final class NuageVspDeallocateVmInterfaceCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(DeallocateVmVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspGuruClient().deallocate(cmd.getNetwork(), cmd.getVm(), cmd.getNic()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, DeallocateVmVspCommand cmd) { - return stringBuilder.append("Deallocated VM ").append(cmd.getVm().getName()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspEntityExistsCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspEntityExistsCommandWrapper.java deleted file mode 100644 index 6e737b8a0c2..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspEntityExistsCommandWrapper.java +++ /dev/null @@ -1,59 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.common.model.NuageVspEntity; -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.manager.EntityExistsCommand; -import com.cloud.dc.Vlan; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.network.vpc.VpcVO; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = EntityExistsCommand.class) -public final class NuageVspEntityExistsCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(EntityExistsCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - NuageVspEntity entityType = getNuageVspEntity(cmd.getType()); - - return nuageVspResource.getNuageVspApiClient().entityExists(entityType, cmd.getUuid()); - } - - private NuageVspEntity getNuageVspEntity(Class clazz) { - NuageVspEntity entityType = null; - - if (Vlan.class.isAssignableFrom(clazz)) { - entityType = NuageVspEntity.SHARED_NETWORK; - } - else if(VpcVO.class.isAssignableFrom(clazz)){ - entityType = NuageVspEntity.ZONE; - } - - return entityType; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, EntityExistsCommand cmd) { - return stringBuilder.append("Check if entity with UUID " + cmd.getUuid() + " of type " + getNuageVspEntity(cmd.getType()) + " exists"); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspExtraDhcpOptionsCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspExtraDhcpOptionsCommandWrapper.java deleted file mode 100644 index 7bd7e7c31f4..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspExtraDhcpOptionsCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import javax.naming.ConfigurationException; - -import com.cloud.agent.api.element.ExtraDhcpOptionsVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles=ExtraDhcpOptionsVspCommand.class) -public class NuageVspExtraDhcpOptionsCommandWrapper extends NuageVspCommandWrapper { - @Override - public boolean executeNuageVspCommand(ExtraDhcpOptionsVspCommand command, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspElementClient().setDhcpOptionsNic(command.getNetwork(), command.getNicUuid(), command.getDhcpOptions()); - return true; - } - - @Override - public StringBuilder fillDetail(StringBuilder stringBuilder, ExtraDhcpOptionsVspCommand command) { - return stringBuilder; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGetApiDefaultsCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGetApiDefaultsCommandWrapper.java deleted file mode 100644 index ac96895bbe4..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGetApiDefaultsCommandWrapper.java +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.manager.GetApiDefaultsAnswer; -import com.cloud.agent.api.manager.GetApiDefaultsCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = GetApiDefaultsCommand.class) -public final class NuageVspGetApiDefaultsCommandWrapper extends CommandWrapper { - - @Override - public GetApiDefaultsAnswer execute(final GetApiDefaultsCommand command, final NuageVspResource nuageVspResource) { - try { - return new GetApiDefaultsAnswer(command, nuageVspResource.getNuageVspManagerClient().getApiDefaults()); - } catch (NuageVspException|ConfigurationException e) { - return new GetApiDefaultsAnswer(command, e); - } - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGuruImplementNetworkCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGuruImplementNetworkCommandWrapper.java deleted file mode 100644 index 4d2ef637386..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGuruImplementNetworkCommandWrapper.java +++ /dev/null @@ -1,50 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import net.nuage.vsp.acs.client.api.NuageVspGuruClient; -import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import com.cloud.agent.api.guru.ImplementNetworkVspCommand; -import com.cloud.agent.api.manager.ImplementNetworkVspAnswer; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ImplementNetworkVspCommand.class) -public final class NuageVspGuruImplementNetworkCommandWrapper extends CommandWrapper { - - @Override - public ImplementNetworkVspAnswer execute(ImplementNetworkVspCommand command, NuageVspResource serverResource) { - try { - NuageVspGuruClient client = serverResource.getNuageVspGuruClient(); - if (command.isVsdManaged()) { - VspNetwork vspNetwork = client.addPermissionL3Network(command.getNetwork()); - return new ImplementNetworkVspAnswer(command, vspNetwork, vspNetwork.getNetworkRelatedVsdIds()); - } else { - NetworkRelatedVsdIds networkRelatedVsdIds = client.implement(command.getNetwork(), command.getDhcpOption()); - return new ImplementNetworkVspAnswer(command, command.getNetwork(), networkRelatedVsdIds); - } - } catch (Exception e) { - return new ImplementNetworkVspAnswer(command, e); - } - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGuruTrashNetworkCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGuruTrashNetworkCommandWrapper.java deleted file mode 100644 index 1f12f94baf6..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspGuruTrashNetworkCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.guru.TrashNetworkVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = TrashNetworkVspCommand.class) -public final class NuageVspGuruTrashNetworkCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(TrashNetworkVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspGuruClient().trash(cmd.getNetwork()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, TrashNetworkVspCommand command) { - return stringBuilder; - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspImplementNetworkCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspImplementNetworkCommandWrapper.java deleted file mode 100644 index d0732dae5cb..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspImplementNetworkCommandWrapper.java +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.element.ImplementVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ImplementVspCommand.class) -public final class NuageVspImplementNetworkCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(ImplementVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspElementClient().implement(cmd.getNetwork(), cmd.getDhcpOption(), cmd.getIngressFirewallRules(), - cmd.getEgressFirewallRules(), cmd.getFloatingIpUuids()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, ImplementVspCommand cmd) { - return stringBuilder.append("Implemented network ").append(cmd.getNetwork().getUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspListDomainTemplatesCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspListDomainTemplatesCommandWrapper.java deleted file mode 100644 index 668034ed8dc..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspListDomainTemplatesCommandWrapper.java +++ /dev/null @@ -1,51 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import com.cloud.agent.api.manager.ListVspDomainTemplatesAnswer; -import com.cloud.agent.api.manager.ListVspDomainTemplatesCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; -import net.nuage.vsp.acs.client.api.NuageVspManagerClient; -import net.nuage.vsp.acs.client.api.model.VspDomainTemplate; -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import javax.naming.ConfigurationException; -import java.util.List; - - -@ResourceWrapper(handles = ListVspDomainTemplatesCommand.class) -public class NuageVspListDomainTemplatesCommandWrapper extends CommandWrapper { - - @Override - public ListVspDomainTemplatesAnswer execute(ListVspDomainTemplatesCommand command, NuageVspResource serverResource) { - NuageVspManagerClient client = null; - try { - client = serverResource.getNuageVspManagerClient(); - List domainTemplates = client.getDomainTemplates(command.getDomain(), command.getName()); - - return new ListVspDomainTemplatesAnswer(command, domainTemplates); - } catch (ConfigurationException | NuageVspException e) { - return new ListVspDomainTemplatesAnswer(command, e); - } - - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspMaintainCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspMaintainCommandWrapper.java deleted file mode 100644 index b0e6db70040..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspMaintainCommandWrapper.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import com.cloud.agent.api.MaintainAnswer; -import com.cloud.agent.api.MaintainCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = MaintainCommand.class) -public final class NuageVspMaintainCommandWrapper extends CommandWrapper { - - @Override - public MaintainAnswer execute(final MaintainCommand command, final NuageVspResource nuageVspResource) { - return new MaintainAnswer(command); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspReadyCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspReadyCommandWrapper.java deleted file mode 100644 index ca95b465703..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspReadyCommandWrapper.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import com.cloud.agent.api.ReadyAnswer; -import com.cloud.agent.api.ReadyCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ReadyCommand.class) -public final class NuageVspReadyCommandWrapper extends CommandWrapper { - - @Override - public ReadyAnswer execute(final ReadyCommand command, final NuageVspResource nuageVspResource) { - return new ReadyAnswer(command); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspReserveVmInterfaceCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspReserveVmInterfaceCommandWrapper.java deleted file mode 100644 index fdf1ab27a75..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspReserveVmInterfaceCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ReserveVmInterfaceVspCommand.class) -public final class NuageVspReserveVmInterfaceCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(ReserveVmInterfaceVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspGuruClient().reserve(cmd.getNetwork(), cmd.getVm(), cmd.getNic(), cmd.getStaticNat(), cmd.getDhcpOption()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, ReserveVmInterfaceVspCommand command) { - return stringBuilder.append("Created NIC that maps to nicUuid ").append(command.getNic().getUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspShutdownNetworkCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspShutdownNetworkCommandWrapper.java deleted file mode 100644 index 1852eb60c30..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspShutdownNetworkCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.element.ShutDownVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ShutDownVspCommand.class) -public final class NuageVspShutdownNetworkCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(ShutDownVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspElementClient().shutdownNetwork(cmd.getNetwork(), cmd.getDhcpOptions()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, ShutDownVspCommand cmd) { - return stringBuilder.append("Shutdown Network " + cmd.getNetwork().getUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspShutdownVpcCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspShutdownVpcCommandWrapper.java deleted file mode 100644 index a3910cfa5a0..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspShutdownVpcCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.element.ShutDownVpcVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = ShutDownVpcVspCommand.class) -public final class NuageVspShutdownVpcCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(ShutDownVpcVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspElementClient().shutdownVpc(cmd.getDomainUuid(), cmd.getVpcUuid(), cmd.getDomainTemplateName(), cmd.getDomainRouterUuids(), cmd.getRelatedVsdIds()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, ShutDownVpcVspCommand cmd) { - return stringBuilder.append("Shutdown VPC " + cmd.getVpcUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspSyncCmsIdCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspSyncCmsIdCommandWrapper.java deleted file mode 100644 index c10134458ec..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspSyncCmsIdCommandWrapper.java +++ /dev/null @@ -1,62 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.api.NuageVspManagerClient; -import net.nuage.vsp.acs.client.common.model.Pair; -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer; -import com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.CommandWrapper; -import com.cloud.resource.ResourceWrapper; -import com.cloud.utils.StringUtils; - -@ResourceWrapper(handles = SyncNuageVspCmsIdCommand.class) -public final class NuageVspSyncCmsIdCommandWrapper extends CommandWrapper { - - @Override public SyncNuageVspCmsIdAnswer execute(SyncNuageVspCmsIdCommand cmd, NuageVspResource nuageVspResource) { - NuageVspManagerClient client = null; - try { - client = nuageVspResource.getNuageVspManagerClient(); - - Pair answer; - switch (cmd.getSyncType()) { - case REGISTER: - String registeredNuageVspCmsId = client.registerNuageVspCmsId(); - answer = Pair.of(StringUtils.isNotBlank(registeredNuageVspCmsId), registeredNuageVspCmsId); - break; - case UNREGISTER: - boolean success = client.unregisterNuageVspCmsId(cmd.getNuageVspCmsId()); - answer = Pair.of(success, cmd.getNuageVspCmsId()); - break; - default: - answer = client.auditNuageVspCmsId(cmd.getNuageVspCmsId(), cmd.getSyncType() == SyncNuageVspCmsIdCommand.SyncType.AUDIT_ONLY); - break; - } - return new SyncNuageVspCmsIdAnswer(answer.getLeft(), answer.getRight(), cmd.getSyncType()); - } catch (ConfigurationException|NuageVspException e) { - return new SyncNuageVspCmsIdAnswer(cmd, e, cmd.getSyncType()); - } - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspSyncDomainCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspSyncDomainCommandWrapper.java deleted file mode 100644 index b32e0b1791c..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspSyncDomainCommandWrapper.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.sync.SyncDomainCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = SyncDomainCommand.class) -public final class NuageVspSyncDomainCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(SyncDomainCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - return nuageVspResource.getNuageVspManagerClient().syncDomainWithNuageVsp(cmd.getDomain(), cmd.isToAdd(), cmd.isToRemove()); - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, SyncDomainCommand cmd) { - return stringBuilder.append("Synced Domain ").append(cmd.getDomain().getUuid()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspUpdateDhcpOptionsCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspUpdateDhcpOptionsCommandWrapper.java deleted file mode 100644 index 56bde5c68c6..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/NuageVspUpdateDhcpOptionsCommandWrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.guru.UpdateDhcpOptionVspCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = UpdateDhcpOptionVspCommand.class) -public final class NuageVspUpdateDhcpOptionsCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(UpdateDhcpOptionVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - nuageVspResource.getNuageVspGuruClient().applyDhcpOptions(cmd.getDhcpOptions(), cmd.getNetwork()); - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, UpdateDhcpOptionVspCommand cmd) { - return stringBuilder.append("Update DhcpOptions on VM's in network: ").append(cmd.getNetwork().getName()); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/UpdateNuageVspDeviceCommandWrapper.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/UpdateNuageVspDeviceCommandWrapper.java deleted file mode 100644 index c8953912d59..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/network/vsp/resource/wrapper/UpdateNuageVspDeviceCommandWrapper.java +++ /dev/null @@ -1,46 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.vsp.resource.wrapper; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.exception.NuageVspException; - -import com.cloud.agent.api.manager.UpdateNuageVspDeviceCommand; -import com.cloud.network.resource.NuageVspResource; -import com.cloud.network.resource.NuageVspResourceConfiguration; -import com.cloud.resource.ResourceWrapper; - -@ResourceWrapper(handles = UpdateNuageVspDeviceCommand.class) -public final class UpdateNuageVspDeviceCommandWrapper extends NuageVspCommandWrapper { - - @Override public boolean executeNuageVspCommand(UpdateNuageVspDeviceCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException { - final NuageVspResourceConfiguration configuration = cmd.getConfiguration(); - nuageVspResource.validate(configuration); - nuageVspResource.getConfigParams().putAll(configuration.build()); - - return true; - } - - @Override public StringBuilder fillDetail(StringBuilder stringBuilder, UpdateNuageVspDeviceCommand cmd) { - return stringBuilder.append("Updated the NuageVspResource parameters"); - } - -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/util/NuageVspEntityBuilder.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/util/NuageVspEntityBuilder.java deleted file mode 100644 index c26b9ae1aa5..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/util/NuageVspEntityBuilder.java +++ /dev/null @@ -1,463 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.util; - -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.inject.Inject; - -import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds; -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspAddressRange; -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption; -import net.nuage.vsp.acs.client.api.model.VspDomain; -import net.nuage.vsp.acs.client.api.model.VspDomainCleanUp; -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspNic; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; -import net.nuage.vsp.acs.client.api.model.VspVm; -import net.nuage.vsp.acs.client.common.model.Pair; - -import org.apache.commons.collections.MapUtils; -import org.apache.log4j.Logger; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao; - -import com.cloud.dc.Vlan; -import com.cloud.dc.VlanVO; -import com.cloud.dc.dao.VlanDao; -import com.cloud.dc.dao.VlanDetailsDao; -import com.cloud.domain.Domain; -import com.cloud.domain.DomainVO; -import com.cloud.domain.dao.DomainDao; -import com.cloud.network.Network; -import com.cloud.network.NetworkModel; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkDetailsDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.network.rules.FirewallRule; -import com.cloud.network.vpc.NetworkACLItem; -import com.cloud.network.vpc.VpcVO; -import com.cloud.network.vpc.dao.VpcDao; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; -import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.user.AccountVO; -import com.cloud.user.dao.AccountDao; -import com.cloud.utils.net.NetUtils; -import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; -import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.dao.NicDao; -import com.cloud.vm.dao.NicSecondaryIpDao; -import com.cloud.vm.dao.NicSecondaryIpVO; -import com.cloud.vm.dao.VMInstanceDao; - -public class NuageVspEntityBuilder { - private static final Logger s_logger = Logger.getLogger(NuageVspEntityBuilder.class); - - @Inject - NetworkDao _networkDao; - @Inject - VpcDao _vpcDao; - @Inject - DomainDao _domainDao; - @Inject - AccountDao _accountDao; - @Inject - NetworkOfferingDao _networkOfferingDao; - @Inject - NetworkOfferingServiceMapDao _networkOfferingServiceMapDao; - @Inject - NetworkModel _networkModel; - @Inject - VlanDao _vlanDao; - @Inject - VlanDetailsDao _vlanDetailsDao; - @Inject - IPAddressDao _ipAddressDao; - @Inject - NetworkDetailsDao _networkDetailsDao; - @Inject - VpcDetailsDao _vpcDetailsDao; - @Inject - VMInstanceDao _vmInstanceDao; - @Inject - NuageVspManager _nuageVspManager; - @Inject - NicDao _nicDao; - @Inject - NicSecondaryIpDao _nicSecondaryIpDao; - @Inject - NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao; - - - public VspDomain buildVspDomain(Domain domain) { - return new VspDomain.Builder() - .uuid(domain.getUuid()) - .name(domain.getName()) - .path(domain.getPath()) - .build(); - } - - public VspDomainCleanUp buildVspDomainCleanUp(Domain domain) { - VspDomainCleanUp.Builder vspDomainCleanUpBuilder = new VspDomainCleanUp.Builder().uuid(domain.getUuid()); - - Map> sharedNetworkUuids = Maps.newHashMap(); - List allSharedNetworks = _networkDao.listByGuestType(Network.GuestType.Shared); - for (NetworkVO sharedNetwork : allSharedNetworks) { - if (_networkModel.isNetworkAvailableInDomain(sharedNetwork.getId(), domain.getId())) { - String preConfiguredDomainTemplateName = _nuageVspManager.getPreConfiguredDomainTemplateName(sharedNetwork); - if (!sharedNetworkUuids.containsKey(preConfiguredDomainTemplateName)) { - sharedNetworkUuids.put(preConfiguredDomainTemplateName, Lists.newArrayList()); - } - sharedNetworkUuids.get(preConfiguredDomainTemplateName).add(sharedNetwork.getUuid()); - } - } - vspDomainCleanUpBuilder.sharedNetworkUuids(sharedNetworkUuids); - - return vspDomainCleanUpBuilder.build(); - } - - public VspNetwork buildVspNetwork(Network network) { - return buildVspNetwork(network.getDomainId(), network, null); - } - - public VspNetwork buildVspNetwork(Network network, String vsdSubnetId) { - return buildVspNetwork(network.getDomainId(), network, vsdSubnetId); - } - - public VspNetwork buildVspNetwork(long domainId, Network network) { - return buildVspNetwork(domainId, network, null); - } - - public VspNetwork buildVspNetwork(long domainId, Network network, String vsdSubnetId) { - VspNetwork.Builder vspNetworkBuilder = new VspNetwork.Builder() - .id(network.getId()) - .uuid(network.getUuid()) - .name(network.getName()) - .cidr(network.getCidr()) - .gateway(network.getGateway()); - - DomainVO domain = _domainDao.findById(domainId); - VspDomain vspDomain = buildVspDomain(domain); - vspNetworkBuilder.domain(vspDomain); - - - AccountVO account = _accountDao.findById(network.getAccountId()); - if (account != null) { - vspNetworkBuilder.accountUuid(account.getUuid()).accountName(account.getAccountName()); - } - - NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId()); - vspNetworkBuilder.egressDefaultPolicy(networkOffering.isEgressDefaultPolicy()) - .publicAccess(networkOffering.isSupportingPublicAccess()); - - Map networkDetails = _networkDetailsDao.listDetailsKeyPairs(network.getId(), false); - - final NetworkRelatedVsdIds.Builder relatedVsdIdsBuilder = new NetworkRelatedVsdIds.Builder(); - - if (MapUtils.isNotEmpty(networkDetails)) { - relatedVsdIdsBuilder.vsdSubnetId(networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID)) - .withVsdManaged("true".equals(networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED))); - } else if (vsdSubnetId != null) { - relatedVsdIdsBuilder.vsdSubnetId(vsdSubnetId) - .withVsdManaged("true".equals(networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED))); - } - - if (network.getVpcId() != null) { - long vpcId = network.getVpcId(); - VpcVO vpc = _vpcDao.findById(vpcId); - vspNetworkBuilder.vpcUuid(vpc.getUuid()) - .vpcName(vpc.getName()) - .networkType(VspNetwork.NetworkType.Vpc); - Map vpcDetails = _vpcDetailsDao.listDetailsKeyPairs(vpcId, false); - applyDomainAndZoneId(relatedVsdIdsBuilder, vpcDetails); - } else { - applyDomainAndZoneId(relatedVsdIdsBuilder, networkDetails); - - if (networkOffering.getGuestType() == Network.GuestType.Shared) { - List vlans = _vlanDao.listVlansByNetworkIdIncludingRemoved(network.getId()); - List vspAddressRanges = - vlans.stream() - .map(vlan -> new VspAddressRange.Builder().gateway(vlan.getVlanGateway()).netmask(vlan.getVlanNetmask()).build()) - .collect(Collectors.toList()); - - - vspNetworkBuilder.networkType(VspNetwork.NetworkType.Shared) - .addressRanges(vspAddressRanges); - } else if (_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.SourceNat) - || _networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.StaticNat)) { - vspNetworkBuilder.networkType(VspNetwork.NetworkType.L3); - } else { - vspNetworkBuilder.networkType(VspNetwork.NetworkType.L2); - } - - } - - NetworkRelatedVsdIds networkRelatedVsdIds = relatedVsdIdsBuilder.build(); - vspNetworkBuilder.networkRelatedVsdIds(networkRelatedVsdIds); - - boolean firewallServiceSupported = _networkModel.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.Firewall); - vspNetworkBuilder.firewallServiceSupported(firewallServiceSupported); - - String preConfiguredDomainTemplateName = _nuageVspManager.getPreConfiguredDomainTemplateName(network); - vspNetworkBuilder.domainTemplateName(preConfiguredDomainTemplateName); - - if (usesVirtualRouter(networkOffering.getId())) { - String virtualRouterIp = getVirtualRouterIP(network); - vspNetworkBuilder.virtualRouterIp(virtualRouterIp); - } - - return vspNetworkBuilder.build(); - } - - private void applyDomainAndZoneId(NetworkRelatedVsdIds.Builder relatedVsdIdsBuilder, Map details) { - if (MapUtils.isNotEmpty(details)) { - relatedVsdIdsBuilder - .vsdDomainId(details.get(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID)) - .vsdZoneId(details.get(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID)); - } - } - - public boolean usesVirtualRouter(long networkOfferingId) { - return _networkOfferingServiceMapDao.isProviderForNetworkOffering(networkOfferingId, Network.Provider.VirtualRouter) || - _networkOfferingServiceMapDao.isProviderForNetworkOffering(networkOfferingId, Network.Provider.VPCVirtualRouter); - } - - public VspNetwork updateVspNetworkByPublicIp(VspNetwork vspNetwork, Network network, String publicIp) { - List vlans = _vlanDao.listVlansByNetworkId(network.getId()); - final long ip = NetUtils.ip2Long(publicIp); - VlanVO matchingVlan = vlans.stream() - .filter(vlan -> isVlanContainingIp(vlan, ip)) - .findFirst() - .get(); - - boolean underlayEnabled = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, matchingVlan); - return new VspNetwork.Builder().fromObject(vspNetwork) - .gateway(matchingVlan.getVlanGateway()) - .cidr(NetUtils.getCidrFromGatewayAndNetmask(matchingVlan.getVlanGateway(), matchingVlan.getVlanNetmask())) - .vlanUnderlay(underlayEnabled) - .build(); - } - - private boolean isVlanContainingIp(Vlan vlan, long ip) { - Pair ipAddressRange = NuageVspUtil.getIpAddressRange(vlan); - long startIp = NetUtils.ip2Long(ipAddressRange.getLeft()); - long endIp = NetUtils.ip2Long(ipAddressRange.getRight()); - return startIp <= ip && ip <= endIp; - } - - private String getVirtualRouterIP(Network network) { - return network.getBroadcastUri() != null ? network.getBroadcastUri().getPath().substring(1) : null; - } - - - public VspVm buildVspVm(VirtualMachine vm, Network network) { - VspVm.Builder vspVmBuilder = new VspVm.Builder() - .uuid(vm.getUuid()) - .name(vm.getInstanceName()) - .state(getEnumValue(vm.getState(), VspVm.State.Unknown)); - - boolean isDomainRouter = vm.getType().equals(VirtualMachine.Type.DomainRouter); - vspVmBuilder.domainRouter(isDomainRouter); - - if (network.getBroadcastUri() != null) { - String domainRouterIp = network.getBroadcastUri().getPath().substring(1); - vspVmBuilder.domainRouterIp(domainRouterIp); - } - - return vspVmBuilder.build(); - } - - public VspNic buildVspNic(String nicUuid, NicProfile nicProfile) { - return buildVspNic(nicUuid, nicProfile.getMacAddress(), nicProfile.getIPv4Address(), nicProfile.getNetworkId(), null); - } - - public VspNic buildVspNic(NicVO nic) { - return buildVspNic(nic.getUuid(), nic.getMacAddress(), nic.getIPv4Address(), nic.getNetworkId(), null); - } - - public VspNic buildVspNic(NicVO nic, NicSecondaryIpVO nicSecondaryIp) { - return buildVspNic(nic.getUuid(), nic.getMacAddress(), nic.getIPv4Address(), nic.getNetworkId(), nicSecondaryIp); - } - - private VspNic buildVspNic(String uuid, String macAddress, String ip, long networkId, NicSecondaryIpVO nicSecondaryIp) { - VspNic.Builder vspNicBuilder = new VspNic.Builder() - .uuid(uuid) - .macAddress(macAddress) - .useStaticIp(true) - .ip(ip); - - if (nicSecondaryIp != null) { - vspNicBuilder.secondaryIpUuid(nicSecondaryIp.getUuid()).secondaryIpAddress(nicSecondaryIp.getIp4Address()); - } - - Network network = _networkDao.findById(networkId); - NetworkOffering networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId()); - - return vspNicBuilder.build(); - } - - public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, VspNic vspNic) { - VspStaticNat.Builder vspStaticNatBuilder = new VspStaticNat.Builder() - .ipUuid(staticNatIp.getUuid()) - .ipAddress(staticNatIp.getAddress().addr()) - .revoke(forRevoke) - .oneToOneNat(staticNatIp.isOneToOneNat()) - .state(getEnumValue(staticNatIp.getState(), VspStaticNat.State.class)) - .vlanUuid(staticNatVlan.getUuid()) - .vlanGateway(staticNatVlan.getVlanGateway()) - .vlanNetmask(staticNatVlan.getVlanNetmask()) - .vlanUnderlay(NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, staticNatVlan)); - - if (staticNatIp.getVmIp() != null) { - vspStaticNatBuilder.destinationIp(staticNatIp.getVmIp() + "/32"); - } - - if (vspNic != null) { - vspStaticNatBuilder.nic(vspNic); - } - - return vspStaticNatBuilder.build(); - } - - public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, NicVO nic) { - NicSecondaryIpVO nicSecondaryIp = null; - - if (nic == null && staticNatIp.getAssociatedWithVmId() != null && staticNatIp.getVmIp() != null) { - nicSecondaryIp = _nicSecondaryIpDao.findByIp4AddressAndInstanceId(staticNatIp.getAssociatedWithVmId(), staticNatIp.getVmIp()); - if (nicSecondaryIp != null) { - nic = _nicDao.findById(nicSecondaryIp.getNicId()); - } - } - - VspNic vspNic = (nic != null) ? buildVspNic(nic, nicSecondaryIp) : null; - return buildVspStaticNat(forRevoke, staticNatIp, staticNatVlan, vspNic); - } - - public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network) { - return buildVspAclRule(firewallRule, network, null); - } - - public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network, IPAddressVO staticNat) { - VspAclRule.Builder vspAclRuleBuilder = new VspAclRule.Builder() - .uuid(firewallRule.getUuid()) - .protocol(firewallRule.getProtocol()) - .startPort(firewallRule.getSourcePortStart()) - .endPort(firewallRule.getSourcePortEnd()) - .sourceCidrList(firewallRule.getSourceCidrList()) - .priority(-1) - .type(VspAclRule.ACLType.Firewall) - .state(getEnumValue(firewallRule.getState(), VspAclRule.ACLState.class)) - .trafficType(getEnumValue(firewallRule.getTrafficType(), VspAclRule.ACLTrafficType.class)); - - NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId()); - if (firewallRule.getTrafficType() == FirewallRule.TrafficType.Egress && networkOffering.isEgressDefaultPolicy()) { - vspAclRuleBuilder.deny(); - } else { - vspAclRuleBuilder.allow(); - } - - if (staticNat == null && firewallRule.getSourceIpAddressId() != null) { - IPAddressVO staticNatIp = _ipAddressDao.findById(firewallRule.getSourceIpAddressId()); - - if (staticNatIp != null) { - VlanVO staticNatVlan = _vlanDao.findById(staticNatIp.getVlanId()); - NicVO nic = _nicDao.findByIp4AddressAndNetworkId(staticNatIp.getVmIp(), staticNatIp.getAssociatedWithNetworkId()); - - vspAclRuleBuilder.staticNat(buildVspStaticNat(null, staticNatIp, staticNatVlan, nic)); - } - } - - return vspAclRuleBuilder.build(); - } - - public VspAclRule buildVspAclRule(NetworkACLItem networkAcl) { - return new VspAclRule.Builder() - .uuid(networkAcl.getUuid()) - .protocol(networkAcl.getProtocol()) - .startPort(networkAcl.getSourcePortStart()) - .endPort(networkAcl.getSourcePortEnd()) - .sourceIpAddress(null) - .sourceCidrList(networkAcl.getSourceCidrList()) - .priority(networkAcl.getNumber()) - .type(VspAclRule.ACLType.NetworkACL) - .state(getEnumValue(networkAcl.getState(), VspAclRule.ACLState.class)) - .trafficType(getEnumValue(networkAcl.getTrafficType(), VspAclRule.ACLTrafficType.class)) - .action(getEnumValue(networkAcl.getAction(), VspAclRule.ACLAction.class)) - .build(); - } - - /** Build VspDhcpVMOption to put on the VM interface */ - public VspDhcpVMOption buildVmDhcpOption (NicVO userNic, boolean defaultHasDns, boolean networkHasDns) { - VMInstanceVO userVm = _vmInstanceDao.findById(userNic.getInstanceId()); - VspDhcpVMOption.Builder vspDhcpVMOptionBuilder = new VspDhcpVMOption.Builder() - .nicUuid(userNic.getUuid()) - .defaultHasDns(defaultHasDns) - .hostname(userVm.getHostName()) - .networkHasDns(networkHasDns) - .isDefaultInterface(userNic.isDefaultNic()) - .domainRouter(VirtualMachine.Type.DomainRouter.equals(userNic.getVmType())); - return vspDhcpVMOptionBuilder.build(); - } - - /** Build VspDhcpVMOption to put on the subnet */ - public VspDhcpDomainOption buildNetworkDhcpOption(Network network, NetworkOffering offering) { - List dnsProvider = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(offering.getId(), Network.Service.Dns); - boolean isVrDnsProvider = dnsProvider.contains("VirtualRouter") || dnsProvider.contains("VpcVirtualRouter"); - VspDhcpDomainOption.Builder vspDhcpDomainBuilder = new VspDhcpDomainOption.Builder() - .dnsServers(_nuageVspManager.getDnsDetails(network.getDataCenterId())) - .vrIsDnsProvider(isVrDnsProvider); - - if (isVrDnsProvider) { - vspDhcpDomainBuilder.networkDomain(network.getVpcId() != null ? _vpcDao.findById(network.getVpcId()).getNetworkDomain() : network.getNetworkDomain()); - } - - return vspDhcpDomainBuilder.build(); - } - - private > E getEnumValue(Enum cloudstackValue, Class target) { - try { - return Enum.valueOf(target, cloudstackValue.name()); - } catch (IllegalArgumentException e) { - return null; - } - } - - private > E getEnumValue(Enum cloudstackValue, E defaultValue) { - try { - return Enum.valueOf(defaultValue.getDeclaringClass(), cloudstackValue.name()); - } catch (IllegalArgumentException e) { - return defaultValue; - } - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/util/NuageVspUtil.java b/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/util/NuageVspUtil.java deleted file mode 100644 index e5266d0ff15..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/java/com/cloud/util/NuageVspUtil.java +++ /dev/null @@ -1,58 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.util; - -import com.cloud.dc.Vlan; -import com.cloud.dc.VlanDetailsVO; -import com.cloud.dc.dao.VlanDetailsDao; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.utils.StringUtils; - -import net.nuage.vsp.acs.client.common.model.Pair; -import org.apache.commons.codec.binary.Base64; - -public class NuageVspUtil { - - public static String encodePassword(String originalPassword) { - byte[] passwordBytes = originalPassword.getBytes(StringUtils.getPreferredCharset()); - byte[] encodedPasswordBytes = Base64.encodeBase64(passwordBytes); - return new String(encodedPasswordBytes, StringUtils.getPreferredCharset()); - } - - public static String decodePassword(String encodedPassword) { - byte[] encodedPasswordBytes = encodedPassword.getBytes(StringUtils.getPreferredCharset()); - byte[] passwordBytes = Base64.decodeBase64(encodedPasswordBytes); - return new String(passwordBytes, StringUtils.getPreferredCharset()); - } - - public static boolean isUnderlayEnabledForVlan(VlanDetailsDao vlanDetailsDao, Vlan vlan) { - VlanDetailsVO nuageUnderlayDetail = vlanDetailsDao.findDetail(vlan.getId(), NuageVspManager.nuageUnderlayVlanIpRangeDetailKey); - return nuageUnderlayDetail != null && nuageUnderlayDetail.getValue().equalsIgnoreCase(String.valueOf(true)); - } - - public static Pair getIpAddressRange(Vlan vlan) { - boolean isIpv4 = StringUtils.isNotBlank(vlan.getIpRange()); - String[] range = isIpv4 ? vlan.getIpRange().split("-") : vlan.getIp6Range().split("-"); - if (range.length == 2) { - return Pair.of(range[0], range[1]); - } - return null; - } -} diff --git a/plugins/network-elements/nuage-vsp/src/main/resources/META-INF/cloudstack/vsp/module.properties b/plugins/network-elements/nuage-vsp/src/main/resources/META-INF/cloudstack/vsp/module.properties deleted file mode 100644 index e51229e199e..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/resources/META-INF/cloudstack/vsp/module.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -name=vsp -parent=network \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/main/resources/META-INF/cloudstack/vsp/spring-vsp-context.xml b/plugins/network-elements/nuage-vsp/src/main/resources/META-INF/cloudstack/vsp/spring-vsp-context.xml deleted file mode 100644 index 54c0b69ebf3..00000000000 --- a/plugins/network-elements/nuage-vsp/src/main/resources/META-INF/cloudstack/vsp/spring-vsp-context.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/NuageTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/NuageTest.java deleted file mode 100644 index 02497994570..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/NuageTest.java +++ /dev/null @@ -1,219 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud; - -import java.util.ArrayList; - -import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds; -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption; -import net.nuage.vsp.acs.client.api.model.VspDomain; -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspNic; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; -import net.nuage.vsp.acs.client.api.model.VspVm; - -import org.apache.cloudstack.framework.config.ConfigKey; -import org.apache.cloudstack.framework.config.impl.ConfigDepotImpl; -import org.apache.cloudstack.framework.config.impl.ConfigurationVO; -import org.junit.Before; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import com.google.common.collect.Lists; - -import org.apache.cloudstack.framework.config.dao.ConfigurationDao; - -import com.cloud.dc.VlanVO; -import com.cloud.domain.Domain; -import com.cloud.network.Network; -import com.cloud.network.NetworkModel; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.rules.FirewallRule; -import com.cloud.network.vpc.NetworkACLItem; -import com.cloud.util.NuageVspEntityBuilder; -import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; -import com.cloud.vm.VirtualMachine; - -import static com.cloud.network.manager.NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName; -import static com.cloud.network.manager.NuageVspManager.NuageVspSharedNetworkDomainTemplateName; -import static com.cloud.network.manager.NuageVspManager.NuageVspVpcDomainTemplateName; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyBoolean; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.when; - -public class NuageTest { - - protected static final long NETWORK_ID = 42L; - - @Mock protected NetworkModel _networkModel; - @Mock protected ConfigurationDao _configDao; - @Mock protected NuageVspEntityBuilder _nuageVspEntityBuilder; - - @InjectMocks - ConfigDepotImpl configDepot = new ConfigDepotImpl(); - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - - // Standard responses - when(_networkModel.isProviderForNetwork(Network.Provider.NuageVsp, NETWORK_ID)).thenReturn(true); - - mockConfigValue(NuageVspIsolatedNetworkDomainTemplateName, "IsolatedDomainTemplate"); - mockConfigValue(NuageVspVpcDomainTemplateName, "VpcDomainTemplate"); - mockConfigValue(NuageVspSharedNetworkDomainTemplateName, "SharedDomainTemplate"); - - ConfigKey.init(configDepot); - - when(_nuageVspEntityBuilder.buildVspDomain(any(Domain.class))).thenReturn(buildVspDomain()); - - VspNetwork vspNetwork = buildVspNetwork(); - when(_nuageVspEntityBuilder.buildVspNetwork(any(Network.class))).thenReturn(vspNetwork); - when(_nuageVspEntityBuilder.buildVspNetwork(anyLong(), any(Network.class))).thenReturn(vspNetwork); - - when(_nuageVspEntityBuilder.buildVspVm(any(VirtualMachine.class), any(Network.class))).thenReturn(buildVspVm()); - - when(_nuageVspEntityBuilder.buildVspNic(anyString(), any(NicProfile.class))).thenReturn(buildVspNic()); - when(_nuageVspEntityBuilder.buildVspNic(any(NicVO.class))).thenReturn(buildVspNic()); - - when(_nuageVspEntityBuilder.buildVspStaticNat(anyBoolean(), any(IPAddressVO.class), any(VlanVO.class), any(NicVO.class))).thenReturn(buildVspStaticNat()); - when(_nuageVspEntityBuilder.buildVspAclRule(any(FirewallRule.class), any(Network.class))).thenReturn(buildVspAclRule()); - when(_nuageVspEntityBuilder.buildVspAclRule(any(NetworkACLItem.class))).thenReturn(buildVspAclRule()); - } - - protected void mockConfigValue(ConfigKey configKey, T value) { - ConfigurationVO vo = new ConfigurationVO("test", configKey); - vo.setValue(value.toString()); - when(_configDao.getValue(configKey.key())).thenReturn(value.toString()); - when(_configDao.findById(configKey.key())).thenReturn(vo); - } - - protected VspDomain buildVspDomain() { - return new VspDomain.Builder() - .uuid("domainUuid") - .name("domainName") - .path("domainPath") - .build(); - } - - protected VspNetwork buildVspNetwork() { - return new VspNetwork.Builder() - .id(NETWORK_ID) - .uuid("networkUuid") - .name("networkName") - .domain(buildVspDomain()) - .accountUuid("networkAccountUuid") - .accountName("networkAccountName") - .vpcUuid("vpcUuid") - .vpcName("vpcName") - .networkType(VspNetwork.NetworkType.L3) - .firewallServiceSupported(true) - .egressDefaultPolicy(true) - .domainTemplateName("domainTemplateName") - .cidr("networkCidr") - .gateway("networkGateway") - .virtualRouterIp("virtualRouterIp") - .networkRelatedVsdIds(buildNetworkRelatedIds()) - .build(); - } - - protected NetworkRelatedVsdIds buildNetworkRelatedIds() { - return new NetworkRelatedVsdIds.Builder() - .vsdZoneId("vsdZoneId") - .vsdDomainId("vsdDomainId") - .vsdSubnetId("vsdSubnetId") - .build(); - } - - protected VspVm buildVspVm() { - return new VspVm.Builder() - .state(VspVm.State.Running) - .uuid("vmUuid") - .name("vmName") - .domainRouter(true) - .domainRouterIp("domainRouterIp") - .build(); - } - - protected VspNic buildVspNic() { - return new VspNic.Builder() - .uuid("nicUuid") - .macAddress("macAddress") - .useStaticIp(true) - .ip("ip") - .build(); - } - - protected VspStaticNat buildVspStaticNat() { - return new VspStaticNat.Builder() - .state(VspStaticNat.State.Allocating) - .ipUuid("ipUuid") - .ipAddress("ipAddress") - .nic(buildVspNic()) - .revoke(false) - .oneToOneNat(true) - .vlanUuid("vlanUuid") - .vlanGateway("vlanGateway") - .vlanNetmask("vlanNetmask") - .build(); - } - - protected VspAclRule buildVspAclRule() { - return new VspAclRule.Builder() - .uuid("aclRuleUuid") - .protocol("protcol") - .startPort(1) - .endPort(9) - .state(VspAclRule.ACLState.Add) - .trafficType(VspAclRule.ACLTrafficType.Ingress) - .action(VspAclRule.ACLAction.Allow) - .sourceIpAddress("sourceIpAddress") - .sourceCidrList(new ArrayList()) - .priority(1) - .type(VspAclRule.ACLType.NetworkACL) - .build(); - } - - protected VspDhcpDomainOption buildspDhcpDomainOption () { - return new VspDhcpDomainOption.Builder() - .vrIsDnsProvider(true) - .networkDomain("networkDomain") - .dnsServers(Lists.newArrayList("10.10.10.10", "20.20.20.20")) - .build(); - } - - protected VspDhcpVMOption buildspDhcpVMOption () { - return new VspDhcpVMOption.Builder() - .defaultHasDns(true) - .hostname("VMx") - .networkHasDns(true) - .isDefaultInterface(true) - .domainRouter(false) - .nicUuid("aaaa-bbbbbbbb-ccccccc") - .build(); - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/agent/api/CommandsTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/agent/api/CommandsTest.java deleted file mode 100644 index 5877ab0ce96..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/agent/api/CommandsTest.java +++ /dev/null @@ -1,175 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.agent.api; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.Map; - -import net.nuage.vsp.acs.client.api.model.Protocol; -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspNetwork; - -import org.junit.Assert; -import org.junit.Test; - -import com.google.common.collect.Maps; -import com.google.common.testing.EqualsTester; -import com.google.gson.Gson; - -import com.cloud.agent.api.element.ApplyAclRuleVspCommand; -import com.cloud.agent.api.element.ApplyStaticNatVspCommand; -import com.cloud.agent.api.element.ImplementVspCommand; -import com.cloud.agent.api.element.ShutDownVpcVspCommand; -import com.cloud.agent.api.guru.DeallocateVmVspCommand; -import com.cloud.agent.api.guru.ImplementNetworkVspCommand; -import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand; -import com.cloud.agent.api.guru.TrashNetworkVspCommand; -import com.cloud.agent.api.manager.EntityExistsCommand; -import com.cloud.agent.api.manager.SupportedApiVersionCommand; -import com.cloud.agent.api.sync.SyncDomainCommand; -import com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand; -import com.cloud.serializer.GsonHelper; - -import static org.hamcrest.core.Is.is; - -public class CommandsTest { - private static final Gson s_gson = GsonHelper.getGson(); - - private EqualsTester tester = new EqualsTester(); - - @Test - public void testCommandEquals() throws IllegalAccessException, InvocationTargetException, InstantiationException { - addCommandEqualityGroup(ApplyAclRuleVspCommand.class); - addCommandEqualityGroup(ImplementVspCommand.class); - addCommandEqualityGroup(ApplyStaticNatVspCommand.class); - addCommandEqualityGroup(ShutDownVpcVspCommand.class); - addCommandEqualityGroup(DeallocateVmVspCommand.class); - addCommandEqualityGroup(ImplementNetworkVspCommand.class); - addCommandEqualityGroup(ReserveVmInterfaceVspCommand.class); - addCommandEqualityGroup(TrashNetworkVspCommand.class); - addCommandEqualityGroup(SyncDomainCommand.class); - addCommandEqualityGroup(SyncNuageVspCmsIdCommand.class); - addCommandEqualityGroup(PingNuageVspCommand.class); - - SupportedApiVersionCommand supportedApiVersionCommandA = new SupportedApiVersionCommand("3.2"); - SupportedApiVersionCommand supportedApiVersionCommandB = new SupportedApiVersionCommand("3.2"); - - EntityExistsCommand entityExistsCommandA = new EntityExistsCommand(Command.class, "uuid"); - EntityExistsCommand entityExistsCommandB = new EntityExistsCommand(Command.class, "uuid"); - - tester - .addEqualityGroup(supportedApiVersionCommandA, supportedApiVersionCommandB) - .addEqualityGroup(entityExistsCommandA, entityExistsCommandB) - .testEquals(); - } - - @Test - public void testCommandGsonEquals() throws IllegalAccessException, InvocationTargetException, InstantiationException { - addCommandGsonEqualityGroup(ApplyAclRuleVspCommand.class); - addCommandGsonEqualityGroup(ImplementVspCommand.class); - addCommandGsonEqualityGroup(ApplyStaticNatVspCommand.class); - addCommandGsonEqualityGroup(ShutDownVpcVspCommand.class); - addCommandGsonEqualityGroup(DeallocateVmVspCommand.class); - addCommandGsonEqualityGroup(ImplementNetworkVspCommand.class); - addCommandGsonEqualityGroup(ReserveVmInterfaceVspCommand.class); - addCommandGsonEqualityGroup(TrashNetworkVspCommand.class); - addCommandGsonEqualityGroup(new SupportedApiVersionCommand("3.2")); - addCommandGsonEqualityGroup(SyncDomainCommand.class); - addCommandGsonEqualityGroup(SyncNuageVspCmsIdCommand.class); - addCommandGsonEqualityGroup(PingNuageVspCommand.class); - addCommandGsonEqualityGroup(new EntityExistsCommand(Command.class, "uuid")); - - tester.testEquals(); - } - - @Test - public void testApplyAclRuleVspCommandGsonEquals() throws IllegalAccessException, InvocationTargetException, InstantiationException { - VspNetwork vspNetwork = new VspNetwork.Builder() - .id(1) - .uuid("uuid") - .name("name") - .cidr("192.168.1.0/24") - .gateway("192.168.1.1") - .build(); - - VspAclRule aclRule = new VspAclRule.Builder() - .action(VspAclRule.ACLAction.Allow) - .uuid("uuid") - .trafficType(VspAclRule.ACLTrafficType.Egress) - .protocol(Protocol.TCP) - .startPort(80) - .endPort(80) - .priority(1) - .state(VspAclRule.ACLState.Active) - .build(); - - ApplyAclRuleVspCommand before = new ApplyAclRuleVspCommand(VspAclRule.ACLType.NetworkACL, vspNetwork, Arrays.asList(aclRule), false); - ApplyAclRuleVspCommand after = serializeAndDeserialize(before); - - Assert.assertThat(after.getAclRules().get(0).getProtocol().hasPort(), is(Protocol.TCP.hasPort())); - } - - private T serializeAndDeserialize(T command) { - Command[] forwardedCommands = s_gson.fromJson(s_gson.toJson(new Command[] { command }), Command[].class); - return (T) forwardedCommands[0]; - } - - private void addCommandGsonEqualityGroup(Class clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException{ - addCommandGsonEqualityGroup(fillObject(clazz)); - } - - private void addCommandGsonEqualityGroup(Command command) throws IllegalAccessException, InvocationTargetException, InstantiationException{ - Command[] forwardedCommands = s_gson.fromJson(s_gson.toJson(new Command[] { command }), Command[].class); - Assert.assertEquals(command, forwardedCommands[0]); - tester.addEqualityGroup(command, forwardedCommands[0]); - } - - private void addCommandEqualityGroup(Class clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException { - Command a = fillObject(clazz); - Command b = fillObject(clazz); - tester.addEqualityGroup(a, b); - } - - private T fillObject(Class clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException { - Constructor constructor = clazz.getDeclaredConstructors()[0]; - Object[] constructorArgs = new Object[constructor.getParameterTypes().length]; - for (int i = 0; i < constructor.getParameterTypes().length; i++) { - Class constructorArgType = constructor.getParameterTypes()[i]; - if (isNumericType(constructorArgType)) { - constructorArgs[i] = constructorArgType.getName().length(); - } else if (String.class.isAssignableFrom(constructorArgType)) { - constructorArgs[i] = constructorArgType.getName(); - } else if (Boolean.class.isAssignableFrom(constructorArgType) || boolean.class.isAssignableFrom(constructorArgType)) { - constructorArgs[i] = constructorArgType.getName().length() % 2 == 0; - } else if (Map.class.isAssignableFrom(constructorArgType)) { - constructorArgs[i] = Maps.newHashMap(); - } else { - constructorArgs[i] = null; - } - } - return (T) constructor.newInstance(constructorArgs); - } - - private boolean isNumericType(Class type) { - return Number.class.isAssignableFrom(type) || int.class.isAssignableFrom(type) || long.class.isAssignableFrom(type); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/element/NuageVspElementTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/element/NuageVspElementTest.java deleted file mode 100644 index da4312ce366..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/element/NuageVspElementTest.java +++ /dev/null @@ -1,382 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.element; - -import static org.hamcrest.Matchers.is; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.withSettings; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Set; - -import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao; -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import com.cloud.NuageTest; -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.deploy.DeployDestination; -import com.cloud.domain.DomainVO; -import com.cloud.domain.dao.DomainDao; -import com.cloud.exception.CloudException; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.ResourceUnavailableException; -import com.cloud.exception.UnsupportedServiceException; -import com.cloud.host.HostVO; -import com.cloud.host.dao.HostDao; -import com.cloud.network.Network; -import com.cloud.network.Network.GuestType; -import com.cloud.network.Network.Provider; -import com.cloud.network.Network.Service; -import com.cloud.network.Networks.BroadcastDomainType; -import com.cloud.network.Networks.TrafficType; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.network.dao.FirewallRulesDao; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkServiceMapDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.NuageVspDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.network.rules.FirewallRule; -import com.cloud.network.rules.FirewallRuleVO; -import com.cloud.network.rules.StaticNat; -import com.cloud.network.vpc.NetworkACLItem; -import com.cloud.network.vpc.Vpc; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; -import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.resource.ResourceManager; -import com.cloud.tags.dao.ResourceTagDao; -import com.cloud.user.Account; -import com.cloud.util.NuageVspEntityBuilder; -import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.dao.DomainRouterDao; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - -public class NuageVspElementTest extends NuageTest { - - @InjectMocks - private NuageVspElement _nuageVspElement = new NuageVspElement(); - - @Mock private NetworkServiceMapDao _networkServiceMapDao; - @Mock private AgentManager _agentManager; - @Mock private HostDao _hostDao; - @Mock private NuageVspDao _nuageVspDao; - @Mock private DomainDao _domainDao; - @Mock private NetworkOfferingDao _networkOfferingDao; - @Mock private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao; - @Mock private NuageVspManager _nuageVspManager; - @Mock private FirewallRulesDao _firewallRulesDao; - @Mock private IPAddressDao _ipAddressDao; - @Mock private PhysicalNetworkDao _physicalNetworkDao; - @Mock private NuageVspEntityBuilder _nuageVspEntityBuilder; - @Mock private VpcDetailsDao _vpcDetailsDao; - @Mock private DomainRouterDao _domainRouterDao; - @Mock private ResourceManager _resourceManager; - @Mock private ResourceTagDao _resourceTagDao; - @Mock private NetworkDao _networkDao; - - @Before - public void setUp() throws Exception { - super.setUp(); - _nuageVspElement._nuageVspEntityBuilder = _nuageVspEntityBuilder; - _nuageVspElement._vpcDetailsDao = _vpcDetailsDao; - _nuageVspElement._routerDao = _domainRouterDao; - _nuageVspElement._networkDao = _networkDao; - - when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(true); - when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.SourceNat, Provider.NuageVsp)).thenReturn(true); - - _nuageVspElement.configure("NuageVspTestElement", Collections.emptyMap()); - } - - @Test - public void testCanHandle() { - final Network net = mock(Network.class); - when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp); - when(net.getId()).thenReturn(NETWORK_ID); - when(net.getNetworkOfferingId()).thenReturn(NETWORK_ID); - - final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class); - when(ntwkoffer.getId()).thenReturn(NETWORK_ID); - when(ntwkoffer.isPersistent()).thenReturn(true); - when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer); - - // Golden path - assertTrue(_nuageVspElement.canHandle(net, Service.Connectivity)); - - when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vlan); - // Only broadcastdomaintype Vsp is supported - assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity)); - - when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp); - when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(false); - // No NuageVsp provider in the network - assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity)); - - when(_networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(false); - when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(true); - // NusageVsp provider does not provide Connectivity for this network - assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity)); - - when(_networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(true); - // Only service Connectivity is supported - assertFalse(_nuageVspElement.canHandle(net, Service.Dhcp)); - - // Can't handle network offerings with specify vlan = true - when(ntwkoffer.isSpecifyVlan()).thenReturn(true); - assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity)); - } - - @Test - public void testImplement() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, URISyntaxException { - final Network network = mock(NetworkVO.class, withSettings().extraInterfaces(Network.class)); - when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp); - when(network.getId()).thenReturn(NETWORK_ID); - when(network.getVpcId()).thenReturn(null); - when(network.getBroadcastUri()).thenReturn(new URI("")); - when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID); - when(network.getDomainId()).thenReturn(NETWORK_ID); - when(network.getDataCenterId()).thenReturn(NETWORK_ID); - when(_networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(true); - - final NetworkVO networkVO = mock(NetworkVO.class); - when(network.getUuid()).thenReturn("aaaaaa"); - - when(_networkDao.findById(NETWORK_ID)).thenReturn(networkVO); - - final NetworkOffering offering = mock(NetworkOffering.class); - when(offering.getId()).thenReturn(NETWORK_ID); - when(offering.getTrafficType()).thenReturn(TrafficType.Guest); - when(offering.getGuestType()).thenReturn(GuestType.Isolated); - - DeployDestination deployDest = mock(DeployDestination.class); - - final DomainVO dom = mock(DomainVO.class); - when(dom.getName()).thenReturn("domain"); - when(_domainDao.findById(NETWORK_ID)).thenReturn(dom); - 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); - - 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(_firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Ingress)).thenReturn(new ArrayList()); - when(_firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Egress)).thenReturn(new ArrayList()); - when(_ipAddressDao.listStaticNatPublicIps(NETWORK_ID)).thenReturn(new ArrayList()); - when(_nuageVspManager.getDnsDetails(network.getDataCenterId())).thenReturn(new ArrayList()); - when(_networkDao.findById(network.getId())).thenReturn((NetworkVO)network); - - assertTrue(_nuageVspElement.implement(network, offering, deployDest, context)); - } - - @Test - public void testVerifyServiceCombination() { - - Set services = Sets.newHashSet( - Service.Dhcp, - Service.StaticNat, - Service.SourceNat, - Service.Connectivity, - Service.Firewall); - assertTrue(_nuageVspElement.verifyServicesCombination(services)); - - services = Sets.newHashSet( - Service.Dhcp, - Service.StaticNat, - Service.Connectivity, - Service.Firewall); - assertTrue(_nuageVspElement.verifyServicesCombination(services)); - - - services = Sets.newHashSet( - Service.Dhcp, - Service.StaticNat, - Service.Firewall); - try { - _nuageVspElement.verifyServicesCombination(services); - fail("Expected Exception"); - } catch (UnsupportedServiceException e) { - assertThat(e.getMessage(), is("Provider Network.Provider[name=NuageVsp] requires services: [Network.Service[name=Connectivity]]")); - } - } - - @Test - public void testApplyStaticNats() throws CloudException { - 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 DomainVO domVo = mock(DomainVO.class); - when(_domainDao.findById(41l)).thenReturn(domVo); - - final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class); - when(ntwkoffer.getId()).thenReturn(NETWORK_ID); - 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.applyStaticNats(network, new ArrayList())); - } - - @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.isEgressDefaultPolicy()).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())); - } - - @Test - public void testApplyNetworkACL() 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.isEgressDefaultPolicy()).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.applyNetworkACLs(network, new ArrayList())); - } - - @Test - public void testShutdownVpc() throws Exception { - final Vpc vpc = mock(Vpc.class); - when(vpc.getUuid()).thenReturn("aaaaaa"); - when(vpc.getState()).thenReturn(Vpc.State.Inactive); - when(vpc.getDomainId()).thenReturn(NETWORK_ID); - when(vpc.getZoneId()).thenReturn(NETWORK_ID); - when(vpc.getId()).thenReturn(NETWORK_ID); - - final DomainVO dom = mock(DomainVO.class); - when(dom.getName()).thenReturn("domain"); - when(_domainDao.findById(NETWORK_ID)).thenReturn(dom); - 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); - - PhysicalNetworkVO physNet = mock(PhysicalNetworkVO.class); - when(physNet.getIsolationMethods()).thenReturn(Lists.newArrayList("VSP")); - when(physNet.getId()).thenReturn(NETWORK_ID); - when(_physicalNetworkDao.listByZone(NETWORK_ID)).thenReturn(Lists.newArrayList(physNet)); - - 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(Lists.newArrayList(nuageVspDevice)); - when(_hostDao.findById(NETWORK_ID)).thenReturn(host); - when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host); - - DomainRouterVO domainRouter = mock(DomainRouterVO.class); - when(domainRouter.getUuid()).thenReturn("aaaaaa"); - when(_domainRouterDao.listByVpcId(NETWORK_ID)).thenReturn(Lists.newArrayList(domainRouter)); - - final Answer answer = mock(Answer.class); - when(answer.getResult()).thenReturn(true); - when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer); - assertTrue(_nuageVspElement.shutdownVpc(vpc, context)); - } -} \ No newline at end of file diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java deleted file mode 100644 index 8a0488d7884..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/guru/NuageVspGuestNetworkGuruTest.java +++ /dev/null @@ -1,511 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.guru; - -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.annotation.Nonnull; - -import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.internal.util.collections.Sets; -import org.mockito.invocation.InvocationOnMock; - -import com.google.common.collect.ImmutableMap; - -import com.cloud.NuageTest; -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.guru.DeallocateVmVspCommand; -import com.cloud.agent.api.guru.ImplementNetworkVspCommand; -import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand; -import com.cloud.agent.api.manager.ImplementNetworkVspAnswer; -import com.cloud.configuration.ConfigurationManager; -import com.cloud.dc.DataCenter.NetworkType; -import com.cloud.dc.DataCenterVO; -import com.cloud.dc.dao.DataCenterDao; -import com.cloud.dc.dao.DataCenterDetailsDao; -import com.cloud.deploy.DeployDestination; -import com.cloud.deploy.DeploymentPlan; -import com.cloud.domain.Domain; -import com.cloud.domain.DomainVO; -import com.cloud.domain.dao.DomainDao; -import com.cloud.exception.InsufficientAddressCapacityException; -import com.cloud.exception.InsufficientVirtualNetworkCapacityException; -import com.cloud.host.HostVO; -import com.cloud.host.dao.HostDao; -import com.cloud.network.Network; -import com.cloud.network.Network.GuestType; -import com.cloud.network.Network.Service; -import com.cloud.network.Networks.BroadcastDomainType; -import com.cloud.network.Networks.Mode; -import com.cloud.network.Networks.TrafficType; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkDetailsDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.NuageVspDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.network.router.VirtualRouter; -import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; -import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.user.Account; -import com.cloud.user.AccountVO; -import com.cloud.user.dao.AccountDao; -import com.cloud.vm.DomainRouterVO; -import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; -import com.cloud.vm.ReservationContext; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.VirtualMachineProfile; -import com.cloud.vm.dao.DomainRouterDao; -import com.cloud.vm.dao.NicDao; - -public class NuageVspGuestNetworkGuruTest extends NuageTest { - private static final long DATACENTER_ID = 100L; - private static final long HOST_ID = 101L; - private static final long DOMAIN_ID = 1L; - private static final long ACCOUNT_ID = 2L; - private static final long OFFERING_ID = 40L; - private static final long NETWORK_ID = 42L; - private static final long VM_ID = 242L; - private static final long NIC_ID = 342L; - - private static final String DATACENTER_UUID = "uuid-datacenter-100"; - private static final String HOST_UUID = "uuid-host-101"; - private static final String DOMAIN_UUID = "uuid-domain-001"; - private static final String ACCOUNT_UUID = "uuid-account-002"; - private static final String OFFERING_UUID = "uuid-offering-040"; - private static final String NETWORK_UUID = "uuid-network-000-42"; - private static final String VM_UUID = "uuid-vm-002-42"; - private static final String NIC_UUID = "uuid-nic-003-42"; - - @Mock private PhysicalNetworkDao _physicalNetworkDao; - @Mock private DataCenterDao _dataCenterDao; - @Mock private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao; - @Mock private AgentManager _agentManager; - @Mock private AccountDao _accountDao; - @Mock private DomainDao _domainDao; - @Mock private NicDao _nicDao; - @Mock private NetworkOfferingDao _networkOfferingDao; - @Mock private NuageVspDao _nuageVspDao; - @Mock private HostDao _hostDao; - @Mock private NetworkDao _networkDao; - @Mock private IPAddressDao _ipAddressDao; - @Mock private NuageVspManager _nuageVspManager; - @Mock private ConfigurationManager _configurationManager; - @Mock private DataCenterDetailsDao _dcDetailsDao; - @Mock private NetworkDetailsDao _networkDetailsDao; - @Mock private PhysicalNetworkVO physnet; - @Mock private DomainRouterDao _routerDao; - - private Account _account; - private Domain _domain; - private DataCenterVO _dc; - private ReservationContext _reservationContext; - - @InjectMocks - private NuageVspGuestNetworkGuru _nuageVspGuestNetworkGuru = new NuageVspGuestNetworkGuru(); - - @Before - public void setUp() throws Exception { - super.setUp(); - - _account = getMockAccount(); - _domain = getMockDomain(); - _dc = mockDataCenter(); - _reservationContext = getMockReservationContext(_account, _domain); - - when(_physicalNetworkDao.findById(any(Long.class))).thenReturn(physnet); - when(physnet.getIsolationMethods()).thenReturn(Collections.singletonList("VSP")); - when(physnet.getId()).thenReturn(NETWORK_ID); - - final HostVO host = mock(HostVO.class); - when(host.getId()).thenReturn(HOST_ID); - when(host.getUuid()).thenReturn(HOST_UUID); - when(_hostDao.findById(HOST_ID)).thenReturn(host); - - when(_agentManager.easySend(eq(HOST_ID), any(Command.class))).thenReturn(new Answer(null)); - when(_agentManager.easySend(eq(HOST_ID), any(ImplementNetworkVspCommand.class))).thenAnswer(this::mockImplement); - when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host); - - final NuageVspDeviceVO device = mock(NuageVspDeviceVO.class); - when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.singletonList(device)); - when(device.getId()).thenReturn(1L); - when(device.getHostId()).thenReturn(HOST_ID); - } - - Answer mockImplement(InvocationOnMock invocation) { - if (invocation.getArguments()[1] instanceof ImplementNetworkVspCommand) { - ImplementNetworkVspCommand command = (ImplementNetworkVspCommand)(invocation.getArguments()[1]); - return new ImplementNetworkVspAnswer(command, command.getNetwork(), new NetworkRelatedVsdIds.Builder().build()); - } else { - return new Answer(null); - } - } - - @Test - public void testCanHandle() { - final NetworkOffering offering = mockNetworkOffering(false); - - when(offering.getTrafficType()).thenReturn(TrafficType.Guest); - when(offering.getGuestType()).thenReturn(GuestType.Isolated); - assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(true)); - - // Not supported TrafficType != Guest - when(offering.getTrafficType()).thenReturn(TrafficType.Management); - assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(false)); - - // Supported: GuestType Shared - when(offering.getTrafficType()).thenReturn(TrafficType.Guest); - when(offering.getGuestType()).thenReturn(GuestType.Shared); - assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(true)); - - // Not supported: Basic networking - when(offering.getGuestType()).thenReturn(GuestType.Isolated); - assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Basic, physnet), is(false)); - - // Not supported: IsolationMethod != VSP - when(physnet.getIsolationMethods()).thenReturn(Collections.singletonList("VLAN")); - assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Basic, physnet), is(false)); - - // Not supported: Non-persistent VPC tier - when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true); - assertFalse(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet)); - } - - @Test - public void testDesign() { - final NetworkOffering offering = mockNetworkOffering(false); - when(offering.isPersistent()).thenReturn(false); - - final DeploymentPlan plan = mockDeploymentPlan(); - final Network network = mock(Network.class); - - final Network designednetwork = _nuageVspGuestNetworkGuru.design(offering, plan, network, _account); - assertThat(designednetwork, notNullValue(Network.class)); - assertThat(designednetwork.getBroadcastDomainType(), is(BroadcastDomainType.Vsp)); - - // Can't design non-persistent VPC tier - when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true); - assertThat(_nuageVspGuestNetworkGuru.design(offering, plan, network, _account), nullValue(Network.class)); - } - - @Test - public void testDesignNoIsolationMethodVSP() { - when(physnet.getIsolationMethods()).thenReturn(Collections.singletonList("VLAN")); - - final NetworkOffering offering = mockNetworkOffering(false); - - final DeploymentPlan plan = mockDeploymentPlan(); - final Network network = mock(Network.class); - - assertThat(_nuageVspGuestNetworkGuru.design(offering, plan, network, _account), nullValue(Network.class)); - } - - @Test - public void testReserve() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException { - final NetworkVO network = mockNetwork(); - final NicProfile nicProfile = mockNicProfile(); - final VirtualMachineProfile vmProfile = mockVirtualMachineProfile(VirtualMachine.State.Starting); - - when(_networkDao.findById(NETWORK_ID)).thenReturn(network); - - _nuageVspGuestNetworkGuru.reserve(nicProfile, network, vmProfile, mock(DeployDestination.class), _reservationContext); - - verify(_agentManager).easySend(anyLong(), any(Command.class)); - } - - @Test - public void testReserveVRRollingRestart() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException { - final NetworkVO network = mockNetwork(); - final NicProfile nicProfile = mockNicProfile(); - final VirtualMachineProfile vmProfile = mockVRProfile(VirtualMachine.State.Starting); - - when(_networkDao.findById(NETWORK_ID)).thenReturn(network); - - _nuageVspGuestNetworkGuru.reserve(nicProfile, network, vmProfile, mock(DeployDestination.class), _reservationContext); - - verifyZeroInteractions(_agentManager); - verify(network).setRollingRestart(true); - } - - @Test - public void testImplementNetwork() throws URISyntaxException, InsufficientVirtualNetworkCapacityException { - final NetworkVO network = mockNetwork(); - - when(network.getState()).thenReturn(com.cloud.network.Network.State.Implementing); - - final NetworkOffering offering = mockNetworkOffering(false); - - final DeployDestination deployDest = mock(DeployDestination.class); - when(deployDest.getDataCenter()).thenReturn(_dc); - _nuageVspGuestNetworkGuru.implement(network, offering, deployDest, _reservationContext); - } - - @Test - public void testDeallocate() throws Exception { - final NetworkVO network = mockNetwork(); - final NicProfile nicProfile = mockNicProfile(); - final VirtualMachineProfile vmProfile = mockVirtualMachineProfile(VirtualMachine.State.Expunging); - - _nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile); - } - - @Test - public void testDeallocateVR() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException { - final NetworkVO network = mockNetwork(); - final NicProfile nicProfile = mockNicProfile(); - final VirtualMachineProfile vmProfile = mockVRProfile(VirtualMachine.State.Expunging); - - when(_networkDao.findById(NETWORK_ID)).thenReturn(network); - - _nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile); - } - - @Test - public void testDeallocateVRRollingRestart() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException { - final NetworkVO network = mockNetwork(); - final NicProfile nicProfile = mockNicProfile(); - final VirtualMachineProfile vmProfile = mockVRProfile(VirtualMachine.State.Expunging); - - DomainRouterVO newVR = mock(DomainRouterVO.class); - - when(_routerDao.listByNetworkAndRole(NETWORK_ID, VirtualRouter.Role.VIRTUAL_ROUTER)).thenReturn(Collections.singletonList(newVR)); - when(_networkDao.findById(NETWORK_ID)).thenReturn(network); - - _nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile); - - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Command.class); - verify(_agentManager, times(2)).easySend(eq(HOST_ID), argumentCaptor.capture()); - final List commands = argumentCaptor.getAllValues(); - assertThat(commands.get(0) instanceof DeallocateVmVspCommand, is(true)); - assertThat(commands.get(1) instanceof ReserveVmInterfaceVspCommand, is(true)); - } - - @Test - public void testTrash() throws Exception { - final NetworkVO network = mock(NetworkVO.class); - when(network.getId()).thenReturn(NETWORK_ID); - when(network.getUuid()).thenReturn(NETWORK_UUID); - when(network.getName()).thenReturn("trash"); - when(network.getDomainId()).thenReturn(DOMAIN_ID); - when(network.getNetworkOfferingId()).thenReturn(OFFERING_ID); - when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID); - when(network.getDataCenterId()).thenReturn(DATACENTER_ID); - when(network.getVpcId()).thenReturn(null); - when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network); - - final NetworkOffering offering = mockNetworkOffering(false); - - when(_nuageVspManager.getDnsDetails(network.getDataCenterId())).thenReturn(new ArrayList<>()); - when(_nuageVspManager.getGatewaySystemIds()).thenReturn(new ArrayList<>()); - - assertTrue(_nuageVspGuestNetworkGuru.trash(network, offering)); - } - - @Nonnull - private NetworkVO mockNetwork() throws URISyntaxException { - final NetworkVO network = mock(NetworkVO.class); - when(network.getId()).thenReturn(NETWORK_ID); - when(network.getUuid()).thenReturn(NETWORK_UUID); - when(network.getDataCenterId()).thenReturn(DATACENTER_ID); - when(network.getNetworkOfferingId()).thenReturn(OFFERING_ID); - when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID); - when(network.getDomainId()).thenReturn(DOMAIN_ID); - when(network.getAccountId()).thenReturn(ACCOUNT_ID); - when(network.getVpcId()).thenReturn(null); - when(network.getTrafficType()).thenReturn(TrafficType.Guest); - when(network.getMode()).thenReturn(Mode.Dhcp); - when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp); - when(network.getBroadcastUri()).thenReturn(new URI("vsp://" + NETWORK_UUID + "/10.1.1.1")); - when(network.getGateway()).thenReturn("10.1.1.1"); - when(network.getCidr()).thenReturn("10.1.1.0/24"); - when(network.getName()).thenReturn("iso"); - - when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network); - when(_networkDao.findById(NETWORK_ID)).thenReturn(network); - - return network; - } - - @Nonnull - private NetworkOffering mockNetworkOffering(boolean forVpc) { - final NetworkOfferingVO offering = mock(NetworkOfferingVO.class); - when(offering.getId()).thenReturn(OFFERING_ID); - when(offering.getUuid()).thenReturn(OFFERING_UUID); - when(offering.getTrafficType()).thenReturn(TrafficType.Guest); - when(offering.getGuestType()).thenReturn(GuestType.Isolated); - when(offering.isForVpc()).thenReturn(forVpc); - when(offering.isPersistent()).thenReturn(false); - when(offering.getTags()).thenReturn("aaaa"); - when(offering.isEgressDefaultPolicy()).thenReturn(true); - - when(_networkOfferingDao.findById(OFFERING_ID)).thenReturn(offering); - - when(_configurationManager.isOfferingForVpc(offering)).thenReturn(forVpc); - - when(_networkOfferingServiceMapDao.canProviderSupportServiceInNetworkOffering(OFFERING_ID, Service.Connectivity, Network.Provider.NuageVsp)).thenReturn(true); - when(_networkOfferingServiceMapDao.canProviderSupportServiceInNetworkOffering(OFFERING_ID, Service.SourceNat, Network.Provider.NuageVsp)).thenReturn(true); - - when(_networkModel.getNetworkOfferingServiceProvidersMap(OFFERING_ID)).thenReturn(ImmutableMap.of( - Service.Connectivity, Sets.newSet(Network.Provider.NuageVsp), - Service.SourceNat, Sets.newSet(Network.Provider.NuageVsp) - )); - - return offering; - } - - private DeploymentPlan mockDeploymentPlan() { - final DeploymentPlan deploymentPlan = mock(DeploymentPlan.class); - when(deploymentPlan.getDataCenterId()).thenReturn(DATACENTER_ID); - return deploymentPlan; - } - - private DataCenterVO mockDataCenter() { - DataCenterVO dc = mock(DataCenterVO.class); - when(dc.getId()).thenReturn(DATACENTER_ID); - when(dc.getUuid()).thenReturn(DATACENTER_UUID); - when(dc.getNetworkType()).thenReturn(NetworkType.Advanced); - when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24"); - when(_dataCenterDao.findById(DATACENTER_ID)).thenReturn(dc); - - return dc; - } - - @Nonnull - private Account getMockAccount() { - final AccountVO account = mock(AccountVO.class); - when(account.getId()).thenReturn(ACCOUNT_ID); - when(account.getAccountId()).thenReturn(ACCOUNT_ID); - when(account.getUuid()).thenReturn(ACCOUNT_UUID); - when(account.getDomainId()).thenReturn(DOMAIN_ID); - when(account.getType()).thenReturn(Account.ACCOUNT_TYPE_NORMAL); - - when(_accountDao.findById(ACCOUNT_ID)).thenReturn(account); - - return account; - } - - @Nonnull - private Domain getMockDomain() { - final DomainVO domain = mock(DomainVO.class); - when(domain.getId()).thenReturn(DOMAIN_ID); - when(domain.getUuid()).thenReturn(DOMAIN_UUID); - when(domain.getName()).thenReturn("aaaaa"); - - when(_domainDao.findById(DOMAIN_ID)).thenReturn(domain); - - return domain; - } - - @Nonnull - private VirtualMachineProfile mockVirtualMachineProfile(VirtualMachine.State state) { - final VirtualMachine vm = mock(VirtualMachine.class); - when(vm.getId()).thenReturn(VM_ID); - when(vm.getType()).thenReturn(VirtualMachine.Type.User); - when(vm.getState()).thenReturn(state); - - final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class); - when(vmProfile.getType()).thenReturn(VirtualMachine.Type.User); - when(vmProfile.getInstanceName()).thenReturn("Test-VM"); - when(vmProfile.getUuid()).thenReturn(VM_UUID); - when(vmProfile.getVirtualMachine()).thenReturn(vm); - return vmProfile; - } - - @Nonnull - private VirtualMachineProfile mockVRProfile(VirtualMachine.State state) { - final VirtualMachine vm = mock(VirtualMachine.class); - when(vm.getId()).thenReturn(VM_ID); - when(vm.getUuid()).thenReturn(VM_UUID); - when(vm.getType()).thenReturn(VirtualMachine.Type.DomainRouter); - when(vm.getState()).thenReturn(state); - - - final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class); - when(vmProfile.getType()).thenReturn(VirtualMachine.Type.DomainRouter); - when(vmProfile.getInstanceName()).thenReturn("Test-VR"); - when(vmProfile.getId()).thenReturn(VM_ID); - when(vmProfile.getUuid()).thenReturn(VM_UUID); - when(vmProfile.getVirtualMachine()).thenReturn(vm); - when(vmProfile.isRollingRestart()).thenReturn(true); - return vmProfile; - } - - @Nonnull - private NicProfile mockNicProfile() { - final NicVO nicvo = mock(NicVO.class); - when(nicvo.getId()).thenReturn(NIC_ID); - when(nicvo.getMacAddress()).thenReturn("c8:60:00:56:e5:58"); - when(nicvo.getIPv4Address()).thenReturn("10.10.10.10"); - when(nicvo.getUuid()).thenReturn("aaaa-fffff"); - when(nicvo.getNetworkId()).thenReturn(NETWORK_ID); - when(nicvo.getInstanceId()).thenReturn(VM_ID); - when(_nicDao.findById(NIC_ID)).thenReturn(nicvo); - when(_nicDao.findDefaultNicForVM(VM_ID)).thenReturn(nicvo); - - NicProfile nicProfile = mock(NicProfile.class); - when(nicProfile.getUuid()).thenReturn("aaa-bbbb"); - when(nicProfile.getId()).thenReturn(NIC_ID); - when(nicProfile.getMacAddress()).thenReturn("c8:60:00:56:e5:58"); - when(nicProfile.getIPv4Address()).thenReturn("10.10.10.10"); - return nicProfile; - } - - @Nonnull - private static ReservationContext getMockReservationContext(Account networksAccount, Domain networksDomain) { - final ReservationContext reservationContext = mock(ReservationContext.class); - when(reservationContext.getAccount()).thenReturn(networksAccount); - when(reservationContext.getDomain()).thenReturn(networksDomain); - return reservationContext; - } - -} diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/manager/NuageVspManagerTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/manager/NuageVspManagerTest.java deleted file mode 100644 index 680a13e9647..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/manager/NuageVspManagerTest.java +++ /dev/null @@ -1,171 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.manager; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; - -import javax.naming.ConfigurationException; - -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import org.apache.cloudstack.framework.config.impl.ConfigurationVO; -import org.apache.cloudstack.resourcedetail.VpcDetailVO; -import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao; - -import com.cloud.NuageTest; -import com.cloud.agent.AgentManager; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer; -import com.cloud.api.commands.DeleteNuageVspDeviceCmd; -import com.cloud.api.commands.ListNuageVspDevicesCmd; -import com.cloud.host.HostVO; -import com.cloud.host.dao.HostDao; -import com.cloud.host.dao.HostDetailsDao; -import com.cloud.network.NuageVspDeviceVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkDetailVO; -import com.cloud.network.dao.NetworkDetailsDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.dao.NuageVspDao; -import com.cloud.network.dao.PhysicalNetworkDao; -import com.cloud.network.dao.PhysicalNetworkServiceProviderDao; -import com.cloud.network.dao.PhysicalNetworkVO; -import com.cloud.resource.ResourceManager; -import com.cloud.util.NuageVspEntityBuilder; - -public class NuageVspManagerTest extends NuageTest { - private static final long NETWORK_ID = 42L; - private static final long VPC_ID = 1L; - private static final long VPC_ID2 = 2L; - - @Mock private PhysicalNetworkDao _physicalNetworkDao ; - @Mock private PhysicalNetworkServiceProviderDao _physicalNetworkServiceProviderDao; - @Mock private ResourceManager _resourceManager; - @Mock private HostDetailsDao _hostDetailsDao; - @Mock private NuageVspDao _nuageVspDao; - @Mock private NetworkDao _networkDao; - @Mock private HostDao _hostDao; - @Mock private AgentManager _agentManager; - @Mock private NuageVspEntityBuilder _nuageVspEntityBuilder; - @Mock private NetworkDetailsDao _networkDetailsDao; - @Mock private VpcDetailsDao _vpcDetailsDao; - - @InjectMocks - private NuageVspManagerImpl _nuageVspManager = new NuageVspManagerImpl(); - - private NetworkVO setUpMockedNetwork(Long vpcId, String domainTemplateName) { - NetworkVO networkToMock = mock(NetworkVO.class); - when(networkToMock.getId()).thenReturn(NETWORK_ID); - - reset(_vpcDetailsDao, _networkDetailsDao); - - when(networkToMock.getVpcId()).thenReturn(vpcId); - - if (domainTemplateName != null) { - if (vpcId != null) { - VpcDetailVO detail = new VpcDetailVO(vpcId, NuageVspManager.nuageDomainTemplateDetailName, domainTemplateName, false); - when(_vpcDetailsDao.findDetail(vpcId, NuageVspManager.nuageDomainTemplateDetailName)).thenReturn(detail); - } else { - NetworkDetailVO detail = new NetworkDetailVO(NETWORK_ID, NuageVspManager.nuageDomainTemplateDetailName, domainTemplateName, false); - when(_networkDetailsDao.findDetail(NETWORK_ID, NuageVspManager.nuageDomainTemplateDetailName)).thenReturn(detail); - } - } - - return networkToMock; - } - - @Test - public void testNuagePreConfiguredDomainTemplates() { - NetworkVO _mockedL2Network = setUpMockedNetwork(VPC_ID, "VpcDomainTemplate2"); - String checkDomainTemplate =_nuageVspManager.getPreConfiguredDomainTemplateName(_mockedL2Network); - assertEquals("VpcDomainTemplate2", checkDomainTemplate); - - _mockedL2Network = setUpMockedNetwork(VPC_ID2, null); - checkDomainTemplate =_nuageVspManager.getPreConfiguredDomainTemplateName(_mockedL2Network); - assertEquals("VpcDomainTemplate", checkDomainTemplate); - - _mockedL2Network = setUpMockedNetwork(null, "IsolatedDomainTemplate2"); - checkDomainTemplate =_nuageVspManager.getPreConfiguredDomainTemplateName(_mockedL2Network); - assertEquals("IsolatedDomainTemplate2", checkDomainTemplate); - - _mockedL2Network = setUpMockedNetwork(null, null); - checkDomainTemplate =_nuageVspManager.getPreConfiguredDomainTemplateName(_mockedL2Network); - assertEquals("IsolatedDomainTemplate", checkDomainTemplate); - - } - - - @Test - public void testDeleteNuageVspDevice() throws ConfigurationException { - - final PhysicalNetworkVO physicalNetwork = mock(PhysicalNetworkVO.class); - when(physicalNetwork.getDataCenterId()).thenReturn(NETWORK_ID); - when(physicalNetwork.getId()).thenReturn(NETWORK_ID); - when(_physicalNetworkDao.findById(NETWORK_ID)).thenReturn(physicalNetwork); - - final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class); - when(nuageVspDevice.getPhysicalNetworkId()).thenReturn(NETWORK_ID); - when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID); - when(_nuageVspDao.findById(NETWORK_ID)).thenReturn(nuageVspDevice); - - when(_networkDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(new ArrayList()); - - final HostVO host = mock(HostVO.class); - when(host.getId()).thenReturn(NETWORK_ID); - when(_hostDao.findById(NETWORK_ID)).thenReturn(host); - - final DeleteNuageVspDeviceCmd cmd = mock(DeleteNuageVspDeviceCmd.class); - when(cmd.getNuageVspDeviceId()).thenReturn(NETWORK_ID); - - ConfigurationVO cmsIdConfig = mock(ConfigurationVO.class); - when(cmsIdConfig.getValue()).thenReturn("1:1"); - when(_configDao.findByName("nuagevsp.cms.id")).thenReturn(cmsIdConfig); - - final SyncNuageVspCmsIdAnswer answer = mock(SyncNuageVspCmsIdAnswer.class); - when(answer.getResult()).thenReturn(true); - when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer); - - _nuageVspManager.deleteNuageVspDevice(cmd); - } - - @Test - public void testListNuageVspDevices() { - final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class); - when(nuageVspDevice.getPhysicalNetworkId()).thenReturn(NETWORK_ID); - - final PhysicalNetworkVO phyNtwkVO = mock(PhysicalNetworkVO.class); - when(_physicalNetworkDao.findById(NETWORK_ID)).thenReturn(phyNtwkVO); - when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(new ArrayList()); - - final ListNuageVspDevicesCmd cmd = mock(ListNuageVspDevicesCmd.class); - when(cmd.getPhysicalNetworkId()).thenReturn(NETWORK_ID); - when(cmd.getNuageVspDeviceId()).thenReturn(null); - _nuageVspManager.listNuageVspDevices(cmd); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/resource/NuageVspResourceTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/resource/NuageVspResourceTest.java deleted file mode 100644 index 560f53dbda2..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/network/resource/NuageVspResourceTest.java +++ /dev/null @@ -1,241 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.network.resource; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.naming.ConfigurationException; - -import net.nuage.vsp.acs.client.api.NuageVspApiClient; -import net.nuage.vsp.acs.client.api.NuageVspElementClient; -import net.nuage.vsp.acs.client.api.NuageVspGuruClient; -import net.nuage.vsp.acs.client.api.NuageVspManagerClient; -import net.nuage.vsp.acs.client.api.NuageVspPluginClientLoader; -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption; -import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption; -import net.nuage.vsp.acs.client.api.model.VspHost; -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspNic; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; -import net.nuage.vsp.acs.client.api.model.VspVm; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - -import com.cloud.NuageTest; -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.PingCommand; -import com.cloud.agent.api.StartupCommand; -import com.cloud.agent.api.element.ApplyAclRuleVspCommand; -import com.cloud.agent.api.element.ApplyStaticNatVspCommand; -import com.cloud.agent.api.element.ShutDownVpcVspCommand; -import com.cloud.agent.api.guru.DeallocateVmVspCommand; -import com.cloud.agent.api.guru.ImplementNetworkVspCommand; -import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand; -import com.cloud.agent.api.guru.TrashNetworkVspCommand; -import com.cloud.agent.api.manager.ImplementNetworkVspAnswer; -import com.cloud.host.Host; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class NuageVspResourceTest extends NuageTest { - private NuageVspResource _resource; - @Mock private NuageVspApiClient _mockNuageVspApiClient; - @Mock private NuageVspElementClient _mockNuageVspElementClient; - @Mock private NuageVspGuruClient _mockNuageVspGuruClient; - @Mock private NuageVspManagerClient _mockNuageVspManagerClient; - @Mock private NuageVspPluginClientLoader _mockNuageVspPluginClientLoader; - private NuageVspResourceConfiguration _resourceConfiguration; - private Map _hostDetails; - - @Before - public void setUp() throws Exception { - super.setUp(); - - MockitoAnnotations.initMocks(this); - - when(_mockNuageVspPluginClientLoader.getNuageVspApiClient()).thenReturn(_mockNuageVspApiClient); - when(_mockNuageVspPluginClientLoader.getNuageVspElementClient()).thenReturn(_mockNuageVspElementClient); - when(_mockNuageVspPluginClientLoader.getNuageVspGuruClient()).thenReturn(_mockNuageVspGuruClient); - when(_mockNuageVspPluginClientLoader.getNuageVspManagerClient()).thenReturn(_mockNuageVspManagerClient); - - _resource = new NuageVspResource() { - @Override protected NuageVspPluginClientLoader getClientLoader(VspHost vspHost) { - return _mockNuageVspPluginClientLoader; - } - - protected void login() throws ConfigurationException { - } - - }; - - _resourceConfiguration = new NuageVspResourceConfiguration() - .guid("aaaaa-bbbbb-ccccc") - .zoneId("blublub") - .hostName("nuagevsd") - .cmsUser("cmsuser") - .cmsUserPassword("cmsuserpass") - .port("8443") - .apiVersion("v3_2") - .apiRelativePath("nuage/api/v3_2") - .retryCount("3") - .retryInterval("3"); - _hostDetails = Maps.newHashMap(_resourceConfiguration.build()); - } - - @Test(expected = Exception.class) - public void resourceConfigureFailure() throws Exception { - _resource.configure("NuageVspResource", Collections. emptyMap()); - } - - @Test - public void resourceConfigure() throws Exception { - _resource.configure("Nuage VSD - nuagevsd", _hostDetails); - - assertEquals("Nuage VSD - nuagevsd", _resource.getName()); - assertEquals(Host.Type.L2Networking, _resource.getType()); - } - - @Test - public void testInitialization() throws Exception { - _resource.configure("Nuage VSD - nuagevsd", _hostDetails); - - StartupCommand[] sc = _resource.initialize(); - assertEquals(1, sc.length); - assertEquals("aaaaa-bbbbb-ccccc", sc[0].getGuid()); - assertEquals("Nuage VSD - nuagevsd", sc[0].getName()); - assertEquals("blublub", sc[0].getDataCenter()); - } - - @Test - public void testPingCommandStatus() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - PingCommand ping = _resource.getCurrentStatus(42); - assertNotNull(ping); - assertEquals(42, ping.getHostId()); - assertEquals(Host.Type.L2Networking, ping.getHostType()); - } - - @Test - public void testImplementNetworkVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - VspNetwork vspNetwork = buildVspNetwork(); - VspDhcpDomainOption vspDhcpOptions = buildspDhcpDomainOption(); - ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpOptions, false); - ImplementNetworkVspAnswer implNtwkAns = (ImplementNetworkVspAnswer)_resource.executeRequest(cmd); - assertTrue(implNtwkAns.getResult()); - verify(_mockNuageVspGuruClient).implement(vspNetwork, vspDhcpOptions); - } - - @Test - public void testImplementVsdManagedNetworkVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - VspNetwork vspNetwork = buildVspNetwork(); - VspDhcpDomainOption vspDhcpOptions = buildspDhcpDomainOption(); - when(_mockNuageVspGuruClient.addPermissionL3Network(vspNetwork)).thenReturn(vspNetwork); - ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpOptions, true); - ImplementNetworkVspAnswer implNtwkAns = (ImplementNetworkVspAnswer)_resource.executeRequest(cmd); - assertTrue(implNtwkAns.getResult()); - verify(_mockNuageVspGuruClient).addPermissionL3Network(vspNetwork); - } - - @Test - public void testReserveVmInterfaceVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - VspNetwork vspNetwork = buildVspNetwork(); - VspVm vspVm = buildVspVm(); - VspNic vspNic = buildVspNic(); - VspStaticNat vspStaticNat = buildVspStaticNat(); - VspDhcpVMOption vspDhcpOption = buildspDhcpVMOption(); - ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat, vspDhcpOption); - Answer rsrvVmInfAns = _resource.executeRequest(cmd); - assertTrue(rsrvVmInfAns.getResult()); - } - - @Test - public void testDeallocateVmVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - VspNetwork vspNetwork = buildVspNetwork(); - VspVm vspVm = buildVspVm(); - VspNic vspNic = buildVspNic(); - DeallocateVmVspCommand cmd = new DeallocateVmVspCommand(vspNetwork, vspVm, vspNic); - Answer dellocateVmAns = _resource.executeRequest(cmd); - assertTrue(dellocateVmAns.getResult()); - } - - @Test - public void testTrashNetworkVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - VspNetwork vspNetwork = buildVspNetwork(); - TrashNetworkVspCommand cmd = new TrashNetworkVspCommand(vspNetwork); - Answer trashNtwkAns = _resource.executeRequest(cmd); - assertTrue(trashNtwkAns.getResult()); - } - - @Test - public void testApplyStaticNatVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - VspNetwork vspNetwork = buildVspNetwork(); - List vspStaticNatDetails = Lists.newArrayList(buildVspStaticNat()); - ApplyStaticNatVspCommand cmd = new ApplyStaticNatVspCommand(vspNetwork, vspStaticNatDetails); - Answer applyNatAns = _resource.executeRequest(cmd); - assertTrue(applyNatAns.getResult()); - } - - @Test - public void testApplyAclRuleVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - VspNetwork vspNetwork = buildVspNetwork(); - List vspAclRules = Lists.newArrayList(buildVspAclRule()); - ApplyAclRuleVspCommand cmd = new ApplyAclRuleVspCommand(VspAclRule.ACLType.NetworkACL, vspNetwork, vspAclRules, false); - Answer applyAclAns = _resource.executeRequest(cmd); - assertTrue(applyAclAns.getResult()); - } - - @Test - public void testShutDownVpcVspCommand() throws Exception { - _resource.configure("NuageVspResource", _hostDetails); - - ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand("domainUuid", "vpcUuid", "domainTemplateName", Lists.newArrayList(), new HashMap<>()); - Answer shutVpcAns = _resource.executeRequest(cmd); - assertTrue(shutVpcAns.getResult()); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/util/NuageVspEntityBuilderTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/util/NuageVspEntityBuilderTest.java deleted file mode 100644 index f5124b20deb..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/util/NuageVspEntityBuilderTest.java +++ /dev/null @@ -1,435 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import net.nuage.vsp.acs.client.api.model.Protocol; -import net.nuage.vsp.acs.client.api.model.VspAclRule; -import net.nuage.vsp.acs.client.api.model.VspDomain; -import net.nuage.vsp.acs.client.api.model.VspNetwork; -import net.nuage.vsp.acs.client.api.model.VspNic; -import net.nuage.vsp.acs.client.api.model.VspStaticNat; -import net.nuage.vsp.acs.client.api.model.VspVm; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.InjectMocks; -import org.mockito.Mock; - -import com.google.common.collect.Lists; - -import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao; - -import com.cloud.NuageTest; -import com.cloud.dc.VlanDetailsVO; -import com.cloud.dc.VlanVO; -import com.cloud.dc.dao.VlanDao; -import com.cloud.dc.dao.VlanDetailsDao; -import com.cloud.domain.DomainVO; -import com.cloud.domain.dao.DomainDao; -import com.cloud.network.IpAddress; -import com.cloud.network.Network; -import com.cloud.network.dao.IPAddressDao; -import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.dao.NetworkDao; -import com.cloud.network.dao.NetworkDetailsDao; -import com.cloud.network.dao.NetworkVO; -import com.cloud.network.manager.NuageVspManager; -import com.cloud.network.rules.FirewallRule; -import com.cloud.network.vpc.NetworkACLItem; -import com.cloud.network.vpc.VpcVO; -import com.cloud.network.vpc.dao.VpcDao; -import com.cloud.offerings.NetworkOfferingVO; -import com.cloud.offerings.dao.NetworkOfferingDao; -import com.cloud.offerings.dao.NetworkOfferingServiceMapDao; -import com.cloud.user.AccountVO; -import com.cloud.user.dao.AccountDao; -import com.cloud.utils.net.Ip; -import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; -import com.cloud.vm.VirtualMachine; -import com.cloud.vm.dao.NicDao; -import com.cloud.vm.dao.NicSecondaryIpDao; - - -public class NuageVspEntityBuilderTest extends NuageTest { - - private static final long DOMAIN_ID = 1L; - private static final long ACCOUNT_ID = 1L; - private static final long NETWORK_OFFERING_ID = 1L; - private static final long SHARED_NETWORK_OFFERING_ID = 2L; - private static final long L2_NETWORK_OFFERING_ID = 3L; - private static final long VPC_ID = 1L; - private static final long SOURCE_IP_ADDRESS_ID = 1L; - private static final long VM_ID = 4L; - private static final long VLAN_ID = 5L; - public static final String VM_IP = "192.168.0.24"; - - @Mock private AccountDao _accountDao; - @Mock private DomainDao _domainDao; - @Mock private IPAddressDao _ipAddressDao; - @Mock private NetworkDao _networkDao; - @Mock private NetworkDetailsDao _networkDetailsDao; - @Mock private NetworkOfferingDao _networkOfferingDao; - @Mock private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao; - @Mock private NicDao _nicDao; - @Mock private NicSecondaryIpDao _nicSecondaryIpDao; - @Mock private VlanDao _vlanDao; - @Mock private VlanDetailsDao _vlanDetailsDao; - @Mock private VpcDao _vpcDao; - @Mock private VpcDetailsDao _vpcDetailsDao; - - @Mock private NuageVspManager _nuageVspManager; - - @InjectMocks - private NuageVspEntityBuilder _nuageVspEntityBuilder = new NuageVspEntityBuilder(); - - private DomainVO _mockedDomain = mock(DomainVO.class); - private AccountVO _mockedAccount = mock(AccountVO.class); - private NetworkOfferingVO _mockedNetworkOffering = mock(NetworkOfferingVO.class); - private NetworkOfferingVO _mockedSharedNetworkOffering = mock(NetworkOfferingVO.class); - private NetworkOfferingVO _mockedL2NetworkOffering = mock(NetworkOfferingVO.class); - private VlanVO _mockedVlan = mock(VlanVO.class); - private VlanDetailsVO _mockedVlanDetail = mock(VlanDetailsVO.class); - private VpcVO _mockedVpc = mock(VpcVO.class); - private NetworkVO _mockedNetwork = mock(NetworkVO.class); - private NetworkVO _mockedVpcNetwork = mock(NetworkVO.class); - private NetworkVO _mockedSharedNetwork = mock(NetworkVO.class); - private NetworkVO _mockedL2Network = mock(NetworkVO.class); - private VirtualMachine _mockedUserVirtualMachine = mock(VirtualMachine.class); - private VirtualMachine _mockedDomainRouterVirtualMachine = mock(VirtualMachine.class); - private NicProfile _mockedNicProfile = mock(NicProfile.class); - private NicVO _mockedNic = mock(NicVO.class); - private IPAddressVO _mockedStaticNatIp = mock(IPAddressVO.class); - private VlanVO _mockedStaticNatVlan = mock(VlanVO.class); - private FirewallRule _mockedFirewallRule = mock(FirewallRule.class); - private NetworkACLItem _mockedNetworkAclItem = mock(NetworkACLItem.class); - - @Before - public void setUp() throws Exception { - super.setUp(); - - setUpMockedDomain(); - setUpMockedAccount(); - setUpMockedNetworkOffering(_mockedNetworkOffering, Network.GuestType.Isolated); - setUpMockedNetworkOffering(_mockedSharedNetworkOffering, Network.GuestType.Shared); - setUpMockedNetworkOffering(_mockedL2NetworkOffering, Network.GuestType.Isolated); - setUpMockedVlan(); - setUpMockedVlanDetail(); - setUpMockedVpc(); - setUpMockedNetwork(_mockedNetwork, NETWORK_OFFERING_ID, null); - setUpMockedNetwork(_mockedVpcNetwork, NETWORK_OFFERING_ID, VPC_ID); - setUpMockedNetwork(_mockedSharedNetwork, SHARED_NETWORK_OFFERING_ID, null); - setUpMockedNetwork(_mockedL2Network, L2_NETWORK_OFFERING_ID, null); - setUpMockedVirtualMachine(_mockedUserVirtualMachine, false); - setUpMockedVirtualMachine(_mockedDomainRouterVirtualMachine, true); - setUpMockedNicProfile(); - setUpMockedNic(); - setUpMockedStaticNatIp(); - setUpMockedStaticNatVlan(); - setUpMockedFirewallRule(); - setUpMockedNetworkAclItem(); - setUpMockedDaoCalls(); - } - - @Test - public void testBuildVspDomain() { - VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(_mockedDomain); - validateVspDomain(vspDomain); - } - - @Test - public void testBuildVspNetwork() { - VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedL2Network); - validateVspNetwork(vspNetwork, true, false, false, false); - - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedL2Network); - validateVspNetwork(vspNetwork, true, false, false, false); - - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedNetwork); - validateVspNetwork(vspNetwork, false, true, false, false); - - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedNetwork); - validateVspNetwork(vspNetwork, false, true, false, false); - - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedVpcNetwork); - validateVspNetwork(vspNetwork, false, false, true, false); - - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedVpcNetwork); - validateVspNetwork(vspNetwork, false, false, true, false); - - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedSharedNetwork); - validateVspNetwork(vspNetwork, false, false, false, true); - - vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(_mockedSharedNetwork); - validateVspNetwork(vspNetwork, false, false, false, true); - } - - @Test - public void testBuildVspVm() { - VspVm vspVm = _nuageVspEntityBuilder.buildVspVm(_mockedUserVirtualMachine, _mockedNetwork); - validateVspVm(vspVm, false); - - vspVm = _nuageVspEntityBuilder.buildVspVm(_mockedDomainRouterVirtualMachine, _mockedNetwork); - validateVspVm(vspVm, true); - } - - @Test - public void testBuildVspNic() { - VspNic vspNic = _nuageVspEntityBuilder.buildVspNic("nicUuid", _mockedNicProfile); - validateVspNic(vspNic); - - vspNic = _nuageVspEntityBuilder.buildVspNic(_mockedNic); - validateVspNic(vspNic); - } - - @Test - public void testBuildVspStaticNat() { - VspStaticNat vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(true, _mockedStaticNatIp, _mockedStaticNatVlan, _mockedNic); - validateVspStaticNat(vspStaticNat, true); - } - - @Test - public void testBuildVspAclRuleAcl() { - VspAclRule vspAclRule = _nuageVspEntityBuilder.buildVspAclRule(_mockedNetworkAclItem); - validateVspAclRule(vspAclRule, false); - } - - @Test - public void testBuildVspAclRuleFirewall() { - VspAclRule vspAclRule = _nuageVspEntityBuilder.buildVspAclRule(_mockedFirewallRule, _mockedNetwork); - validateVspAclRule(vspAclRule, true); - } - - private void validateVspDomain(VspDomain vspDomain) { - assertEquals("domainUuid", vspDomain.getUuid()); - assertEquals("domainName", vspDomain.getName()); - assertEquals("domainPath", vspDomain.getPath()); - } - - private void validateVspNetwork(VspNetwork vspNetwork, boolean isL2, boolean isL3, boolean isVpc, boolean isShared) { - assertEquals(NETWORK_ID, vspNetwork.getId()); - assertEquals("networkUuid", vspNetwork.getUuid()); - assertEquals("networkName", vspNetwork.getName()); - assertNotNull(vspNetwork.getVspDomain()); - validateVspDomain(vspNetwork.getVspDomain()); - - assertEquals("accountName", vspNetwork.getAccountName()); - assertEquals("accountUuid", vspNetwork.getAccountUuid()); - - if (isVpc) { - assertEquals("vpcUuid", vspNetwork.getVpcUuid()); - assertEquals("vpcName", vspNetwork.getVpcName()); - } else { - assertNull(vspNetwork.getVpcUuid()); - assertNull(vspNetwork.getVpcName()); - } - - assertEquals(isL2, vspNetwork.isL2()); - assertEquals(isL3, vspNetwork.isL3()); - assertEquals(isVpc, vspNetwork.isVpc()); - assertEquals(isShared, vspNetwork.isShared()); - assertEquals(true, vspNetwork.isFirewallServiceSupported()); - assertEquals(true, vspNetwork.isEgressDefaultPolicy()); - assertEquals("10.10.10.0/24", vspNetwork.getCidr()); - assertEquals("10.10.10.1", vspNetwork.getGateway()); - } - - private void validateVspVm(VspVm vspVm, boolean isDomainRouter) { - assertEquals("virtualMachineUuid", vspVm.getUuid()); - assertEquals("virtualMachineInstanceName", vspVm.getName()); - assertEquals(VspVm.State.Running, vspVm.getState()); - assertEquals(isDomainRouter, vspVm.getDomainRouter()); - } - - private void validateVspNic(VspNic vspNic) { - assertEquals("nicUuid", vspNic.getUuid()); - assertEquals("macAddress", vspNic.getMacAddress()); - assertEquals(true, vspNic.getUseStaticIp()); - assertEquals("192.168.0.24", vspNic.getIp()); - } - - private void validateVspStaticNat(VspStaticNat vspStaticNat, Boolean forRevoke) { - assertEquals("staticNatIpUuid", vspStaticNat.getIpUuid()); - assertEquals("10.10.10.2", vspStaticNat.getIpAddress()); - assertEquals(forRevoke, vspStaticNat.getRevoke()); - assertEquals(VspStaticNat.State.Allocated, vspStaticNat.getState()); - assertEquals(true, vspStaticNat.getOneToOneNat()); - assertEquals("staticNatVlanUuid", vspStaticNat.getVlanUuid()); - assertEquals("10.10.10.1", vspStaticNat.getVlanGateway()); - assertEquals("255.255.255.0", vspStaticNat.getVlanNetmask()); - } - - private void validateVspAclRule(VspAclRule vspAclRule, boolean isFirewall) { - assertEquals("aclUuid", vspAclRule.getUuid()); - assertEquals(Protocol.TCP, vspAclRule.getProtocol()); - assertEquals(new Integer(1), vspAclRule.getStartPort()); - assertEquals(new Integer(20), vspAclRule.getEndPort()); - assertEquals(Lists.newArrayList("10.10.0.0/16"), vspAclRule.getSourceCidrList()); - assertEquals(VspAclRule.ACLState.Active, vspAclRule.getState()); - assertEquals(VspAclRule.ACLTrafficType.Egress, vspAclRule.getTrafficType()); - - if (isFirewall) { - assertEquals(VspAclRule.ACLType.Firewall, vspAclRule.getType()); - final VspStaticNat staticNat = vspAclRule.getStaticNat(); - assertNotNull(staticNat); - assertEquals("192.168.0.24/32", staticNat.getDestinationIp()); - assertEquals(VspAclRule.ACLAction.Deny, vspAclRule.getAction()); - } else { - assertEquals(VspAclRule.ACLType.NetworkACL, vspAclRule.getType()); - assertNull(vspAclRule.getStaticNat()); - assertNull(vspAclRule.getSourceIpAddress()); - assertEquals(VspAclRule.ACLAction.Allow, vspAclRule.getAction()); - } - } - - private void setUpMockedDomain() { - when(_mockedDomain.getUuid()).thenReturn("domainUuid"); - when(_mockedDomain.getName()).thenReturn("domainName"); - when(_mockedDomain.getPath()).thenReturn("domainPath"); - } - - private void setUpMockedAccount() { - when(_mockedAccount.getUuid()).thenReturn("accountUuid"); - when(_mockedAccount.getAccountName()).thenReturn("accountName"); - } - - private void setUpMockedNetworkOffering(NetworkOfferingVO networkOfferingToMock, Network.GuestType guestType) { - when(networkOfferingToMock.isEgressDefaultPolicy()).thenReturn(true); - when(networkOfferingToMock.getGuestType()).thenReturn(guestType); - } - - private void setUpMockedVlan() { - when(_mockedVlan.getIpRange()).thenReturn("192.168.2.2-192.168.2.200"); - } - - private void setUpMockedVlanDetail() { - when(_mockedVlanDetail.getValue()).thenReturn("true"); - } - - private void setUpMockedVpc() { - when(_mockedVpc.getUuid()).thenReturn("vpcUuid"); - when(_mockedVpc.getName()).thenReturn("vpcName"); - } - - private void setUpMockedNetwork(NetworkVO networkToMock, long networkOfferingId, Long vpcId) { - when(networkToMock.getId()).thenReturn(NETWORK_ID); - when(networkToMock.getUuid()).thenReturn("networkUuid"); - when(networkToMock.getName()).thenReturn("networkName"); - when(networkToMock.getCidr()).thenReturn("10.10.10.0/24"); - when(networkToMock.getGateway()).thenReturn("10.10.10.1"); - when(networkToMock.getDomainId()).thenReturn(DOMAIN_ID); - when(networkToMock.getAccountId()).thenReturn(ACCOUNT_ID); - when(networkToMock.getNetworkOfferingId()).thenReturn(networkOfferingId); - when(networkToMock.getVpcId()).thenReturn(vpcId != null ? vpcId : null); - } - - private void setUpMockedVirtualMachine(VirtualMachine virtualMachineToMock, boolean isDomainRouter) { - when(virtualMachineToMock.getUuid()).thenReturn("virtualMachineUuid"); - when(virtualMachineToMock.getInstanceName()).thenReturn("virtualMachineInstanceName"); - when(virtualMachineToMock.getState()).thenReturn(VirtualMachine.State.Running); - when(virtualMachineToMock.getType()).thenReturn(isDomainRouter ? VirtualMachine.Type.DomainRouter : VirtualMachine.Type.User); - } - - private void setUpMockedNicProfile() { - when(_mockedNicProfile.getMacAddress()).thenReturn("macAddress"); - when(_mockedNicProfile.getIPv4Address()).thenReturn(VM_IP); - when(_mockedNicProfile.getNetworkId()).thenReturn(NETWORK_ID); - } - - private void setUpMockedNic() { - when(_mockedNic.getUuid()).thenReturn("nicUuid"); - when(_mockedNic.getMacAddress()).thenReturn("macAddress"); - when(_mockedNic.getIPv4Address()).thenReturn(VM_IP); - when(_mockedNic.getNetworkId()).thenReturn(NETWORK_ID); - } - - private void setUpMockedStaticNatIp() { - when(_mockedStaticNatIp.getUuid()).thenReturn("staticNatIpUuid"); - when(_mockedStaticNatIp.getAddress()).thenReturn(new Ip("10.10.10.2")); - when(_mockedStaticNatIp.isOneToOneNat()).thenReturn(true); - when(_mockedStaticNatIp.getVmIp()).thenReturn(VM_IP); - when(_mockedStaticNatIp.getAssociatedWithNetworkId()).thenReturn(NETWORK_ID); - when(_mockedStaticNatIp.getAssociatedWithVmId()).thenReturn(VM_ID); - when(_mockedStaticNatIp.getState()).thenReturn(IpAddress.State.Allocated); - when(_mockedStaticNatIp.getVlanId()).thenReturn(VLAN_ID); - } - - private void setUpMockedStaticNatVlan() { - when(_mockedStaticNatVlan.getUuid()).thenReturn("staticNatVlanUuid"); - when(_mockedStaticNatVlan.getVlanGateway()).thenReturn("10.10.10.1"); - when(_mockedStaticNatVlan.getVlanNetmask()).thenReturn("255.255.255.0"); - } - - private void setUpMockedFirewallRule() { - when(_mockedFirewallRule.getUuid()).thenReturn("aclUuid"); - when(_mockedFirewallRule.getProtocol()).thenReturn("TCP"); - when(_mockedFirewallRule.getSourcePortStart()).thenReturn(1); - when(_mockedFirewallRule.getSourcePortEnd()).thenReturn(20); - when(_mockedFirewallRule.getSourceCidrList()).thenReturn(Lists.newArrayList("10.10.0.0/16")); - when(_mockedFirewallRule.getState()).thenReturn(FirewallRule.State.Active); - when(_mockedFirewallRule.getTrafficType()).thenReturn(FirewallRule.TrafficType.Egress); - when(_mockedFirewallRule.getSourceIpAddressId()).thenReturn(SOURCE_IP_ADDRESS_ID); - } - - private void setUpMockedNetworkAclItem() { - when(_mockedNetworkAclItem.getUuid()).thenReturn("aclUuid"); - when(_mockedNetworkAclItem.getProtocol()).thenReturn("TCP"); - when(_mockedNetworkAclItem.getSourcePortStart()).thenReturn(1); - when(_mockedNetworkAclItem.getSourcePortEnd()).thenReturn(20); - when(_mockedNetworkAclItem.getSourceCidrList()).thenReturn(Lists.newArrayList("10.10.0.0/16")); - when(_mockedNetworkAclItem.getNumber()).thenReturn(1337); - when(_mockedNetworkAclItem.getState()).thenReturn(NetworkACLItem.State.Active); - when(_mockedNetworkAclItem.getTrafficType()).thenReturn(NetworkACLItem.TrafficType.Egress); - when(_mockedNetworkAclItem.getAction()).thenReturn(NetworkACLItem.Action.Allow); - } - - private void setUpMockedDaoCalls() { - when(_domainDao.findById(DOMAIN_ID)).thenReturn(_mockedDomain); - when(_accountDao.findById(ACCOUNT_ID)).thenReturn(_mockedAccount); - when(_networkDao.findById(NETWORK_ID)).thenReturn(_mockedNetwork); - when(_networkOfferingDao.findById(NETWORK_OFFERING_ID)).thenReturn(_mockedNetworkOffering); - when(_networkOfferingDao.findById(SHARED_NETWORK_OFFERING_ID)).thenReturn(_mockedSharedNetworkOffering); - when(_networkOfferingDao.findById(L2_NETWORK_OFFERING_ID)).thenReturn(_mockedL2NetworkOffering); - when(_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(NETWORK_OFFERING_ID, Network.Service.SourceNat)).thenReturn(true); - when(_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(NETWORK_OFFERING_ID, Network.Service.StaticNat)).thenReturn(true); - when(_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(SHARED_NETWORK_OFFERING_ID, Network.Service.SourceNat)).thenReturn(true); - when(_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(SHARED_NETWORK_OFFERING_ID, Network.Service.StaticNat)).thenReturn(true); - when(_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(L2_NETWORK_OFFERING_ID, Network.Service.SourceNat)).thenReturn(false); - when(_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(L2_NETWORK_OFFERING_ID, Network.Service.StaticNat)).thenReturn(false); - when(_networkModel.areServicesSupportedByNetworkOffering(NETWORK_OFFERING_ID, Network.Service.Firewall)).thenReturn(true); - when(_networkModel.areServicesSupportedByNetworkOffering(SHARED_NETWORK_OFFERING_ID, Network.Service.Firewall)).thenReturn(true); - when(_networkModel.areServicesSupportedByNetworkOffering(L2_NETWORK_OFFERING_ID, Network.Service.Firewall)).thenReturn(true); - when(_vlanDao.listVlansByNetworkId(NETWORK_ID)).thenReturn(Lists.newArrayList(_mockedVlan)); - when(_vlanDao.findById(VLAN_ID)).thenReturn(_mockedVlan); - when(_vlanDetailsDao.findDetail(anyLong(), anyString())).thenReturn(_mockedVlanDetail); - when(_vpcDao.findById(VPC_ID)).thenReturn(_mockedVpc); - when(_ipAddressDao.findById(SOURCE_IP_ADDRESS_ID)).thenReturn(_mockedStaticNatIp); - when(_vpcDetailsDao.listDetailsKeyPairs(VPC_ID)).thenReturn(null); - when(_nicDao.findByIp4AddressAndNetworkId("192.168.0.24", NETWORK_ID)).thenReturn(_mockedNic); - } -} diff --git a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/util/NuageVspUtilTest.java b/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/util/NuageVspUtilTest.java deleted file mode 100644 index 6f1414a7db7..00000000000 --- a/plugins/network-elements/nuage-vsp/src/test/java/com/cloud/util/NuageVspUtilTest.java +++ /dev/null @@ -1,43 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -package com.cloud.util; - -import org.junit.Test; - -import static junit.framework.Assert.assertEquals; - -public class NuageVspUtilTest { - - @Test - public void testEncodePassword() { - String password = "Password!@#$%^&*()-_{}?><"; - String expectedEncodedPassword = "UGFzc3dvcmQhQCMkJV4mKigpLV97fT8+PA=="; - String encodedPassword = NuageVspUtil.encodePassword(password); - assertEquals(expectedEncodedPassword, encodedPassword); - } - - @Test - public void testDecodePassword() { - String password = "UGFzc3dvcmQhQCMkJV4mKigpLV97fT8+PA=="; - String expectedDecodedPassword = "Password!@#$%^&*()-_{}?><"; - String decodedPassword = NuageVspUtil.decodePassword(password); - assertEquals(expectedDecodedPassword, decodedPassword); - } -} diff --git a/plugins/pom.xml b/plugins/pom.xml index 01c48f48e0e..ff84955a813 100755 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -102,7 +102,6 @@ network-elements/palo-alto network-elements/stratosphere-ssp network-elements/brocade-vcs - network-elements/nuage-vsp network-elements/vxlan outofbandmanagement-drivers/ipmitool diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index 4f36447d66d..c10744d2e42 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -2570,7 +2570,7 @@ public class ApiResponseHelper implements ResponseGenerator { for (Network.Provider serviceProvider : serviceProviders) { // return only Virtual Router/JuniperSRX/CiscoVnmc as a provider for the firewall if (service == Service.Firewall - && !(serviceProvider == Provider.VirtualRouter || serviceProvider == Provider.JuniperSRX || serviceProvider == Provider.CiscoVnmc || serviceProvider == Provider.PaloAlto || serviceProvider == Provider.NuageVsp || serviceProvider == Provider.BigSwitchBcf)) { + && !(serviceProvider == Provider.VirtualRouter || serviceProvider == Provider.JuniperSRX || serviceProvider == Provider.CiscoVnmc || serviceProvider == Provider.PaloAlto || serviceProvider == Provider.BigSwitchBcf)) { continue; } diff --git a/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java index 8bb5c9abf83..21538a8a528 100644 --- a/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java +++ b/server/src/main/java/com/cloud/network/guru/DirectNetworkGuru.java @@ -146,7 +146,6 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru { && isMyTrafficType(offering.getTrafficType()) && isMyIsolationMethod(physnet) && offering.getGuestType() == GuestType.Shared - && !_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NuageVsp) && !_ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NiciraNvp)) { return true; } else { diff --git a/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java index fef08519055..a4ea50d94dd 100644 --- a/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/main/java/com/cloud/network/vpc/VpcManagerImpl.java @@ -212,7 +212,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis private List vpcElements = null; private final List nonSupportedServices = Arrays.asList(Service.SecurityGroup, Service.Firewall); private final List supportedProviders = Arrays.asList(Provider.VPCVirtualRouter, Provider.NiciraNvp, Provider.InternalLbVm, Provider.Netscaler, - Provider.JuniperContrailVpcRouter, Provider.Ovs, Provider.NuageVsp, Provider.BigSwitchBcf, Provider.ConfigDrive); + Provider.JuniperContrailVpcRouter, Provider.Ovs, Provider.BigSwitchBcf, Provider.ConfigDrive); int _cleanupInterval; int _maxNetworks; @@ -353,7 +353,6 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis final Set sdnProviders = new HashSet(); sdnProviders.add(Provider.NiciraNvp); sdnProviders.add(Provider.JuniperContrailVpcRouter); - sdnProviders.add(Provider.NuageVsp); boolean sourceNatSvc = false; boolean firewallSvs = false; diff --git a/server/src/test/java/com/cloud/network/NetworkModelTest.java b/server/src/test/java/com/cloud/network/NetworkModelTest.java index f707329557a..cd24a0b14cd 100644 --- a/server/src/test/java/com/cloud/network/NetworkModelTest.java +++ b/server/src/test/java/com/cloud/network/NetworkModelTest.java @@ -21,22 +21,16 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyLong; import static org.mockito.Matchers.eq; import static org.mockito.Matchers.isNull; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.mockito.Mockito.spy; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.Set; import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenterVO; @@ -52,10 +46,8 @@ import org.junit.Test; import com.cloud.dc.VlanVO; import com.cloud.dc.dao.VlanDao; -import com.cloud.exception.UnsupportedServiceException; import com.cloud.network.dao.IPAddressDao; import com.cloud.network.dao.IPAddressVO; -import com.cloud.network.element.NetworkElement; import com.cloud.user.Account; import com.cloud.utils.db.Filter; import com.cloud.utils.db.SearchBuilder; @@ -153,54 +145,6 @@ public class NetworkModelTest { } - @Test - public void testCapabilityForProvider() { - NetworkModelImpl modelImpl = spy(NetworkModelImpl.class); - Set providers = new HashSet<>(); - providers.add(Provider.NuageVsp); - NetworkElement nuageVspElement = mock(NetworkElement.class); - HashMap> nuageVspCap = new HashMap>(); - HashMap nuageVspConnectivity = new HashMap(); - nuageVspConnectivity.put(Network.Capability.NoVlan, "FindMe"); - nuageVspConnectivity.put(Network.Capability.PublicAccess, ""); - - nuageVspCap.put(Network.Service.Connectivity, nuageVspConnectivity); - when(nuageVspElement.getName()).thenReturn("NuageVsp"); - doReturn(nuageVspCap).when(nuageVspElement).getCapabilities(); - doReturn(nuageVspElement).when(modelImpl).getElementImplementingProvider("NuageVsp"); - - try { - modelImpl.checkCapabilityForProvider(providers, Network.Service.UserData, null, null); - Assert.fail(); - } catch (UnsupportedServiceException e) { - Assert.assertEquals(e.getMessage(), "Service " + Network.Service.UserData.getName() + " is not supported by the element=NuageVsp implementing Provider=" + Provider.NuageVsp.getName()); - } - - try { - modelImpl.checkCapabilityForProvider(providers, Network.Service.Connectivity, Network.Capability.ElasticIp, null); - Assert.fail(); - } catch (UnsupportedServiceException e) { - Assert.assertEquals(e.getMessage(), "Service " + Network.Service.Connectivity.getName() + " doesn't have capability " + Network.Capability.ElasticIp.getName() + " for element=NuageVsp implementing Provider=" + Provider.NuageVsp.getName()); - } - try { - modelImpl.checkCapabilityForProvider(providers, Network.Service.Connectivity, Network.Capability.PublicAccess, "NonExistingVal"); - Assert.fail(); - } catch (UnsupportedServiceException e){ - Assert.assertEquals(e.getMessage(),"Service Connectivity doesn't have capability PublicAccess for element=NuageVsp implementing Provider=NuageVsp"); - } - - modelImpl.checkCapabilityForProvider(providers, Network.Service.Connectivity, Network.Capability.NoVlan, "FindMe"); - - NetworkElement nuageVspElement2 = mock(NetworkElement.class); - doReturn(null).when(nuageVspElement).getCapabilities(); - try { - modelImpl.checkCapabilityForProvider(providers, Network.Service.Connectivity, Network.Capability.PublicAccess, ""); - Assert.fail(); - } catch (UnsupportedServiceException e) { - Assert.assertEquals(e.getMessage(), "Service Connectivity is not supported by the element=NuageVsp implementing Provider=NuageVsp"); - } - } - @Test public void testVerifyDisabledConfigDriveEntriesOnZonesBothEnabledZones() { networkModel.verifyDisabledConfigDriveEntriesOnEnabledZones(); diff --git a/server/src/test/java/com/cloud/network/guru/DirectNetworkGuruTest.java b/server/src/test/java/com/cloud/network/guru/DirectNetworkGuruTest.java index 72bec5017ad..750bee49c8a 100644 --- a/server/src/test/java/com/cloud/network/guru/DirectNetworkGuruTest.java +++ b/server/src/test/java/com/cloud/network/guru/DirectNetworkGuruTest.java @@ -92,7 +92,6 @@ public class DirectNetworkGuruTest { when(offering.getGuestType()).thenReturn(GuestType.Shared); when(offering.getTrafficType()).thenReturn(TrafficType.Guest); when(offering.getId()).thenReturn(42l); - when(ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NuageVsp)).thenReturn(false); when(ntwkOfferingSrvcDao.isProviderForNetworkOffering(offering.getId(), Network.Provider.NiciraNvp)).thenReturn(false); } diff --git a/test/integration/plugins/nuagevsp/__init__.py b/test/integration/plugins/nuagevsp/__init__.py deleted file mode 100644 index 13a83393a91..00000000000 --- a/test/integration/plugins/nuagevsp/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. diff --git a/test/integration/plugins/nuagevsp/libVSD/__init__.py b/test/integration/plugins/nuagevsp/libVSD/__init__.py deleted file mode 100644 index 3377d9cc4ce..00000000000 --- a/test/integration/plugins/nuagevsp/libVSD/__init__.py +++ /dev/null @@ -1,22 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -from .client import ApiClient -from .helpers import VSDHelpers - -__version__ = "1.0" -__all__ = ['ApiClient', 'VSDHelpers'] diff --git a/test/integration/plugins/nuagevsp/libVSD/client.py b/test/integration/plugins/nuagevsp/libVSD/client.py deleted file mode 100644 index 38ab6f0802b..00000000000 --- a/test/integration/plugins/nuagevsp/libVSD/client.py +++ /dev/null @@ -1,135 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import bambou -import importlib - - -class ApiClient(object): - """ - This class provides utilities to instantiate an API client using vspk. - Args: - address (str): ip address or hostname where the VSD API is exposed. - user (str): username to authenticate on the API. - password (str): password to authenticate on the API. - enterprise (str): VSD organization to use to authenticate on the API. - version (str): version of the API to use. - """ - - def __init__(self, address, port='8443', user='csproot', - password='csproot', enterprise='csp', version=None): - if not version: - version = '5.0' - self.url = 'https://{}:{}'.format(address, port) - self.version = version - self.user = user - self.password = password - self.enterprise = enterprise - self.last_pushes = [] - self.session = None - - @staticmethod - def import_vspk(version): - """ - Return the vspk module corresponding to a given version of the API. - Args: - version (str): version of the API - """ - version = 'v{}'.format(str(version).replace('.', '_')) - try: - vsdk = importlib.import_module('vspk.%s' % version) - except: - vsdk = importlib.import_module('vspk.vsdk.%s' % version) - return vsdk - - def import_vsdenvs(self): - """ - Return the root class a `vsdenvs`. - """ - if not self.session: - raise Exception('You must have an active session to use vsdenvs') - self.vsdenvs = __import__('vsdenvs', globals(), locals(), [], -1) - self.vsdenvs.NUCsprootEnvironment.instance = self.session.user - - def new_session(self): - """ - Start a new API session via vspk an return the corresponding - `vspk.NUVSDSession` object. Note that this object is also exposed as - `self.session` - """ - vspk = self.import_vspk(self.version) - self.session = vspk.NUVSDSession( - username=self.user, - password=self.password, - enterprise=self.enterprise, - api_url=self.url) - self.session.start() - return self.session - - def start_push_center(self, callback=None): - """ - Add a vspk push center to the current session. - """ - if not callback: - callback = self.default_callback - self.session.push_center.add_delegate(callback) - self.session.push_center.start() - - def stop_push_center(self, callback=None): - """ - Stop the vpsk push center for the current session. - """ - self.session.push_center.stop() - - def default_callback(self, data): - """ - Default callback for the push center. It just stores the new event in - a LILO queue exposed as `self.last_pushe` - """ - self.last_pushes.append(data) - # keep only the last 10 events - if len(self.last_pushes) == 100: - del self.last_pushes[-1] - - def __call__(self): - if not self.session: - return self.new_session() - return self.session - - def add_license(self): - """ - Add a license to the VSD - """ - vspk = self.import_vspk(self.version) - self.session.license = vspk.NULicense(license=self.license) - try: - self.session.user.create_child(self.session.license) - except bambou.exceptions.BambouHTTPError: - pass - else: - self.session.user.add_child(self.session.license) - - def delete_license(self): - """ - Delete license on the VSD - """ - self.session.user.licenses.fetch() - for license in self.session.user.licenses: - try: - license.delete() - except bambou.exceptions.BambouHTTPError: - pass diff --git a/test/integration/plugins/nuagevsp/libVSD/helpers.py b/test/integration/plugins/nuagevsp/libVSD/helpers.py deleted file mode 100644 index cdc0e639d66..00000000000 --- a/test/integration/plugins/nuagevsp/libVSD/helpers.py +++ /dev/null @@ -1,602 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import logging -import functools -import bambou - -LOG = logging.getLogger() - - -class recreate_session_on_timeout(object): - def __init__(self, method): - self.method = method - - def __get__(self, obj=None, objtype=None): - @functools.wraps(self.method) - def _wrapper(*args, **kwargs): - try: - return self.method(obj, *args, **kwargs) - except bambou.exceptions.BambouHTTPError as e: - if e.connection.response.status_code == 401: - obj.session = obj.api_client.new_session() - return self.method(obj, *args, **kwargs) - else: - raise e - - return _wrapper - - -class VSDHelpers(object): - - def __init__(self, api_client): - """ - Create a wrapper - provide a cspsession and a vpsk object, all from the VSD object - """ - self.api_client = api_client - self.session = api_client.session - self.vspk = api_client.import_vspk(api_client.version) - - def update_vsd_session(self, api_client=None): - """ - This method is used when Helper is - initialized before we create a new_session. - """ - if api_client: - self.session = api_client.session - self.vspk = api_client.import_vspk(api_client.version) - else: - self.session = self.api_client.session - - @recreate_session_on_timeout - def add_user_to_group(self, enterprise, user=None, group=None, - usr_filter=None, grp_filter=None): - """ - Add user to a group on VSD. - For example: Add csproot to cms group - Here you can couple of things: - 1. enterprise can be id or NURest Object - 2. And User group both need to be NURest object - or both can be filters. - """ - if not isinstance(enterprise, self.vspk.NUEnterprise): - enterprise = self.vspk.NUEnterprise(id=enterprise) - if isinstance(group, self.vspk.NUGroup): - if isinstance(user, self.vspk.NUUser): - all_users = group.users.get() - all_users.append(user) - group.assign(all_users, self.vspk.NUUser) - elif usr_filter and grp_filter: - group = enterprise.groups.get_first(filter=grp_filter) - all_users = group.users.get() - user = enterprise.users.get_first(filter=usr_filter) - if not group: - LOG.error('could not fetch the group matching the filter "{}"' - .format(grp_filter)) - return - if not user: - LOG.error('could not fetch the user matching the filter "{}"' - .format(usr_filter)) - return - all_users.append(user) - group.assign(all_users, self.vspk.NUUser) - - def set_name_filter(self, name): - """ set name filter for vsd query - @param: name: string name - @return: filter string - """ - return 'name is "{}"'.format(name) - - def set_externalID_filter(self, id): - """ set externalID filter for vsd query - @param: id: string externalID - @return: filter string - """ - return 'externalID is "{}"'.format(id) - - @recreate_session_on_timeout - def get_enterprise(self, filter): - """ get_enterprise - @params: enterprise filter following vspk filter structure - @return: enterprise object - @Example: - self.vsd.get_enterprise( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - enterprise = self.session.user.enterprises.get_first(filter=filter) - if not enterprise: - LOG.error('could not fetch the enterprise matching the filter "{}"' - .format(filter)) - return enterprise - - @recreate_session_on_timeout - def get_l2domain(self, enterprise=None, filter=None): - """ get_l2domain - @params: enterprise object or enterprise id - filter following vspk filter structure - @return l2 domain object - @Example: - self.vsd.get_l2domain(enterprise=enterprise, - filter='name == "{}"'.format(name)) - self.vsd.get_l2domain(enterprise=enterprise_id, - filter='name == "{}"'.format(name)) - self.vsd.get_l2domain(filter='externalID == "{}"'.format(ext_id)) - """ - l2_domain = None - if enterprise: - if not isinstance(enterprise, self.vspk.NUEnterprise): - enterprise = self.vspk.NUEnterprise(id=enterprise) - l2_domain = enterprise.l2_domains.get_first(filter=filter) - elif filter: - l2_domain = self.session.user.l2_domains.get_first(filter=filter) - if not l2_domain: - LOG.error('could not fetch the l2 domain matching the filter "{}"' - .format(filter)) - return l2_domain - - @recreate_session_on_timeout - def get_domain(self, enterprise=None, filter=None): - """ get_domain - @params: enterprise object or enterprise id - filter following vspk filter structure - @return: domain object - @Example: - self.vsd.get_domain(enterprise=enterprise, - filter='name == "{}"'.format(name)) - self.vsd.get_domain(enterprise=enterprise_id, - filter='name == "{}"'.format(name)) - self.vsd.get_domain(filter='externalID == "{}"'.format(ext_id)) - """ - domain = None - if enterprise: - if not isinstance(enterprise, self.vspk.NUEnterprise): - enterprise = self.vspk.NUEnterprise(id=enterprise) - domain = enterprise.domains.get_first(filter=filter) - elif filter: - domain = self.session.user.domains.get_first(filter=filter) - if not domain: - LOG.error('could not fetch the domain matching the filter "{}"' - .format(filter)) - return domain - - @recreate_session_on_timeout - def get_domain_template(self, enterprise=None, filter=None): - """ get_domain - @params: enterprise object or enterprise id - filter following vspk filter structure - @return: domain object - @Example: - self.vsd.get_domain(enterprise=enterprise, - filter='name == "{}"'.format(name)) - self.vsd.get_domain(enterprise=enterprise_id, - filter='name == "{}"'.format(name)) - self.vsd.get_domain(filter='externalID == "{}"'.format(ext_id)) - """ - domain = None - if enterprise: - if not isinstance(enterprise, self.vspk.NUEnterprise): - enterprise = self.vspk.NUEnterprise(id=enterprise) - domain = enterprise.domain_templates.get_first(filter=filter) - elif filter: - domain = \ - self.session.user.domain_templates.get_first(filter=filter) - if not domain: - LOG.error('could not fetch the domain template ' - 'matching the filter "{}"' - .format(filter)) - return domain - - @recreate_session_on_timeout - def get_zone(self, domain=None, filter=None): - """ get_zone - @params: domain object or domain id - filter following vspk filter structure - @return: zone object - @Example: - self.vsd.get_zone(domain=domain, - filter='name == "{}"'.format(name)) - self.vsd.get_zone(domain=domain_id, - filter='name == "{}"'.format(name)) - self.vsd.get_zone(filter='externalID == "{}"'.format(ext_id)) - """ - zone = None - if domain: - if not isinstance(domain, self.vspk.NUDomain): - domain = self.vspk.NUDomain(id=domain) - zone = domain.zones.get_first(filter=filter) - elif filter: - zone = self.session.user.zones.get_first(filter=filter) - if not zone: - LOG.error('could not fetch the zone matching the filter "{}"' - .format(filter)) - return zone - - @recreate_session_on_timeout - def get_subnet(self, zone=None, filter=None): - """ get_subnet - @params: zone object or zone id - filter following vspk filter structure - @return: subnet object - @Example: - self.vsd.get_subnet(zone=zone, - filter='name == "{}"'.format(name)) - self.vsd.get_subnet(zone=zone_id, - filter='name == "{}"'.format(name)) - self.vsd.get_subnet(filter='externalID == "{}"'.format(ext_id)) - """ - subnet = None - if zone: - if not isinstance(zone, self.vspk.NUZone): - zone = self.vspk.NUZone(id=zone) - subnet = zone.subnets.get_first(filter=filter) - elif filter: - subnet = self.session.user.subnets.get_first(filter=filter) - if not subnet: - LOG.error('could not fetch the subnet matching the filter "{}"' - .format(filter)) - return subnet - - @recreate_session_on_timeout - def get_subnet_from_domain(self, domain=None, filter=None): - """ get_subnet - @params: domain object or domain id - filter following vspk filter structure - @return: subnet object - @Example: - self.vsd.get_subnet(domain=domain, - filter='name == "{}"'.format(name)) - self.vsd.get_subnet(domain=domain_id, - filter='name == "{}"'.format(name)) - self.vsd.get_subnet(filter='externalID == "{}"'.format(ext_id)) - """ - subnet = None - if domain: - if not isinstance(domain, self.vspk.NUDomain): - domain = self.vspk.NUDomain(id=domain) - subnet = domain.subnets.get_first(filter=filter) - elif filter: - subnet = self.session.user.subnets.get_first(filter=filter) - if not subnet: - LOG.error('could not fetch the subnet matching the filter "{}"' - .format(filter)) - return subnet - - @recreate_session_on_timeout - def get_vm(self, subnet=None, filter=None): - """ get_vm - @params: subnet object or subnet id - filter following vspk filter structure - @return: vm object - @Example: - self.vsd.get_vm(subnet=subnet, - filter='name == "{}"'.format(name)) - self.vsd.get_vm(subnet=subnet_id, - filter='name == "{}"'.format(name)) - self.vsd.get_vm(filter='externalID == "{}"'.format(ext_id)) - """ - vm = None - if subnet: - if not isinstance(subnet, self.vspk.NUSubnet): - subnet = self.vspk.NUSubnet(id=subnet) - vm = subnet.vms.get_first(filter=filter) - elif filter: - vm = self.session.user.vms.get_first(filter=filter) - if not vm: - LOG.error('could not fetch the vm matching the filter "{}"' - .format(filter)) - return vm - - @recreate_session_on_timeout - def get_subnet_dhcpoptions(self, subnet=None, filter=None): - """ get_subnet_dhcpoptions - @params: subnet object or - subnet filter following vspk filter structure - @return: subnet dhcpoptions object - @Example: - self.vsd.get_subnet_dhcpoptions(subnet=subnet) - self.vsd.get_subnet_dhcpoptions( - filter='externalID == "{}"'.format(subnet_externalID)) - """ - if not isinstance(subnet, self.vspk.NUSubnet): - if not filter: - LOG.error('a filter is required') - return None - subnet = self.session.user.subnets.get_first(filter=filter) - dhcp_options = subnet.dhcp_options.get() - if not dhcp_options: - if filter: - LOG.error('could not fetch the dhcp options on the subnet ' - 'matching the filter "{}"' - .format(filter)) - else: - LOG.error('could not fetch the dhcp options on the subnet') - return dhcp_options - - @recreate_session_on_timeout - def get_vport(self, subnet, filter): - """ get_vport - @params: subnet object - vport filter following vspk filter structure - @return: vport object - @Example: - self.vsd.get_vport(subnet=subnet, - filter='externalID == "{}"'.format(ext_id)) - """ - if not isinstance(subnet, self.vspk.NUSubnet): - LOG.error('a subnet is required') - return None - if not filter: - LOG.error('a filter is required') - return None - vport = subnet.vports.get_first(filter=filter) - if not vport: - LOG.error('could not fetch the vport from the subnet ' - 'matching the filter "{}"' - .format(filter)) - return vport - - @recreate_session_on_timeout - def get_vm_interface(self, filter): - """ get_vm_interface - @params: vm interface filter following vspk filter structure - @return: vm interface object - @Example: - self.vsd.get_vm_interface( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - vm_interface = self.session.user.vm_interfaces.get_first(filter=filter) - if not vm_interface: - LOG.error('could not fetch the vm interface ' - 'matching the filter "{}"' - .format(filter)) - return vm_interface - - @recreate_session_on_timeout - def get_vm_interface_policydecisions(self, vm_interface=None, filter=None): - """ get_vm_interface_policydecisions - @params: vm interface object or - vm interface filter following vspk filter structure - @return: vm interface policydecisions object - @Example: - self.vsd.get_vm_interface_policydecisions(vm_interface=interface) - self.vsd.get_vm_interface_policydecisions( - filter='externalID == "{}"'.format(vm_interface_externalID)) - """ - if not isinstance(vm_interface, self.vspk.NUVMInterface): - if not filter: - LOG.error('a filter is required') - return None - vm_interface = \ - self.session.user.vm_interfaces.get_first(filter=filter) - policy_decisions = self.vspk.NUPolicyDecision( - id=vm_interface.policy_decision_id).fetch() - if not policy_decisions: - if filter: - LOG.error('could not fetch the policy decisions on the ' - 'vm interface matching the filter "{}"' - .format(filter)) - else: - LOG.error('could not fetch the policy decisions ' - 'on the vm interface') - return policy_decisions - - @recreate_session_on_timeout - def get_vm_interface_dhcpoptions(self, vm_interface=None, filter=None): - """ get_vm_interface_dhcpoptions - @params: vm interface object or - vm interface filter following vspk filter structure - @return: vm interface dhcpoptions object - @Example: - self.vsd.get_vm_interface_dhcpoptions(vm_interface=vm_interface) - self.vsd.get_vm_interface_dhcpoptions( - filter='externalID == "{}"'.format(vm_interface_externalID)) - """ - if not isinstance(vm_interface, self.vspk.NUVMInterface): - if not filter: - LOG.error('a filter is required') - return None - vm_interface = self.session.user.vm_interfaces.get_first( - filter=filter) - dhcp_options = vm_interface.dhcp_options.get() - if not dhcp_options: - if filter: - LOG.error('could not fetch the dhcp options on the ' - 'vm interface matching the filter "{}"' - .format(filter)) - else: - LOG.error('could not fetch the dhcp options on the ' - 'vm interface') - return dhcp_options - - @recreate_session_on_timeout - def get_ingress_acl_entry(self, filter): - """ get_ingress_acl_entry - @params: ingress acl entry filter following vspk filter structure - @return: ingress acl entry object - @Example: - self.vsd.get_ingress_acl_entry( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - acl = self.session.user.ingress_acl_entry_templates.get_first( - filter=filter) - if not acl: - LOG.error('could not fetch the ingress acl entry ' - 'matching the filter "{}"' - .format(filter)) - return acl - - @recreate_session_on_timeout - def get_egress_acl_entry(self, filter): - """ get_egress_acl_entry - @params: egress acl entry filter following vspk filter structure - @return: egress acl entry object - @Example: - self.vsd.get_egress_acl_entry( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - acl = self.session.user.egress_acl_entry_templates.get_first( - filter=filter) - if not acl: - LOG.error('could not fetch the egress acl entry ' - 'matching the filter "{}"' - .format(filter)) - return acl - - @recreate_session_on_timeout - def get_qoss(self, vport): - """ get_qoss - @params: vport object - @return: qoss object - @Example: - self.vsd.get_qoss(vport=vport) - """ - if not isinstance(vport, self.vspk.NUVPort): - LOG.error('a vport is required') - return None - qoss = vport.qoss.get() - if not qoss: - LOG.error('could not fetch the qoss from the vport') - return qoss - - @recreate_session_on_timeout - def get_floating_ip(self, filter): - """ get_floating_ip - @params: floating ip filter following vspk filter structure - @return: floating ip object - @Example: - self.vsd.get_floating_ip( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - floating_ip = self.session.user.floating_ips.get_first(filter=filter) - if not floating_ip: - LOG.error('could not fetch the floating ip ' - 'matching the filter "{}"' - .format(filter)) - return floating_ip - - @recreate_session_on_timeout - def get_ingress_acl_entries(self, filter): - """ get_ingress_acl_entries - @params: ingress acl entries (templates) filter following vspk - filter structure - @return: ingress acl entries (objects) list - @Example: - self.vsd.get_ingress_acl_entries( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - templates = self.session.user.ingress_acl_templates.get(filter=filter) - if not templates: - LOG.error('could not fetch the ingress acl entries (templates) ' - 'matching the filter "{}"' - .format(filter)) - return None - acls = [] - for template in templates: - tmp = self.vspk.NUIngressACLTemplate(id=template.id) - acl = tmp.ingress_acl_entry_templates.get() - acls.append(acl) - return acls - - @recreate_session_on_timeout - def get_egress_acl_entries(self, filter): - """ get_egress_acl_entries - @params: egress acl entries (templates) filter - following vspk filter structure - @return: egress acl entries (objects) list - @Example: - self.vsd.get_egress_acl_entries( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - templates = self.session.user.egress_acl_templates.get(filter=filter) - if not templates: - LOG.error('could not fetch the egress acl entries (templates) ' - 'matching the filter "{}"' - .format(filter)) - return None - acls = [] - for template in templates: - tmp = self.vspk.NUEgressACLTemplate(id=template.id) - acl = tmp.egress_acl_entry_templates.get() - acls.append(acl) - return acls - - @recreate_session_on_timeout - def get_shared_network_resource(self, filter): - """ get_shared_network_resource - @params: shared network resource filter - following vspk filter structure - @return: shared network resource object - @Example: - self.vsd.get_shared_network_resource( - filter='externalID == "{}"'.format(ext_id)) - """ - if not filter: - LOG.error('a filter is required') - return None - shared_network_resource = \ - self.session.user.shared_network_resources.get_first(filter=filter) - if not shared_network_resource: - LOG.error('could not fetch the shared network resource ' - 'matching the filter "{}"' - .format(filter)) - return shared_network_resource - - @recreate_session_on_timeout - def get_virtualip(self, vport, filter): - """ get_virtualip - @params: vport object - virtualip filter following vspk filter structure - @return: virtualip object - @Example: - self.vsd.get_virtualip(vport=vport, - filter='externalID == "{}"'.format(ext_id)) - """ - if not isinstance(vport, self.vspk.NUVPort): - LOG.error('a vport is required') - return None - if not filter: - LOG.error('a filter is required') - return None - virtualip = vport.virtual_ips.get_first(filter=filter) - - if not virtualip: - LOG.error('could not fetch the virtualip matching the filter "{}"' - .format(filter)) - return virtualip diff --git a/test/integration/plugins/nuagevsp/nuageTestCase.py b/test/integration/plugins/nuagevsp/nuageTestCase.py deleted file mode 100644 index 7c9d424caaa..00000000000 --- a/test/integration/plugins/nuagevsp/nuageTestCase.py +++ /dev/null @@ -1,1546 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Custom base class for Nuage VSP SDN plugin specific Marvin tests -""" -import functools -import importlib -import logging -import socket - -import sys -import time -# Import Local Modules -from bambou.nurest_object import NURESTObject -from marvin.cloudstackAPI import (restartVPC, - enableNuageUnderlayVlanIpRange, - disableNuageUnderlayVlanIpRange, - listNuageUnderlayVlanIpRanges) -from marvin.cloudstackTestCase import cloudstackTestCase, unittest -from marvin.lib.base import (Domain, - EgressFireWallRule, - FireWallRule, - Host, - Hypervisor, - Network, - NetworkACL, - NetworkACLList, - NetworkOffering, - NetworkServiceProvider, - Nuage, - PhysicalNetwork, - PublicIPAddress, - Router, - ServiceOffering, - StaticNATRule, - ResourceDetails, - VirtualMachine, - VPC, - VpcOffering, - Zone) -from marvin.lib.common import (get_domain, - get_template, - get_zone) -# Import System Modules -from retry import retry - -from nuage_test_data import nuage_test_data - - -class needscleanup(object): - """ - Decorator to add the returned object automatically to the cleanup list. - """ - def __init__(self, method): - self.method = method - - def __get__(self, obj=None, objtype=None): - @functools.wraps(self.method) - def _wrapper(*args, **kwargs): - wants_cleanup = True - if "cleanup" in kwargs: - wants_cleanup = kwargs["cleanup"] - del kwargs["cleanup"] - if obj is not None: - result = self.method(obj, *args, **kwargs) - if hasattr(obj, 'cleanup'): - cleanup = obj.cleanup - else: - result = self.method(objtype, *args, **kwargs) - cleanup = objtype._cleanup - if wants_cleanup: - cleanup.append(result) - return result - return _wrapper - - -class nuageTestCase(cloudstackTestCase): - - @classmethod - def setUpClass(cls): - cls.debug("setUpClass nuageTestCase") - cls._cleanup = [] - - # We want to fail quicker, if it's a failure - socket.setdefaulttimeout(60) - - # Get test client and test data - cls.test_client = super(nuageTestCase, cls).getClsTestClient() - cls.api_client = cls.test_client.getApiClient() - cls.db_client = cls.test_client.getDbConnection() - cls.test_data = cls.test_client.getParsedTestDataConfig() - cls.test_data.update(nuage_test_data) - - # Get Zones and Domains - cls.zones = Zone.list(cls.api_client) - cls.domains = Domain.list(cls.api_client, listall=True) - cls.domain = get_domain(cls.api_client) - cls.root_domain = get_domain(cls.api_client, domain_name="ROOT") - - # Get Zone details - cls.getZoneDetails() - - # Configure VSD sessions - cls.configureVSDSessions() - - # Create service offering - cls.service_offering = ServiceOffering.create( - cls.api_client, - cls.test_data["service_offering"] - ) - cls._cleanup.append(cls.service_offering) - cls.debug("setUpClass nuageTestCase [DONE]") - - @classmethod - def getZoneDetails(cls, zone=None): - """Get Zone details""" - cls.zone = zone if zone else get_zone( - cls.api_client, - zone_name=cls.test_client.getZoneForTests() - ) - cls.template = get_template(cls.api_client, - cls.zone.id, - cls.test_data["ostype"] - ) - cls.test_data["virtual_machine"]["zoneid"] = cls.zone.id - cls.test_data["virtual_machine"]["template"] = cls.template.id - - # Check if the host hypervisor type is simulator - hypervisors = Hypervisor.list(cls.api_client, zoneid=cls.zone.id) - assert hypervisors is not None and len(hypervisors) > 0, \ - "Expected at least one hypervisor" - cls.isSimulator = any(map(lambda h: h.name == "Simulator", - hypervisors)) - - # Get configured Nuage VSP device details - try: - physical_networks = PhysicalNetwork.list( - cls.api_client, - zoneid=cls.zone.id - ) - - cls.vsp_physical_network = next(pn for pn in physical_networks - if pn.isolationmethods == "VSP") - cls.nuage_vsp_device = Nuage.list( - cls.api_client, - physicalnetworkid=cls.vsp_physical_network.id)[0] - - # Get username and password from the Marvin config file, - # as they are not returned by the API. - config_nuage_device = next(device for zone in cls.config.zones - if zone.name == cls.zone.name - for physnet in zone.physical_networks - if "VSP" in physnet.isolationmethods - for provider in physnet.providers - if provider.name == "NuageVsp" - for device in provider.devices) - - cls.nuage_vsp_device.username = config_nuage_device.username - cls.nuage_vsp_device.password = config_nuage_device.password - cls.cms_id = cls.nuage_vsp_device.cmsid - except Exception as e: - cls.tearDownClass() - raise unittest.SkipTest("Warning: Could not get configured " - "Nuage VSP device details - %s" % e) - - # Get data center Internet connectivity information from the Marvin - # config file, which is required to perform Internet connectivity and - # traffic tests from the guest VMs. - cls.dcInternetConnectivityInfo() - - # Check if the configured Nuage VSP SDN platform infrastructure - # supports underlay networking - cmd = listNuageUnderlayVlanIpRanges.listNuageUnderlayVlanIpRangesCmd() - cmd.zoneid = cls.zone.id - cmd.underlay = True - cls.isNuageInfraUnderlay = isinstance( - cls.api_client.listNuageUnderlayVlanIpRanges(cmd), list) - return - - @classmethod - def dcInternetConnectivityInfo(cls): - cls.isInternetConnectivityAvailable = False - cls.http_proxy = None - cls.https_proxy = None - zone = next(zone for zone in cls.config.zones - if zone.name == cls.zone.name) - - cls.isInternetConnectivityAvailable = \ - hasattr(zone, "dcInternetConnectivityInfo") \ - and hasattr(zone.dcInternetConnectivityInfo, "available") \ - and zone.dcInternetConnectivityInfo.available == "true" - - if cls.isInternetConnectivityAvailable: - if zone.dcInternetConnectivityInfo.httpProxy: - cls.http_proxy = zone.dcInternetConnectivityInfo.httpProxy - if zone.dcInternetConnectivityInfo.httpsProxy: - cls.https_proxy = zone.dcInternetConnectivityInfo.httpsProxy - - @classmethod - def configureVSDSessions(cls): - # VSD is a programmable policy and analytics engine of Nuage VSP SDN - # platform; vspk is a Python SDK for Nuage VSP's VSD; libVSD is a - # library that wraps vspk package - try: - vspk_module = "vspk." + cls.nuage_vsp_device.apiversion - cls.vsdk = importlib.import_module(vspk_module) - except ImportError as e: - try: - vspk_module = "vspk.vsdk." + cls.nuage_vsp_device.apiversion - cls.vsdk = importlib.import_module(vspk_module) - except ImportError: - cls.tearDownClass() - raise unittest.SkipTest("Warning: vspk import failure" - " - %s" % e) - - try: - from libVSD import ApiClient, VSDHelpers - except ImportError as e: - cls.tearDownClass() - raise unittest.SkipTest("Warning: libVSD package import failure " - "- %s" % e) - - # Configure VSD session - cls._session = cls.vsdk.NUVSDSession( - username=cls.nuage_vsp_device.username, - password=cls.nuage_vsp_device.password, - enterprise="csp", - api_url="https://%s:%d" % (cls.nuage_vsp_device.hostname, - cls.nuage_vsp_device.port) - ) - cls._session.start() - - # Configure libVSD session - root = logging.getLogger() - log_handler = logging.StreamHandler(sys.stdout) - formatter = logging.Formatter('%(asctime)s - %(name)s - ' - '%(levelname)s - %(message)s') - log_handler.setFormatter(formatter) - root.addHandler(log_handler) - vsd_info = cls.nuage_vsp_device.__dict__ - - cls.debug("Nuage VSP device (VSD) details - %s" % vsd_info) - vsd_api_client = ApiClient( - address=cls.nuage_vsp_device.hostname, - user=cls.nuage_vsp_device.username, - password=cls.nuage_vsp_device.password, - version=cls.nuage_vsp_device.apiversion[1] + - "." + cls.nuage_vsp_device.apiversion[3] - ) - vsd_api_client.new_session() - cls.vsd = VSDHelpers(vsd_api_client) - return - - def setUp(self): - self.cleanup = [] - return - - @classmethod - def tearDownClass(cls): - # Cleanup resources used - cls.debug("Cleaning up the class resources") - for obj in reversed(cls._cleanup): - try: - if isinstance(obj, VirtualMachine): - obj.delete(cls.api_client, expunge=True) - else: - obj.delete(cls.api_client) - except Exception as e: - cls.error("Failed to cleanup %s, got %s" % (obj, e)) - # cleanup_resources(cls.api_client, cls._cleanup) - cls._cleanup = [] - cls.debug("Cleanup class complete!") - return - - def tearDown(self): - # Cleanup resources used - self.debug("Cleaning up the test resources") - for obj in reversed(self.cleanup): - try: - if isinstance(obj, VirtualMachine): - obj.delete(self.api_client, expunge=True) - elif isinstance(obj, NURESTObject): - obj.delete() - else: - obj.delete(self.api_client) - except Exception as e: - self.error("Failed to cleanup %s, got %s" % (obj, e)) - # cleanup_resources(self.api_client, self.cleanup) - self.cleanup = [] - self.debug("Cleanup test complete!") - return - - def enable_NuageUnderlayPublicIpRange(self, vlanid): - """Enables/configures underlay networking - for the given public IP range in Nuage VSP - - :param vlanid: Vlan ID - :type vlanid: marvin.lib.base.PublicIpRange.vlan - """ - cmd = enableNuageUnderlayVlanIpRange. \ - enableNuageUnderlayVlanIpRangeCmd() - cmd.id = vlanid - self.api_client.enableNuageUnderlayVlanIpRange(cmd) - - def disable_NuageUnderlayPublicIpRange(self, public_ip_range): - """Disables underlay networking - for the given public IP range in Nuage VSP - - :param public_ip_range: Public IP range - :type public_ip_range: marvin.lib.base.PublicIpRange - """ - cmd = disableNuageUnderlayVlanIpRange. \ - disableNuageUnderlayVlanIpRangeCmd() - cmd.id = public_ip_range.vlan.id - self.api_client.enableNuageUnderlayVlanIpRange(cmd) - - # list_NuageUnderlayPublicIpRanges - Lists underlay networking - # enabled/configured public IP ranges in Nuage VSP - def list_NuageUnderlayPublicIpRanges(self, public_ip_range=None): - """Lists Vlan IP ranges that have the nuage underlay flag set to True - - :param public_ip_range: Optionally filter by Public IP range - :type public_ip_range: marvin.lib.base.PublicIpRange - """ - cmd = listNuageUnderlayVlanIpRanges.listNuageUnderlayVlanIpRangesCmd() - if public_ip_range: - cmd.id = public_ip_range.vlan.id - cmd.underlay = True - return self.api_client.listNuageUnderlayVlanIpRanges(cmd) - - # create_VpcOffering - Creates VPC offering - @needscleanup - def create_VpcOffering(cls, vpc_offering, suffix=None): - """Creates VPC offering""" - cls.debug("Creating VPC offering") - if suffix: - vpc_offering["name"] = "VPC_OFF-" + str(suffix) - vpc_off = VpcOffering.create(cls.api_client, - vpc_offering - ) - # Enable VPC offering - vpc_off.update(cls.api_client, state="Enabled") - cls.debug("Created and Enabled VPC offering") - return vpc_off - - # create_Vpc - Creates VPC with the given VPC offering - @needscleanup - def create_vpc(cls, vpc_offering, cidr='10.1.0.0/16', testdata=None, - account=None, networkDomain=None): - """Creates VPC with the given VPC offering - :param vpc_offering: vpc offering - :type vpc_offering: VpcOffering - :param cidr: CIDR - :param testdata: vpc details - :param account: Account which will be the owner. - :param networkDomain: - :return: created VPC - :rtype: VPC - """ - if not account: - account = cls.account - cls.debug("Creating a VPC in the account - %s" % account.name) - if not testdata: - testdata = cls.test_data["vpc"] - testdata["name"] = "TestVPC-" + cidr + "-" + str(vpc_offering.name) - testdata["displaytext"] = "Test VPC" - testdata["cidr"] = cidr - vpc = VPC.create(cls.api_client, - testdata, - vpcofferingid=vpc_offering.id, - zoneid=cls.zone.id, - account=account.name, - domainid=account.domainid, - networkDomain=networkDomain - ) - cls.debug("Created VPC with ID - %s" % vpc.id) - return vpc - - # restart_Vpc - Restarts the given VPC with/without cleanup - def restart_Vpc(self, vpc, cleanup=False): - """Restarts the given VPC with/without cleanup - :param vpc: vpc to restart - :type vpc: VPC - :param cleanup: whether to restart with cleanup - :type cleanup: bool - """ - self.debug("Restarting VPC with ID - %s" % vpc.id) - cmd = restartVPC.restartVPCCmd() - cmd.id = vpc.id - cmd.cleanup = cleanup - cmd.makeredundant = False - self.api_client.restartVPC(cmd) - self.debug("Restarted VPC with ID - %s" % vpc.id) - - # create_NetworkOffering - Creates Network offering - @needscleanup - def create_NetworkOffering(cls, net_offering, suffix=None, - conserve_mode=False): - """Creates a Network Offering - :param net_offering: offering details - :type net_offering: object - :param suffix: string to append to the offering name - :param conserve_mode: - :return: created Network Offering - :rtype: NetworkOffering - """ - cls.debug("Creating Network offering") - if suffix: - net_offering["name"] = "NET_OFF-" + str(suffix) - nw_off = NetworkOffering.create(cls.api_client, - net_offering, - conservemode=conserve_mode - ) - # Enable Network offering - nw_off.update(cls.api_client, state="Enabled") - cls.debug("Created and Enabled Network offering") - return nw_off - - # create_Network - Creates network with the given Network offering - @needscleanup - def create_Network(cls, nw_off, gateway="10.1.1.1", - netmask="255.255.255.0", vpc=None, acl_list=None, - testdata=None, account=None, vlan=None, - externalid=None): - """Creates Network with the given Network offering - :param nw_off: Network offering - :type nw_off: NetworkOffering - :param gateway: gateway - :param netmask: netmask - :param vpc: in case of a VPC tier, the parent VPC - :type vpc: VPC - :param acl_list: in case of a VPC tier, the acl list - :type acl_list: NetworkACLList - :param testdata: Network details - :param account: Account which will be the owner. - :param vlan: vlan id - :param externalid: external id, in case of VSD managed networks - - :return: created Network - :rtype: Network - """ - if not account: - account = cls.account - cls.debug("Creating a network in the account - %s" % account.name) - if not testdata: - testdata = cls.test_data["network"] - testdata["name"] = "TestNet-" + gateway + "-" + str(nw_off.name) - testdata["displaytext"] = "Test Network" - testdata["gateway"] = gateway - testdata["netmask"] = netmask - network = Network.create(cls.api_client, - testdata, - accountid=account.name, - domainid=account.domainid, - networkofferingid=nw_off.id, - zoneid=cls.zone.id, - vlan=vlan, - externalid=externalid, - vpcid=vpc.id if vpc else cls.vpc.id - if hasattr(cls, "vpc") and cls.vpc else None, - aclid=acl_list.id if acl_list else None - ) - cls.debug("Created network with ID - %s" % network.id) - return network - - # upgrade_Network - Upgrades the given network - def upgrade_Network(self, nw_off, network, forced=True): - if not hasattr(nw_off, "id"): - nw_off = self.create_NetworkOffering(nw_off) - self.debug("Updating Network with ID - %s" % network.id) - updated_network =\ - network.update(self.api_client, - networkofferingid=nw_off.id, - changecidr=False, - forced=forced - ) - self.debug("Updated network with ID - %s" % network.id) - return updated_network - - # delete_Network - Deletes the given network - def delete_Network(self, network): - self.debug("Deleting Network with ID - %s" % network.id) - network.delete(self.api_client) - if network in self.cleanup: - self.cleanup.remove(network) - self.debug("Deleted Network with ID - %s" % network.id) - - # create_VM - Creates VM in the given network(s) - @needscleanup - def create_VM(cls, network_list, host_id=None, start_vm=True, - testdata=None, account=None, keypair=None): - network_ids = [] - if isinstance(network_list, list): - for network in network_list: - network_ids.append(str(network.id)) - else: - network_ids.append(str(network_list.id)) - if not account: - account = cls.account - cls.debug("Creating VM in network(s) with ID(s) - %s in the " - "account - %s" % (network_ids, account.name)) - if not testdata: - testdata = cls.test_data["virtual_machine"] - vm = VirtualMachine.create(cls.api_client, - testdata, - accountid=account.name, - domainid=account.domainid, - serviceofferingid=cls.service_offering.id, - templateid=cls.template.id, - zoneid=cls.zone.id, - networkids=network_ids, - startvm=start_vm, - hostid=host_id, - keypair=keypair - ) - cls.debug("Created VM with ID - %s in network(s) with ID(s) - %s" - % (vm.id, network_ids)) - return vm - - # nic_operation_VM - Performs NIC operations such as add, remove, and - # update default NIC in the given VM and network - def nic_operation_VM(self, vm, network, operation="add"): - self.debug("Performing %s NIC operation in VM with ID - %s and " - "network with ID - %s" % (operation, vm.id, network.id)) - if operation is "add": - vm.add_nic(self.api_client, network.id) - self.debug("Added NIC in VM with ID - %s and network with ID - %s" - % (vm.id, network.id)) - vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - for nic in vm_info.nic: - if nic.networkid == network.id: - nic_id = nic.id - if operation is "update": - vm.update_default_nic(self.api_client, nic_id) - self.debug("Updated default NIC to NIC with ID - %s in VM with ID " - "- %s and network with ID - %s" % - (nic_id, vm.id, network.id)) - if operation is "remove": - vm.remove_nic(self.api_client, nic_id) - self.debug("Removed NIC with ID - %s in VM with ID - %s and " - "network with ID - %s" % (nic_id, vm.id, network.id)) - - # migrate_VM - Migrates VM to another host, if available - def migrate_VM(self, vm): - self.debug("Checking if a host is available for migration...") - hosts = Host.listForMigration(self.api_client, virtualmachineid=vm.id) - if hosts: - self.assertEqual(isinstance(hosts, list), True, - "List hosts should return a valid list" - ) - host = hosts[0] - self.debug("Migrating VM with ID: " - "%s to Host: %s" % (vm.id, host.id)) - try: - vm.migrate(self.api_client, hostid=host.id) - except Exception as e: - self.fail("Failed to migrate instance, %s" % e) - self.debug("Migrated VM with ID: " - "%s to Host: %s" % (vm.id, host.id)) - else: - self.debug("No host available for migration. " - "Test requires at-least 2 hosts") - - # delete_VM - Deletes the given VM - def delete_VM(self, vm, expunge=True): - self.debug("Deleting VM with ID - %s" % vm.id) - vm.delete(self.api_client, expunge=expunge) - if vm in self.cleanup: - self.cleanup.remove(vm) - self.debug("Deleted VM with ID - %s" % vm.id) - - # get_Router - Returns router for the given network - def get_Router(self, network): - self.debug("Finding the virtual router for network with ID - %s" % - network.id) - routers = Router.list(self.api_client, - networkid=network.id, - listall=True - ) - self.assertEqual(isinstance(routers, list), True, - "List routers should return a valid virtual router " - "for network" - ) - return routers[0] - - # acquire_PublicIPAddress - Acquires public IP address for the given - # network/VPC - def acquire_PublicIPAddress(self, network, vpc=None, account=None): - if not account: - account = self.account - self.debug("Associating public IP for network with ID - %s in the " - "account - %s" % (network.id, account.name)) - public_ip = PublicIPAddress.create(self.api_client, - accountid=account.name, - domainid=account.domainid, - zoneid=self.zone.id, - networkid=network.id - if vpc is None else None, - vpcid=vpc.id if vpc else self.vpc.id - if hasattr(self, "vpc") and self.vpc - else None - ) - self.debug("Associated public IP address - %s with network with ID - " - "%s" % (public_ip.ipaddress.ipaddress, network.id)) - return public_ip - - # create_StaticNatRule_For_VM - Creates Static NAT rule on the given - # public IP for the given VM in the given network - def create_StaticNatRule_For_VM(self, vm, public_ip, network, - vmguestip=None): - self.debug("Enabling Static NAT rule on public IP - %s for VM with ID " - "- %s in network with ID - %s" % - (public_ip.ipaddress.ipaddress, vm.id, network.id)) - static_nat_rule = StaticNATRule.enable( - self.api_client, - ipaddressid=public_ip.ipaddress.id, - virtualmachineid=vm.id, - networkid=network.id, - vmguestip=vmguestip - ) - self.debug("Static NAT rule enabled on public IP - %s for VM with ID " - "- %s in network with ID - %s" % - (public_ip.ipaddress.ipaddress, vm.id, network.id)) - return static_nat_rule - - # delete_StaticNatRule_For_VM - Deletes Static NAT rule on the given - # public IP - def delete_StaticNatRule_For_VM(self, public_ip): - self.debug("Disabling Static NAT rule on public IP - %s" % - public_ip.ipaddress.ipaddress) - StaticNATRule.disable(self.api_client, - ipaddressid=public_ip.ipaddress.id - ) - self.debug("Static NAT rule disabled on public IP - %s" % - public_ip.ipaddress.ipaddress) - - # create_FirewallRule - Creates (Ingress) Firewall rule on the given - # Static NAT rule enabled public IP for Isolated networks - def create_FirewallRule(self, public_ip, rule=None): - if not rule: - rule = self.test_data["ingress_rule"] - self.debug("Adding an (Ingress) Firewall rule to make Guest VMs " - "accessible through Static NAT rule - %s" % rule) - return FireWallRule.create(self.api_client, - ipaddressid=public_ip.ipaddress.id, - protocol=rule["protocol"], - cidrlist=rule["cidrlist"], - startport=rule["startport"], - endport=rule["endport"] - ) - - # create_EgressFirewallRule - Creates Egress Firewall rule in the given - # Isolated network - def create_EgressFirewallRule(self, network, rule): - self.debug("Adding an Egress Firewall rule to allow/deny outgoing " - "traffic from Guest VMs - %s" % rule) - return EgressFireWallRule.create(self.api_client, - networkid=network.id, - protocol=rule["protocol"], - cidrlist=rule["cidrlist"], - startport=rule["startport"], - endport=rule["endport"] - ) - - # create_NetworkAclList - Creates network ACL list in the given VPC - def create_NetworkAclList(self, name, description, vpc): - self.debug("Adding NetworkACL list in VPC with ID - %s" % vpc.id) - return NetworkACLList.create(self.api_client, - services={}, - name=name, - description=description, - vpcid=vpc.id - ) - - # create_NetworkAclRule - Creates Ingress/Egress Network ACL rule in the - # given VPC network/acl list - def create_NetworkAclRule(self, rule, traffic_type="Ingress", network=None, - acl_list=None): - self.debug("Adding NetworkACL rule - %s" % rule) - if acl_list: - return NetworkACL.create(self.api_client, - networkid=network.id if network else None, - services=rule, - traffictype=traffic_type, - aclid=acl_list.id - ) - else: - return NetworkACL.create(self.api_client, - networkid=network.id if network else None, - services=rule, - traffictype=traffic_type - ) - - def ssh_into_VM(self, vm, public_ip, reconnect=True, negative_test=False, - keypair=None): - """Creates a SSH connection to the VM - - :returns: the SSH connection - :rtype: marvin.sshClient.SshClient - """ - if self.isSimulator: - self.debug("Simulator Environment: Skipping ssh into VM") - return - - self.debug("SSH into VM with ID - %s on public IP address - %s" % - (vm.id, public_ip.ipaddress.ipaddress)) - tries = 1 if negative_test else 3 - - @retry(tries=tries) - def retry_ssh(): - ssh_client = vm.get_ssh_client( - ipaddress=public_ip.ipaddress.ipaddress, - reconnect=reconnect, - retries=3 if negative_test else 30, - keyPairFileLocation=keypair.private_key_file - if keypair else None - ) - self.debug("Successful to SSH into VM with ID - %s on " - "public IP address - %s" % - (vm.id, public_ip.ipaddress.ipaddress)) - return ssh_client - - return retry_ssh() - - def execute_cmd(self, ssh_client, cmd): - """Executes the given command on the given ssh client - - :param ssh_client: SSH session to the remote machine - :type ssh_client: marvin.SshClient - :param cmd: Command to run on the remote machine - :type cmd: str - :return: command output - """ - self.debug("SSH client executing command - %s" % cmd) - ret_data = "" - out_list = ssh_client.execute(cmd) - if out_list is not None: - ret_data = ' '.join(map(str, out_list)).strip() - self.debug("SSH client executed command result - %s" % ret_data) - else: - self.debug("SSH client executed command result is None") - return ret_data - - def wget_from_server(self, public_ip, port=80, file_name="index.html", - disable_system_proxies=True): - """Fetches file with the given file name from a web server - - :param public_ip: HTTP server IP - :type public_ip: PublicIPAddress - :param port: HTTP server port - :param file_name: URL path - :param disable_system_proxies: whether to bypass system proxy - :return: filename, headers - """ - import urllib - if disable_system_proxies: - urllib.getproxies = lambda: {} - self.debug("wget file - %s from a http web server listening on " - "public IP address - %s and port - %s" % - (file_name, public_ip.ipaddress.ipaddress, port)) - filename, headers = urllib.urlretrieve( - "http://%s:%s/%s" % - (public_ip.ipaddress.ipaddress, port, file_name), - filename=file_name - ) - self.debug("Successful to wget file - %s from a http web server " - "listening on public IP address - %s and port - %s" % - (file_name, public_ip.ipaddress.ipaddress, port)) - return filename, headers - - def validate_NetworkServiceProvider(self, provider_name, state=None): - """Validates the Network Service Provider in the Nuage VSP Physical - Network. - - :param provider_name Provider name - :param state Expected state - :raises AssertionError when provider isn't found, - or has an incorrect state. - """ - self.debug("Validating the creation and state of Network Service " - "Provider - %s" % provider_name) - providers = NetworkServiceProvider.list( - self.api_client, - name=provider_name, - physicalnetworkid=self.vsp_physical_network.id - ) - self.assertIsInstance(providers, list, - "List Network Service Provider should return a " - "valid list") - self.assertEqual(provider_name, providers[0].name, - "Name of the Network Service Provider should match " - "with the returned list data" - ) - if state: - self.assertEqual(providers[0].state, state, - "Network Service Provider state should be '%s'" % - state - ) - self.debug("Successfully validated the creation and state of Network " - "Service Provider - %s" % provider_name) - - def validate_VpcOffering(self, vpc_offering, state=None): - """Validates the VPC offering - - Fetches the Vpc offering by id, - verifies that the name is correct, - and if en expected state is given, verifies that it is correct. - - :param vpc_offering: cs object - :type vpc_offering: VpcOffering - :param state: optional state - :raise AssertionError when VPC offering isn't found, - or has an incorrect state. - """ - self.debug("Validating the creation and state of VPC offering - %s" % - vpc_offering.name) - vpc_offs = VpcOffering.list(self.api_client, - id=vpc_offering.id - ) - self.assertEqual(isinstance(vpc_offs, list), True, - "List VPC offering should return a valid list" - ) - self.assertEqual(vpc_offering.name, vpc_offs[0].name, - "Name of the VPC offering should match with the " - "returned list data" - ) - if state: - self.assertEqual(vpc_offs[0].state, state, - "VPC offering state should be '%s'" % state - ) - self.debug("Successfully validated the creation and state of VPC " - "offering - %s" % vpc_offering.name) - - def validate_vpc(self, vpc, state=None): - """Validates the VPC - - Fetches the vpc by id, - verifies that the name is correct, - and if en expected state is given, verifies that it is correct. - - :param vpc: cs object - :type vpc: Vpc - :param state: optional state - :raise AssertionError when vpc isn't found, - or has an incorrect state.""" - self.debug("Validating the creation and state of VPC - %s" % vpc.name) - vpcs = VPC.list(self.api_client, - id=vpc.id - ) - self.assertEqual(isinstance(vpcs, list), True, - "List VPC should return a valid list" - ) - self.assertEqual(vpc.name, vpcs[0].name, - "Name of the VPC should match with the returned " - "list data" - ) - if state: - self.assertEqual(vpcs[0].state, state, - "VPC state should be '%s'" % state - ) - self.debug("Successfully validated the creation and state of VPC - %s" - % vpc.name) - - def validate_NetworkOffering(self, net_offering, state=None): - """Validates the Network offering - - Fetches the Network offering by id, - verifies that the name is correct, - and if en expected state is given, verifies that it is correct. - - :param net_offering: cs object - :type net_offering: NetworkOffering - :param state: optional state - :raise AssertionError when network offering isn't found, - or has an incorrect state.""" - - self.debug("Validating the creation and state of Network offering - %s" - % net_offering.name) - net_offs = NetworkOffering.list(self.api_client, - id=net_offering.id - ) - self.assertEqual(isinstance(net_offs, list), True, - "List Network offering should return a valid list" - ) - self.assertEqual(net_offering.name, net_offs[0].name, - "Name of the Network offering should match with the " - "returned list data" - ) - if state: - self.assertEqual(net_offs[0].state, state, - "Network offering state should be '%s'" % state - ) - self.debug("Successfully validated the creation and state of Network " - "offering - %s" % net_offering.name) - - def validate_Network(self, network, state=None): - """Validates the network - - Fetches the Network by id, - verifies that the name is correct, - and if en expected state is given, verifies that it is correct. - - :param network: cs object - :type network: Network - :param state: optional state - :raise AssertionError when network isn't found, - or has an incorrect state.""" - self.debug("Validating the creation and state of Network - %s" % - network.name) - networks = Network.list(self.api_client, - id=network.id - ) - self.assertEqual(isinstance(networks, list), True, - "List network should return a valid list" - ) - self.assertEqual(network.name, networks[0].name, - "Name of the network should match with with the " - "returned list data" - ) - if state: - self.assertEqual(networks[0].state, state, - "Network state should be '%s'" % state - ) - self.debug("Successfully validated the creation and state of Network " - "- %s" % network.name) - - def check_VM_state(self, vm, state=None): - """Validates the VM state - :param vm: cs object - :type vm: VirtualMachine - :param state: optional state - :raise AssertionError when vm isn't found, - or has an incorrect state.""" - - self.debug("Validating the deployment and state of VM - %s" % vm.name) - vms = VirtualMachine.list(self.api_client, - id=vm.id, - listall=True - ) - self.assertEqual(isinstance(vms, list), True, - "List virtual machine should return a valid list" - ) - if state: - self.assertEqual(vms[0].state, state, - "Virtual machine is not in the expected state" - ) - self.debug("Successfully validated the deployment and state of VM - %s" - % vm.name) - - def check_Router_state(self, router=None, network=None, state=None): - """Validates the Router state - :param router: cs object - :type router: Router - :param state: optional state - :raise AssertionError when router isn't found, - or has an incorrect state.""" - - if router: - self.debug("Validating the deployment and state of Router - %s" % - router.name) - routers = Router.list(self.api_client, id=router.id, - listall=True) - elif network: - routers = Router.list(self.api_client, networkid=network.id, - listall=True) - else: - raise AttributeError("Either router or network " - "has to be specified") - self.assertEqual(isinstance(routers, list), True, - "List router should return a valid list" - ) - if state: - self.assertEqual(routers[0].state, state, - "Virtual router is not in the expected state" - ) - self.debug("Successfully validated the deployment and state of Router " - "- %s" % routers[0].name) - - return routers[0] - - def validate_PublicIPAddress(self, public_ip, network, static_nat=False, - vm=None): - """Validates the Public IP Address - :param public_ip: cs object - :type public_ip: PublicIPAddress - :param network: cs object - :type network: Network - :param static_nat: optional state - :type static_nat: bool - :param vm: Virtual machine the public ip should be forwarding to. - :type vm: VirtualMachine - :raise AssertionError when Public IP isn't found, isn't Allocated - or has an incorrect ip address.""" - - self.debug("Validating the assignment and state of public IP address " - "- %s" % public_ip.ipaddress.ipaddress) - public_ips = PublicIPAddress.list(self.api_client, - id=public_ip.ipaddress.id, - networkid=network.id, - isstaticnat=static_nat, - listall=True - ) - self.assertEqual(isinstance(public_ips, list), True, - "List public IP for network should return a " - "valid list" - ) - self.assertEqual(public_ips[0].ipaddress, - public_ip.ipaddress.ipaddress, - "List public IP for network should list the assigned " - "public IP address" - ) - self.assertEqual(public_ips[0].state, "Allocated", - "Assigned public IP is not in the allocated state" - ) - if static_nat and vm: - self.assertEqual(public_ips[0].virtualmachineid, vm.id, - "Static NAT rule is not enabled for the VM on " - "the assigned public IP" - ) - self.debug("Successfully validated the assignment and state of public " - "IP address - %s" % public_ip.ipaddress.ipaddress) - - def verify_VRWithoutPublicIPNIC(self, vr): - """Verifies that the given Virtual Router has no public IP nor NIC - :param vr: cs object - :type vr: Router - :raise AssertionError when router isn't found, - has an incorrect name, has a public ip for source nat - or has a nic in the public network.""" - - self.debug("Verifies that there is no public IP and NIC in Virtual " - "Router - %s" % vr.name) - self.assertEqual(vr.publicip, None, - "Virtual router has public IP" - ) - for nic in vr.nic: - self.assertNotEqual(nic.traffictype, "Public", - "Virtual router has public NIC" - ) - self.debug("Successfully verified that there is no public IP and NIC " - "in Virtual Router - %s" % vr.name) - - def verify_vpc_has_no_src_nat(self, vpc, account=None): - """Verifies that the given Vpc has no public IP nor NIC - :param vpc: cs object - :type vpc: VPC - :raise AssertionError when the VPC has a public ip for source nat. - """ - if not account: - account = self.account - self.debug("Verify that there is no src NAT ip address " - "allocated for the vpc") - src_nat_ip = PublicIPAddress.list( - self.api_client, - vpcid=vpc.id, - issourcenat=True, - account=account.name) - self.assertEqual(src_nat_ip, None, "VPC has a source NAT ip!") - - # VSD verifications; VSD is a programmable policy and analytics engine of - # Nuage VSP SDN platform - - def get_externalID_filter(self, object_id): - """Builds a VSD filter to search by external ID - - :param object_id: Cloudstack UUID - :type object_id: str - :rtype: str - :return: filter - """ - ext_id = object_id + "@" + self.cms_id - return self.vsd.set_externalID_filter(ext_id) - - # fetch_by_externalID - Returns VSD object with the given external ID - def fetch_by_externalID(self, fetcher, *cs_objects): - """ Fetches a child object by external id using the given fetcher, and - uuids of the given cloudstack objects. - E.G. - - fetch_by_external_id(vsdk.NUSubnet - (id="954de425-b860-410b-be09-c560e7dbb474").vms, cs_vm) - - fetch_by_external_id - (session.user.floating_ips, cs_network, cs_public_ip) - :param fetcher: VSPK Fetcher to use to find the child entity - :param cs_objects: Cloudstack objects to take the UUID from. - :return: the VSPK object having the correct externalID - """ - object_id = ":".join([o.id for o in cs_objects]) - ext_id = object_id + "@" + self.cms_id - return fetcher.get_first(filter="externalID is '%s'" % ext_id) - - def fetch_vsd_objects(self, domain_id, network, vpc=None): - vsd_enterprise = self.vsd.get_enterprise( - filter=self.get_externalID_filter(domain_id)) - - ext_network_filter = self.get_externalID_filter(vpc.id) if vpc \ - else self.get_externalID_filter(network.id) - vsd_domain = self.vsd.get_domain(filter=ext_network_filter) - vsd_zone = self.vsd.get_zone(filter=ext_network_filter) - vsd_subnet = self.vsd.get_subnet( - filter=self.get_externalID_filter(network.id)) - - return [ - ext_network_filter, - vsd_enterprise, - vsd_domain, - vsd_zone, - vsd_subnet - ] - - # verify_vsd_network - Verifies the given CloudStack domain and network/VPC - # against the corresponding installed enterprise, domain, zone, and subnet - # in VSD - def verify_vsd_network(self, domain_id, network, vpc=None, - domain_template_name=None): - self.debug("Verifying the creation and state of Network - %s in VSD" % - network.name) - - [ - ext_network_filter, - vsd_enterprise, - vsd_domain, - vsd_zone, - vsd_subnet - ] = self.fetch_vsd_objects(domain_id, network, vpc) - - self.assertEqual(vsd_enterprise.name, domain_id, - "VSD enterprise name should match CloudStack domain " - "uuid" - ) - if domain_template_name: - vsd_domain_template = self.vsd.get_domain_template( - enterprise=vsd_enterprise, - filter=self.vsd.set_name_filter(domain_template_name)) - else: - vsd_domain_template = self.vsd.get_domain_template( - enterprise=vsd_enterprise, - filter=ext_network_filter) - self.assertEqual(vsd_domain.template_id, vsd_domain_template.id, - "VSD domain should be instantiated from appropriate " - "domain template" - ) - if vpc: - self.assertEqual(vsd_domain.description, "VPC_" + vpc.name, - "VSD domain description should match VPC name in " - "CloudStack" - ) - self.assertEqual(vsd_zone.description, "VPC_" + vpc.name, - "VSD zone description should match VPC name in " - "CloudStack" - ) - else: - self.assertEqual(vsd_domain.description, network.name, - "VSD domain description should match network " - "name in CloudStack" - ) - self.assertEqual(vsd_zone.description, network.name, - "VSD zone description should match network name " - "in CloudStack" - ) - self.assertEqual(vsd_subnet.description, network.name, - "VSD subnet description should match network name in " - "CloudStack" - ) - self.debug("Successfully verified the creation and state of Network " - "- %s in VSD" % network.name) - - def verify_vsd_network_not_present(self, network, vpc=None): - self.debug("Verifying the creation and state of Network - %s in VSD" % - network.name) - ext_network_filter = self.get_externalID_filter(vpc.id) if vpc \ - else self.get_externalID_filter(network.id) - - vsd_domain = self.vsd.get_domain(filter=ext_network_filter) - if vsd_domain is None: - return - - vsd_zone = self.vsd.get_zone(filter=ext_network_filter) - if vsd_zone is None: - return - vsd_subnet = self.vsd.get_subnet( - filter=self.get_externalID_filter(network.id)) - self.assertEqual(vsd_subnet, None, "Network is present on the vsd.") - - def get_subnet_id(self, network_id, gateway): - """ Calculates the subnet ID in VSD with - the given CloudStack network ID and subnet gateway - - :param gateway: Gateway - :type gateway: str - :type network_id: str - :rtype: str - :return: Expected Subnet UUID - - """ - try: - import uuid - - class NULL_NAMESPACE: - bytes = b'' - - # The UUID of the shared network in ACS - # The gateway IP of the address range - network_id = str(network_id) - bytes = bytearray(network_id) - ipbytes = bytearray(gateway) - subnet_id = uuid.uuid3(NULL_NAMESPACE, bytes + ipbytes) - self.debug("The required subnet id is %s in VSD" % subnet_id) - return str(subnet_id) - except Exception as e: - self.debug("Failed to get the subnet id due to %s" % e) - self.fail("Unable to get the subnet id, failing the test case") - - def verify_vsd_shared_network(self, domain_id, network, - gateway="10.1.1.1"): - """Verifies the given CloudStack domain and - shared network against the corresponding installed enterprise, - domain, zone, subnet, and shared network resource in VSD""" - self.debug("Verifying the creation and state of Shared Network - %s " - "in VSD" % network.name) - vsd_enterprise = self.vsd.get_enterprise( - filter=self.get_externalID_filter(domain_id)) - ext_network_id_filter = self.get_externalID_filter(network.id) - vsd_domain = self.vsd.get_domain(filter=ext_network_id_filter) - vsd_zone = self.vsd.get_zone(filter=ext_network_id_filter) - subnet_id = self.get_subnet_id(network.id, gateway) - vsd_subnet = self.vsd.get_subnet( - filter=self.get_externalID_filter(subnet_id)) - - self.assertNotEqual(vsd_enterprise, None, - "VSD enterprise (CloudStack domain) data format " - "should not be of type None" - ) - self.assertEqual(vsd_domain.description, network.name, - "VSD domain description should match network name in " - "CloudStack" - ) - self.assertEqual(vsd_zone.description, network.name, - "VSD zone description should match network name in " - "CloudStack" - ) - self.assertEqual(vsd_subnet.description, network.name, - "VSD subnet description '%s' should match network " - "name in CloudStack" % vsd_subnet.description - ) - shared_resource = self.vsd.get_shared_network_resource( - filter=self.get_externalID_filter(subnet_id)) - self.assertEqual(shared_resource.description, network.name, - "VSD shared resources description should match " - "network name in CloudStack" - ) - self.debug("Successfully verified the creation and state of Shared " - "Network - %s in VSD" % network.name) - - def verify_vsd_object_status(self, cs_object, stopped): - """ Verifies the VM status in VSD for a given Cloudstack VM, - retrying every 5 seconds for 10 minutes. - - :param cs_object: Cloudstack VM - :param stopped: boolean: specifying if the vm is stopped. - """ - vsd_object = self.vsd.get_vm( - filter=self.get_externalID_filter(cs_object.id)) - expected_status = cs_object.state.upper() if not stopped \ - else "DELETE_PENDING" - tries = 0 - while (vsd_object.status != expected_status) and (tries < 120): - self.debug("Waiting for the CloudStack object " + cs_object.name + - " to be fully resolved in VSD...") - time.sleep(5) - self.debug("Rechecking the CloudStack object " + cs_object.name + - " status in VSD...") - vsd_object = self.vsd.get_vm( - filter=self.get_externalID_filter(cs_object.id)) - tries += 1 - self.assertEqual(vsd_object.status, expected_status, - "Object " + cs_object.name + - " state in VSD should match its state in CloudStack" - ) - - # verify_vsd_vm - Verifies the given CloudStack VM deployment and status in - # VSD - def verify_vsd_vm(self, vm, stopped=False): - self.debug("Verifying the deployment and state of VM - %s in VSD" % - vm.name) - vsd_vm = self.vsd.get_vm(filter=self.get_externalID_filter(vm.id)) - self.assertNotEqual(vsd_vm, None, - "VM data format in VSD should not be of type None" - ) - vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - for nic in vm_info.nic: - if nic.type == "Shared": - continue - vsd_subnet = self.vsd.get_subnet( - filter=self.get_externalID_filter(nic.networkid)) - vsd_vport = self.vsd.get_vport( - subnet=vsd_subnet, filter=self.get_externalID_filter(nic.id)) - vsd_vm_interface = self.vsd.get_vm_interface( - filter=self.get_externalID_filter(nic.id)) - self.assertEqual(vsd_vport.active, True, - "VSD VM vport should be active" - ) - self.assertEqual(vsd_vm_interface.ip_address, nic.ipaddress, - "VSD VM interface IP address should match VM's " - "NIC IP address in CloudStack" - ) - if not self.isSimulator: - self.verify_vsd_object_status(vm, stopped) - self.debug("Successfully verified the deployment and state of VM - %s " - "in VSD" % vm.name) - - # verify_vsd_enterprise_vm - Verifies the given CloudStack domain VM - # deployment and status in the corresponding VSD enterprise - def verify_vsd_enterprise_vm(self, domain_id, network, vm, vpc=None, - stopped=False, sharedsubnetid=None): - self.debug("Verifying the creation and state of Network - %s in VSD" % - network.name) - vsd_enterprise = self.vsd.get_enterprise( - filter=self.get_externalID_filter(domain_id)) - ext_network_id_filter = self.get_externalID_filter(vpc.id) if vpc \ - else self.get_externalID_filter(network.id) - vsd_domain = self.vsd.get_domain( - enterprise=vsd_enterprise, filter=ext_network_id_filter) - vsd_zone = self.vsd.get_zone( - domain=vsd_domain, filter=ext_network_id_filter) - if sharedsubnetid: - vsd_subnet = self.vsd.get_subnet( - zone=vsd_zone, - filter=self.get_externalID_filter(sharedsubnetid)) - else: - vsd_subnet = self.vsd.get_subnet( - zone=vsd_zone, filter=self.get_externalID_filter(network.id)) - self.assertNotEqual(vsd_enterprise, None, - "VSD enterprise (CloudStack domain) data format " - "should not be of type None" - ) - if vpc: - self.assertEqual(vsd_domain.description, "VPC_" + vpc.name, - "VSD domain description should match VPC name in " - "CloudStack" - ) - self.assertEqual(vsd_zone.description, "VPC_" + vpc.name, - "VSD zone description should match VPC name in " - "CloudStack" - ) - else: - self.assertEqual(vsd_domain.description, network.name, - "VSD domain description should match network " - "name in CloudStack" - ) - self.assertEqual(vsd_zone.description, network.name, - "VSD zone description should match network name " - "in CloudStack" - ) - self.assertEqual(vsd_subnet.description, network.name, - "VSD subnet description '%s' should match network " - "name in CloudStack" % vsd_subnet.description - ) - self.debug("Successfully verified the creation and state of Network - " - "%s in VSD" % network.name) - self.debug("Verifying the deployment and state of VM - %s in VSD" % - vm.name) - vsd_vm = self.vsd.get_vm( - subnet=vsd_subnet, filter=self.get_externalID_filter(vm.id)) - self.assertNotEqual(vsd_vm, None, - "VM data format in VSD should not be of type None" - ) - vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - for nic in vm_info.nic: - if nic.networkid == network.id: - vsd_vport = self.vsd.get_vport( - subnet=vsd_subnet, - filter=self.get_externalID_filter(nic.id)) - vsd_vm_interface = self.vsd.get_vm_interface( - filter=self.get_externalID_filter(nic.id)) - self.assertEqual(vsd_vport.active, True, - "VSD VM vport should be active" - ) - self.assertEqual(vsd_vm_interface.ip_address, nic.ipaddress, - "VSD VM interface IP address should match " - "VM's NIC IP address in CloudStack" - ) - if not self.isSimulator: - self.verify_vsd_object_status(vm, stopped) - self.debug("Successfully verified the deployment and state of VM - %s " - "in VSD" % vm.name) - - # verify_vsd_router - Verifies the given CloudStack network router - # deployment and status in VSD - def verify_vsd_router(self, router, stopped=False): - self.debug("Verifying the deployment and state of Router - %s in VSD" % - router.name) - vsd_router = self.vsd.get_vm( - filter=self.get_externalID_filter(router.id)) - self.assertNotEqual(vsd_router, None, - "Router data format in VSD should not be of type " - "None" - ) - if not self.isSimulator: - self.verify_vsd_object_status(router, stopped) - self.debug("Successfully verified the deployment and state of Router " - "- %s in VSD" % router.name) - - # verify_vsd_lb_device - Verifies the given CloudStack LB device deployment - # and status in VSD - def verify_vsd_lb_device(self, lb_device, stopped=False): - self.debug("Verifying the deployment and state of LB device - %s in " - "VSD" % lb_device.name) - vsd_lb_device = self.vsd.get_vm( - filter=self.get_externalID_filter(lb_device.id)) - self.assertNotEqual(vsd_lb_device, None, - "LB device data format in VSD should not be of " - "type None" - ) - if not self.isSimulator: - self.verify_vsd_object_status(lb_device, stopped) - self.debug("Successfully verified the deployment and state of LB " - "device - %s in VSD" % lb_device.name) - - # verify_vsd_floating_ip - Verifies the CloudStack Static NAT rule on the - # given public IP of the given VM in the given network against the - # corresponding installed Floating IP in VSD - def verify_vsd_floating_ip(self, network, vm, public_ipaddress, vpc=None): - self.debug("Verifying the assignment and state of public IP address " - "- %s in VSD" % public_ipaddress.ipaddress) - ext_fip_filter = self.get_externalID_filter(vpc.id + ":" + - public_ipaddress.id) \ - if vpc else self.get_externalID_filter(network.id + ":" + - public_ipaddress.id) - vsd_fip = self.vsd.get_floating_ip(filter=ext_fip_filter) - self.assertEqual(vsd_fip.address, public_ipaddress.ipaddress, - "Floating IP address in VSD should match acquired " - "public IP address in CloudStack" - ) - self.assertEqual(vsd_fip.assigned, True, - "Floating IP in VSD should be assigned" - ) - ext_fip_subnet_filter = self.get_externalID_filter( - public_ipaddress.vlanid) - vsd_fip_subnet = self.vsd.get_shared_network_resource( - filter=ext_fip_subnet_filter) - - if self.isNuageInfraUnderlay: - self.assertEqual(vsd_fip_subnet.underlay, True, - "Floating IP subnet in VSD should be underlay " - "enabled" - ) - else: - self.assertEqual(vsd_fip_subnet.underlay, False, - "Floating IP subnet in VSD should be underlay " - "disabled" - ) - - ext_network_filter = self.get_externalID_filter(vpc.id) if vpc \ - else self.get_externalID_filter(network.id) - vsd_domain = self.vsd.get_domain(filter=ext_network_filter) - self.assertEqual(vsd_domain.id, vsd_fip.parent_id, - "Floating IP in VSD should be associated with the " - "correct VSD domain, which in turn should correspond " - "to the correct VPC (or) network in CloudStack" - ) - vsd_subnet = self.vsd.get_subnet( - filter=self.get_externalID_filter(network.id)) - vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - for nic in vm_info.nic: - if nic.networkid == network.id: - vsd_vport = self.vsd.get_vport( - subnet=vsd_subnet, - filter=self.get_externalID_filter(nic.id)) - self.assertEqual(vsd_vport.associated_floating_ip_id, vsd_fip.id, - "Floating IP in VSD should be associated to the " - "correct VSD vport, which in turn should correspond " - "to the correct Static NAT rule enabled VM and " - "network in CloudStack" - ) - self.debug("Successfully verified the assignment and state of public " - "IP address - %s in VSD" % public_ipaddress.ipaddress) - - # verify_vsd_firewall_rule - Verifies the given CloudStack Network Firewall - # (Ingress/Egress ACL) rule against the corresponding installed firewall - # rule in VSD - def verify_vsd_firewall_rule(self, firewall_rule, traffic_type="Ingress"): - self.debug("Verifying the creation and state of Network Firewall " - "(Ingress/Egress ACL) rule with ID - %s in VSD" % - firewall_rule.id) - ext_fw_rule_filter = self.get_externalID_filter(firewall_rule.id) - vsd_fw_rule = self.vsd.get_egress_acl_entry( - filter=ext_fw_rule_filter) if traffic_type is "Ingress" \ - else self.vsd.get_ingress_acl_entry(filter=ext_fw_rule_filter) - self.assertEqual(vsd_fw_rule.policy_state, "LIVE", - "Ingress/Egress ACL rule's policy state in VSD " - "should be LIVE" - ) - dest_port = \ - str(firewall_rule.startport) + "-" + str(firewall_rule.endport) - self.assertEqual(vsd_fw_rule.destination_port, dest_port, - "Ingress/Egress ACL rule's destination port in VSD " - "should match corresponding rule's destination port " - "in CloudStack" - ) - vsd_protocol = int(vsd_fw_rule.protocol) - protocol = "tcp" - if vsd_protocol == 6: - protocol = "tcp" - elif vsd_protocol == 1: - protocol = "icmp" - elif vsd_protocol == 17: - protocol = "udp" - self.assertEqual(protocol, firewall_rule.protocol.lower(), - "Ingress/Egress ACL rule's protocol in VSD should " - "match corresponding rule's protocol in CloudStack" - ) - self.debug("Successfully verified the creation and state of Network " - "Firewall (Ingress/Egress ACL) rule with ID - %s in VSD" % - firewall_rule.id) - - def add_resource_tag(self, resource_id, resource_type, key, value, - fordisplay=False): - details = {key: value} - return ResourceDetails.create(self.api_client, resourceid=resource_id, - resourcetype=resource_type, - details=details, fordisplay=fordisplay) - - def list_resource_tag(self, resource_id, resource_type, key, - fordisplay=False): - return ResourceDetails.list(self.api_client, resourceid=resource_id, - resourcetype=resource_type, key=key, - fordisplay=fordisplay) - - def delete_resource_tag(self, resource_id, resource_type): - return ResourceDetails.delete(self.api_client, - resourceid=resource_id, - resourcetype=resource_type) diff --git a/test/integration/plugins/nuagevsp/nuage_lib.py b/test/integration/plugins/nuagevsp/nuage_lib.py deleted file mode 100644 index d248b207390..00000000000 --- a/test/integration/plugins/nuagevsp/nuage_lib.py +++ /dev/null @@ -1,98 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -import functools - -from marvin.cloudstackAPI import createSSHKeyPair, deleteSSHKeyPair - - -class MySSHKeyPair: - """Manage SSH Key pairs""" - - def __init__(self, items): - self.__dict__.update(items) - - @classmethod - def create(cls, apiclient, name=None, account=None, - domainid=None, projectid=None): - """Creates SSH keypair""" - cmd = createSSHKeyPair.createSSHKeyPairCmd() - cmd.name = name - if account is not None: - cmd.account = account - if domainid is not None: - cmd.domainid = domainid - if projectid is not None: - cmd.projectid = projectid - return MySSHKeyPair(apiclient.createSSHKeyPair(cmd).__dict__) - - def delete(self, apiclient): - """Delete SSH key pair""" - cmd = deleteSSHKeyPair.deleteSSHKeyPairCmd() - cmd.name = self.name - cmd.account = self.account - cmd.domainid = self.domainid - apiclient.deleteSSHKeyPair(cmd) - - -class GherkinMetaClass(type): - def __new__(mcs, name, bases, namespace): - namespace = { - k: gherkin(v) - if k.startswith('given_') or - k.startswith('when_') or - k.startswith('then_') - else v for k, v in namespace.items() - } - return super(GherkinMetaClass, mcs)\ - .__new__(mcs, name, bases, namespace) - - -class gherkin(object): - """Decorator to mark a method as Gherkin style. - Add extra colored logging - """ - BLACK = "\033[0;30m" - BLUE = "\033[0;34m" - GREEN = "\033[0;32m" - CYAN = "\033[0;36m" - RED = "\033[0;31m" - BOLDBLUE = "\033[1;34m" - NORMAL = "\033[0m" - - def __init__(self, method): - self.method = method - - def __get__(self, obj=None, objtype=None): - @functools.wraps(self.method) - def _wrapper(*args, **kwargs): - if self.method.__doc__: - gherkin_step = self.method.__doc__.format(*args, **kwargs) - else: - gherkin_step = self.method.__name__\ - .replace("_", " ")\ - .capitalize() - obj.info("=G= %s%s%s" % (self.BOLDBLUE, gherkin_step, self.NORMAL)) - try: - result = self.method(obj, *args, **kwargs) - obj.info("=G= %s%s: [SUCCESS]%s" % - (self.GREEN, gherkin_step, self.NORMAL)) - return result - except Exception as e: - obj.info("=G= %s%s: [FAILED]%s%s" % - (self.RED, gherkin_step, self.NORMAL, e)) - raise - return _wrapper diff --git a/test/integration/plugins/nuagevsp/nuage_test_data.py b/test/integration/plugins/nuagevsp/nuage_test_data.py deleted file mode 100644 index d3b87d283fa..00000000000 --- a/test/integration/plugins/nuagevsp/nuage_test_data.py +++ /dev/null @@ -1,561 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -nuage_test_data = { - "dns_rule": { - "privateport": 53, - "publicport": 53, - "startport": 53, - "endport": 53, - "protocol": "UDP", - "cidrlist": '0.0.0.0/0', - }, - "vpc_offering_reduced": { - "name": "VPC reduced off", - "displaytext": "VPC reduced off", - "supportedservices": - "Dhcp,Dns,SourceNat,UserData,StaticNat,NetworkACL" - }, - "shared_network_config_drive_offering": { - "name": 'shared_network_config_drive_offering', - "displaytext": 'shared_network_config_drive_offering', - "guestiptype": 'shared', - "supportedservices": 'Dhcp,UserData', - "traffictype": 'GUEST', - "specifyVlan": "True", - "specifyIpRanges": "True", - "availability": 'Optional', - "serviceProviderList": { - "Dhcp": "VirtualRouter", - "UserData": 'ConfigDrive' - } - }, - "isolated_staticnat_network_offering": { - "name": 'isolated_staticnat_net_off_marvin', - "displaytext": 'isolated_staticnat_net_off_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,StaticNat,UserData,Firewall,Dns', - "traffictype": 'GUEST', - "ispersistent": 'True', - "availability": 'Optional', - "tags": 'native', - "serviceProviderList": { - "Dhcp": 'VirtualRouter', - "StaticNat": 'VirtualRouter', - "SourceNat": 'VirtualRouter', - "Firewall": 'VirtualRouter', - "UserData": 'VirtualRouter', - "Dns": 'VirtualRouter' - } - }, - "nw_offering_reduced_vpc": { - "name": 'Reduced Network for VPC', - "displaytext": 'Reduced Network for VPC', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,UserData,' - 'Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "tags": "native", - "useVpc": 'on', - "ispersistent": 'True', - "serviceProviderList": { - "Dhcp": "VpcVirtualRouter", - "StaticNat": "VpcVirtualRouter", - "SourceNat": "VpcVirtualRouter", - "NetworkACL": "VpcVirtualRouter", - "UserData": "VpcVirtualRouter", - "Dns": "VpcVirtualRouter" - } - }, - # Nuage VSP SDN plugin specific test data - "nuagevsp": { - # Services supported by the Nuage VSP plugin for Isolated networks - "isolated_network_offering": { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "tags": "nuage", - "serviceProviderList": { - "Dhcp": 'NuageVsp', - "StaticNat": 'NuageVsp', - "SourceNat": 'NuageVsp', - "Firewall": 'NuageVsp', - "Connectivity": 'NuageVsp', - "UserData": 'VirtualRouter', - "Dns": 'VirtualRouter' - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - # Persistent services supported by the Nuage VSP plugin for Isolated networks - "isolated_network_offering_persistent": { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "ispersistent": 'True', - "tags": "nuage", - "serviceProviderList": { - "Dhcp": 'NuageVsp', - "StaticNat": 'NuageVsp', - "SourceNat": 'NuageVsp', - "Firewall": 'NuageVsp', - "Connectivity": 'NuageVsp', - "UserData": 'VirtualRouter', - "Dns": 'VirtualRouter' - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - # Persistent services supported by the Nuage VSP plugin for Isolated networks - "isolated_network_offering_persistent": { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "ispersistent": 'True', - "tags": "nuage", - "serviceProviderList": { - "Dhcp": 'NuageVsp', - "StaticNat": 'NuageVsp', - "SourceNat": 'NuageVsp', - "Firewall": 'NuageVsp', - "Connectivity": 'NuageVsp', - "UserData": 'VirtualRouter', - "Dns": 'VirtualRouter' - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - # Purely nuage network offering - "isolated_network_offering_without_vr": { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,Firewall', - "traffictype": 'GUEST', - "availabiliy": 'Optional', - "tags": "nuage", - "serviceProviderList": { - "Dhcp": 'NuageVsp', - "StaticNat": 'NuageVsp', - "SourceNat": 'NuageVsp', - "Firewall": 'NuageVsp', - "Connectivity": 'NuageVsp' - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - # Purely persistent nuage network offering - "isolated_network_offering_without_vr_persistent": { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,Firewall', - "traffictype": 'GUEST', - "availability": 'Optional', - "tags": "nuage", - "ispersistent": 'True', - "serviceProviderList": { - "Dhcp": 'NuageVsp', - "StaticNat": 'NuageVsp', - "SourceNat": 'NuageVsp', - "Firewall": 'NuageVsp', - "Connectivity": 'NuageVsp' - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - # Services supported by the Nuage VSP plugin for VPC networks - "vpc_network_offering": { - "name": 'nuage_vpc_marvin', - "displaytext": 'nuage_vpc_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "useVpc": 'on', - "ispersistent": 'True', - "tags": "nuage", - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "VpcVirtualRouter", - "Dns": "VpcVirtualRouter" - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - "vpc_network_offering_internal_lb": { - "name": "nuage_vpc_marvin_internal_lb", - "displaytext": "nuage_vpc_marvin_internal_lb", - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "tags": "nuage", - "useVpc": 'on', - "ispersistent": 'True', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "Lb": "InternalLbVm", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "VpcVirtualRouter", - "Dns": "VpcVirtualRouter" - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"}, - "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"} - } - }, - # Services supported by the Nuage VSP plugin for VPCs - "vpc_offering": { - "name": 'Nuage VSP VPC offering', - "displaytext": 'Nuage VSP VPC offering', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "VpcVirtualRouter", - "Dns": "VpcVirtualRouter" - } - }, - "vpc_offering_lb": { - "name": 'Nuage VSP VPC offering with Lb', - "displaytext": 'Nuage VSP VPC offering with Lb', - "supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "Lb": "InternalLbVm", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "VpcVirtualRouter", - "Dns": "VpcVirtualRouter" - } - }, - # Services supported by the Nuage VSP plugin for VPC without userdata - "vpc_network_offering_nuage_dhcp": { - "name": 'nuage_vpc_marvin', - "displaytext": 'nuage_vpc_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "useVpc": 'on', - "ispersistent": 'True', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "Dns": "VpcVirtualRouter", - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - "isolated_configdrive_network_offering_withoutdns" : { - "name": 'nuage_configdrive_withoutDns_marvin', - "displaytext": 'nuage_configdrive_withoutDns_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall', - "traffictype": 'GUEST', - "availability": 'Optional', - "serviceProviderList": { - "Dhcp": 'NuageVsp', - "StaticNat": 'NuageVsp', - "SourceNat": 'NuageVsp', - "Firewall": 'NuageVsp', - "Connectivity": 'NuageVsp', - "UserData": 'ConfigDrive' - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - "isolated_configdrive_network_offering": { - "name": 'nuage_configdrive_marvin', - "displaytext": 'nuage_configdrive_marvin', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "serviceProviderList": { - "Dhcp": 'NuageVsp', - "StaticNat": 'NuageVsp', - "SourceNat": 'NuageVsp', - "Firewall": 'NuageVsp', - "Connectivity": 'NuageVsp', - "UserData": 'ConfigDrive', - "Dns": 'VirtualRouter' - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - "vpc_network_offering_configdrive_withoutdns" : { - "name": 'nuage_vpc_marvin_configdrive_withoutdns', - "displaytext": 'nuage_vpc_marvin_configdrive_withoutdns', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData', - "traffictype": 'GUEST', - "availability": 'Optional', - "useVpc": 'on', - "ispersistent": 'True', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "ConfigDrive" - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - "vpc_network_offering_configdrive_withdns" : { - "name": 'nuage_vpc_marvin_configdrive_withdns', - "displaytext": 'nuage_vpc_marvin_configdrive_withdns', - "guestiptype": 'Isolated', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns', - "traffictype": 'GUEST', - "availability": 'Optional', - "useVpc": 'on', - "ispersistent": 'True', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "ConfigDrive", - "Dns": "VpcVirtualRouter" - }, - "serviceCapabilityList": { - "SourceNat": {"SupportedSourceNatTypes": "perzone"} - } - }, - "vpc_offering_configdrive_withoutdns" : { - "name": 'Nuage VSP VPC offering ConfigDrive', - "displaytext": 'Nuage VSP VPC offering ConfigDrive', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "ConfigDrive" - } - }, - "vpc_offering_configdrive_withdns" :{ - "name": 'Nuage VSP VPC offering ConfigDrive withVR', - "displaytext": 'Nuage VSP VPC offering ConfigDrive withVR', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": "ConfigDrive", - "Dns": "VpcVirtualRouter" - } - }, - "shared_nuage_network_config_drive_offering" : { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'shared', - "supportedservices": 'Dhcp,Connectivity,UserData', - "traffictype": 'GUEST', - "specifyVlan": "False", - "specifyIpRanges": "True", - "availability": 'Optional', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "Connectivity": "NuageVsp", - "UserData": 'ConfigDrive' - }, - "serviceCapabilityList": { - "Connectivity": { - "PublicAccess": "true" - } - } - }, - "network_all2" : { - "name": "SharedNetwork2-All-nuage", - "displaytext": "SharedNetwork2-All-nuage", - "gateway": "10.200.200.1", - "netmask": "255.255.255.0", - "startip": "10.200.200.21", - "endip": "10.200.200.100", - "acltype": "Domain" - }, - # Services supported by the Nuage VSP plugin for VPCs - "vpc_offering_nuage_dhcp": { - "name": 'Nuage VSP VPC offering', - "displaytext": 'Nuage VSP VPC offering', - "supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,Dns', - "serviceProviderList": { - "Dhcp": "NuageVsp", - "StaticNat": "NuageVsp", - "SourceNat": "NuageVsp", - "NetworkACL": "NuageVsp", - "Connectivity": "NuageVsp", - "Dns": "VpcVirtualRouter", - } - }, - "shared_nuage_network_offering": { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'shared', - "supportedservices": 'Dhcp,Connectivity', - "traffictype": 'GUEST', - "specifyVlan": "False", - "specifyIpRanges": "True", - "availability": 'Optional', - "tags": "nuage", - "serviceProviderList": { - "Dhcp": "NuageVsp", - "Connectivity": "NuageVsp" - } - }, - "shared_nuage_public_network_offering": { - "name": 'nuage_marvin', - "displaytext": 'nuage_marvin', - "guestiptype": 'shared', - "supportedservices": 'Dhcp,Connectivity', - "traffictype": 'GUEST', - "specifyVlan": "False", - "specifyIpRanges": "True", - "availability": 'Optional', - "tags": "nuage", - "serviceProviderList": { - "Dhcp": "NuageVsp", - "Connectivity": "NuageVsp" - }, - "serviceCapabilityList": { - "Connectivity": { - "PublicAccess": "true" - } - } - - }, - # Test data for Shared Network creation - "network_all": { - "name": "SharedNetwork-All-nuage", - "displaytext": "SharedNetwork-All-nuage", - "gateway": "10.200.100.1", - "netmask": "255.255.255.0", - "startip": "10.200.100.21", - "endip": "10.200.100.100", - "acltype": "Domain" - }, - "network_domain_with_no_subdomain_access": { - "name": "SharedNetwork-Domain-nosubdomain-nuage", - "displaytext": "SharedNetwork-Domain-nosubdomain-nuage", - "gateway": "10.222.1.1", - "netmask": "255.255.255.0", - "startip": "10.222.1.2", - "endip": "10.222.1.100", - "acltype": "Domain", - "subdomainaccess": "false" - }, - "network_domain_with_subdomain_access": { - "name": "SharedNetwork-Domain-withsubdomain-nuage", - "displaytext": "SharedNetwork-Domain-withsubdomain-nuage", - "gateway": "10.221.1.1", - "netmask": "255.255.255.0", - "startip": "10.221.1.2", - "endip": "10.221.1.100", - "acltype": "Domain", - "subdomainaccess": "true" - }, - "network_account": { - "name": "SharedNetwork-Account-nuage", - "displaytext": "SharedNetwork-Account-nuage", - "gateway": "10.220.1.1", - "netmask": "255.255.255.0", - "startip": "10.220.1.2", - "endip": "10.220.1.100", - "acltype": "Account" - }, - "shared_network_offering": { - "name": "MySharedOffering-shared", - "displaytext": "MySharedOffering", - "guestiptype": "Shared", - "supportedservices": "Dhcp,Dns,UserData", - "specifyVlan": "True", - "specifyIpRanges": "True", - "traffictype": "GUEST", - "tags": "native", - "serviceProviderList": { - "Dhcp": "VirtualRouter", - "Dns": "VirtualRouter", - "UserData": "VirtualRouter" - } - }, - "publiciprange1": { - "gateway": "10.200.100.1", - "netmask": "255.255.255.0", - "startip": "10.200.100.101", - "endip": "10.200.100.105", - "forvirtualnetwork": "false" - }, - "publiciprange2": { - "gateway": "10.219.1.1", - "netmask": "255.255.255.0", - "startip": "10.219.1.2", - "endip": "10.219.1.5", - "forvirtualnetwork": "false" - }, - "publiciprange3": { - "gateway": "10.200.100.1", - "netmask": "255.255.255.0", - "startip": "10.200.100.2", - "endip": "10.200.100.20", - "forvirtualnetwork": "false" - } - } -} diff --git a/test/integration/plugins/nuagevsp/nuage_vsp_statistics.py b/test/integration/plugins/nuagevsp/nuage_vsp_statistics.py deleted file mode 100644 index f4fcde84dba..00000000000 --- a/test/integration/plugins/nuagevsp/nuage_vsp_statistics.py +++ /dev/null @@ -1,202 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -import jpype -from jpype import * -from jpype import java -from jpype import javax - -J_STRING = "java.lang.String" - - -class VsdDataCollector: - def __init__(self, name, host="localhost", port=1099, debug=False, - output_channel=None): - self.jmx = ConnectionJmx(host, port, debug, output_channel) - self.jmx.create_management_object(name=name) - self.saved_stats = None - self.saved_vsd_calls = 0 - - def start_test(self): - self.saved_stats = self.jmx.get_attribute("VsdStatisticsReport") - self.saved_vsd_calls = self.jmx.get_attribute("VSDStatistics") - return - - def end_test(self): - self.jmx.print_rapport(old_stats=self.saved_stats, - old_vsd_count=self.saved_vsd_calls) - return - - -class ConnectionJmx: - - def __init__(self, host="localhost", port=1099, debug=False, - output_channel=None): - self.host = host - self.port = port - self.url = "service:jmx:rmi:///jndi/rmi://%s:%d/jmxrmi" % (host, port) - self.debug = debug - self.mbean = None - self.output_channel = output_channel - jpype.startJVM(jpype.get_default_jvm_path()) - if debug: - self.__print_to_ouput_channel("JVM loaded") - self.__print_to_ouput_channel(jpype.get_default_jvm_path()) - - jmx_url = javax.management.remote.JMXServiceURL(self.url) - jmx_soc = javax.management.remote.JMXConnectorFactory.connect( - jmx_url, java.util.HashMap()) - self.connection = jmx_soc.getMBeanServerConnection() - if self.debug: - self.__print_to_ouput_channel("Connection successful") - - def __print_to_ouput_channel(self, text): - if self.output_channel: - self.output_channel.debug(text) - else: - print text - - def create_management_object(self, domain="com.cloud", - type="NuageVspResource", - name="Nuage VSD - 0.0.0.0"): - if name is not None: - object_name = domain + ":type=" + type + ", name=" + name - else: - object_name = domain + ":" + type - - if self.debug: - self.__print_to_ouput_channel(object_name) - - self.mbean = javax.management.ObjectName(object_name) - return self.mbean - - def get_vsd_statistics_by_request_and_entity_type(self, - entity_type, - request_type, - mbean=None): - self._get_stats_by_entity_or_request_type( - mbean, [[entity_type, request_type]], - "getVsdStatisticsByEntityType") - - def _jStringArray(self, elements): - return jpype.JArray(java.lang.String)(elements) - - def get_vsd_statistics_by_request_type(self, request_type, mbean=None): - return self._get_stats_by_entity_or_request_type( - mbean, [request_type], "getVsdStatisticsByRequestType") - - def get_vsd_statistics_by_entity_type(self, entity_type, mbean=None): - return self._get_stats_by_entity_or_request_type( - mbean, [entity_type], "getVsdStatisticsByEntityType") - - def _get_stats_by_entity_or_request_type(self, vars, method, mbean=None): - if not mbean: - mbean = self.mbean - jarray = self._jStringArray(vars) - signature = self._jStringArray([J_STRING for _ in vars]) - result = self.connection.invoke(mbean, method, jarray, signature) - if self.debug: - self.__print_to_ouput_channel(vars + ": " + str(result)) - return result - - def get_attribute(self, attribute, mbean=None): - if not mbean: - mbean = self.mbean - - result = self.connection.getAttribute(mbean, attribute) - if self.debug: - self.__print_to_ouput_channel("Attribute " + attribute + ": " + - str(result)) - return result - - def print_rapport(self, mbean=None, old_stats=None, old_vsd_count=0): - if not mbean: - mbean = self.mbean - stat = self.get_attribute("VsdStatisticsReport", mbean) - number_of_vsd_calls = int(str(self.get_attribute("VSDStatistics", - mbean))) - number_of_vsd_calls = number_of_vsd_calls - int(str(old_vsd_count)) - - self.__print_to_ouput_channel("\n================" - "RAPPORT:" - "================\n") - self.__print_to_ouput_channel("Total VSD calls: " + - str(number_of_vsd_calls)) - self.__print_to_ouput_channel("For each Entity:\n") - self.__print_total_for_entity(stat, old_stats) - self.__print_to_ouput_channel("\nFor each Request:\n") - self.__print_total_per_request(stat, old_stats) - self.__print_to_ouput_channel("\nCombined:\n") - self.__print_total_per_entity_and_request(stat, old_stats) - self.__print_to_ouput_channel("\n=============" - "END OF RAPPORT" - "=============") - - def __print_total_per_request(self, stat, old_stat=None): - data = dict() - - entries = ((entry.getKey(), entry.getValue().get()) - for requestmap in stat.values() - for entry in requestmap.entrySet()) - - for request, value in entries: - if request in data: - data[request] += value - else: - data[request] = value - - if old_stat: - old_entries = ((entry.getKey(), entry.getValue().get()) - for requestmap in old_stat.values() - for entry in requestmap.entrySet()) - - for request, value in old_entries: - if request in data: - data[request] -= value - else: - data[request] = 0 - - for key, value in data.iteritems(): - self.__print_to_ouput_channel(" " + str(key) + ": " + str(value)) - - def __print_total_per_entity_and_request(self, stat, old_stat=None): - for entity in stat: - self.__print_to_ouput_channel(entity + ":") - for request in stat[entity]: - previous = 0 - if old_stat and old_stat[entity] and old_stat[entity][request]: - previous = int(str(old_stat[entity][request])) - - current = int(str(stat[entity][request])) - - self.__print_to_ouput_channel(" " + str(request) + ":" + - str(current - previous)) - self.__print_to_ouput_channel("--------------------" - "--------------------") - - def __print_total_for_entity(self, stat, old_stat=None): - for entity in stat: - total = 0 - for val in stat[entity]: - minus = 0 - if old_stat and old_stat[entity] and old_stat[entity][val]: - minus = int(str(old_stat[entity][val])) - total = str(stat[entity][val]) - - total = int(total) - minus - self.__print_to_ouput_channel(" " + str(entity) + - ": " + str(total)) diff --git a/test/integration/plugins/nuagevsp/test_nuage_configdrive.py b/test/integration/plugins/nuagevsp/test_nuage_configdrive.py deleted file mode 100644 index 731694822f0..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_configdrive.py +++ /dev/null @@ -1,1213 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for user data, meta data, ssh keys - and password reset functionality with - ConfigDrive and Nuage VSP SDN plugin -""" -import base64 -import copy -import os -import threading - -from datetime import datetime -from marvin.lib.base import (Account, - NetworkServiceProvider, - PublicIpRange, - PublicIPAddress, - VirtualMachine) -# Import System Modules -from nose.plugins.attrib import attr -from nuage_lib import GherkinMetaClass - -# Import Local Modules -from component.test_configdrive import ConfigDriveUtils -from nuageTestCase import nuageTestCase - -NO_SUCH_FILE = "No such file or directory" - - -class TestNuageConfigDrive(nuageTestCase, ConfigDriveUtils): - """Test user data and password reset functionality - using configDrive with Nuage VSP SDN plugin - """ - - __metaclass__ = GherkinMetaClass - - class StartVM(threading.Thread): - - def __init__(self, nuagetestcase, network, index): - threading.Thread.__init__(self) - self.network = network - self.nuagetestcase = nuagetestcase - self.vm = None - self.index = index - - def run(self): - self.vm = self.nuagetestcase.create_VM( - self.network, - account=self.nuagetestcase.account, - cleanup=False) - self.nuagetestcase.check_VM_state(self.vm, state="Running") - self.nuagetestcase.debug("[Concurrency]VM %d running, name = %s" - % (self.index + 1, self.vm.name)) - - def get_vm(self): - return self.vm - - def stop(self): - self.vm.delete(self.nuagetestcase.api_client) - - def update(self): - expected_user_data = "hello world vm %s" % self.vm.name - user_data = base64.b64encode(expected_user_data) - self.vm.update(self.nuagetestcase.api_client, userdata=user_data) - - class StopVM(threading.Thread): - - def __init__(self, nuagetestcase, vm, **kwargs): - threading.Thread.__init__(self) - self.vm = vm - self.nuagetestcase = nuagetestcase - - def run(self): - self.vm.delete(self.nuagetestcase.api_client) - if self.vm in self.nuagetestcase.cleanup: - self.nuagetestcase.cleanup.remove(self.vm) - - def get_vm(self): - return self.vm - - @staticmethod - def get_name(): - return "delete" - - class UpdateVM(threading.Thread): - - def __init__(self, nuagetestcase, vm, **kwargs): - threading.Thread.__init__(self) - self.vm = vm - self.nuagetestcase = nuagetestcase - self.idx = kwargs["idx"] - - def run(self): - self.expected_user_data = "hello world vm %s" % self.vm.name - self.end = None - self.start = datetime.now() - self.nuagetestcase.when_I_update_userdata(self.vm, - self.expected_user_data) - self.end = datetime.now() - self.nuagetestcase.debug("[Concurrency]Update userdata idx=%d " - "for vm: %s. Duration in seconds: %s " % - (self.idx, self.vm.name, - (self.end - self.start).total_seconds())) - return self.expected_user_data - - def get_vm(self): - return self.vm - - def get_timestamps(self): - if not self.end: - self.end = datetime.now() - return [self.start, self.end] - - def get_userdata(self): - return self.expected_user_data - - @staticmethod - def get_name(): - return "userdata" - - class ResetPassword(threading.Thread): - - def __init__(self, nuagetestcase, vm, **kwargs): - threading.Thread.__init__(self) - self.vm = vm - self.nuagetestcase = nuagetestcase - - def run(self): - self.start = datetime.now() - self.nuagetestcase.when_I_reset_the_password(self.vm) - self.end = datetime.now() - self.nuagetestcase.debug("[Concurrency]Reset password for vm: %s. " - "Duration in seconds: %s " - % - (self.vm.name, - (self.end - self.start).total_seconds())) - - def get_vm(self): - return self.vm - - def get_timestamps(self): - if not self.end: - self.end = datetime.now() - return [self.start, self.end] - - def get_password(self): - return self.vm.password - - @staticmethod - def get_name(): - return "reset password" - - def __init__(self, methodName='runTest'): - super(TestNuageConfigDrive, self).__init__(methodName) - ConfigDriveUtils.__init__(self) - - @classmethod - def setUpClass(cls): - super(TestNuageConfigDrive, cls).setUpClass() - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.tmp_files = [] - self.cleanup = [self.account] - self.generate_ssh_keys() - return - - def tearDown(self): - super(TestNuageConfigDrive, self).tearDown() - for tmp_file in self.tmp_files: - os.remove(tmp_file) - - self.update_template(passwordenabled=False) - return - - def validate_acl_rule(self, fw_rule): - self.verify_vsd_firewall_rule(fw_rule) - - def validate_StaticNat_rule_For_VM(self, public_ip, network, vm): - self.verify_vsd_floating_ip(network, vm, public_ip.ipaddress, self.vpc) - - def validate_vm_networking(self, vm): - self.verify_vsd_vm(vm) - - def validate_network_networking(self, network, vpc): - self.verify_vsd_network(self.domain.id, network, vpc=vpc) - - def validate_shared_networking(self, network, vm): - # Verify shared Network and VM in VSD - subnet_id = self.get_subnet_id(network.id, network.gateway) - - self.verify_vsd_shared_network(self.domain.id, network, - gateway=network.gateway) - self.verify_vsd_enterprise_vm(self.domain.id, network, vm, - sharedsubnetid=subnet_id) - - def _get_test_data(self, key): - return self.test_data["nuagevsp"][key] - - def get_configdrive_provider(self): - return NetworkServiceProvider.list( - self.api_client, - name="ConfigDrive", - physicalnetworkid=self.vsp_physical_network.id)[0] - - def get_vpc_offering_name(self): - return "vpc_offering_configdrive_withoutdns" - - def get_network_offering_name(self): - return "isolated_configdrive_network_offering_withoutdns" - - def get_network_offering_name_for_vpc(self): - return "vpc_network_offering_configdrive_withoutdns" - - # ========================================================================= - # --- Gherkin style helper methods --- - # ========================================================================= - - def then_vr_is_as_expected(self, network): - """Then there is a VR or not in network {network.id}""" - if "Dns" in [s.name for s in network.service]: - vr = self.check_Router_state(network=network, state="Running") - self.verify_vsd_router(vr) - else: - with self.assertRaises(Exception): - self.get_Router(network) - self.debug("+++Verified no VR is spawned for this network ") - - def when_I_change_the_network_offering_to(self, network, offering_name): - updated_network =\ - self.upgrade_Network(self._get_test_data(offering_name), network) - network.service = updated_network.service - - # ========================================================================= - # --- TEST CASES --- - # ========================================================================= - - @attr(tags=["advanced", "nuagevsp", "isonw"], required_hardware="true") - def test_nuage_config_drive_isolated_network_with_vr(self): - self.debug("+++Test user data & password reset functionality " - "using configdrive in an Isolated network with VR") - - self.given_config_drive_provider_is("Enabled") - self.given_template_password_enabled_is(True) - self.given_a_network_offering("isolated_configdrive_network_offering") - create_vrnetwork =\ - self.when_I_create_a_network_with_that_offering(gateway='10.1.3.1') - self.then_the_network_is_successfully_created(create_vrnetwork) - self.then_the_network_has(create_vrnetwork, state="Allocated") - - vrnetwork = create_vrnetwork.network - - vm = self.when_I_deploy_a_vm(vrnetwork) - self.then_vr_is_as_expected(network=vrnetwork) - - # We need to have the vm password - self.when_I_reset_the_password(vm) - public_ip = self.when_I_create_a_static_nat_ip_to(vm, vrnetwork) - - self.then_config_drive_is_as_expected(vm, public_ip, metadata=True) - - self.update_and_validate_userdata(vm, "helloworld vm", public_ip) - self.then_config_drive_is_as_expected(vm, public_ip) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after restart Isolated network without" - " cleanup...") - self.when_I_restart_the_network_with(vrnetwork, cleanup=False) - self.then_config_drive_is_as_expected(vm, public_ip, metadata=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after restart Isolated network with" - " cleanup...") - self.when_I_restart_the_network_with(vrnetwork, cleanup=True) - self.then_config_drive_is_as_expected(vm, public_ip, metadata=True) - - self.debug("+++ Upgrade offering of created Isolated network with " - "an offering which removes the VR...") - self.when_I_change_the_network_offering_to( - vrnetwork, "isolated_configdrive_network_offering_withoutdns") - self.then_vr_is_as_expected(network=vrnetwork) - self.then_config_drive_is_as_expected(vm, public_ip, metadata=True) - - vm.delete(self.api_client, expunge=True) - vrnetwork.delete(self.api_client) - - @attr(tags=["advanced", "nuagevsp", "isonw"], required_hardware="true") - def test_nuage_configdrive_isolated_network(self): - """Test Configdrive as provider for isolated Networks - to provide userdata and password reset functionality - with Nuage VSP SDN plugin - """ - - # 1. Given ConfigDrive provider is disabled in zone - # And a network offering which has - # user data provided by ConfigDrive - # Then creating an Isolated Network - # using that network offering fails - - # 2. Given ConfigDrive provider is enabled in zone - # And a network offering which has - # * user data provided by ConfigDrive - # * No DNS - # When I create an Isolated Network using that network offering - # Then the network is successfully created, - # And is in the "Allocated" state. - - # 3. When I deploy a VM in the created Isolated network with user data, - # Then the Isolated network state is changed to "Implemented" - # And the VM is successfully deployed and is in the "Running" state - # And there is no VR is deployed. - # 4. And the user data in the ConfigDrive device is as expected - # 5. And the the vm's password in the ConfigDrive device is as expected - - # 6. When I stop, reset the password, and start the VM - # 7. Then I can login into the VM using the new password. - # 8. SSH into the VM for verifying its new password - # after its password reset. - - # 9. Verify various scenarios and check the data in configdriveIso - # 10. Delete all the created objects (cleanup). - - self.debug("+++ Scenario: creating an Isolated network with " - "config drive fails when config drive provider is " - "disabled.") - self.given_config_drive_provider_is("Disabled") - self.given_a_network_offering_with_configdrive() - self.then_creating_a_network_with_that_offering_fails() - - self.debug("+++ Preparation Scenario: " - "creating an Isolated networks with " - "config drive when config drive provider is " - "enabled.") - - self.given_config_drive_provider_is("Enabled") - - create_network1 = self.when_I_create_a_network_with_that_offering() - self.then_the_network_is_successfully_created(create_network1) - self.then_the_network_has(create_network1, state="Allocated") - - create_network2 = self.when_I_create_a_network_with_that_offering() - self.then_the_network_is_successfully_created(create_network2) - self.then_the_network_has(create_network2, state="Allocated") - - network1 = create_network1.network - network2 = create_network2.network - - self.given_template_password_enabled_is(True) - - self.debug("+++Deploy VM in the created Isolated network " - "with user data provider as configdrive") - - vm1 = self.when_I_deploy_a_vm_with_keypair_in(network1) - public_ip_1 = \ - self.when_I_create_a_static_nat_ip_to(vm1, network1) - - self.then_vr_is_as_expected(network=network1) - self.then_config_drive_is_as_expected( - vm1, public_ip_1, - metadata=True) - - self.update_and_validate_userdata(vm1, "helloworld vm1", public_ip_1) - self.update_and_validate_sshkeypair(vm1, public_ip_1) - - # ===================================================================== - - self.debug("Adding a non-default nic to the VM " - "making it a multi-nic VM...") - self.plug_nic(vm1, network2) - self.then_config_drive_is_as_expected(vm1, public_ip_1, - metadata=True, reconnect=False) - - with self.stopped_vm(vm1): - self.when_I_reset_the_password(vm1) - self.when_I_update_userdata(vm1, "hellomultinicvm1") - - self.then_config_drive_is_as_expected(vm1, public_ip_1) - - # ===================================================================== - # Test using network2 as default network - # ===================================================================== - - self.debug("updating non-default nic as the default nic " - "of the multi-nic VM and enable staticnat...") - self.update_default_nic(vm1, network2) - - public_ip_2 = \ - self.when_I_create_a_static_nat_ip_to(vm1, network2) - self.stop_and_start_vm(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_2, metadata=True) - - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_2) - - user_data = "hellomultinicvm1again" - self.update_and_validate_userdata(vm1, user_data, public_ip_2) - - self.debug("Updating the default nic of the multi-nic VM, " - "deleting the non-default nic...") - self.update_default_nic(vm1, network1) - self.stop_and_start_vm(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_1, metadata=True) - - self.delete(public_ip_2) - self.unplug_nic(vm1, network2) - - # ===================================================================== - # Another Multinic VM - # ===================================================================== - self.debug("+++ Scenario: " - "Reset password and update userdata on a multi nic vm") - multinicvm1 = self.when_I_deploy_a_vm([network2, network1]) - self.when_I_reset_the_password(multinicvm1) - public_ip_3 = self.when_I_create_a_static_nat_ip_to(multinicvm1, - network2) - self.then_config_drive_is_as_expected( - multinicvm1, public_ip_3, - metadata=True) - - user_data2 = "hello multinicvm1" - self.update_and_validate_userdata(multinicvm1, user_data2, public_ip_3) - - self.delete(multinicvm1, expunge=True) - self.delete(public_ip_3) - self.delete(network2) - - # ===================================================================== - # Network restart tests - # ===================================================================== - - self.debug("+++ Scenario: " - "verify config drive after restart Isolated network without" - " cleanup...") - self.when_I_reset_the_password(vm1) - self.when_I_restart_the_network_with(network1, cleanup=False) - self.then_config_drive_is_as_expected(vm1, public_ip_1, - metadata=True, reconnect=False) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after restart Isolated network with" - " cleanup...") - self.when_I_restart_the_network_with(network1, cleanup=True) - self.then_config_drive_is_as_expected(vm1, public_ip_1, - metadata=True, reconnect=False) - - # ===================================================================== - # Nuage -- - # Update offering to VR - # ===================================================================== - self.debug("+++ Upgrade offering of created Isolated network with " - "a dns offering which spins a VR") - self.upgrade_Network(self.test_data["nuagevsp"][ - "isolated_configdrive_network_offering"], - create_network1.network) - vr = self.get_Router(create_network1.network) - self.check_Router_state(vr, state="Running") - # VSD verification - self.verify_vsd_network(self.domain.id, create_network1.network) - self.verify_vsd_router(vr) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after reboot") - vm1.reboot(self.api_client) - self.then_config_drive_is_as_expected(vm1, public_ip_1, metadata=True) - self.update_and_validate_userdata(vm1, "hello afterboot", public_ip_1) - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_1) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after migrate") - self.migrate_VM(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_1, metadata=True) - self.debug("Updating userdata after migrating VM - %s" % vm1.name) - self.update_and_validate_userdata(vm1, "hello after migrate", - public_ip_1) - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_1) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after stop/start") - self.stop_and_start_vm(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_1, metadata=True) - self.update_and_validate_userdata(vm1, "hello afterstopstart", - public_ip_1) - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_1) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after delete/recover") - self.delete_and_recover_vm(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_1, - metadata=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Start VM fails when ConfigDrive provider is disabled") - self.given_config_drive_provider_is("Disabled") - with self.assertRaises(Exception): - self.when_I_update_userdata(vm1, "hi with provider state Disabled") - self.given_config_drive_provider_is("Enabled") - - self.delete(vm1, expunge=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Update Userdata on a VM that is not password enabled") - self.update_template(passwordenabled=False) - vm1 = self.when_I_deploy_a_vm_with_keypair_in(network1) - - public_ip_1 = \ - self.when_I_create_a_static_nat_ip_to(vm1, network1) - - self.update_and_validate_userdata(vm1, - "This is sample data", - public_ip_1, - metadata=True) - - @attr(tags=["advanced", "nuagevsp", "vpc"], required_hardware="true") - def test_nuage_configdrive_vpc_network_with_vr(self): - self.debug("Testing user data & password reset functionality " - " using configdrive in a VPC network with VR...") - - self.given_config_drive_provider_is("Enabled") - self.given_template_password_enabled_is(True) - self.given_a_vpc_with_offering("vpc_offering_configdrive_withdns") - self.given_a_network_offering( - "vpc_network_offering_configdrive_withdns") - create_tier = self.when_I_create_a_vpc_tier_with_that_offering( - gateway='10.1.3.1') - self.then_the_network_is_successfully_created(create_tier) - self.then_the_network_has(create_tier, state="Implemented") - - tier = create_tier.network - - # ===================================================================== - self.debug("+++ Scenario: " - "Deploy VM in the Tier 1 with user data") - vm = self.when_I_deploy_a_vm(tier) - self.then_vr_is_as_expected(network=tier) - - public_ip = \ - self.when_I_create_a_static_nat_ip_to(vm, tier) - self.then_config_drive_is_as_expected(vm, public_ip, metadata=True) - - self.when_I_reset_the_password(vm) - self.then_config_drive_is_as_expected(vm, public_ip) - - self.update_and_validate_userdata(vm, "helloworld vm2", public_ip, - metadata=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Restarting the created vpc without cleanup...") - self.when_I_restart_the_vpc_with(cleanup=False) - self.then_config_drive_is_as_expected(vm, public_ip, metadata=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after Restart VPC with cleanup...") - self.when_I_restart_the_vpc_with(cleanup=True) - self.then_config_drive_is_as_expected(vm, public_ip, - metadata=True, reconnect=False) - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after Restart tier without cleanup...") - self.when_I_restart_the_network_with(tier, cleanup=False) - self.then_config_drive_is_as_expected(vm, public_ip, - metadata=True, reconnect=False) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after restart tier with cleanup...") - self.when_I_restart_the_network_with(tier, cleanup=True) - self.then_config_drive_is_as_expected(vm, public_ip, - metadata=True, reconnect=False) - - self.debug("+++ Upgrade offering of created VPC network with " - "an offering which removes the VR...") - self.when_I_change_the_network_offering_to( - tier, "vpc_network_offering_configdrive_withoutdns") - self.then_vr_is_as_expected(network=tier) - self.then_config_drive_is_as_expected(vm, public_ip, - metadata=True, reconnect=False) - - vm.delete(self.api_client, expunge=True) - tier.delete(self.api_client) - self.vpc.delete(self.api_client) - - @attr(tags=["advanced", "nuagevsp", "vpc"], required_hardware="true") - def test_nuage_configdrive_vpc_network(self): - """Test Configdrive for VPC Networks - choose user data with configDrive as service provider - and test password reset functionality using ConfigDrive - with Nuage VSP SDN plugin - """ - - # 1. Given ConfigDrive provider is disabled in zone - # And a network offering for VPC which has - # user data provided by ConfigDrive - # And a VPC - # Then creating an VPC Tier in the VPC - # using that network offering fails - - # 2. Given ConfigDrive provider is enabled in zone - # And a network offering for VPC which has - # user data provided by ConfigDrive - # And a VPC - # When I create an VPC Tier in the VPC using that network offering - # Then the network is successfully created, - # And is in the "Allocated" state. - - # 3. When I deploy a VM in the created VPC tier with user data, - # Then the network state is changed to "Implemented" - # And the VM is successfully deployed and is in the "Running" state - - # 4. And the user data in the ConfigDrive device is as expected - # 5. And the the vm password in the ConfigDrive device is as expected - - # 6. When I stop, reset the password, and start the VM - # 7. Then I can login into the VM using the new password. - # 8. And the the vm password in the ConfigDrive device is the new one - - # 9. Verify various scenarios and check the data in configdriveIso - # 10. Delete all the created objects (cleanup). - - self.debug("+++ Scenario: creating an VPC tier with " - "config drive fails when config drive provider is " - "disabled.") - self.given_a_vpc() - self.given_config_drive_provider_is("Disabled") - self.given_a_network_offering_for_vpc_with_configdrive() - self.then_creating_a_vpc_tier_with_that_offering_fails() - - self.debug("+++ Preparation Scenario: " - "Create 2 tier with config drive " - "when config drive provider is enabled.") - - self.given_config_drive_provider_is("Enabled") - - create_network1 = self.when_I_create_a_vpc_tier_with_that_offering( - gateway='10.1.1.1') - self.then_the_network_is_successfully_created(create_network1) - self.then_the_network_has(create_network1, state="Implemented") - - create_network2 = self.when_I_create_a_vpc_tier_with_that_offering( - gateway='10.1.2.1') - self.then_the_network_is_successfully_created(create_network2) - self.then_the_network_has(create_network2, state="Implemented") - - network1 = create_network1.network - network2 = create_network2.network - - self.given_template_password_enabled_is(True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Deploy VM in the Tier 1 with user data") - vm = self.when_I_deploy_a_vm(network1, - keypair=self.keypair.name) - public_ip_1 = \ - self.when_I_create_a_static_nat_ip_to(vm, network1) - self.then_config_drive_is_as_expected(vm, public_ip_1, metadata=True) - - self.update_and_validate_userdata(vm, "helloworld vm1", - public_ip_1, - metadata=True) - - self.when_I_reset_the_password(vm) - self.then_config_drive_is_as_expected(vm, public_ip_1) - - self.update_and_validate_sshkeypair(vm, public_ip_1) - - # ===================================================================== - self.debug("+++ Scenario: " - "Restarting the created vpc without cleanup...") - self.when_I_restart_the_vpc_with(cleanup=False) - self.then_config_drive_is_as_expected(vm, public_ip_1, metadata=True) - - # ===================================================================== - self.debug("Adding a non-default nic to the VM " - "making it a multi-nic VM...") - self.plug_nic(vm, network2) - self.then_config_drive_is_as_expected(vm, public_ip_1, - metadata=True, reconnect=False) - with self.stopped_vm(vm): - self.when_I_reset_the_password(vm) - self.when_I_update_userdata(vm, "hellomultinicvm1") - - self.then_config_drive_is_as_expected(vm, public_ip_1, metadata=True) - - self.unplug_nic(vm, network2) - self.delete(network2) - - self.debug("+++ Scenario: " - "verify config drive after Restart VPC with cleanup...") - self.when_I_restart_the_vpc_with(cleanup=True) - self.then_config_drive_is_as_expected(vm, public_ip_1, - metadata=True, reconnect=False) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after Restart tier without cleanup...") - self.when_I_restart_the_network_with(network1, cleanup=False) - self.then_config_drive_is_as_expected(vm, public_ip_1, - metadata=True, reconnect=False) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after restart tier with cleanup...") - self.when_I_restart_the_network_with(network1, cleanup=True) - self.then_config_drive_is_as_expected(vm, public_ip_1, - metadata=True, reconnect=False) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after reboot") - vm.reboot(self.api_client) - self.then_config_drive_is_as_expected(vm, public_ip_1, metadata=True) - self.update_and_validate_userdata(vm, "hello reboot", public_ip_1) - - self.when_I_reset_the_password(vm) - self.then_config_drive_is_as_expected(vm, public_ip_1) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after migrate") - self.migrate_VM(vm) - self.then_config_drive_is_as_expected(vm, public_ip_1, metadata=True) - self.update_and_validate_userdata(vm, "hello migrate", public_ip_1) - - self.when_I_reset_the_password(vm) - self.then_config_drive_is_as_expected(vm, public_ip_1) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after stop/start") - self.stop_and_start_vm(vm) - self.then_config_drive_is_as_expected(vm, public_ip_1, metadata=True) - - self.update_and_validate_userdata(vm, "hello stop/start", public_ip_1) - - self.when_I_reset_the_password(vm) - self.then_config_drive_is_as_expected(vm, public_ip_1) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after delete/recover") - self.delete_and_recover_vm(vm) - self.then_config_drive_is_as_expected(vm, public_ip_1, metadata=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Verify configdrive when template is not password enabled") - self.given_config_drive_provider_is("Disabled") - self.then_config_drive_is_as_expected(vm, public_ip_1, - metadata=True, reconnect=False) - self.given_config_drive_provider_is("Enabled") - - self.delete(vm, expunge=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Update Userdata on a VM that is not password enabled") - - self.update_template(passwordenabled=False) - - vm = self.when_I_deploy_a_vm(network1, - keypair=self.keypair.name) - public_ip_1 = \ - self.when_I_create_a_static_nat_ip_to(vm, network1) - self.update_and_validate_userdata(vm, "This is sample data", - public_ip_1, - metadata=True) - - self.delete(vm, expunge=True) - self.delete(network1) - - def handle_threads(self, source_threads, thread_class, **kwargs): - my_threads = [] - for aThread in source_threads: - my_vm = aThread.get_vm() - self.debug("[Concurrency]%s in vm: %s" - % (thread_class.get_name(), my_vm.name)) - new_thread = thread_class(self, my_vm, **kwargs) - my_threads.append(new_thread) - new_thread.start() - # - # Wait until all threads are finished - self.wait_until_done(my_threads, thread_class.get_name()) - return my_threads - - @attr( - tags=["advanced", "nuagevsp", "concurrency"], required_hardware="true") - def test_nuage_configDrive_concurrency(self): - """ Verify concurrency of ConfigDrive userdata update & password reset - """ - - # Validate the following - # 1. When ConfigDrive is enabled as provider in zone - # Create an Isolated Network with Nuage VSP Isolated Network - # offering specifying ConfigDrive as serviceProvider for userdata, - # make sure no Dns is in the offering so no VR is spawned. - # check if it is successfully created and is in the "Allocated" - # state. - # 2. Concurrently create a number of VM's in the above isolated network - # 3. Wait until all VM's are running - # 4. Concurrently update the userdata of all the VM's - # 5. Wait util all updates are finished - # 6. Repeat above (5-6) x times - # 7. Check userdata in all VM's - # 8. Concurrently reset password on all VM's - # 9. Wait until all resets are finished - # 10. Verify all passwords - # 11. Concurrently delete all VM's. - # 12. Restore ConfigDrive provider state - # 13. Delete all the created objects (cleanup). - - # - # 1. When ConfigDrive enabled create network - default_state = self.given_config_drive_provider_is("Enabled") - create_network = self.verify_network_creation( - offering_name="isolated_configdrive_network_offering_withoutdns", - gateway='10.1.1.1') - # - # 2. Concurrently create all VMs - self.password_enabled = self.given_template_password_enabled_is(False) - my_create_threads = [] - nbr_vms = 5 - for i in range(nbr_vms): - # Add VM - self.debug("+++ [Concurrency]Going to verify %d VM's, starting " - "the %d VM" % (nbr_vms, i + 1)) - vm_thread = self.StartVM(self, create_network.network, i) - my_create_threads.append(vm_thread) - vm_thread.start() - # - # 3. Wait until all VM's are running - self.wait_until_done(my_create_threads, "creation") - self.assertEqual( - nbr_vms, len(my_create_threads), "Not all VM's are up") - - try: - for i in range(2): - self.debug("\n+++ [Concurrency]Start update on all VM's") - # - # 5. Concurrently update all VM's - my_update_threads = self.handle_threads(my_create_threads, - self.UpdateVM, idx=i) - - first = my_update_threads[0].get_timestamps() - last = my_update_threads[-1].get_timestamps() - self.debug("[Concurrency] Update report: first start %s, " - "last start %s. Duration in seconds: %s" % - (first[0].strftime("%H:%M:%S-%f"), - last[0].strftime("%H:%M:%S-%f"), - (last[0] - first[0]).total_seconds())) - self.debug("[Concurrency] Update report: first end %s, " - "last end %s. Duration in seconds: %s" % - (first[1].strftime("%H:%M:%S-%f"), - last[1].strftime("%H:%M:%S-%f"), - (last[0] - first[0]).total_seconds())) - # - # 7. Check userdata in all VM's - self.debug("\n+++ [Concurrency]Check userdata") - public_ip_1 = self.acquire_PublicIPAddress(create_network.network) - for aThread in my_update_threads: - # - # create floating ip - self.when_I_create_a_static_nat_ip_to(aThread.get_vm(), - create_network.network, - public_ip_1) - # - # verify userdata - self.debug("[Concurrency]verify userdata for vm %s" - % aThread.get_vm().name) - self.then_config_drive_is_as_expected( - aThread.get_vm(), public_ip_1) - self.delete_StaticNatRule_For_VM(public_ip_1) - # - # 8. Concurrently reset password on all VM's - self.given_template_password_enabled_is(True) - my_reset_threads = self.handle_threads(my_create_threads, - self.ResetPassword) - # - # 10. Verify the passwords - self.debug("\n+++ [Concurrency]Verify passwords on all VM's") - for aThread in my_reset_threads: - # create floating ip - self.when_I_create_a_static_nat_ip_to(aThread.get_vm(), - create_network.network, - public_ip_1) - - # verify password - self.debug("[Concurrency]verify password for vm %s" - % aThread.get_vm().name) - self.then_config_drive_is_as_expected( - aThread.get_vm(), public_ip_1) - self.delete_StaticNatRule_For_VM(public_ip_1) - public_ip_1.delete(self.api_client) - - self.debug("\n+++ [Concurrency]Stop all VM's") - - finally: - self.given_template_password_enabled_is(self.password_enabled) - # - # 11. Concurrently delete all VM's. - self.handle_threads(my_create_threads, self.StopVM) - # - # 12. Restore ConfigDrive provider state - self.given_config_drive_provider_is(default_state) - # - # 13. Delete all the created objects (cleanup). - self.delete_Network(create_network.network) - - @attr(tags=["advanced", "nuagevsp", "shared"], required_hardware="true") - def test_nuage_configdrive_shared_network(self): - """Test Configdrive as provider for shared Networks - to provide userdata and password reset functionality - with Nuage VSP SDN plugin - """ - - # 1. When ConfigDrive is disabled as provider in zone - # Verify Shared Network creation with a network offering - # which has userdata provided by ConfigDrive fails - # 2. When ConfigDrive is enabled as provider in zone - # Create a shared Network with Nuage VSP Isolated Network - # offering specifying ConfigDrive as serviceProvider - # for userdata, - # make sure no Dns is in the offering so no VR is spawned. - # check if it is successfully created and - # is in the "Allocated" state. - # 3. Deploy a VM in the created Shared network with user data, - # check if the Shared network state is changed to - # "Implemented", and the VM is successfully deployed and - # is in the "Running" state. - # Check that no VR is deployed. - # 4. SSH into the deployed VM and verify its user data in the iso - # (expected user data == actual user data). - # 5. Verify that the guest VM's password in the iso. - # 6. Reset VM password, and start the VM. - # 7. Verify that the new guest VM template is password enabled by - # checking the VM's password (password != "password"). - # 8. SSH into the VM for verifying its new password - # after its password reset. - # 9. Verify various scenarios and check the data in configdriveIso - # 10. Delete all the created objects (cleanup). - - if not self.isNuageInfraUnderlay: - self.skipTest( - "Configured Nuage VSP SDN platform infrastructure " - "does not support underlay networking: " - "skipping test") - - self.debug("+++Testing configdrive in an shared network fails..." - "as provider configdrive is still disabled...") - self.given_config_drive_provider_is("Disabled") - shared_test_data = self.test_data["nuagevsp"]["network_all"] - shared_network = self.verify_network_creation( - offering_name="shared_nuage_network_config_drive_offering", - testdata=shared_test_data) - self.assertFalse(shared_network.success, - 'Network found success = %s, expected success =%s' - % (str(shared_network.success), 'False')) - - self.given_config_drive_provider_is("Enabled") - shared_network = self.verify_network_creation( - offering=shared_network.offering, testdata=shared_test_data) - self.assertTrue(shared_network.success, - 'Network found success = %s, expected success = %s' - % (str(shared_network.success), 'True')) - - shared_nw_1 = shared_network.network - - self.validate_Network(shared_nw_1, state="Allocated") - - shared_test_data2 = self.test_data["nuagevsp"]["network_all2"] - shared_network2 = self.verify_network_creation( - offering=shared_network.offering, - testdata=shared_test_data2) - self.assertTrue(shared_network2.success, - 'Network found success = %s, expected success = %s' - % (str(shared_network2.success), 'True')) - - shared_nw_1 = shared_network.network - shared_nw_2 = shared_network2.network - shared_nw_ids = [shared_nw_1.id, shared_nw_2.id] - self.validate_Network(shared_nw_2, state="Allocated") - - self.debug("+++Test user data & password reset functionality " - "using configdrive in an Isolated network without VR") - - self.given_template_password_enabled_is(True) - public_ip_ranges = PublicIpRange.list(self.api_client) - for ip_range in public_ip_ranges: - if ip_range.networkid in shared_nw_ids: - self.enable_NuageUnderlayPublicIpRange(ip_range.id) - - self.debug("+++Deploy of a VM on a shared network with multiple " - "ip ranges, all should have the same value for the " - "underlay flag.") - # Add subnet of different gateway - self.debug("+++ Adding subnet of different gateway") - - subnet = self.add_subnet_to_shared_network_and_verify( - shared_nw_1, - self.test_data["nuagevsp"]["publiciprange2"]) - tmp_test_data = copy.deepcopy( - self.test_data["virtual_machine"]) - - tmp_test_data["ipaddress"] = \ - self.test_data["nuagevsp"]["network_all"]["endip"] - - with self.assertRaises(Exception): - self.create_VM([shared_nw_1], testdata=tmp_test_data) - - self.debug("+++ In a shared network with multiple ip ranges, " - "userdata with config drive must be allowed.") - - self.enable_NuageUnderlayPublicIpRange(subnet.vlan.id) - - vm1 = self.when_I_deploy_a_vm_with_keypair_in([shared_nw_1]) - - self.then_vr_is_as_expected(shared_nw_1) - - public_ip = self.get_public_shared_ip(vm1, shared_nw_1) - self.then_config_drive_is_as_expected(vm1, public_ip, metadata=True) - - self.update_and_validate_userdata(vm1, "helloworld vm1", public_ip) - self.then_config_drive_is_as_expected(vm1, public_ip) - - # ===================================================================== - # Test using network2 as default network - # ===================================================================== - - self.debug("+++ Adding a non-default nic to the VM " - "making it a multi-nic VM...") - self.plug_nic(vm1, shared_nw_2) - self.then_config_drive_is_as_expected(vm1, public_ip, metadata=True) - - self.when_I_reset_the_password(vm1) - self.update_and_validate_userdata(vm1, "hellomultinicvm1", public_ip) - - self.debug("+++ Updating non-default nic as the default nic " - "of the multi-nic VM...") - self.update_default_nic(vm1, shared_nw_2) - self.stop_and_start_vm(vm1) - - public_ip_2 = self.get_public_shared_ip(vm1, shared_nw_2) - self.then_config_drive_is_as_expected(vm1, public_ip_2, metadata=True) - - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip_2) - - self.update_and_validate_userdata(vm1, "hellomultinicvm1again", - public_ip_2) - - self.debug("+++ Updating the default nic of the multi-nic VM, " - "deleting the non-default nic...") - self.update_default_nic(vm1, shared_nw_1) - self.stop_and_start_vm(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip, metadata=True) - - self.unplug_nic(vm1, shared_nw_2) - - # ===================================================================== - # Another Multinic VM - # ===================================================================== - - multinicvm1 = self.when_I_deploy_a_vm([shared_nw_2, shared_nw_1]) - public_ip_3 = self.get_public_shared_ip(multinicvm1, shared_nw_2) - self.then_config_drive_is_as_expected( - multinicvm1, public_ip_3, - metadata=True) - self.update_and_validate_userdata(multinicvm1, "hello multinicvm1", - public_ip) - self.then_config_drive_is_as_expected(multinicvm1, public_ip_3) - multinicvm1.delete(self.api_client, expunge=True) - shared_nw_2.delete(self.api_client) - - # ===================================================================== - - self.debug("+++ Scenario: " - "update userdata and reset password after reboot") - vm1.reboot(self.api_client) - self.then_config_drive_is_as_expected(vm1, public_ip, metadata=True) - self.update_and_validate_userdata(vm1, "hello afterboot", public_ip) - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after migrate") - self.migrate_VM(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip, metadata=True) - self.update_and_validate_userdata(vm1, "hello after migrate", - public_ip) - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip) - - # ===================================================================== - self.debug("+++ Scenario: " - "update userdata and reset password after stop/start") - self.stop_and_start_vm(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip, metadata=True) - - self.update_and_validate_userdata(vm1, "hello afterstopstart", - public_ip) - self.when_I_reset_the_password(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip) - - # ===================================================================== - self.debug("+++ Scenario: " - "verify config drive after delete/recover") - self.delete_and_recover_vm(vm1) - self.then_config_drive_is_as_expected(vm1, public_ip, - metadata=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Start VM fails when ConfigDrive provider is disabled") - self.given_config_drive_provider_is("Disabled") - with self.assertRaises(Exception): - self.when_I_update_userdata(vm1, "hi with provider state Disabled") - self.given_config_drive_provider_is("Enabled") - - self.delete(vm1, expunge=True) - - # ===================================================================== - self.debug("+++ Scenario: " - "Update Userdata on a VM that is not password enabled") - self.update_template(passwordenabled=False) - - vm1 = self.create_VM( - [shared_nw_1], - testdata=self.test_data["virtual_machine_userdata"], - keypair=self.keypair.name) - - self.update_and_validate_userdata(vm1, "This is sample data", - public_ip) - public_ip = PublicIPAddress({"ipaddress": vm1}) - self.then_config_drive_is_as_expected(vm1, public_ip, - metadata=True) - - self.delete(vm1, expunge=True) - self.delete(shared_nw_1) - - @attr(tags=["advanced", "nuagevsp", "endurance"], required_hardware="true") - def test_nuage_configdrive_endurance(self): - """ Verify endurance of ConfigDrive userdata update - """ - # Validate the following - # 1. When ConfigDrive is enabled as provider in zone - # Create an Isolated Network with Nuage VSP Isolated Network - # offering specifying ConfigDrive as serviceProvider for userdata, - # make sure no Dns is in the offering so no VR is spawned. - # 2. create a VM in the above isolated network - # 3. Wait until VM is running - # 4. Concurrently update the userdata for the VM - # 5. Wait util all updates are finished - # 6. Check userdata in VM - # 7. Delete all the created objects (cleanup). - - self.given_config_drive_provider_is("Enabled") - self.given_template_password_enabled_is(True) - self.given_a_network_offering_with_configdrive() - create_network = self.when_I_create_a_network_with_that_offering( - gateway='10.5.1.1' - ) - self.then_the_network_is_successfully_created(create_network) - self.then_the_network_has(create_network, state="Allocated") - - network = create_network.network - - vm = self.when_I_deploy_a_vm(network, keypair=self.keypair.name) - self.then_vr_is_as_expected(network=network) - - public_ip = \ - self.when_I_create_a_static_nat_ip_to(vm, create_network.network) - self.then_config_drive_is_as_expected(vm, public_ip, metadata=True) - - for i in range(0, 30): - self.update_and_validate_userdata(vm, 'This is sample data %s' % i, - public_ip) - -if __name__ == "__main__" and __package__ is None: - __package__ = "integration.plugins.nuage" diff --git a/test/integration/plugins/nuagevsp/test_nuage_extra_dhcp.py b/test/integration/plugins/nuagevsp/test_nuage_extra_dhcp.py deleted file mode 100644 index 3b58cbd017b..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_extra_dhcp.py +++ /dev/null @@ -1,2027 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for extra dhcp options functionality with -Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import (nuageTestCase) -from nuage_lib import gherkin -from marvin.cloudstackAPI import updateVirtualMachine, updateZone -from marvin.lib.base import (Account, - Network, - Configurations, - NetworkOffering) -# Import System Modules -from concurrent.futures import ThreadPoolExecutor, wait -from nose.plugins.attrib import attr -import copy -import time - - -class TestNuageExtraDhcp(nuageTestCase): - """ Test basic VPC Network functionality with Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls, zone=None): - super(TestNuageExtraDhcp, cls).setUpClass() - cls.vmdata = cls.test_data["virtual_machine"] - cls.sharednetworkdata = cls.test_data["acl"] - - # Create an account - cls.account = Account.create(cls.api_client, - cls.test_data["account"], - admin=True, - domainid=cls.domain.id - ) - - cmd = updateZone.updateZoneCmd() - cmd.id = cls.zone.id - cmd.domain = "testvpc.com" - cls.api_client.updateZone(cmd) - cls.vpc_offering = cls.create_VpcOffering( - cls.test_data["nuagevsp"]["vpc_offering_nuage_dhcp"]) - cls.vpc1 = cls.create_vpc(cls.vpc_offering, cidr="10.0.0.0/16", - networkDomain="testvpc.com") - - cls.vpc_network_offering = cls.create_NetworkOffering( - cls.test_data["nuagevsp"]["vpc_network_offering_nuage_dhcp"]) - - cls.vpc_network = cls.create_Network( - cls.vpc_network_offering, gateway="10.0.0.1", vpc=cls.vpc1) - - cmd.domain = "testisolated.com" - cls.api_client.updateZone(cmd) - - # create the isolated network - cls.isolated_network_offering = cls.create_NetworkOffering( - cls.test_data["nuagevsp"]["isolated_network_offering"], True) - cls.isolated_network = cls.create_Network( - cls.isolated_network_offering, gateway="10.0.0.1", - netmask="255.255.255.0") - - cmd.domain = "testshared.com" - cls.api_client.updateZone(cmd) - # Create Shared Network - cls.shared_network_offering = NetworkOffering.create( - cls.api_client, - cls.test_data["nuagevsp"]["shared_nuage_network_offering"], - conservemode=False - ) - - cls.shared_network_offering.update(cls.api_client, state='Enabled') - cls.shared_network_offering_id = cls.shared_network_offering.id - - cls.shared_network_all = Network.create( - cls.api_client, - cls.test_data["nuagevsp"]["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id - ) - cls.dhcp_options_map = {} - cls.dhcp_options_to_verify_map = {} - cls.expected_dhcp_options_on_vm = {} - cls.dhcp_options_map_keys = [1, 16, 28, 41, 64, 93] - - cls._cleanup.append(cls.account) - cls._cleanup.append(cls.shared_network_offering) - cls._cleanup.append(cls.shared_network_all) - - def setUp(self): - self.vmdata["displayname"] = "vm" - self.vmdata["name"] = "vm" - self.update_NuageVspGlobalDomainTemplateName(name="") - self.dhcp_options_map.update({1: {"dhcp:1": "255.255.255.0", - "dhcp:2": "10", - "dhcp:4": "10.0.0.2," - "10.0.0.3," - "10.0.0.4", - "dhcp:7": "10.0.0.5,10.0.0.6", - "dhcp:9": "10.0.0.7", - "dhcp:13": "255", - }}) - self.dhcp_options_map.update({16: {"dhcp:16": "10.0.0.8", - "dhcp:17": "/tmp/", - "dhcp:18": "/ext/", - "dhcp:19": "1", - "non-local-source-routing": "0", - "policy-filter": "10.1.2.12," - "255.255.255.0", - "max-datagram-reassembly": "1000", - "default-ttl": "255", - "mtu": "1024", - "all-subnets-local": "1"}}) - self.dhcp_options_map.update({28: {"broadcast": "10.1.2.255", - "router-discovery": "0", - "router-solicitation": "10.1.2.2", - "static-route": "10.0.0.1,10.0.0.2", - "trailer-encapsulation": "1", - "arp-timeout": "255", - "ethernet-encap": "1", - "tcp-ttl": "255", - "tcp-keepalive": "255", - "nis-domain": "www.test.com"}}) - self.dhcp_options_map.update({41: {"nis-server": "10.1.1.1,10.1.1.2", - "ntp-server": "10.1.1.3,10.1.1.4", - "netbios-ns": "10.1.1.5,10.1.1.6", - "netbios-dd": "10.1.1.8,10.1.1.7", - "netbios-nodetype": "08", - "netbios-scope": "test2", - "x-windows-fs": "10.1.2.13," - "10.1.2.16", - "x-windows-dm": "10.1.2.14," - "10.1.2.15", - "requested-address": "10.1.2.16", - "vendor-class": "01"}}) - self.dhcp_options_map.update({64: {"nis+-domain": "www.test3.com", - "nis+-server": "10.1.2.255," - "10.1.2.254", - "tftp-server": "www.test4.com", - "bootfile-name": "file.txt", - "mobile-ip-home": "10.1.2.18," - "10.1.2.19", - "smtp-server": "10.1.2.20," - "10.1.2.21", - "pop3-server": "10.1.2.2,10.1.2.3", - "nntp-server": "10.1.2.5,10.1.2.4", - "irc-server": "10.1.2.1,10.1.2.4", - "user-class": "user-class"}}) - self.dhcp_options_map.update({93: {"client-arch": "16", - "client-interface-id": "01", - "client-machine-id": "01", - "dhcp:114": - "http://www.testdhcpfeature." - "com/adfsgbfgtdhh125ki-23-fdh" - "-09", - "domain-search": "www.domain.com", - "sip-server": "www.sip.com", - "classless-static-route": - "10.1.0.0/16,10.1.0.1", - "vendor-id-encap": - "0000ACEF04CAFEBABE" - }}) - self.dhcp_options_to_verify_map.update({1: {1: "255.255.255.0", - 2: "10", - 4: ["10.0.0.2", - "10.0.0.3", - "10.0.0.4"], - 7: ["10.0.0.5", - "10.0.0.6"], - 9: "10.0.0.7", - 13: "255"}}) - self.dhcp_options_to_verify_map.update({16: {16: "10.0.0.8", - 17: "/tmp/", - 18: "/ext/", - 19: "1", - 20: "0", - 21: ["10.1.2.12", - "255.255.255.0"], - 22: "1000", - 23: "255", - 26: "1024", - 27: "1"}}) - self.dhcp_options_to_verify_map.update({28: {28: "10.1.2.255", - 31: "0", - 32: "10.1.2.2", - 33: ["10.0.0.1", - "10.0.0.2"], - 34: "1", - 35: "255", - 36: "1", - 37: "255", - 38: "255", - 40: "www.test.com"}}) - self.dhcp_options_to_verify_map.update({41: {41: ["10.1.1.1", - "10.1.1.2"], - 42: ["10.1.1.3", - "10.1.1.4"], - 44: ["10.1.1.5", - "10.1.1.6"], - 45: ["10.1.1.8", - "10.1.1.7"], - 46: "H-node", - 47: "test2", - 48: ["10.1.2.13", - "10.1.2.16"], - 49: ["10.1.2.14", - "10.1.2.15"], - 50: "10.1.2.16", - 60: "01"}}) - self.dhcp_options_to_verify_map.update({64: {64: "www.test3.com", - 65: ["10.1.2.255", - "10.1.2.254"], - 66: "www.test4.com", - 67: "file.txt", - 68: ["10.1.2.18", - "10.1.2.19"], - 69: ["10.1.2.20", - "10.1.2.21"], - 70: ["10.1.2.2", - "10.1.2.3"], - 71: ["10.1.2.5", - "10.1.2.4"], - 74: ["10.1.2.1", - "10.1.2.4"], - 77: "user-class"}}) - self.dhcp_options_to_verify_map.update({93: {93: "16", - 94: "01", - 97: "01", - 114: "http://www.testdhcp" - "feature.com/adfsgbf" - "gtdhh125ki-23-fdh-" - "09", - 119: "www.domain.com", - 120: "www.sip.com", - 121: ["10.1.0.0/16", - "10.1.0.1"], - 125: "0000acef04cafebabe" - }}) - self.expected_dhcp_options_on_vm.update({46: "netbios-node-type 8", - 60: "vendor-class-identifier" - " 1", - 94: "unknown-94 1", - 93: "unknown-93", - 97: "unknown-97 1", - 119: "unknown-119", - 120: "unknown-120", - 121: "unknown-121", - 125: "0:0:ac:ef:4:ca:fe:ba:be" - }) - self.cleanup = [] - return - - def tearDown(self): - super(TestNuageExtraDhcp, self).tearDown() - # Cleanup resources used - self.debug("Cleaning up the resources") - self.update_NuageVspGlobalDomainTemplateName(name="") - self.debug("Cleanup complete!") - return - - def retrieve_dhcp_values_to_verify_on_vm_based_on(self, dhcp_map): - vm_dhcp_map = copy.deepcopy(dhcp_map) - for dhcpcode, dhcpval in self.expected_dhcp_options_on_vm.iteritems(): - if dhcpcode in dhcp_map: - vm_dhcp_map[dhcpcode] = dhcpval - - return vm_dhcp_map - - def verify_vsd_dhcp_option_subnet(self, dhcp_type, value, subnet): - self.debug("Verifying the creation and value of DHCP option type -" - " %s in VSD" % dhcp_type) - found_dhcp_type = False - dhcp_options = self.vsd.get_subnet_dhcpoptions( - filter=self.get_externalID_filter(subnet.id)) - for dhcp_option in dhcp_options: - self.debug("dhcptype option in vsd is : %s" - % dhcp_option.actual_type) - self.debug("dhcptype expected value is: %s" % value) - if dhcp_option.actual_type == dhcp_type: - found_dhcp_type = True - if isinstance(dhcp_option.actual_values, list): - self.debug("dhcptype actual value on vsd is %s:" - "" % dhcp_option.actual_values) - if value in dhcp_option.actual_values: - self.debug("Excepted DHCP option value found in" - " VSD") - else: - self.fail("Excepted DHCP option value not found" - " in VSD") - else: - self.debug("dhcptype actual value on vsd is %s:" - % dhcp_option.actual_values) - self.assertEqual(dhcp_option.actual_values, value, - "Expected DHCP option value is not same" - " in both CloudStack and VSD") - if not found_dhcp_type: - self.fail("Expected DHCP option type and value not found" - " in the VSD") - self.debug("Successfully verified the creation and value of DHCP" - " option type - %s in VSD" % dhcp_type) - - def verify_vsd_dhcp_option(self, dhcp_type, value, vm_interface): - self.debug("Verifying the creation and value of DHCP option type -" - " %s in VSD" % dhcp_type) - self.debug("Expected value for this dhcp option is - %s in VSD" - % value) - found_dhcp_type = False - dhcp_options = self.vsd.get_vm_interface_dhcpoptions( - filter=self.get_externalID_filter(vm_interface.id)) - for dhcp_option in dhcp_options: - self.debug("dhcptype on vsd is %s:" % dhcp_option.actual_type) - self.debug("dhcp value on vsd is: %s:" % dhcp_option.actual_values) - if dhcp_option.actual_type == dhcp_type: - found_dhcp_type = True - if isinstance(dhcp_option.actual_values, list): - self.debug("dhcptype actual value is %s:" % - dhcp_option.actual_values) - if type(value) is list: - for val in value: - self.is_value_in_options(dhcp_option.actual_values, - val) - else: - self.is_value_in_options(dhcp_option.actual_values, - value) - else: - self.assertEqual(dhcp_option.actual_values, value, - "Expected DHCP option value is not same" - " in both CloudStack and VSD") - if not found_dhcp_type: - self.fail("Expected DHCP option type and value not found in " - "the VSD for dhcp type %s " % dhcp_type) - self.debug("Successfully verified the creation and value of DHCP" - " option type - %s in VSD" % dhcp_type) - - def is_value_in_options(self, actual_options, value): - if value in actual_options: - self.debug("Excepted DHCP option value found in VSD") - else: - self.fail("Excepted DHCP option value not found in VSD") - - def verify_vsd_dhcp_option_empty(self, dhcp_type, vm_interface): - self.debug("Verifying the creation and value of DHCP option" - " type - %s in VSD" % dhcp_type) - self.debug("Expected value is empty string") - dhcp_options = self.vsd.get_vm_interface_dhcpoptions( - filter=self.get_externalID_filter(vm_interface.id)) - for dhcp_option in dhcp_options: - self.debug("dhcptype on vsd is %s:" % dhcp_option.actual_type) - self.debug("dhcp value on vsd is: %s:" % dhcp_option.value) - if dhcp_option.actual_type == dhcp_type: - if dhcp_type == 15: - self.assertEqual(dhcp_option.value, "\x00", - "Expected DHCP option value is not" - " same in both CloudStack and VSD") - else: - self.assertEqual(dhcp_option.value, "00", - "Expected DHCP option value is not" - " same in both CloudStack and VSD") - self.debug("Successfully verified the creation and value of" - " DHCP option type - %s in VSD" % dhcp_type) - - def verify_vsd_dhcp_value_notpresent(self, value, vm_interface): - self.debug("Verifying that on vminterface value is not present- %s" - % value) - dhcp_options = self.vsd.get_vm_interface_dhcpoptions( - filter=self.get_externalID_filter(vm_interface.id)) - for dhcp_option in dhcp_options: - self.debug("dhcptype option is %s:" % dhcp_option.actual_type) - if isinstance(dhcp_option.actual_values, list): - self.debug("dhcptype actual value is %s:" - % dhcp_option.actual_values) - if value in dhcp_option.actual_values: - self.fail("This value is not expected on vminterface but " - "present as dhcp_type %s" - % dhcp_option.actual_type) - else: - self.debug("As Excepted DHCP value not found in VSD") - else: - try: - self.assertEqual(dhcp_option.actual_values, value, - "Expected DHCP option value is not same " - "in both CloudStack and VSD") - self.fail("This value is not expected on vm interface but " - "present as dhcp_type %s" - % dhcp_option.actual_type) - except Exception: - self.debug("As Expected DHCP value not found in VSD") - self.debug("Successfully verified dhcp value is not present - %s " - "in VSD" % value) - - def verify_vsd_dhcp_type_notpresent(self, dhcp_types, vm_interface): - if type(dhcp_types) is not list: - dhcp_types = [dhcp_types] - - for dhcp_type in dhcp_types: - self.debug("Verifying that DHCP option type - %s not present" - " in VSD" % dhcp_type) - dhcp_options = self.vsd.get_vm_interface_dhcpoptions( - filter=self.get_externalID_filter(vm_interface.id)) - for dhcp_option in dhcp_options: - self.debug("dhcptype on vsd is %s:" % dhcp_option.actual_type) - if dhcp_option.actual_type == dhcp_type: - self.fail("Expected DHCP option type is not expected in " - "the VSD: %s" % dhcp_type) - self.debug("Successfully verified DHCP option type - %s " - "not present in the VSD" % dhcp_type) - - def verify_dhcp_on_vm( - self, dhcpleasefile, dhcp_option_map, ssh_client, cleanlease=True): - if self.isSimulator: - self.debug("Simulator Environment: " - "Skipping VM DHCP option verification") - return - - cmd = 'cat /var/lib/dhclient/'+dhcpleasefile - self.debug("get content of dhcp lease file " + cmd) - outputlist = ssh_client.execute(cmd) - self.debug("command is executed properly " + cmd) - completeoutput = str(outputlist).strip('[]') - self.debug("complete output is " + completeoutput) - - for key, value in dhcp_option_map.iteritems(): - if type(value) is list: - for val in value: - self.check_if_value_contains(completeoutput, val) - else: - self.check_if_value_contains(completeoutput, value) - if cleanlease: - self.remove_lease_file(ssh_client, dhcpleasefile) - - def check_if_value_contains(self, completeoutput, value): - if value in completeoutput: - self.debug("excepted value found in vm: " + value) - else: - self.fail("excepted value not found in vm: " + value) - - def remove_lease_file(self, ssh_client, dhcpleasefile): - cmd = 'rm -rf /var/lib/dhclient/'+dhcpleasefile - outputlist = ssh_client.execute(cmd) - completeoutput = str(outputlist).strip('[]') - self.debug("clear lease is done properly:" + completeoutput) - - def update_zone_details(self, value): - """Updates Network Domain at zone level""" - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = value - self.api_client.updateZone(cmd) - - def update_NuageVspGlobalDomainTemplateName(self, name): - self.debug("Updating global setting nuagevsp.vpc.domaintemplate.name " - "with value - %s" % name) - Configurations.update(self.api_client, - name="nuagevsp.vpc.domaintemplate.name", - value=name) - self.debug("Successfully updated global setting " - "nuagevsp.vpc.domaintemplate.name with value - %s" % name) - - def create_isolated_network( - self, network_offering=None, gateway="10.1.1.1", - netmask="255.255.255.0"): - # create a isolated network - self.debug("Creating an Isolated network...") - if not network_offering: - network_offering = self.create_isolated_network_offering() - - network = self.create_Network(network_offering, gateway, netmask) - - return network - - def validate_isolated_network( - self, network_offering, network): - self.debug("Validating network...") - self.validate_NetworkOffering(network_offering, state="Enabled") - self.validate_Network(network) - - def validate_vpc_and_vpcoffering(self, vpc, vpc_offering): - self.debug("Validating vpc...") - self.validate_vpc(vpc) - self.validate_VpcOffering(vpc_offering) - - def verify_dhcp_options_on_vm( - self, vm, network, vpc, dhcp_options, remove_lease_file=True, - lease_file="dhclient-eth0.leases", verify_on_vsd=True): - # Adding Ingress Firewall/Network ACL rule - self.debug("Adding Ingress Firewall/Network ACL rule to make the " - "created Static NAT rule (wget) accessible...") - public_ip = self.acquire_PublicIPAddress(network, vpc=vpc) - self.create_StaticNatRule_For_VM( - vm, public_ip, network) - - if vpc: - public_http_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=network) - else: - public_http_rule = self.create_FirewallRule(public_ip) - - # VSD verification - if verify_on_vsd: - self.verify_vsd_firewall_rule(public_http_rule) - - ssh_client = self.ssh_into_VM(vm, public_ip) - dhcp_options_to_verify_on_vm =\ - self.retrieve_dhcp_values_to_verify_on_vm_based_on( - dhcp_options) - self.verify_dhcp_on_vm( - lease_file, dhcp_options_to_verify_on_vm, - ssh_client, remove_lease_file) - - # Removing Ingress Firewall/Network ACL rule - self.debug("Removing the created Ingress Firewall/Network ACL " - "rule in the network...") - public_http_rule.delete(self.api_client) - - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network) - - def verify_dhcp_options_on_vsd( - self, vm, dhcp_options, - networks_with_options=None, - verify_vm_on_vsd=True): - - if verify_vm_on_vsd: - self.verify_vsd_vm(vm) - - if networks_with_options: - for nic in vm.nic: - if self.is_nic_in_network_list(nic, networks_with_options): - for key, value in dhcp_options.iteritems(): - self.verify_vsd_dhcp_option(key, value, nic) - else: - for nic in vm.nic: - for key, value in dhcp_options.iteritems(): - self.verify_vsd_dhcp_option(key, value, nic) - - @staticmethod - def is_nic_in_network_list(nic, network_list): - if type(network_list) is list: - for network in network_list: - if network.id == nic.networkid: - return True - return False - elif network_list.id == nic.networkid: - return True - return False - - def validate_network_on_vsd_based_on_networktype( - self, network, vpc=None, is_shared_network=False): - if is_shared_network: - self.verify_vsd_shared_network( - self.domain.id, network, - gateway=self.test_data["nuagevsp"]["network_all"]["gateway"]) - else: - self.verify_vsd_network(self.domain.id, network, vpc) - - def create_vpc_offering_with_nuage_dhcp(self): - # Creating a VPC offering - self.debug("Creating Nuage VSP VPC offering without dhcp...") - vpc_offering = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_nuage_dhcp"]) - self.validate_VpcOffering(vpc_offering, state="Enabled") - - return vpc_offering - - def create_isolated_network_offering(self): - network_offering = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - return network_offering - - def create_vpc_network_offering(self): - network_offering = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_nuage_dhcp"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - return network_offering - - def create_and_validate_vpc(self, vpc_offering, cidr="10.0.0.0/16"): - # Creating a VPC - self.debug("Creating a VPC with Nuage VSP VPC offering...") - vpc = self.create_vpc(vpc_offering, cidr=cidr, - networkDomain="testvpc.com") - self.validate_vpc(vpc, state="Enabled") - - return vpc - - def create_vpc_with_tier(self, domain_name="testvpc.com"): - vpc_offering = self.create_vpc_offering_with_nuage_dhcp() - vpc = self.create_and_validate_vpc(vpc_offering) - - vpc_network_offering = self.create_vpc_network_offering() - acl_list = self.create_acl_list_with_item(vpc) - vpc_first_tier = \ - self.when_i_create_a_first_vpc_network_with_nuage_dhcp( - vpc, vpc_network_offering, acl_list) - - self.verify_vsd_dhcp_option_subnet(15, domain_name, vpc_first_tier) - - return {"vpc": vpc, "tier": vpc_first_tier} - - def create_acl_list_with_item(self, vpc): - # Creating an ACL list - acl_list = self.create_NetworkAclList(name="acl", description="acl", - vpc=vpc) - - # Creating an ACL item - self.create_NetworkAclRule(self.test_data["ingress_rule"], - acl_list=acl_list) - - return acl_list - - @staticmethod - def add_extra_dhcp_options_to_check(dhcp_options_to_verify, domain_name, - remove_dns_options=False): - if not remove_dns_options: - dhcp_options_to_verify[12] = "vm1" - dhcp_options_to_verify[15] = domain_name - return dhcp_options_to_verify - - def get_extra_dhcp_options_starting_with(self, dhcp_option_code, - network=None): - dhcp_options =\ - copy.deepcopy(self.dhcp_options_map.get(dhcp_option_code)) - if network: - dhcp_options["networkid"] = network.id - return dhcp_options - - def get_extra_dhcp_options_to_verify_starting_with( - self, number, domain_name, remove_dns_options=False): - dhcp_options_to_verify = copy.deepcopy( - self.dhcp_options_to_verify_map.get(number)) - self.add_extra_dhcp_options_to_check( - dhcp_options_to_verify, domain_name, remove_dns_options) - return dhcp_options_to_verify - - @gherkin - def when_i_update_the_zone_details_and_restart_a_vpc(self, vpc): - self.update_zone_details("testvpc.com") - vpc.restart(self.api_client) - - @gherkin - def when_i_create_a_first_vpc_network_with_nuage_dhcp( - self, vpc, network_offering, acl_list, gateway="10.0.0.1"): - # Creating a VPC network in the VPC - self.debug( - "Creating a VPC network with Nuage VSP VPC Network offering...") - vpc_network = self.create_Network(network_offering, gateway=gateway, - vpc=vpc, acl_list=acl_list) - self.validate_Network(vpc_network, state="Implemented") - - return vpc_network - - @gherkin - def when_i_create_a_second_vpc_network_with_nuage_dhcp( - self, vpc, network_offering, acl_list): - vpc_network_1 = self.create_Network( - network_offering, gateway='10.1.2.1', vpc=vpc, acl_list=acl_list) - self.validate_Network(vpc_network_1, state="Implemented") - - return vpc_network_1 - - @gherkin - def when_i_stop_and_start_a_vm(self, vm): - vm.stop(self.api_client) - vm.start(self.api_client) - - @gherkin - def when_i_add_an_extra_nic_to_a_vm(self, vm, network, dhcp_options=None): - dhcp_options_list = None - - if dhcp_options: - if type(dhcp_options) is list: - dhcp_options_list = [] - for item in dhcp_options: - dhcp_options_list.extend([item]) - else: - dhcp_options_list = [dhcp_options] - - return vm.add_nic(self.api_client, network.id, - dhcpoptions=dhcp_options_list) - - @gherkin - def when_i_restart_a_network(self, network): - network.restart(self.api_client, cleanup=True) - - @gherkin - def when_i_create_a_vm( - self, network, vpc, vm_name, dhcp_options, - start_vm=True, is_shared_network=False, - ip_address=None): - vm_data = copy.deepcopy(self.vmdata) - if dhcp_options: - if type(dhcp_options) is list: - dhcp_options_list = [] - for item in dhcp_options: - dhcp_options_list.extend([item]) - else: - dhcp_options_list = [dhcp_options] - - vm_data["dhcpoptionsnetworklist"] = dhcp_options_list - elif "dhcpoptionsnetworklist" in vm_data: - del vm_data["dhcpoptionsnetworklist"] - - if ip_address: - vm_data["ipaddress"] = ip_address - if vm_name: - vm_data["displayname"] = vm_name - vm_data["name"] = vm_name - - vm = self.create_VM(network, start_vm=start_vm, testdata=vm_data) - if start_vm: - self.check_VM_state(vm, state="Running") - else: - self.check_VM_state(vm, state="Stopped") - # VSD verification - if type(network) is not list: - self.validate_network_on_vsd_based_on_networktype( - network, vpc, is_shared_network) - - return vm - - @gherkin - def when_i_update_extra_dhcp_options_on_a_vm(self, vm, dhcp_options): - """Updates the VM data""" - if type(dhcp_options) is list: - dhcp_options_list = [] - for item in dhcp_options: - dhcp_options_list.extend([item]) - else: - dhcp_options_list = [dhcp_options] - - cmd = updateVirtualMachine.updateVirtualMachineCmd() - cmd.id = vm.id - cmd.dhcpoptionsnetworklist = dhcp_options_list - self.api_client.updateVirtualMachine(cmd) - - @gherkin - def then_verify_domain_name_and_router_options_multi_nic_set( - self, multinic_vm, primary_network, domain_name="testvpc.com"): - for nic in multinic_vm.nic: - if nic.networkid != primary_network.id: - self.verify_vsd_dhcp_option(3, "0.0.0.0", nic) - self.verify_vsd_dhcp_option(15, "\x00", nic) - else: - self.verify_vsd_dhcp_option(15, domain_name, nic) - - @gherkin - def then_verify_dhcp_options_on_vsd_and_vm(self, vm, network, - dhcp_options_to_verify, - network_with_options=None, - is_shared_network=False, - verify_on_vm=False, - default_network=None, - vpc=None, - remove_lease_file=False, - verify_on_vsd=True): - - if verify_on_vsd: - self.verify_dhcp_options_on_vsd( - vm, dhcp_options_to_verify, network_with_options, - not is_shared_network) - if verify_on_vm and not self.isSimulator and not is_shared_network: - if default_network: - network = default_network - lease_file = "dhclient-eth1.leases" - else: - lease_file = "dhclient-eth0.leases" - - self.verify_dhcp_options_on_vm( - vm=vm, - network=network, - vpc=vpc, - dhcp_options=dhcp_options_to_verify, - lease_file=lease_file, - remove_lease_file=remove_lease_file, - verify_on_vsd=verify_on_vsd) - - @gherkin - def then_no_dhcp_options_present_on_vsd(self, dhcp_options_map, vm, - excluded_nics=None): - for nic in vm.nic: - if not excluded_nics or nic not in excluded_nics: - self.verify_vsd_dhcp_type_notpresent( - dhcp_options_map.keys(), nic) - self.verify_vsd_dhcp_value_notpresent( - dhcp_options_map.values(), nic) - - def validate_all_extra_dhcp_for_add_remove_nic_after_migrate( - self, network, domain_name="testisolated.com", - is_shared_network=False, verify_all_options=False): - # 1 - create an extra isolated network - # 2 - for each extra dhc option: - # a - deploy a vm - # b - migrate vm - # c - plug nic - # d - verify the dhcp options are correctly set on the nic - # e - remove nic - # f - verify the dhcp options are no longer present on the vsd - # and vm - # 3 - try to remove the default nic which has extra dhcp options set - # (this should fail) - - isolated_network2 =\ - self.create_isolated_network(gateway="10.0.1.1") - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - vm1 = self.when_i_create_a_vm( - isolated_network2, None, "vm1", - dhcp_options=None, - is_shared_network=False) - - if not self.isSimulator: - self.migrate_VM(vm1) - - result = self.when_i_add_an_extra_nic_to_a_vm(vm1, network, None) - dhcp_options_network = self.get_extra_dhcp_options_starting_with( - number, network) - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, dhcp_options_network) - self.when_i_stop_and_start_a_vm(vm1) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, remove_dns_options=True) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - network_with_options=network, - is_shared_network=is_shared_network, - verify_on_vm=True, - default_network=isolated_network2, - vpc=None) - - vm1.remove_nic( - self.api_client, - [nic for nic in result.nic - if nic.networkid == network.id][0].id) - - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, remove_dns_options=True) - self.then_no_dhcp_options_present_on_vsd(dhcp_options_to_verify, - vm1) - self.delete_VM(vm1) - - def validate_vm_deploy_concurrency( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False): - - old_dhcp_options =\ - self.get_extra_dhcp_options_starting_with(1, network) - old_dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - 1, domain_name, True) - - new_dhcp_options =\ - self.get_extra_dhcp_options_starting_with(16, network) - new_dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - 16, domain_name, True) - - def deploy_update_validate_vm(number): - vm = self.when_i_create_a_vm( - [network], vpc, "vm-%02d" % number, - old_dhcp_options, - is_shared_network=is_shared_network) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm, network, old_dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc, - verify_on_vsd=False) - - self.when_i_update_extra_dhcp_options_on_a_vm(vm, new_dhcp_options) - self.when_i_stop_and_start_a_vm(vm) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm, network, new_dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc, - verify_on_vsd=False) - - self.delete_VM(vm) - - try: - executor = ThreadPoolExecutor(max_workers=10) - - vm_futures = [executor.submit( - deploy_update_validate_vm, i) - for i in range(10)] - - wait(vm_futures) - - [f.result() - for f in vm_futures] - - finally: - executor.shutdown(wait=True) - - def validate_all_extra_dhcp_for_network_actions_in_network( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - for each extra dhcp option: - # a - deploy a vm with dhcp options - # b - restart the network - # c - check if the extra dhcp options are still correct - # d - restart the network with clean up = false - # e - check if the extra dhcp options are still correct - # f - if the network is a vpc, restart the vpc - # g - check if the extra dhcp options are still correct - # h - delete the vm - # i - create a vm - # j - stop the vm - # k - start the vm in a seperate thread - # l - add an extra nic while the vn is still in starting state - # m - delete the the vm - # 2 - deploy a vm - # 3 - wait for the network to go into allocated state - # 4 - deploy a new vm in the network - # 5 - check if all options are set correctly - # 6 - delete the network - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - dhcp_options_network =\ - self.get_extra_dhcp_options_starting_with(number, network) - vm1 = self.when_i_create_a_vm( - network, vpc, "vm1", dhcp_options_network, - is_shared_network=is_shared_network) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, is_shared_network) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc, remove_lease_file=False) - - network.restart(self.api_client, True) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc, remove_lease_file=False) - - network.restart(self.api_client, False) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc, remove_lease_file=False) - - if vpc: - self.restart_Vpc(vpc) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc, remove_lease_file=False) - - self.restart_Vpc(vpc, True) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc) - - self.delete_VM(vm1) - - dhcp_options_network = \ - self.get_extra_dhcp_options_starting_with(number, network) - - vm2 = self.when_i_create_a_vm( - network, vpc, "vm2", dhcp_options_network, - is_shared_network=is_shared_network) - - isolated_network2 =\ - self.create_isolated_network(gateway="10.0.1.1") - - dhcp_options_network =\ - self.get_extra_dhcp_options_starting_with( - number, None) - vm_nic = self.when_i_add_an_extra_nic_to_a_vm( - vm2, isolated_network2, dhcp_options=dhcp_options_network) - - dhcp_options_to_verify = \ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, remove_dns_options=True) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm2, isolated_network2, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=False) - - if not is_shared_network: - self.then_verify_domain_name_and_router_options_multi_nic_set( - vm2, network, domain_name) - - vm2.update_default_nic( - self.api_client, - [nic - for nic in vm_nic.nic - if not nic.isdefault][0].id) - self.when_i_stop_and_start_a_vm(vm2) - - if not is_shared_network: - self.then_verify_domain_name_and_router_options_multi_nic_set( - vm2, isolated_network2, domain_name) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm2, isolated_network2, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True) - self.delete_VM(vm2) - - def validate_all_extra_dhcp_for_network_in_allocated( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False): - dhcp_options_network =\ - self.get_extra_dhcp_options_starting_with(1, network) - vm3 = self.when_i_create_a_vm( - network, vpc, "vm3", dhcp_options_network, - is_shared_network=is_shared_network) - vm3.stop(self.api_client) - # wait 1 min for network to go into allocated state - time.sleep(60) - dhcp_options_network =\ - self.get_extra_dhcp_options_starting_with(64, network) - vm4 = self.when_i_create_a_vm( - network, vpc, "vm1", dhcp_options_network, - is_shared_network=is_shared_network) - dhcp_options_to_verify = \ - self.get_extra_dhcp_options_to_verify_starting_with( - 64, domain_name, is_shared_network) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm4, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, vpc=vpc) - - self.delete_VM(vm4) - self.delete_VM(vm3) - - def validate_all_extra_dhcp_for_vm_actions_in_network( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - for each extra dhcp options: - # a - create a vm with dhcp options - # b - start and stop the vm - # c - check if the dhcp options are set correctly - # d - reboot the vm - # e - check if the dhcp options are set correctly - # f - delete a vm without expunging it - # g - recover the vm - # h - start the vm - # i - check if the dhcp options are set correctly - # j - delete the vm - # 2 - create a vm with extra dhcp options set - # 3 - check if the dhcp options are set correctly - # 4 - update the vm with new extra dhcp options - # 5 - reboot the vm - # 6 - verify the dhcp options on the vm and the vsd are not updated - # 7 - delete the vm - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - dhcp_options_network =\ - self.get_extra_dhcp_options_starting_with(number, network) - vm1 = self.when_i_create_a_vm( - network, vpc, "vm1", dhcp_options_network, - is_shared_network=is_shared_network) - - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, is_shared_network) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - self.when_i_stop_and_start_a_vm(vm1) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - vm1.reboot(self.api_client) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - vm1.delete(self.api_client, False) - vm1.recover(self.api_client) - vm1.start(self.api_client) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - vm1.restore(self.api_client) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - if not self.isSimulator: - self.migrate_VM(vm1) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc) - - vm1.delete(self.api_client, True) - - dhcp_options_network = self.get_extra_dhcp_options_starting_with( - 1, network) - vm1 = self.when_i_create_a_vm( - network, vpc, "vm1", dhcp_options_network, - is_shared_network=is_shared_network) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - 1, domain_name, is_shared_network) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - dhcp_options_network_not_present =\ - self.get_extra_dhcp_options_starting_with(93, network) - dhcp_options_to_verify_network_not_present =\ - self.get_extra_dhcp_options_to_verify_starting_with( - 93, domain_name, True) - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, dhcp_options_network_not_present) - vm1.reboot(self.api_client) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - self.then_no_dhcp_options_present_on_vsd( - dhcp_options_to_verify_network_not_present, vm1) - - if not self.isSimulator: - self.migrate_VM(vm1) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - dhcp_options_network = self.get_extra_dhcp_options_starting_with( - 64, network) - dhcp_options_to_verify = \ - self.get_extra_dhcp_options_to_verify_starting_with( - 64, domain_name, is_shared_network) - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, dhcp_options_network) - vm1.restore(self.api_client) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - - self.delete_VM(vm1) - - def validate_all_extra_dhcp_for_remove_nic_from_vm( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - create an extra isolated network - # 2 - for each extra dhc option: - # a - deploy a vm - # b - plug nic - # c - verify the dhcp options are correctly set on the nic - # d - remove nic - # e - verify the dhcp options are no longer present on the vsd - # and vm - # 3 - try to remove the default nic which has extra dhcp options set - # (this should fail) - - isolated_network2 =\ - self.create_isolated_network(gateway="10.0.1.1") - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - vm1 = self.when_i_create_a_vm( - isolated_network2, None, "vm1", dhcp_options=None, - is_shared_network=False) - result = self.when_i_add_an_extra_nic_to_a_vm(vm1, network, None) - dhcp_options_network = self.get_extra_dhcp_options_starting_with( - number, network) - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, dhcp_options_network) - self.when_i_stop_and_start_a_vm(vm1) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify=dhcp_options_to_verify, - network_with_options=network, - is_shared_network=is_shared_network, verify_on_vm=True, - default_network=isolated_network2, vpc=None) - vm1.remove_nic( - self.api_client, - [nic for nic in result.nic - if nic.networkid == network.id][0].id) - - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - self.then_no_dhcp_options_present_on_vsd(dhcp_options_to_verify, - vm1) - self.delete_VM(vm1) - - # invalid remove option - vm1 = self.when_i_create_a_vm( - network, vpc, "vm1", None, is_shared_network=is_shared_network) - result = self.when_i_add_an_extra_nic_to_a_vm( - vm1, isolated_network2, None) - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, dhcp_options_network) - self.when_i_stop_and_start_a_vm(vm1) - with self.assertRaises(Exception): - vm1.remove_nic( - self.api_client, - [nic for nic in result.nic - if nic.networkid == network.id][0].id) - - def validate_all_extra_dhcp_for_update_multinic( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - create an extra isolated network - # 2 - for each extra dhcp option: - # a - deploy a vm and ad an extra nic - # b - update the dhcp options on both nics - # c - verify the dhcp options are not yet set on the vsd and vm - # d - start and stop the vm - # e - verify the new dhcp options are set on the vsd and vm - # 3 - try to update a multi nic vm with invalid options - # (this should fail) - - isolated_network2 =\ - self.create_isolated_network(gateway="10.0.1.1") - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - vm1 = self.when_i_create_a_vm( - isolated_network2, None, "vm1", - dhcp_options=None, - is_shared_network=False) - self.when_i_add_an_extra_nic_to_a_vm(vm1, network, None) - - dhcp_options_network = self.get_extra_dhcp_options_starting_with( - number, network) - dhcp_options_network2 = self.get_extra_dhcp_options_starting_with( - number, isolated_network2) - dhcp_options_list = [dhcp_options_network, dhcp_options_network2] - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - self.when_i_update_extra_dhcp_options_on_a_vm(vm1, - dhcp_options_list) - self.then_no_dhcp_options_present_on_vsd(dhcp_options_to_verify, - vm1) - - self.when_i_stop_and_start_a_vm(vm1) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify=dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - default_network=isolated_network2, vpc=None) - self.delete_VM(vm1) - - invalid_dhcp_options_list = [{"networkid": network.id, - "dhcp:": - "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": network.id, - "dhcp:241": - "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": network.id, - "unknownvalue": - "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": "invalidnetworkid", - "dhcp:114": - "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"}] - valid_dhcp_option = {"networkid": isolated_network2.id, - "dhcp:124": - "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"} - for invalid_dhcp_option in invalid_dhcp_options_list: - vm1 = self.when_i_create_a_vm( - isolated_network2, vpc, "vm1", - dhcp_options=None, - is_shared_network=False) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - 93, domain_name, True) - self.then_no_dhcp_options_present_on_vsd(dhcp_options_to_verify, - vm1) - combined_options = [invalid_dhcp_option, valid_dhcp_option] - with self.assertRaises(Exception): - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, combined_options) - self.delete_VM(vm1) - - def validate_all_extra_dhcp_for_multi_nic( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - create an extra isolated network - # 2 - for each extra dhcp option: - # a - deploy a vm with a nic in two networks - # b - verify that the dhcp options are correctly set on the vsd - # and vn - # c - deploy a vm with a nic in two networks but now, let the other - # network be the default network of the vm - # d - verify that the dhcp options are correctly set on the vsd - # and vm - # 3 - try to deploy a multi nic vm with invalid dhcp options - # (should fail) - - isolated_network2 =\ - self.create_isolated_network(gateway="10.0.1.1") - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - dhcp_options_network = self.get_extra_dhcp_options_starting_with( - number, network) - dhcp_options_network2 = self.get_extra_dhcp_options_starting_with( - number, isolated_network2) - dhcp_options = [dhcp_options_network, dhcp_options_network2] - - # default nic is the network provided - multinic_vm = self.when_i_create_a_vm( - [network, isolated_network2], vpc, "vm1", dhcp_options, - is_shared_network=is_shared_network) - - if not is_shared_network: - self.then_verify_domain_name_and_router_options_multi_nic_set( - multinic_vm, network, domain_name) - - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, is_shared_network) - self.then_verify_dhcp_options_on_vsd_and_vm( - multinic_vm, network, dhcp_options_to_verify, - network_with_options=network, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc) - - # is not primary nic so no option 12 - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, remove_dns_options=True) - self.then_verify_dhcp_options_on_vsd_and_vm( - multinic_vm, network, dhcp_options_to_verify, - network_with_options=isolated_network2, - is_shared_network=is_shared_network, verify_on_vm=False, - default_network=network, vpc=vpc) - self.delete_VM(multinic_vm) - - # default nic is isolated_network2 - multinic_vm = self.when_i_create_a_vm( - [isolated_network2, network], vpc, "vm1", dhcp_options, - is_shared_network=is_shared_network) - - if not is_shared_network: - self.then_verify_domain_name_and_router_options_multi_nic_set( - multinic_vm, isolated_network2, domain_name) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, is_shared_network) - self.then_verify_dhcp_options_on_vsd_and_vm( - multinic_vm, network, dhcp_options_to_verify, - network_with_options=isolated_network2, - is_shared_network=is_shared_network, verify_on_vm=False, - vpc=vpc) - - # is not primary nic so no option 12 - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - self.then_verify_dhcp_options_on_vsd_and_vm( - multinic_vm, network, - dhcp_options_to_verify=dhcp_options_to_verify, - network_with_options=network, - is_shared_network=is_shared_network, verify_on_vm=True, - default_network=isolated_network2, vpc=None) - self.delete_VM(multinic_vm) - - invalid_dhcp_options_list = [{"networkid": network.id, - "dhcp:": - "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": network.id, - "dhcp:241": - "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": network.id, - "unknownvalue": - "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": "invalidnetworkid", - "dhcp:114": - "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh-09"}] - for invalid_dhcp_option in invalid_dhcp_options_list: - with self.assertRaises(Exception): - self.when_i_create_a_vm( - [isolated_network2, network], vpc, "vm1", - dhcp_options=invalid_dhcp_option, - is_shared_network=is_shared_network) - - def validate_all_extra_dhcp_after_plug_nic( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - create an extra isolated network - # 2 - for each extra dchp options: - # a - deploy a vm in the created isolated network - # b - add an extra nic - # c - verify if the dhcp options are correctly set - # 3 - try to add a nic with invalid dhcp options (this should fail) - - isolated_network2 =\ - self.create_isolated_network(gateway="10.0.1.1") - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - vm1 = self.when_i_create_a_vm( - isolated_network2, vpc, "vm1", None, - is_shared_network=False) - - self.then_no_dhcp_options_present_on_vsd( - dhcp_options_to_verify, vm1) - - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - - dhcp_options = self.get_extra_dhcp_options_starting_with(number) - self.when_i_add_an_extra_nic_to_a_vm(vm1, network, - dhcp_options=dhcp_options) - vm1.reboot(self.api_client) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify=dhcp_options_to_verify, - network_with_options=network, - is_shared_network=is_shared_network, verify_on_vm=True, - default_network=isolated_network2, vpc=None) - self.delete_VM(vm1) - - invalid_dhcp_options_list = [ - {"dhcp:": "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"}, - {"dhcp:241": "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"}, - {"unknownvalue": "http://www.testdhcpfeature.com/" - "adfsgbfgtdhh125ki-23-fdh-09"}] - for invalid_dhcp_option in invalid_dhcp_options_list: - vm1 = self.when_i_create_a_vm( - isolated_network2, vpc, "vm1", None, - is_shared_network=False) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - 93, domain_name, remove_dns_options=True) - self.then_no_dhcp_options_present_on_vsd(dhcp_options_to_verify, - vm1) - with self.assertRaises(Exception): - self.when_i_add_an_extra_nic_to_a_vm( - vm1, network, dhcp_options=invalid_dhcp_option) - self.delete_VM(vm1) - - def validate_all_extra_dhcp_after_vm_update( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - deploy a vm without extra dhcp options - # 2 - verify no dhcp options are present - # 3 - For each extra dhcp options - # a - update the vm with extra dhcp options - # b - check that the vm options are yet not updated on the vsd - # and vm - # c - stop and start the vm - # d - check that the dhcp options are set on the vsd an vm - # 4 - update a vm zith invalid dhcp options (this should fail) - - # option 1 to 13 is special because we start a vm here - # instead of update - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with(1, domain_name, - True) - vm1 = self.when_i_create_a_vm( - network, vpc, "vm1", None, - is_shared_network=is_shared_network) - self.then_no_dhcp_options_present_on_vsd(dhcp_options_to_verify, vm1) - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - dhcp_options = self.get_extra_dhcp_options_starting_with(number, - network) - self.when_i_update_extra_dhcp_options_on_a_vm(vm1, dhcp_options) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, True) - self.then_no_dhcp_options_present_on_vsd(dhcp_options_to_verify, - vm1) - - # dhcp options get applied after start stop vm - self.when_i_stop_and_start_a_vm(vm1) - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, is_shared_network) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, verify_on_vm=True, - vpc=vpc) - - invalid_dhcp_options_list = [{"networkid": network.id, - "dhcp:": "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": network.id, - "dhcp:241": "http://www.testdhcpfeature" - ".com/adfsgbfgtdhh125ki-23" - "-fdh-09"}, - {"networkid": network.id, - "unknownvalue": "http://www.testdhcp" - "feature.com/" - "adfsgbfgtdhh125ki-23-" - "fdh-09"}, - {"networkid": "invalidnetworkid", - "dhcp:114": "http://www.testdhcpfeature" - ".com/adfsgbfgtdhh125ki-23-" - "fdh-09"}] - for invalid_dhcp_option in invalid_dhcp_options_list: - with self.assertRaises(Exception): - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, invalid_dhcp_option) - - def validate_all_extra_dhcp_deploy_vm( - self, network, - vpc=None, - domain_name="testisolated.com", - is_shared_network=False, - verify_all_options=False): - # 1 - For each extra dhcp option: - # a - deploy a vm with extra dhcp options - # b - verify if the options are present on the vsd and vm - # c - delete the VM - # 2 - create a vm with different invalid dhcp options - # (this should fail) - - if verify_all_options: - options_to_verify = self.dhcp_options_map_keys - else: - options_to_verify = [1] - - for number in options_to_verify: - dhcp_options = self.get_extra_dhcp_options_starting_with( - number, network) - - dhcp_options_to_verify =\ - self.get_extra_dhcp_options_to_verify_starting_with( - number, domain_name, is_shared_network) - vm1 = self.when_i_create_a_vm( - network, vpc, "vm1", dhcp_options, - is_shared_network=is_shared_network) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - is_shared_network=is_shared_network, - verify_on_vm=True, - vpc=vpc) - self.delete_VM(vm1) - - invalid_dhcp_options_list = [{"networkid": network.id, - "dhcp:": "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh" - "-09"}, - {"networkid": network.id, - "dhcp:241": - "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": network.id, - "unknownvalue": - "http://www.testdhcpfeature" - ".com/adfsgbfgtdhh125ki-23-fdh-09"}, - {"networkid": "invalidnetworkid", - "dhcp:114": - "http://www.testdhcpfeature.com" - "/adfsgbfgtdhh125ki-23-fdh-09"}] - for invalid_dhcp_option in invalid_dhcp_options_list: - with self.assertRaises(Exception): - self.when_i_create_a_vm( - network, vpc, "vm2", invalid_dhcp_option, - is_shared_network=is_shared_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_nuage_extra_dhcp_single_nic_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_deploy_vm(self.isolated_network, - verify_all_options=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_nuage_extra_dhcp_single_nic_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_deploy_vm( - self.vpc_network, - self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_nuage_extra_dhcp_single_nic_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_deploy_vm( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_nuage_extra_dhcp_update_vm_in_isoltated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_after_vm_update( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_05_nuage_extra_dhcp_update_vm_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_after_vm_update( - self.vpc_network, self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_06_nuage_extra_dhcp_update_vm_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_after_vm_update( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_07_nuage_extra_dhcp_add_nic_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_after_plug_nic( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_08_nuage_extra_dhcp_add_nic_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_after_plug_nic( - self.vpc_network, self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_09_nuage_extra_dhcp_add_nic_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_after_plug_nic( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_10_nuage_extra_dhcp_deploy_multi_nic_vm_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_for_multi_nic( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_11_nuage_extra_dhcp_deploy_multi_nic_vm_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_for_multi_nic( - self.vpc_network, self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_12_nuage_extra_dhcp_deploy_multi_nic_vm_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_for_multi_nic( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_13_nuage_extra_dhcp_update_multi_nic_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_for_update_multinic( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_14_nuage_extra_dhcp_update_multi_nic_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_for_update_multinic( - self.vpc_network, self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_15_nuage_extra_dhcp_update_multi_nic_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_for_update_multinic( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_16_nuage_extra_dhcp_remove_nic_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_for_remove_nic_from_vm( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_17_nuage_extra_dhcp_remove_nic_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_for_remove_nic_from_vm( - network=self.vpc_network, - vpc=self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_18_nuage_extra_dhcp_remove_nic_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_for_remove_nic_from_vm( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_19_nuage_extra_dhcp_vm_actions_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_for_vm_actions_in_network( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_20_nuage_nuage_extra_dhcp_vm_actions_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_for_vm_actions_in_network( - network=self.vpc_network, - vpc=self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_21_nuage_extra_dhcp_vm_actions_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_for_vm_actions_in_network( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_22_nuage_extra_dhcp_network_actions_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_for_network_actions_in_network( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_23_nuage_nuage_extra_dhcp_network_actions_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_for_network_actions_in_network( - self.vpc_network, - vpc=self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_24_nuage_extra_dhcp_network_actions_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_for_network_actions_in_network( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_25_nuage_extra_dhcp_nic_after_migrate_in_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network) - self.validate_all_extra_dhcp_for_add_remove_nic_after_migrate( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_26_nuage_nuage_extra_dhcp_nic_after_migrate_in_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_for_add_remove_nic_after_migrate( - self.vpc_network, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_27_nuage_extra_dhcp_nic_after_migrate_in_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_for_add_remove_nic_after_migrate( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_28_nuage_extra_dhcp_deploy_multiple_vms(self): - self.update_zone_details("testisolated.com") - isolated_network =\ - self.create_isolated_network(gateway="10.0.0.1") - self.validate_vm_deploy_concurrency( - isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_29_nuage_extra_dhcp_allocated_isolated_network(self): - self.update_zone_details("testisolated.com") - self.validate_isolated_network( - self.isolated_network_offering, self.isolated_network,) - self.validate_all_extra_dhcp_for_network_in_allocated( - self.isolated_network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_30_nuage_extra_dhcp_allocated_vpc(self): - self.update_zone_details("testvpc.com") - self.validate_vpc_and_vpcoffering(self.vpc1, self.vpc_offering) - self.validate_Network(self.vpc_network) - - self.validate_all_extra_dhcp_for_network_in_allocated( - self.vpc_network, self.vpc1, - domain_name="testvpc.com") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_31_nuage_extra_dhcp_allocated_shared_network(self): - self.update_zone_details("testshared.com") - self.validate_all_extra_dhcp_for_network_in_allocated( - self.shared_network_all, - domain_name="testshared.com", - is_shared_network=True) - - @attr(tags=["advanced", "nuagevsp", "smoke"], required_hardware="false") - def smoke_test(self): - # This test does basic sanity checks to see if basic - # DHCP options still work. - # 1 - deploy vm in an isolated network - # 2 - verify dhcp options - # 3 - update dhcp options - # 4 - add nic to a vpc_network with different dhcp options - # 5 - restart the vm - # 6 - check if dhcp options are on the extra nic and the default nic - # 7 - restart the network - # 8 - verify if the dhcp options are set correctly - # 9 - remove the vm - - network = self.isolated_network - domain_name = "testisolated.com" - self.update_zone_details(domain_name) - - dhcp_options_isolated_network =\ - self.get_extra_dhcp_options_starting_with(1, network) - - dhcp_options_to_verify = \ - self.get_extra_dhcp_options_to_verify_starting_with( - 1, domain_name, remove_dns_options=False) - vm1 = self.when_i_create_a_vm( - network, - vpc=None, - vm_name="vm1", - dhcp_options=dhcp_options_isolated_network) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify, - verify_on_vm=True) - - dhcp_options_isolated_network =\ - self.get_extra_dhcp_options_starting_with(16, network) - self.when_i_update_extra_dhcp_options_on_a_vm( - vm1, dhcp_options_isolated_network) - - dhcp_options_vpc_network = self.get_extra_dhcp_options_starting_with( - 28, None) - self.when_i_add_an_extra_nic_to_a_vm( - vm1, self.vpc_network, dhcp_options_vpc_network) - - self.when_i_stop_and_start_a_vm(vm1) - - dhcp_options_to_verify_on_default_nic = \ - self.get_extra_dhcp_options_to_verify_starting_with( - 16, domain_name, False) - - dhcp_options_to_verify_on_second_nic = \ - self.get_extra_dhcp_options_to_verify_starting_with( - 28, domain_name, remove_dns_options=True) - - # dhcp options get applied after start stop vm - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify_on_default_nic, - verify_on_vm=True) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify_on_second_nic, - network_with_options=self.vpc_network, - verify_on_vm=True, - default_network=network, - vpc=None) - - network.restart(self.api_client, True) - self.vpc_network.restart(self.api_client, True) - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify_on_default_nic, - verify_on_vm=True) - - self.then_verify_dhcp_options_on_vsd_and_vm( - vm1, network, dhcp_options_to_verify_on_second_nic, - network_with_options=self.vpc_network, - verify_on_vm=True, - default_network=network, - vpc=None) - - self.delete_VM(vm1) diff --git a/test/integration/plugins/nuagevsp/test_nuage_internal_dns.py b/test/integration/plugins/nuagevsp/test_nuage_internal_dns.py deleted file mode 100644 index 5b8130231f1..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_internal_dns.py +++ /dev/null @@ -1,779 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Internal DNS functionality with Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.cloudstackAPI import updateZone -from marvin.lib.base import Account, Network -# Import System Modules -from nose.plugins.attrib import attr - -UPDATED_DOMAIN_NAME = "update.com" - -ISOLATED_DOMAIN_NAME = "isolated.com" - -VPC_DOMAIN_NAME = "vpc.com" - - -class TestNuageInternalDns(nuageTestCase): - DNS = "06" - HOSTNAME = "0c" - DOMAINNAME = "0f" - - @classmethod - def setUpClass(cls): - super(TestNuageInternalDns, cls).setUpClass() - cls.dnsdata = cls.test_data["nuagevsp"] - return - - def setUp(self): - self.apiclient = self.testClient.getApiClient() - self.account = Account.create( - self.apiclient, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.test_data["virtual_machine"]["displayname"] = "vm1" - self.test_data["virtual_machine"]["name"] = "vm1" - - self.cleanup = [self.account] - return - - # Creates and verifies the firewall rule - def create_and_verify_fw(self, vm, public_ip, network): - self.debug("Create and verify firewall rule") - self.create_StaticNatRule_For_VM(vm, public_ip, network) - - # VSD verification - self.verify_vsd_floating_ip(network, vm, public_ip.ipaddress) - - fw_rule = self.create_FirewallRule( - public_ip, self.test_data["ingress_rule"]) - self.verify_vsd_firewall_rule(fw_rule) - - def verify_vsd_dhcp_option(self, dhcp_type, value, subnet_or_vm_interface, - is_vm_interface=False): - self.debug("Verifying the creation and value of DHCP option type - %s " - "in VSD" % dhcp_type) - found_dhcp_type = False - if is_vm_interface: - dhcp_options = self.vsd.get_vm_interface_dhcpoptions( - filter=self.get_externalID_filter(subnet_or_vm_interface.id)) - else: - dhcp_options = self.vsd.get_subnet_dhcpoptions( - filter=self.get_externalID_filter(subnet_or_vm_interface.id)) - for dhcp_option in dhcp_options: - self.debug("dhcptype option is %s:" % dhcp_option.actual_type) - self.debug("dhcptype expected value is option is %s:" % dhcp_type) - if dhcp_option.type == dhcp_type: - found_dhcp_type = True - if isinstance(dhcp_option.actual_values, list): - self.debug("dhcptype actual value is %s:" % - dhcp_option.actual_values) - if value in dhcp_option.actual_values: - self.debug("Excepted DHCP option value found in VSD") - else: - self.fail("Excepted DHCP option value not found in " - "VSD") - else: - self.assertEqual(dhcp_options.actual_values, value, - "Expected DHCP option value is not same " - "in both CloudStack and VSD" - ) - if not found_dhcp_type: - self.fail("Expected DHCP option type and value not found in the " - "VSD") - self.debug("Successfully verified the creation and value of DHCP " - "option type - %s in VSD" % dhcp_type) - - def vm_verify_ping(self, src_vm, public_ip, dst_vm, domain_name): - if self.isSimulator: - self.debug("Simulator Environment: not verifying ping.") - return - - src_vm.ssh_ip = public_ip - src_vm.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - src_vm.username = self.test_data["virtual_machine"]["username"] - src_vm.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (src_vm.ssh_ip, src_vm.password)) - - ssh = self.ssh_into_VM(src_vm, public_ip) - - cmd = 'ping -c 2 ' + dst_vm.name - self.debug("ping vm2 by hostname with command: " + cmd) - outputlist = ssh.execute(cmd) - self.debug("command is executed properly " + cmd) - completeoutput = str(outputlist).strip('[]') - self.debug("complete output is " + completeoutput) - expectedlist = ['2 received', dst_vm.name + '.' + domain_name, - dst_vm.ipaddress] - for item in expectedlist: - if item in completeoutput: - self.debug("excepted value found in vm: " + item) - else: - self.fail("excepted value not found in vm: " + item) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_Isolated_Network_with_zone(self): - """ Verify InternalDns on Isolated Network - """ - - # Validate the following - # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS - # network offering. - # 2. Deploy vm1 in network1. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - - # update Network Domain at zone level - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = ISOLATED_DOMAIN_NAME - self.apiclient.updateZone(cmd) - self.debug("Creating and enabling Nuage Vsp Isolated Network " - "offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["isolated_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - network_1 = self.create_Network(network_offering) - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_vm(vm_1) - - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, ISOLATED_DOMAIN_NAME, - network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_02_Isolated_Network(self): - """ Verify InternalDns on Isolated Network with ping by hostname - """ - - # Validate the following - # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS - # network offering. - # 2. Deploy vm1 in network1. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - # 5. Deploy VM2 in network1. - # 6. Verify end to end by pinging with hostname - - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = ISOLATED_DOMAIN_NAME - self.apiclient.updateZone(cmd) - - self.debug("Creating and enabling Nuage Vsp Isolated Network " - "offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["isolated_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - network_1 = self.create_Network(network_offering) - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_vm(vm_1) - - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, ISOLATED_DOMAIN_NAME, - network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - self.test_data["virtual_machine"]["displayname"] = "vm2" - self.test_data["virtual_machine"]["name"] = "vm2" - vm_2 = self.create_VM(network_1) - self.test_data["virtual_machine"]["displayname"] = "vm1" - self.test_data["virtual_machine"]["name"] = "vm1" - self.verify_vsd_vm(vm_2) - for nic in vm_2.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True) - - public_ip_1 = self.acquire_PublicIPAddress(network_1) - self.create_and_verify_fw(vm_1, public_ip_1, network_1) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, ISOLATED_DOMAIN_NAME) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_03_Isolated_Network_restarts(self): - """ Verify InternalDns on Isolated Network with restart networks and - ping by hostname - """ - - # Validate the following - # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS - # network offering. - # 2. Deploy vm1 in network1. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - # 5. Deploy VM2 in network1. - # 6. Verify end to end by pinging with hostname while restarting - # network1 without and with cleanup. - - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = ISOLATED_DOMAIN_NAME - self.apiclient.updateZone(cmd) - - self.debug("Creating and enabling Nuage Vsp Isolated Network " - "offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["isolated_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - network_1 = self.create_Network(network_offering) - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_vm(vm_1) - - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, ISOLATED_DOMAIN_NAME, - network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - self.test_data["virtual_machine"]["displayname"] = "vm2" - self.test_data["virtual_machine"]["name"] = "vm2" - vm_2 = self.create_VM(network_1) - self.test_data["virtual_machine"]["displayname"] = "vm1" - self.test_data["virtual_machine"]["name"] = "vm1" - self.verify_vsd_vm(vm_2) - for nic in vm_2.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True) - - public_ip_1 = self.acquire_PublicIPAddress(network_1) - self.create_and_verify_fw(vm_1, public_ip_1, network_1) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, ISOLATED_DOMAIN_NAME) - - # Restarting Isolated network (cleanup = false) - self.debug("Restarting the created Isolated network without " - "cleanup...") - Network.restart(network_1, self.api_client, cleanup=False) - self.validate_Network(network_1, state="Implemented") - vr = self.get_Router(network_1) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - self.verify_vsd_vm(vm_2) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, ISOLATED_DOMAIN_NAME) - - # Restarting Isolated network (cleanup = true) - self.debug("Restarting the created Isolated network with cleanup...") - Network.restart(network_1, self.api_client, cleanup=True) - self.validate_Network(network_1, state="Implemented") - vr = self.get_Router(network_1) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - self.verify_vsd_vm(vm_2) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, ISOLATED_DOMAIN_NAME) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_Update_Network_with_Domain(self): - """ Verify update NetworkDomain for InternalDns on Isolated Network - """ - - # Validate the following - # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS - # network offering. - # 2. Deploy vm1 in network1. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - # 5. Update Network domain and verify it is properly updated - - # update Network Domain at zone level - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = ISOLATED_DOMAIN_NAME - self.apiclient.updateZone(cmd) - - self.debug("Creating and enabling Nuage Vsp Isolated Network " - "offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["isolated_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - network_1 = self.create_Network(network_offering) - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_vm(vm_1) - - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, "isolated.com", network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - update_response = Network.update( - network_1, self.apiclient, id=network_1.id, - networkdomain=UPDATED_DOMAIN_NAME, changecidr=False) - completeoutput = str(update_response).strip('[]') - self.debug("network update response is " + completeoutput) - self.assertEqual(UPDATED_DOMAIN_NAME, update_response.networkdomain, - "Network Domain is not updated as expected" - ) - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, UPDATED_DOMAIN_NAME, - network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, UPDATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_05_Update_Network_with_Domain(self): - """ Verify update NetworkDomain for InternalDns on Isolated Network - with ping VM - """ - - # Validate the following - # 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS - # network offering. - # 2. Deploy vm1 in network1. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - # 5. Update Network domain and verify it is properly updated - - # update Network Domain at zone level - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = ISOLATED_DOMAIN_NAME - self.apiclient.updateZone(cmd) - - self.debug("Creating and enabling Nuage Vsp Isolated Network " - "offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["isolated_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - network_1 = self.create_Network(network_offering) - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_vm(vm_1) - - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, ISOLATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - update_response = Network.update( - network_1, self.apiclient, id=network_1.id, - networkdomain=UPDATED_DOMAIN_NAME, changecidr=False) - completeoutput = str(update_response).strip('[]') - self.debug("network update response is " + completeoutput) - self.assertEqual(UPDATED_DOMAIN_NAME, update_response.networkdomain, - "Network Domain is not updated as expected" - ) - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, UPDATED_DOMAIN_NAME, - network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, UPDATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - # stop and start VM to get new DHCP option - try: - vm_1.stop(self.apiclient) - except Exception as e: - self.fail("Failed to stop the virtual instances, %s" % e) - - self.test_data["virtual_machine"]["displayname"] = "vm2" - self.test_data["virtual_machine"]["name"] = "vm2" - vm_2 = self.create_VM(network_1) - self.test_data["virtual_machine"]["displayname"] = "vm1" - self.test_data["virtual_machine"]["name"] = "vm1" - self.verify_vsd_vm(vm_2) - for nic in vm_2.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option( - self.DOMAINNAME, UPDATED_DOMAIN_NAME, nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True) - - try: - vm_1.start(self.apiclient) - except Exception as e: - self.fail("Failed to start the virtual instances, %s" % e) - - public_ip_1 = self.acquire_PublicIPAddress(network_1) - self.create_and_verify_fw(vm_1, public_ip_1, network_1) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, UPDATED_DOMAIN_NAME) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_06_VPC_Network_With_InternalDns(self): - """ Verify InternalDns on VPC Network - """ - - # Validate the following - # 1. Create a VPC and tier network by using DNS network offering. - # 2. Deploy vm1 in tier network. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = VPC_DOMAIN_NAME - self.apiclient.updateZone(cmd) - vpc_off = self.create_VpcOffering(self.dnsdata["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16', cleanup=False) - - self.debug("Creating Nuage Vsp VPC Network offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["vpc_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - network_1 = self.create_Network( - network_offering, gateway='10.1.1.1', vpc=vpc) - - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1, vpc) - self.verify_vsd_vm(vm_1) - - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, VPC_DOMAIN_NAME, - network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option(self.DOMAINNAME, VPC_DOMAIN_NAME, - nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_07_VPC_Network_With_InternalDns(self): - """ Verify InternalDns on VPC Network by ping with hostname - """ - - # Validate the following - # 1. Create a VPC and Tier network by using DNS network offering. - # 2. Deploy vm1 in Tier network network1. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - # 5. Deploy Vm2. - # 6. Verify end to end by pinging with hostname - - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = VPC_DOMAIN_NAME - self.apiclient.updateZone(cmd) - - vpc_off = self.create_VpcOffering(self.dnsdata["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16', cleanup=False) - - self.debug("Creating Nuage Vsp VPC Network offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["vpc_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - network_1 = self.create_Network( - network_offering, gateway='10.1.1.1', vpc=vpc) - - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1, vpc) - self.verify_vsd_vm(vm_1) - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option(self.DOMAINNAME, VPC_DOMAIN_NAME, - nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - self.test_data["virtual_machine"]["displayname"] = "vm2" - self.test_data["virtual_machine"]["name"] = "vm2" - vm_2 = self.create_VM(network_1) - self.test_data["virtual_machine"]["displayname"] = "vm1" - self.test_data["virtual_machine"]["name"] = "vm1" - self.verify_vsd_vm(vm_2) - for nic in vm_2.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option(self.DOMAINNAME, VPC_DOMAIN_NAME, - nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True) - - public_ip_1 = self.acquire_PublicIPAddress(network_1, vpc) - self.create_StaticNatRule_For_VM(vm_1, public_ip_1, network_1) - # Adding Network ACL rule in the Public tier - self.debug("Adding Network ACL rule to make the created NAT rule " - "(SSH) accessible...") - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=network_1) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - self.vm_verify_ping(vm_1, public_ip_1, vm_2, VPC_DOMAIN_NAME) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_08_VPC_Network_Restarts_With_InternalDns(self): - """ Verify InternalDns on VPC Network with restarts and ping by - hostname - """ - - # Validate the following - # 1. Create a VPC and Tier network by using DNS network offering. - # 2. Deploy vm1 in Tier network network1. - # 3. Verify dhcp option 06 and 0f for subnet - # 4. Verify dhcp option 06,15 and 0f for vm Interface. - # 5. Deploy Vm2. - # 6. Verify end to end by pinging with hostname while restarting - # VPC and Tier without and with cleanup. - - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = VPC_DOMAIN_NAME - self.apiclient.updateZone(cmd) - - vpc_off = self.create_VpcOffering(self.dnsdata["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16', cleanup=False) - - self.debug("Creating Nuage Vsp VPC Network offering...") - network_offering = self.create_NetworkOffering( - self.dnsdata["vpc_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - network_1 = self.create_Network( - network_offering, gateway='10.1.1.1', vpc=vpc) - - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1, vpc) - self.verify_vsd_vm(vm_1) - # Internal DNS check point on VSD - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1) - self.verify_vsd_dhcp_option(self.DOMAINNAME, VPC_DOMAIN_NAME, - network_1) - for nic in vm_1.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option(self.DOMAINNAME, VPC_DOMAIN_NAME, - nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True) - - self.test_data["virtual_machine"]["displayname"] = "vm2" - self.test_data["virtual_machine"]["name"] = "vm2" - vm_2 = self.create_VM(network_1) - self.test_data["virtual_machine"]["displayname"] = "vm1" - self.test_data["virtual_machine"]["name"] = "vm1" - self.verify_vsd_vm(vm_2) - for nic in vm_2.nic: - self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True) - self.verify_vsd_dhcp_option(self.DOMAINNAME, VPC_DOMAIN_NAME, - nic, True) - self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True) - - public_ip_1 = self.acquire_PublicIPAddress(network_1, vpc) - self.create_StaticNatRule_For_VM(vm_1, public_ip_1, network_1) - # Adding Network ACL rule in the Public tier - self.debug("Adding Network ACL rule to make the created NAT rule " - "(SSH) accessible...") - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=network_1) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, VPC_DOMAIN_NAME) - - # Restarting VPC network (cleanup = false) - self.debug("Restarting the created VPC network without cleanup...") - Network.restart(network_1, self.api_client, cleanup=False) - self.validate_Network(network_1, state="Implemented") - vr = self.get_Router(network_1) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - self.verify_vsd_vm(vm_2) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, VPC_DOMAIN_NAME) - - # Restarting VPC network (cleanup = true) - self.debug("Restarting the created VPC network with cleanup...") - Network.restart(network_1, self.api_client, cleanup=True) - self.validate_Network(network_1, state="Implemented") - vr = self.get_Router(network_1) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - self.verify_vsd_vm(vm_2) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, VPC_DOMAIN_NAME) - - # Restarting VPC (cleanup = false) - self.debug("Restarting the VPC without cleanup...") - self.restart_Vpc(vpc, cleanup=False) - self.validate_Network(network_1, state="Implemented") - vr = self.get_Router(network_1) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, VPC_DOMAIN_NAME) - - # Restarting VPC (cleanup = true) - self.debug("Restarting the VPC with cleanup...") - self.restart_Vpc(vpc, cleanup=True) - self.validate_Network(network_1, state="Implemented") - vr = self.get_Router(network_1) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - - self.vm_verify_ping(vm_1, public_ip_1, vm_2, VPC_DOMAIN_NAME) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_09_update_network_offering_isolated_network(self): - """Test Update network offering for isolated Networks - with Nuage VSP SDN plugin - """ - # Create an Isolated Network with Nuage VSP Isolated Network - # offering specifying Services which don't need a VR. - # Update the network offering of this network to one that - # needs a VR, check that a VR is spawn - # After that update network to previous offering - # Check that VR is destroyed and removed. - - self.debug("+++Create an Isolated network with a network " - "offering which has only services without VR") - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = "isolated.com" - self.apiclient.updateZone(cmd) - self.debug("Creating and enabling Nuage Vsp Isolated Network " - "offering which has only service without VR...") - network_offering = self.create_NetworkOffering( - self.test_data["nuagevsp"] - ["isolated_network_offering_without_vr"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - network_1 = self.create_Network(network_offering) - self.validate_Network(network_1, state="Allocated") - - self.debug("+++Deploy VM in the created Isolated network " - "with only services without VR") - vm_1 = self.create_VM(network_1) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_vm(vm_1) - - with self.assertRaises(Exception): - self.get_Router(network_1) - self.debug("+++Verified no VR is spawned for this network ") - - self.debug("+++ Upgrade offering of created Isolated network with " - "a dns offering which spins a VR") - self.upgrade_Network(self.test_data["nuagevsp"][ - "isolated_network_offering"], - network_1) - vr = self.get_Router(network_1) - self.check_Router_state(vr, state="Running") - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_router(vr) - - self.debug("+++ Upgrade offering of created Isolated network with " - "an offering which removes the VR...") - self.upgrade_Network(self.test_data["nuagevsp"][ - "isolated_network_offering_without_vr"], - network_1) - with self.assertRaises(Exception): - self.get_Router(network_1) - self.debug("+++Verified no VR is spawned for this network ") diff --git a/test/integration/plugins/nuagevsp/test_nuage_network_migration.py b/test/integration/plugins/nuagevsp/test_nuage_network_migration.py deleted file mode 100644 index d051712dc01..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_network_migration.py +++ /dev/null @@ -1,2002 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Network migration test with Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import (Account, Host) -from marvin.lib.utils import is_server_ssh_ready -from marvin.cloudstackAPI import updateZone - -# Import System Modules -from nose.plugins.attrib import attr -import time -import base64 -import unittest -import re - - -class TestNuageMigration(nuageTestCase): - """Test Native to Nuage Migration - """ - - @classmethod - def setUpClass(cls): - super(TestNuageMigration, cls).setUpClass() - - if not hasattr(cls.vsp_physical_network, "tags") \ - or cls.vsp_physical_network.tags != 'nuage': - raise unittest.SkipTest("Require migrateACS configuration - skip") - - # create a native vpc offering - cls.native_vpc_offering = cls.create_VpcOffering(cls.test_data - ["vpc_offering"]) - # create a nuage vpc offering - cls.nuage_vpc_offering = \ - cls.create_VpcOffering(cls.test_data["nuagevsp"]["vpc_offering"]) - - # tier network offerings - cls.nuage_vpc_network_offering = \ - cls.create_NetworkOffering(cls.test_data["nuagevsp"] - ["vpc_network_offering"]) - cls.native_vpc_network_offering = \ - cls.create_NetworkOffering(cls.test_data - ["nw_offering_isolated_vpc"]) - - # create a Nuage isolated network offering with vr - cls.nuage_isolated_network_offering = cls.create_NetworkOffering( - cls.test_data["nuagevsp"]["isolated_network_offering"], True) - - # create a Nuage isolated network offering with vr and persistent - cls.nuage_isolated_network_offering_persistent = \ - cls.create_NetworkOffering( - cls.test_data["nuagevsp"] - ["isolated_network_offering_persistent"], - True) - - # create a Nuage isolated network offering without vr - cls.nuage_isolated_network_offering_without_vr = \ - cls.create_NetworkOffering( - cls.test_data["nuagevsp"] - ["isolated_network_offering_without_vr"], - True) - - # create a Nuage isolated network offering without vr but persistent - cls.nuage_isolated_network_offering_without_vr_persistent = \ - cls.create_NetworkOffering( - cls.test_data["nuagevsp"] - ["isolated_network_offering_without_vr_persistent"], - True) - - # create a native isolated network offering - cls.native_isolated_network_offering = cls.create_NetworkOffering( - cls.test_data["isolated_network_offering"], True) - - # create a native persistent isolated network offering - cls.native_isolated_network_offering_persistent = \ - cls.create_NetworkOffering( - cls.test_data["nw_off_isolated_persistent"], True) - - # create a native persistent staticNat isolated network offering - cls.native_isolated_network_staticnat_offering_persistent = \ - cls.create_NetworkOffering( - cls.test_data["isolated_staticnat_network_offering"], True) - - # create a Native shared network offering - cls.native_shared_network_offering = cls.create_NetworkOffering( - cls.services["shared_network_offering"], False) - - # create a Nuage shared network offering - cls.nuage_shared_network_offering = cls.create_NetworkOffering( - cls.test_data["nuagevsp"]["shared_nuage_network_offering"], - False) - - cls._cleanup = [ - cls.nuage_isolated_network_offering, - cls.nuage_isolated_network_offering_persistent, - cls.nuage_isolated_network_offering_without_vr, - cls.nuage_isolated_network_offering_without_vr_persistent, - cls.native_isolated_network_offering, - cls.native_isolated_network_offering_persistent, - cls.native_vpc_offering, - cls.nuage_vpc_offering, - cls.nuage_vpc_network_offering, - cls.native_vpc_network_offering, - cls.native_shared_network_offering, - cls.nuage_shared_network_offering - ] - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - def migrate_network(self, nw_off, network, resume=False): - return network.migrate(self.api_client, nw_off.id, resume) - - def migrate_vpc(self, vpc, vpc_offering, - network_offering_map, resume=False): - return vpc.migrate(self.api_client, - vpc_offering.id, - network_offering_map, resume) - - def verify_pingtovmipaddress(self, ssh, pingtovmipaddress): - """verify ping to ipaddress of the vm and retry 3 times""" - successfull_ping = False - nbr_retries = 0 - max_retries = 5 - cmd = 'ping -c 2 ' + pingtovmipaddress - - while not successfull_ping and nbr_retries < max_retries: - self.debug("ping vm by ipaddress with command: " + cmd) - outputlist = ssh.execute(cmd) - self.debug("command is executed properly " + cmd) - completeoutput = str(outputlist).strip('[]') - self.debug("complete output is " + completeoutput) - if '2 received' in completeoutput: - self.debug("PASS as vm is pingeable: " + completeoutput) - successfull_ping = True - else: - self.debug("FAIL as vm is not pingeable: " + completeoutput) - time.sleep(3) - nbr_retries = nbr_retries + 1 - - if not successfull_ping: - self.fail("FAILED TEST as excepted value not found in vm") - - def verify_pingtovmhostname(self, ssh, pingtovmhostname): - """verify ping to hostname of the vm and retry 3 times""" - successfull_ping = False - nbr_retries = 0 - max_retries = 5 - cmd = 'ping -c 2 ' + pingtovmhostname - - while not successfull_ping and nbr_retries < max_retries: - self.debug("ping vm by hostname with command: " + cmd) - outputlist = ssh.execute(cmd) - self.debug("command is executed properly " + cmd) - completeoutput = str(outputlist).strip('[]') - self.debug("complete output is " + completeoutput) - if '2 received' in completeoutput: - self.debug("PASS as vm is pingeable: " + completeoutput) - successfull_ping = True - else: - self.debug("FAIL as vm is not pingeable: " + completeoutput) - time.sleep(3) - nbr_retries = nbr_retries + 1 - - if not successfull_ping: - self.fail("FAILED TEST as excepted value not found in vm") - - def update_userdata(self, vm, expected_user_data): - updated_user_data = base64.b64encode(expected_user_data) - vm.update(self.api_client, userdata=updated_user_data) - return expected_user_data - - def get_userdata_url(self, vm): - self.debug("Getting user data url") - nic = vm.nic[0] - gateway = str(nic.gateway) - self.debug("Gateway: " + gateway) - user_data_url = 'curl "http://' + gateway + ':80/latest/user-data"' - return user_data_url - - def define_cloudstack_managementip(self): - # get cloudstack managementips from cfg file - config = self.getClsConfig() - return [config.mgtSvr[0].mgtSvrIp, config.mgtSvr[1].mgtSvrIp] - - def cloudstack_connection_vsd(self, connection="up", - cscip=["csc-1", "csc-2"]): - self.debug("SSH into cloudstack management server(s), setting " - "connection to VSD as %s " % connection) - try: - for ip in cscip: - csc_ssh_client = is_server_ssh_ready( - ipaddress=ip, - port=22, - username="root", - password="tigris", - retries=2 - ) - self.debug("SSH is successful for cloudstack management " - "server with IP %s" % ip) - if connection == "down": - cmd = "iptables -A OUTPUT -p tcp --dport 8443 -j DROP" - else: - cmd = "iptables -D OUTPUT -p tcp --dport 8443 -j DROP" - self.execute_cmd(csc_ssh_client, cmd) - except Exception as e: - self.debug("Setting cloudstack management server(s) connection %s " - "to VSD fails with exception %s" % (connection, e)) - - def verify_cloudstack_host_state_up(self, state): - nbr_retries = 0 - max_retries = 30 - self.debug("Verify state by list hosts type=L2Networking") - result = Host.list(self.api_client, type="L2Networking") - while result[0].state != state and nbr_retries < max_retries: - time.sleep(5) - result = Host.list(self.api_client, type="L2Networking") - nbr_retries = nbr_retries + 1 - - if nbr_retries == max_retries: - self.debug("TIMEOUT - state of list hosts unchanged") - - def verifymigrationerrortext(self, errortext, expectstr): - if expectstr in errortext: - self.debug("Migrate_network fails with expected errortext %s", - errortext) - else: - self.fail("Migrate_network fails but test expects " - "other errortext %s", expectstr) - - @attr(tags=["migrateACS", "novms"], - required_hardware="false") - def test_01_native_to_nuage_network_migration_novms(self): - """ - Verify Migration for an isolated network without VMs - 1. create multiple native non-persistent isolated network - 2. move to nuage non-persistent isolated network - 3. move to native persistent network, check VR state - 4. move to nuage persistent network, check VR state - """ - isolated_network = self.create_Network( - self.native_isolated_network_offering, gateway="10.0.0.1", - netmask="255.255.255.0") - - isolated_network2 = self.create_Network( - self.native_isolated_network_offering, gateway="10.1.0.1", - netmask="255.255.255.0") - - shared_network = self.create_Network( - self.native_shared_network_offering, gateway="10.3.0.1", - netmask="255.255.255.0", vlan=1201) - - try: - self.migrate_network( - self.nuage_shared_network_offering, - shared_network, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "NetworkOfferingId can be upgraded only for the " \ - "network of type Isolated" - self.verifymigrationerrortext(errortext, expectstr) - - try: - self.migrate_network( - self.nuage_shared_network_offering, - isolated_network, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Can't upgrade from network offering" - self.verifymigrationerrortext(errortext, expectstr) - - self.nuage_isolated_network_offering.update(self.api_client, - state="Disabled") - self.validate_NetworkOffering( - self.nuage_isolated_network_offering, state="Disabled") - - try: - self.migrate_network( - self.nuage_isolated_network_offering, - isolated_network, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate network as the specified network " \ - "offering is not enabled." - self.verifymigrationerrortext(errortext, expectstr) - - self.nuage_isolated_network_offering.update(self.api_client, - state="Enabled") - self.validate_NetworkOffering( - self.nuage_isolated_network_offering, state="Enabled") - - self.migrate_network( - self.nuage_isolated_network_offering, isolated_network, - resume=True) - - self.verify_vsd_network_not_present(isolated_network, None) - - self.migrate_network( - self.native_isolated_network_offering_persistent, isolated_network) - self.verify_vsd_network_not_present(isolated_network, None) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - - try: - self.migrate_network( - self.nuage_vpc_offering, isolated_network, resume=False) - except Exception as e: - self.debug("Migration fails with %s" % e) - - try: - self.migrate_network( - self.nuage_vpc_network_offering, isolated_network, - resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate network as the specified network " \ - "offering is a VPC offering" - self.verifymigrationerrortext(errortext, expectstr) - - self.migrate_network( - self.nuage_isolated_network_offering_persistent, isolated_network) - self.verify_vsd_network(self.domain.id, isolated_network, None) - - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - self.verify_vsd_router(vr) - with self.assertRaises(Exception): - self.verify_vsd_network(self.domain.id, isolated_network2, None) - - self.add_resource_tag( - self.native_isolated_network_offering_persistent.id, - "NetworkOffering", "RelatedNetworkOffering", - self.native_isolated_network_offering.id) - result = self.list_resource_tag( - self.native_isolated_network_offering_persistent.id, - "NetworkOffering", "RelatedNetworkOffering") - if result[0].value != self.native_isolated_network_offering.id: - self.fail("Listed resource value does not match with stored" - " resource value!") - self.delete_resource_tag( - self.native_isolated_network_offering_persistent.id, - "NetworkOffering") - empty = self.list_resource_tag( - self.native_isolated_network_offering_persistent.id, - "NetworkOffering", "RelatedNetworkOffering") - if empty: - self.fail("clean up of resource values did was not successful!") - - @attr(tags=["migrateACS", "stoppedvms"], - required_hardware="false") - def test_02_native_to_nuage_network_migration_stoppedvms(self): - """ - Verify Migration for an isolated network with stopped VMs - 1. create multiple native non-persistent isolated network - 2. deploy vm and stop vm - 3. move to nuage non-persistent isolated network - 4. deploy vm and stop vm - 5. move to native persistent network, check VR state - 6. deploy vm and stop vm - 7. move to nuage persistent network, check VR state - """ - - isolated_network = self.create_Network( - self.native_isolated_network_offering, gateway="10.0.0.1", - netmask="255.255.255.0") - - vm_1 = self.create_VM(isolated_network) - vm_1.stop(self.api_client) - - self.migrate_network( - self.nuage_isolated_network_offering, isolated_network) - - vm_1.delete(self.api_client, expunge=True) - vm_2 = self.create_VM(isolated_network) - vm_2.stop(self.api_client) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - - self.migrate_network( - self.native_isolated_network_offering_persistent, isolated_network) - - self.verify_vsd_network_not_present(isolated_network, None) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - - vm_2.delete(self.api_client, expunge=True) - vm_3 = self.create_VM(isolated_network) - vm_3.stop(self.api_client) - - self.migrate_network( - self.nuage_isolated_network_offering_persistent, isolated_network) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - vr2 = self.get_Router(isolated_network) - self.check_Router_state(vr2, "Running") - self.verify_vsd_router(vr2) - self.verify_vsd_network(self.domain.id, isolated_network, None) - - @attr(tags=["migrateACS", "nonpersist"], - required_hardware="false") - def test_03_migrate_native_nonpersistent_network_to_nuage_traffic(self): - """ - Verify traffic after Migration of a non-persistent isolated network - 1. create native non-persistent isolated network - 2. move to nuage non-persistent isolated network - 3. Spin VM's and verify traffic provided by Nuage - """ - for i in range(1, 3): - isolated_network = self.create_Network( - self.native_isolated_network_offering, gateway="10.1.0.1", - netmask="255.255.255.0", account=self.account) - - try: - self.migrate_network( - self.nuage_vpc_network_offering, - isolated_network, resume=False) - except Exception as e: - errortext = re.search(".*errortext\s*:\s*u?'([^']+)'.*", - e.message).group(1) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate network as the specified network " \ - "offering is a VPC offering" - self.verifymigrationerrortext(errortext, expectstr) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network, resume=True) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network, resume=False) - - self.verify_vsd_network_not_present(isolated_network, None) - - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(isolated_network) - self.validate_Network(isolated_network, state="Implemented") - self.check_VM_state(vm_1, state="Running") - vm_2 = self.create_VM(isolated_network) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, isolated_network) - # self.verify_vsd_router(vr_1) - self.verify_vsd_vm(vm_1) - self.verify_vsd_vm(vm_2) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.validate_PublicIPAddress(public_ip, isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - self.validate_PublicIPAddress( - public_ip, isolated_network, static_nat=True, vm=vm_1) - fw_rule = self.create_FirewallRule( - public_ip, self.test_data["ingress_rule"]) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(isolated_network, vm_1, - public_ip.ipaddress) - self.verify_vsd_firewall_rule(fw_rule) - - # Ssh into the VM via floating ip - vm_public_ip = public_ip.ipaddress.ipaddress - try: - vm_1.ssh_ip = vm_public_ip - vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_1.username = self.test_data["virtual_machine"]["username"] - vm_1.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_1.ssh_ip, vm_1.password)) - - ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_2.ipaddress) - - vm_1.delete(self.api_client, expunge=True) - vm_2.delete(self.api_client, expunge=True) - isolated_network.delete(self.api_client) - self.debug("Number of loops %s" % i) - - @attr(tags=["migrateACS", "persist"], - required_hardware="false") - def test_04_migrate_native_persistentnetwork_to_nuage_traffic(self): - """ - Verify traffic after Migration of a persistent isolated network - 1. create native persistent isolated network - 2. move to nuage persistent isolated network without VR - 3. Spin VM's and verify traffic provided by Nuage - """ - for i in range(1, 3): - isolated_network = self.create_Network( - self.native_isolated_network_offering_persistent, - gateway="10.2.0.1", - netmask="255.255.255.0", account=self.account) - self.verify_vsd_network_not_present(isolated_network, None) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - - csc_ips = self.define_cloudstack_managementip() - self.cloudstack_connection_vsd(connection="down", cscip=csc_ips) - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.debug("Migrate_network fails if connection ACS VSD is down") - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.verify_cloudstack_host_state_up("Alert") - try: - self.migrate_network( - self.nuage_isolated_network_offering_without_vr_persistent, - isolated_network, resume=False) - except Exception as e: - errortext = re.search(".*errortext\s*:\s*u?'([^']+)'.*", - e.message).group(1) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to implement network (with specified id) " \ - "elements and resources as a part of network update" - self.verifymigrationerrortext(errortext, expectstr) - - self.cloudstack_connection_vsd(connection="up", cscip=csc_ips) - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.debug("Migrate_network resumes if connection ACS VSD is up") - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.verify_cloudstack_host_state_up("Up") - try: - self.migrate_network( - self.nuage_isolated_network_offering_without_vr_persistent, - isolated_network, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate network as previous migration " \ - "left this network in transient condition. " \ - "Specify resume as true." - self.verifymigrationerrortext(errortext, expectstr) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr_persistent, - isolated_network, resume=True) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - with self.assertRaises(Exception): - self.get_Router(isolated_network) - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(isolated_network) - self.validate_Network(isolated_network, state="Implemented") - with self.assertRaises(Exception): - self.get_Router(isolated_network) - self.check_VM_state(vm_1, state="Running") - vm_2 = self.create_VM(isolated_network) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, isolated_network) - self.verify_vsd_vm(vm_1) - self.verify_vsd_vm(vm_2) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.validate_PublicIPAddress(public_ip, isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - self.validate_PublicIPAddress( - public_ip, isolated_network, static_nat=True, vm=vm_1) - fw_rule = self.create_FirewallRule( - public_ip, self.test_data["ingress_rule"]) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(isolated_network, vm_1, - public_ip.ipaddress) - self.verify_vsd_firewall_rule(fw_rule) - - # Ssh into the VM via floating ip - vm_public_ip = public_ip.ipaddress.ipaddress - try: - vm_1.ssh_ip = vm_public_ip - vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_1.username = self.test_data["virtual_machine"]["username"] - vm_1.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_1.ssh_ip, vm_1.password)) - - ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_2.ipaddress) - - vm_1.delete(self.api_client, expunge=True) - vm_2.delete(self.api_client, expunge=True) - isolated_network.delete(self.api_client) - self.debug("Number of loops %s" % i) - - @attr(tags=["migrateACS", "nicmigration"], - required_hardware="false") - def test_05_native_to_nuage_nic_migration(self): - """ - Verify Nic migration of GuestVm in an isolated network - 1. create multiple native non-persistent isolated network - 2. populate network with 2 vm's - 3. enable static nat + create FW rule - 4. move to nuage non-persistent isolated network, check: - - public ip - - FW rules - - VR - - VM's - """ - isolated_network = self.create_Network( - self.native_isolated_network_offering, gateway="10.0.0.1", - netmask="255.255.255.0") - - isolated_network2 = self.create_Network( - self.native_isolated_network_offering, gateway="10.1.0.1", - netmask="255.255.255.0") - - vm1 = self.create_VM(isolated_network) - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.create_StaticNatRule_For_VM(vm1, public_ip, isolated_network) - firewall_rule = self.create_FirewallRule(public_ip) - - vm2 = self.create_VM(isolated_network) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - - self.migrate_network( - self.nuage_isolated_network_offering, isolated_network) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - self.verify_vsd_vm(vm1) - self.verify_vsd_floating_ip(isolated_network, vm1, public_ip.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule) - self.verify_vsd_vm(vm2) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - self.verify_vsd_router(vr) - with self.assertRaises(Exception): - self.verify_vsd_network(self.domain.id, isolated_network2, None) - - @attr(tags=["migrateACS", "nonpersistnic"], - required_hardware="false") - def test_06_migrate_native_nonpersistent_nic_to_nuage_traffic(self): - """ - Verify Nic migration of GuestVm in a non-persistent isolated network - 1. create two native non-persistent isolated networks - 2. Deploy 2 vm's in first network - 3. enable static nat + create FW rule - 4. move first network to nuage non-persistent isolated network, - check: - - public ip - - FW rules - - VR - - VM's - 5. Destroy and expunge 1 VM in first network - 6. Deploy a new VM in first network and check traffic - 7. Move second network to nuage non-persistent isolated network, - check: - - public ip - - FW rules - - VR - - VM's - 8. Deploy 2 vm in second network , move it and check - 9. Cleanup - """ - isolated_network = self.create_Network( - self.native_isolated_network_offering, gateway="10.3.0.1", - netmask="255.255.255.0") - - isolated_network2 = self.create_Network( - self.native_isolated_network_offering, gateway="10.4.0.1", - netmask="255.255.255.0") - - vm_1 = self.create_VM(isolated_network) - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - firewall_rule = self.create_FirewallRule(public_ip) - - vm_2 = self.create_VM(isolated_network) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - - self.migrate_network( - self.nuage_isolated_network_offering, isolated_network) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - self.verify_vsd_vm(vm_1) - self.verify_vsd_floating_ip(isolated_network, vm_1, - public_ip.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule) - self.verify_vsd_vm(vm_2) - vr_3 = self.get_Router(isolated_network) - self.check_Router_state(vr_3, "Running") - self.verify_vsd_router(vr_3) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(isolated_network, vm_1, - public_ip.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule) - - # Ssh into the VM via floating ip - vm_public_ip = public_ip.ipaddress.ipaddress - try: - vm_1.ssh_ip = vm_public_ip - vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_1.username = self.test_data["virtual_machine"]["username"] - vm_1.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_1.ssh_ip, vm_1.password)) - - ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_2.ipaddress) - - vm_2.delete(self.api_client, expunge=True) - with self.assertRaises(Exception): - self.verify_vsd_vm(vm_2) - vm_4 = self.create_VM(isolated_network) - self.verify_vsd_vm(vm_4) - with self.assertRaises(Exception): - self.verify_vsd_network(self.domain.id, isolated_network2, None) - - vm_3 = self.create_VM(isolated_network2) - vr_2 = self.get_Router(isolated_network2) - self.check_Router_state(vr_2, "Running") - - # Ssh into the VM via floating ip - vm_public_ip = public_ip.ipaddress.ipaddress - try: - vm_1.ssh_ip = vm_public_ip - vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_1.username = self.test_data["virtual_machine"]["username"] - vm_1.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_1.ssh_ip, vm_1.password)) - - ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_4.ipaddress) - - vm_1.delete(self.api_client, expunge=True) - vm_4.delete(self.api_client, expunge=True) - isolated_network.delete(self.api_client) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network2) - - public_ip_2 = self.acquire_PublicIPAddress(isolated_network2) - self.create_StaticNatRule_For_VM(vm_3, public_ip_2, isolated_network2) - firewall_rule_2 = self.create_FirewallRule(public_ip_2) - self.verify_vsd_floating_ip(isolated_network2, vm_3, - public_ip_2.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule_2) - - self.verify_vsd_network(self.domain.id, isolated_network2, None) - self.verify_vsd_vm(vm_3) - self.verify_vsd_floating_ip(isolated_network2, vm_3, - public_ip_2.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule_2) - - with self.assertRaises(Exception): - self.get_Router(isolated_network2) - vm_5 = self.create_VM(isolated_network2) - self.verify_vsd_vm(vm_5) - - # Ssh into the VM via floating ip - vm_public_ip_2 = public_ip_2.ipaddress.ipaddress - try: - vm_3.ssh_ip = vm_public_ip_2 - vm_3.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_3.username = self.test_data["virtual_machine"]["username"] - vm_3.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_3.ssh_ip, vm_3.password)) - - ssh = vm_3.get_ssh_client(ipaddress=vm_public_ip_2) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_5.ipaddress) - - @attr(tags=["migrateACS", "persistnic"], - required_hardware="false") - def test_07_migrate_native_persistent_nic_to_nuage_traffic(self): - """ - Verify Nic migration of GuestVm in a persistent isolated network - 1. create two native persistent isolated networks - 2. deploy 2 vm's in this network - 3. move to nuage non-persistent isolated network, - 4. enable static nat + create FW rule - check: - - public ip - - FW rules - - VR - - VM's - """ - isolated_network = self.create_Network( - self.native_isolated_network_offering_persistent, - gateway="10.5.0.1", - netmask="255.255.255.0") - - isolated_network2 = self.create_Network( - self.native_isolated_network_offering_persistent, - gateway="10.6.0.1", - netmask="255.255.255.0") - - vm_1 = self.create_VM(isolated_network) - vm_2 = self.create_VM(isolated_network) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - vm_3 = self.create_VM(isolated_network2) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr_persistent, - isolated_network) - - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - firewall_rule = self.create_FirewallRule(public_ip) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - self.verify_vsd_vm(vm_1) - self.verify_vsd_floating_ip(isolated_network, vm_1, - public_ip.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule) - self.verify_vsd_vm(vm_2) - with self.assertRaises(Exception): - self.get_Router(isolated_network) - - # Ssh into the VM via floating ip - vm_public_ip = public_ip.ipaddress.ipaddress - try: - vm_1.ssh_ip = vm_public_ip - vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_1.username = self.test_data["virtual_machine"]["username"] - vm_1.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_1.ssh_ip, vm_1.password)) - - ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_2.ipaddress) - - vm_1.delete(self.api_client, expunge=True) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr_persistent, - isolated_network2) - - vm_2.delete(self.api_client, expunge=True) - isolated_network.delete(self.api_client) - - self.verify_vsd_network(self.domain.id, isolated_network2, None) - self.verify_vsd_vm(vm_3) - public_ip_2 = self.acquire_PublicIPAddress(isolated_network2) - self.create_StaticNatRule_For_VM(vm_3, public_ip_2, isolated_network2) - firewall_rule_2 = self.create_FirewallRule(public_ip_2) - vm_4 = self.create_VM(isolated_network2) - self.verify_vsd_floating_ip(isolated_network2, vm_3, - public_ip_2.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule_2) - self.verify_vsd_vm(vm_4) - - # Ssh into the VM via floating ip - vm_public_ip_2 = public_ip_2.ipaddress.ipaddress - try: - vm_3.ssh_ip = vm_public_ip_2 - vm_3.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_3.username = self.test_data["virtual_machine"]["username"] - vm_3.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_3.ssh_ip, vm_3.password)) - - ssh = vm_3.get_ssh_client(ipaddress=vm_public_ip_2) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_4.ipaddress) - - @attr(tags=["migrateACS", "isomultinic"], - required_hardware="false") - def test_08_migrate_native_multinic_to_nuage_traffic(self): - """ - Verify MultiNic migration of GuestVm with multiple isolated networks - 1. create one native non-persistent isolated network - 2. create one native persistent isolated network - 3. deploy 2 vm's in both these network - 4. move non-persist to nuage non-persistent isolated network, - 5. move persist to nuage persistent isolated network - 6. enable static nat + create FW rule - check: - - public ip - - FW rules - - VR - - VM's - """ - isolated_network = self.create_Network( - self.native_isolated_network_offering, - gateway="10.7.0.1", - netmask="255.255.255.0") - - isolated_network2 = self.create_Network( - self.native_isolated_network_offering_persistent, - gateway="10.8.0.1", - netmask="255.255.255.0") - - vm_1 = self.create_VM([isolated_network, isolated_network2]) - vm_2 = self.create_VM([isolated_network2, isolated_network]) - vr = self.get_Router(isolated_network2) - self.check_Router_state(vr, "Running") - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network) - - vm_3 = self.create_VM(isolated_network) - - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.create_StaticNatRule_For_VM(vm_3, public_ip, isolated_network) - firewall_rule = self.create_FirewallRule(public_ip) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - - self.verify_vsd_vm(vm_3) - self.verify_vsd_floating_ip(isolated_network, vm_3, - public_ip.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule) - - # Ssh into the VM via floating ip - vm_public_ip = public_ip.ipaddress.ipaddress - try: - vm_3.ssh_ip = vm_public_ip - vm_3.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_3.username = self.test_data["virtual_machine"]["username"] - vm_3.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_3.ssh_ip, vm_3.password)) - - ssh = vm_3.get_ssh_client(ipaddress=vm_public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - defaultipaddress = \ - [nic.ipaddress for nic in vm_1.nic if nic.isdefault][0] - - self.verify_pingtovmipaddress(ssh, defaultipaddress) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr_persistent, - isolated_network2) - - vm_3.delete(self.api_client, expunge=True) - public_ip.delete(self.api_client) - vm_4 = self.create_VM(isolated_network2) - - public_ip_2 = self.acquire_PublicIPAddress(isolated_network2) - self.create_StaticNatRule_For_VM(vm_4, public_ip_2, isolated_network2) - firewall_rule_2 = self.create_FirewallRule(public_ip_2) - - self.verify_vsd_floating_ip(isolated_network2, vm_4, - public_ip_2.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule_2) - self.verify_vsd_vm(vm_4) - - # Ssh into the VM via floating ip - vm_public_ip_2 = public_ip_2.ipaddress.ipaddress - try: - vm_4.ssh_ip = vm_public_ip_2 - vm_4.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_4.username = self.test_data["virtual_machine"]["username"] - vm_4.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_4.ssh_ip, vm_4.password)) - - ssh = vm_4.get_ssh_client(ipaddress=vm_public_ip_2) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - defaultipaddress2 = \ - [nic.ipaddress for nic in vm_2.nic if nic.isdefault][0] - - self.verify_pingtovmipaddress(ssh, defaultipaddress2) - - @attr(tags=["migrateACS", "persiststaticnat"], - required_hardware="false") - def test_09_migrate_native_persist_staticnat_to_nuage_traffic(self): - """ - Verify StaticNat migration of GuestVm in a persistent isolated network - 1. create one native persistent isolated network offering - 2. with Dhcp,SourceNat,StaticNat,Dns,Userdata and Firewall - 3. create one native persistent isolated network with above - 4. deploy 2 vm's in this network - 5. In a loop - enable staticnat on first vm and open port 22 for ssh - login to vm1 and ping vm2 - verify userdata in Native - move to nuage persistent isolated network, - deploy 2 new vm's in this network - enable staticnat on new vm and open port 22 for ssh - check: - - public ips - - FW rules - - VR - - VM's ping old and new VM's - - verify userdata in Nuage - - Release public ips - move back to native persistent isolated network, - """ - isolated_network = self.create_Network( - self.native_isolated_network_staticnat_offering_persistent, - gateway="10.9.0.1", - netmask="255.255.255.0", account=self.account) - - vm_1 = self.create_VM(isolated_network) - vm_2 = self.create_VM(isolated_network) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - - for i in range(1, 3): - self.debug("+++++Starting again as Native in Loop+++++") - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - firewall_rule = self.create_FirewallRule(public_ip) - - self.migrate_network( - self.nuage_isolated_network_offering_persistent, - isolated_network) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - self.verify_vsd_vm(vm_1) - self.verify_vsd_floating_ip(isolated_network, vm_1, - public_ip.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule) - self.verify_vsd_vm(vm_2) - - vm_3 = self.create_VM(isolated_network) - public_ip_2 = self.acquire_PublicIPAddress(isolated_network) - self.create_StaticNatRule_For_VM(vm_3, - public_ip_2, - isolated_network) - firewall_rule_2 = self.create_FirewallRule(public_ip_2) - vm_4 = self.create_VM(isolated_network) - self.verify_vsd_floating_ip(isolated_network, vm_3, - public_ip_2.ipaddress) - self.verify_vsd_firewall_rule(firewall_rule_2) - self.verify_vsd_vm(vm_3) - self.verify_vsd_vm(vm_4) - - # Ssh into the VM via floating ip - vm_public_ip_2 = public_ip_2.ipaddress.ipaddress - try: - vm_3.ssh_ip = vm_public_ip_2 - vm_3.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_3.username = self.test_data["virtual_machine"]["username"] - vm_3.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_3.ssh_ip, vm_3.password)) - - ssh2 = vm_3.get_ssh_client(ipaddress=vm_public_ip_2) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh2, vm_1.ipaddress) - - self.verify_pingtovmipaddress(ssh2, vm_4.ipaddress) - - self.verify_pingtovmipaddress(ssh2, vm_2.ipaddress) - - self.debug("Updating the running vm_3 with new user data...") - expected_user_data2 = self.update_userdata(vm_3, "hellonuage vm3") - self.debug("SSHing into the vm_3 for verifying its user data...") - user_data_cmd = self.get_userdata_url(vm_3) - self.debug("Getting user data with command: " + user_data_cmd) - actual_user_data2 = self.execute_cmd(ssh2, user_data_cmd) - self.debug("Actual user data - " + actual_user_data2 + - ", Expected user data - " + expected_user_data2) - self.assertEqual(actual_user_data2, expected_user_data2, - "Un-expected VM (VM_3) user data") - - vm_3.delete(self.api_client, expunge=True) - vm_4.delete(self.api_client, expunge=True) - public_ip_2.delete(self.api_client) - - # ReleaseIP as get_ssh_client fails when migrating back to native - public_ip.delete(self.api_client) - - self.debug("++++++++Migrating network back to native+++++++") - self.migrate_network( - self.native_isolated_network_staticnat_offering_persistent, - isolated_network) - - @attr(tags=["migrateACS", "vpcnovms"], - required_hardware="false") - def test_10_migrate_native_vpc(self): - vpc = self.create_vpc(self.native_vpc_offering) - network = self.create_Network(self.native_vpc_network_offering, - vpc=vpc) - self.create_VM(network) - - network_offering_map = \ - [{"networkid": network.id, - "networkofferingid": - self.nuage_isolated_network_offering_without_vr.id}] - - try: - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=False) - except Exception as e: - errortext = re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "can't be used for VPC networks" - self.verifymigrationerrortext(errortext, expectstr) - - network_offering_map = \ - [{"networkid": network.id, - "networkofferingid": self.nuage_vpc_network_offering.id}] - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map) - self.verify_vsd_network(self.domain.id, network, vpc) - - @attr(tags=["migrateACS", "vpcstaticnat"], - required_hardware="false") - def test_11_migrate_native_vpc_staticnat_to_nuage_traffic(self): - """ - Verify StaticNat migration of GuestVm in a vpc network - 1. create one native vpc network offering - 2. create one native vpc tier network offering - 3. with Dhcp,SourceNat,StaticNat,Dns,Userdata and NetworkACL - 4. create one vpc with above native vpc network offering - 5. create one native vpc tier network in above vpc - 6. deploy 2 vm's in this tier network - 7. In a loop - enable staticnat on first vm and ssh into vm - login to vm1 and ping vm2 - verify userdata in Native - move to nuage vpc tier networkoffering, - deploy 2 new vm's in this network - enable staticnat on new vm and ssh into vm - check: - - public ips - - NetworkACL rules - - VR - - VM's ping old and new VM's - - verify userdata in Nuage - - Release public ips - move back to native vpc tier network offering, - """ - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = "vpc.com" - self.api_client.updateZone(cmd) - - self.debug("Creating Native VSP VPC offering with Static NAT service " - "provider as VPCVR...") - native_vpc_off = self.create_VpcOffering( - self.test_data["vpc_offering_reduced"]) - self.validate_VpcOffering(native_vpc_off, state="Enabled") - - self.debug("Creating a VPC with Static NAT service provider as " - "VpcVirtualRouter") - vpc = self.create_vpc(native_vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - self.debug("Creating native VPC Network Tier offering " - "with Static NAT service provider as VPCVR") - native_tiernet_off = self.create_NetworkOffering( - self.test_data["nw_offering_reduced_vpc"]) - self.validate_NetworkOffering(native_tiernet_off, state="Enabled") - - acl_list = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc) - - acl_item = self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list) - self.create_NetworkAclRule( - self.test_data["icmprule"], acl_list=acl_list) - - self.debug("Creating a VPC tier network with Static NAT service") - vpc_tier = self.create_Network(native_tiernet_off, - gateway='10.1.0.1', - vpc=vpc, - acl_list=acl_list) - self.validate_Network(vpc_tier, state="Implemented") - - self.debug("Creating 2nd VPC tier network with Static NAT service") - vpc_2ndtier = self.create_Network(native_tiernet_off, - gateway='10.1.128.1', - vpc=vpc, - acl_list=acl_list) - self.validate_Network(vpc_2ndtier, state="Implemented") - - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - self.debug("Deploying a VM in the created VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm1" - self.test_data["virtual_machine"]["name"] = "vpcvm1" - vpc_vm_1 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_1, state="Running") - - self.debug("Deploying another VM in the created VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm2" - self.test_data["virtual_machine"]["name"] = "vpcvm2" - vpc_vm_2 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_2, state="Running") - - self.debug("Deploying a VM in the 2nd VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm12" - self.test_data["virtual_machine"]["name"] = "vpcvm12" - vpc_vm_12 = self.create_VM(vpc_2ndtier) - self.check_VM_state(vpc_vm_2, state="Running") - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - - for i in range(1, 3): - self.debug("+++++Starting again as Native in Loop+++++") - self.debug("Creating Static NAT rule for the deployed VM " - "in the created VPC network...") - public_ip_1 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_1, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm_1, public_ip_1, vpc_tier) - self.validate_PublicIPAddress( - public_ip_1, vpc_tier, static_nat=True, vm=vpc_vm_1) - - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}] - - csc_ips = self.define_cloudstack_managementip() - self.cloudstack_connection_vsd(connection="down", - cscip=csc_ips) - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.debug("Migrate_vpc fails when connection ACS VSD is down") - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.verify_cloudstack_host_state_up("Alert") - try: - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to implement network (with specified id) " \ - "elements and resources as a part of network update" - self.verifymigrationerrortext(errortext, expectstr) - - self.cloudstack_connection_vsd(connection="up", - cscip=csc_ips) - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.debug("Migrate_vpc resumes when connection ACS VSD is up") - self.debug("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=") - self.verify_cloudstack_host_state_up("Up") - try: - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate VPC as previous migration " \ - "left this VPC in transient condition. " \ - "Specify resume as true." - self.verifymigrationerrortext(errortext, expectstr) - - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": - self.nuage_isolated_network_offering.id}] - try: - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=True) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "can't be used for VPC networks for network" - self.verifymigrationerrortext(errortext, expectstr) - - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}] - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=True) - # checking after successful migrate vpc, migrate still succeeds - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=True) - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=False) - - # VSD verification after VPC migration functionality - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_vm(vpc_vm_1) - self.verify_vsd_vm(vpc_vm_2) - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm_1, public_ip_1.ipaddress, vpc=vpc) - self.verify_vsd_firewall_rule(acl_item) - # self.verify_vsd_firewall_rule(acl_item2) - self.verify_vsd_vm(vpc_vm_12) - - self.test_data["virtual_machine"]["displayname"] = "vpcvm3" - self.test_data["virtual_machine"]["name"] = "vpcvm3" - vpc_vm_3 = self.create_VM(vpc_tier) - - public_ip_2 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.create_StaticNatRule_For_VM(vpc_vm_3, - public_ip_2, - vpc_tier) - - self.test_data["virtual_machine"]["displayname"] = "vpcvm4" - self.test_data["virtual_machine"]["name"] = "vpcvm4" - vpc_vm_4 = self.create_VM(vpc_tier) - self.verify_vsd_floating_ip(vpc_tier, vpc_vm_3, - public_ip_2.ipaddress, vpc=vpc) - self.verify_vsd_vm(vpc_vm_3) - self.verify_vsd_vm(vpc_vm_4) - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - - vm_public_ip_2 = public_ip_2.ipaddress.ipaddress - try: - vpc_vm_3.ssh_ip = vm_public_ip_2 - vpc_vm_3.ssh_port = \ - self.test_data["virtual_machine"]["ssh_port"] - vpc_vm_3.username = \ - self.test_data["virtual_machine"]["username"] - vpc_vm_3.password = \ - self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vpc_vm_3.ssh_ip, vpc_vm_3.password)) - - ssh2 = vpc_vm_3.get_ssh_client(ipaddress=vm_public_ip_2) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh2, vpc_vm_1.ipaddress) - self.verify_pingtovmhostname(ssh2, "vpcvm1") - - self.verify_pingtovmipaddress(ssh2, vpc_vm_4.ipaddress) - self.verify_pingtovmhostname(ssh2, "vpcvm4") - - self.verify_pingtovmipaddress(ssh2, vpc_vm_2.ipaddress) - self.verify_pingtovmhostname(ssh2, "vpcvm2") - - self.debug("Updating the running vm_3 with new user data...") - expected_user_data2 = self.update_userdata(vpc_vm_3, - "hellonuage vm3") - self.debug("SSHing into the vm_3 for verifying its user data...") - user_data_cmd = self.get_userdata_url(vpc_vm_3) - self.debug("Getting user data with command: " + user_data_cmd) - actual_user_data2 = self.execute_cmd(ssh2, user_data_cmd) - self.debug("Actual user data - " + actual_user_data2 + - ", Expected user data - " + expected_user_data2) - self.assertEqual(actual_user_data2, expected_user_data2, - "Un-expected VM (VM_3) user data") - - self.verify_pingtovmipaddress(ssh2, vpc_vm_12.ipaddress) - self.verify_pingtovmhostname(ssh2, "vpcvm12") - - vpc_vm_3.delete(self.api_client, expunge=True) - vpc_vm_4.delete(self.api_client, expunge=True) - public_ip_2.delete(self.api_client) - - # ReleaseIP as get_ssh_client fails when migrating back to native - public_ip_1.delete(self.api_client) - - self.debug("++++++++Migrating network back to native+++++++") - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": native_tiernet_off.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": native_tiernet_off.id}] - - self.migrate_vpc(vpc, native_vpc_off, - network_offering_map) - - @attr(tags=["migrateACS", "vpcmultinic"], - required_hardware="false") - def test_12_migrate_native_vpc_multinic_to_nuage_traffic(self): - """ - Verify MultiNic migration of GuestVm in multiple networks - 1. create one native vpc network offering - 2. create one native vpc tier network offering - 3. with Dhcp,SourceNat,StaticNat,Dns,Userdata and NetworkACL - 4. create one vpc with above native vpc network offering - 5. create one native vpc tier network in above vpc - 6. create 2nd isolated network - 7. deploy 2 vm's in both networks - 8. move to nuage vpc tier networkoffering, - 9. deploy vm3 in vpc tier network - 10. enable staticnat on first vm and ssh into vm - 11. login to vm3 and ping vm1 nic1 - 12. move isolated network to nuage networkoffering, - 13. deploy vm4 in 2nd vpc tier network - 14. enable staticnat on new vm4 and ssh into vm - 15. login to vm4 and ping vm2 nic1 - """ - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = "vpc.com" - self.api_client.updateZone(cmd) - - self.debug("Creating Native VSP VPC offering with Static NAT service " - "provider as VPCVR...") - native_vpc_off = self.create_VpcOffering( - self.test_data["vpc_offering_reduced"]) - self.validate_VpcOffering(native_vpc_off, state="Enabled") - - self.debug("Creating a VPC with Static NAT service provider as " - "VpcVirtualRouter") - vpc = self.create_vpc(native_vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - self.debug("Creating native VPC Network Tier offering " - "with Static NAT service provider as VPCVR") - native_tiernet_off = self.create_NetworkOffering( - self.test_data["nw_offering_reduced_vpc"]) - self.validate_NetworkOffering(native_tiernet_off, state="Enabled") - - acl_list = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc) - - acl_item = self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list) - self.create_NetworkAclRule( - self.test_data["icmprule"], acl_list=acl_list) - - self.debug("Creating a VPC tier network with Static NAT service") - vpc_tier = self.create_Network(native_tiernet_off, - gateway='10.1.0.1', - vpc=vpc, - acl_list=acl_list) - self.validate_Network(vpc_tier, state="Implemented") - - self.debug("Creating 2nd VPC tier network with Static NAT service") - vpc_2ndtier = self.create_Network(native_tiernet_off, - gateway='10.1.128.1', - vpc=vpc, - acl_list=acl_list) - self.validate_Network(vpc_2ndtier, state="Implemented") - - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - isolated_network = self.create_Network( - self.native_isolated_network_staticnat_offering_persistent, - gateway="10.10.0.1", - netmask="255.255.255.0", account=self.account) - self.debug("Creating isolated network with Static NAT service") - - self.debug("Deploying a multinic VM in both networks") - self.test_data["virtual_machine"]["displayname"] = "vpcvm1" - self.test_data["virtual_machine"]["name"] = "vpcvm1" - vpc_vm_1 = self.create_VM([vpc_tier, isolated_network]) - self.check_VM_state(vpc_vm_1, state="Running") - - self.debug("Deploying another VM in both networks other defaultnic") - self.test_data["virtual_machine"]["displayname"] = "vpcvm2" - self.test_data["virtual_machine"]["name"] = "vpcvm2" - vpc_vm_2 = self.create_VM([isolated_network, vpc_tier]) - self.check_VM_state(vpc_vm_2, state="Running") - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - network_offering_map_fault = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}] - - try: - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map_fault, resume=False) - except Exception as e: - errortext = re.search(".*errortext\s*:\s*u?'([^']+)'.*", - e.message).group(1) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate VPC as the specified " \ - "tierNetworkOfferings is not complete" - self.verifymigrationerrortext(errortext, expectstr) - - try: - self.migrate_network(self.nuage_isolated_network_offering, - vpc_tier, resume=False) - except Exception as e: - errortext = re.search(".*errortext\s*:\s*u?'([^']+)'.*", - e.message).group(1) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate network as the specified " \ - "network is a vpc tier. Use migrateVpc." - self.verifymigrationerrortext(errortext, expectstr) - - network_offering_map_fault2 = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": self.nuage_isolated_network_offering.id}] - - try: - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map_fault2, resume=True) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "can't be used for VPC networks for network" - self.verifymigrationerrortext(errortext, expectstr) - - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}] - - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=True) - - self.debug("Deploying another VM in the created VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm3" - self.test_data["virtual_machine"]["name"] = "vpcvm3" - vpc_vm_3 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_3, state="Running") - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - self.debug("Creating Static NAT rule for the deployed VM " - "in the created VPC network...") - public_ip_1 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_1, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm_3, public_ip_1, vpc_tier) - self.validate_PublicIPAddress( - public_ip_1, vpc_tier, static_nat=True, vm=vpc_vm_3) - - # VSD verification after VPC migration functionality - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_vm(vpc_vm_3) - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm_3, public_ip_1.ipaddress, vpc=vpc) - self.verify_vsd_firewall_rule(acl_item) - # self.verify_vsd_vm(vpc_vm_1) - - vm_public_ip_1 = public_ip_1.ipaddress.ipaddress - try: - vpc_vm_3.ssh_ip = vm_public_ip_1 - vpc_vm_3.ssh_port = \ - self.test_data["virtual_machine"]["ssh_port"] - vpc_vm_3.username = \ - self.test_data["virtual_machine"]["username"] - vpc_vm_3.password = \ - self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vpc_vm_3.ssh_ip, vpc_vm_1.password)) - - ssh = vpc_vm_3.get_ssh_client(ipaddress=vm_public_ip_1) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - defaultipaddress = \ - [nic.ipaddress for nic in vpc_vm_1.nic if nic.isdefault][0] - - self.verify_pingtovmipaddress(ssh, defaultipaddress) - - vpc_vm_3.delete(self.api_client, expunge=True) - public_ip_1.delete(self.api_client) - - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network) - - self.test_data["virtual_machine"]["displayname"] = "vm4" - self.test_data["virtual_machine"]["name"] = "vm4" - vm_4 = self.create_VM(isolated_network) - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - self.debug("Creating Static NAT rule for the deployed VM " - "in the created VPC network...") - public_ip_2 = self.acquire_PublicIPAddress(isolated_network) - self.validate_PublicIPAddress(public_ip_1, isolated_network) - self.create_StaticNatRule_For_VM(vm_4, public_ip_2, isolated_network) - self.validate_PublicIPAddress( - public_ip_2, isolated_network, static_nat=True, vm=vm_4) - firewall_rule_2 = self.create_FirewallRule(public_ip_2) - self.verify_vsd_network(self.domain.id, isolated_network) - self.verify_vsd_floating_ip(isolated_network, vm_4, - public_ip_2.ipaddress) - self.verify_vsd_vm(vm_4) - self.verify_vsd_firewall_rule(firewall_rule_2) - # self.verify_vsd_vm(vpc_vm_2) - - vm_public_ip_2 = public_ip_2.ipaddress.ipaddress - try: - vm_4.ssh_ip = vm_public_ip_2 - vm_4.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_4.username = self.test_data["virtual_machine"]["username"] - vm_4.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_4.ssh_ip, vm_4.password)) - - ssh2 = vm_4.get_ssh_client(ipaddress=vm_public_ip_2) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - defaultipaddress2 = \ - [nic.ipaddress for nic in vpc_vm_2.nic if nic.isdefault][0] - - self.verify_pingtovmipaddress(ssh2, defaultipaddress2) - - @attr(tags=["migrateACS", "guestvmip2"], - required_hardware="false") - def test_13_verify_guestvmip2_when_migrating_to_nuage(self): - """ - Verify migration of GuestVm with ip .2 still works - when migrating isolated or vpc tier networks - """ - isolated_network = self.create_Network( - self.native_isolated_network_offering, - gateway="10.13.0.1", - netmask="255.255.255.248", account=self.account) - - self.test_data["virtual_machine"]["ipaddress"] = "10.13.0.2" - vm_11 = self.create_VM(isolated_network) - self.test_data["virtual_machine"]["ipaddress"] = "10.13.0.3" - vm_12 = self.create_VM(isolated_network) - self.test_data["virtual_machine"]["ipaddress"] = "10.13.0.4" - vm_13 = self.create_VM(isolated_network) - self.test_data["virtual_machine"]["ipaddress"] = "10.13.0.5" - vm_14 = self.create_VM(isolated_network) - self.test_data["virtual_machine"]["ipaddress"] = None - vm_15 = self.create_VM(isolated_network) - - try: - self.migrate_network( - self.nuage_isolated_network_offering_persistent, - isolated_network, resume=False) - except Exception as e: - errortext = re.search(".*errortext\s*:\s*u?'([^']+)'.*", - e.message).group(1) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to implement network (with specified id) " \ - "elements and resources as a part of network update" - self.verifymigrationerrortext(errortext, expectstr) - - try: - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate network as previous migration " \ - "left this network in transient condition. " \ - "Specify resume as true." - self.verifymigrationerrortext(errortext, expectstr) - - try: - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network, resume=True) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to resume migrating network as network offering " \ - "does not match previously specified network offering" - self.verifymigrationerrortext(errortext, expectstr) - - vm_13.delete(self.api_client, expunge=True) - - try: - self.migrate_network( - self.nuage_isolated_network_offering_without_vr, - isolated_network, resume=True) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to resume migrating network as network offering " \ - "does not match previously specified network offering" - self.verifymigrationerrortext(errortext, expectstr) - - try: - self.migrate_network( - self.nuage_isolated_network_offering_persistent, - isolated_network, resume=False) - except Exception as e: - errortext = \ - re.search(".*errortext\s*:\s*u?(['\"])([^\\1]+)\\1.*", - e.message).group(2) - self.debug("Migration fails with %s" % errortext) - - expectstr = "Failed to migrate network as previous migration " \ - "left this network in transient condition. " \ - "Specify resume as true." - self.verifymigrationerrortext(errortext, expectstr) - - self.migrate_network( - self.nuage_isolated_network_offering_persistent, - isolated_network, resume=True) - - self.verify_vsd_network(self.domain.id, isolated_network, None) - self.verify_vsd_vm(vm_11) - self.verify_vsd_vm(vm_12) - self.verify_vsd_vm(vm_14) - self.verify_vsd_vm(vm_15) - - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = "vpc.com" - self.api_client.updateZone(cmd) - - self.debug("Creating Native VSP VPC offering with Static NAT service " - "provider as VPCVR...") - native_vpc_off = self.create_VpcOffering( - self.test_data["vpc_offering_reduced"]) - self.validate_VpcOffering(native_vpc_off, state="Enabled") - - self.debug("Creating a VPC with Static NAT service provider as " - "VpcVirtualRouter") - vpc = self.create_vpc(native_vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - self.debug("Creating native VPC Network Tier offering " - "with Static NAT service provider as VPCVR") - native_tiernet_off = self.create_NetworkOffering( - self.test_data["nw_offering_reduced_vpc"]) - self.validate_NetworkOffering(native_tiernet_off, state="Enabled") - - acl_list = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc) - - self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list) - self.create_NetworkAclRule( - self.test_data["icmprule"], acl_list=acl_list) - - self.debug("Creating a VPC tier network with Static NAT service") - vpc_tier = self.create_Network(native_tiernet_off, - gateway='10.1.1.1', - vpc=vpc, - acl_list=acl_list) - self.validate_Network(vpc_tier, state="Implemented") - - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - self.debug("Deploying a VM in a vpc tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm1" - self.test_data["virtual_machine"]["name"] = "vpcvm1" - self.test_data["virtual_machine"]["ipaddress"] = "10.1.1.2" - vpc_vm_1 = self.create_VM(vpc_tier) - self.test_data["virtual_machine"]["ipaddress"] = None - self.check_VM_state(vpc_vm_1, state="Running") - - self.debug("Deploying another VM in vpc tier") - self.test_data["virtual_machine"]["displayname"] = "vpcvm2" - self.test_data["virtual_machine"]["name"] = "vpcvm2" - vpc_vm_2 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_2, state="Running") - - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.nuage_vpc_network_offering.id}] - - self.migrate_vpc(vpc, self.nuage_vpc_offering, - network_offering_map, resume=False) - - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_vm(vpc_vm_1) - self.verify_vsd_vm(vpc_vm_2) - - @attr(tags=["migrateACS", "nativeisoonly"], - required_hardware="false") - def test_14_native_to_native_network_migration(self): - """ - Verify Migration for an isolated network nativeOnly - 1. create native non-persistent isolated network - 2. migrate to native persistent isolated network, check VR state - 3. migrate back to native non-persistent network - 4. deploy VM in non-persistent isolated network - 5. acquire ip and enable staticnat - 6. migrate to native persistent isolated network - 7. migrate back to native non-persistent network - """ - isolated_network = self.create_Network( - self.native_isolated_network_offering, gateway="10.0.0.1", - netmask="255.255.255.0") - - self.migrate_network( - self.native_isolated_network_offering_persistent, - isolated_network, resume=False) - - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - - self.migrate_network( - self.native_isolated_network_offering, - isolated_network, resume=False) - - vm_1 = self.create_VM(isolated_network) - vr = self.get_Router(isolated_network) - self.check_Router_state(vr, "Running") - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - self.create_FirewallRule(public_ip) - - self.migrate_network( - self.native_isolated_network_offering_persistent, - isolated_network, resume=False) - - self.migrate_network( - self.native_isolated_network_offering, - isolated_network, resume=False) - - @attr(tags=["migrateACS", "nativevpconly"], - required_hardware="false") - def test_15_native_to_native_vpc_migration(self): - """ - Verify Migration for a vpc network nativeOnly - 1. create native vpc with 2 tier networks - 2. migrate to native vpc, check VR state - 3. deploy VM in vpc tier network - 4. acquire ip and enable staticnat - 5. migrate to native vpc network - """ - - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = "vpc.com" - self.api_client.updateZone(cmd) - - self.debug("Creating Native VSP VPC offering with Static NAT service " - "provider as VPCVR...") - native_vpc_off = self.create_VpcOffering( - self.test_data["vpc_offering_reduced"]) - self.validate_VpcOffering(native_vpc_off, state="Enabled") - - self.debug("Creating a VPC with Static NAT service provider as " - "VpcVirtualRouter") - vpc = self.create_vpc(native_vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - self.debug("Creating native VPC Network Tier offering " - "with Static NAT service provider as VPCVR") - native_tiernet_off = self.create_NetworkOffering( - self.test_data["nw_offering_reduced_vpc"]) - self.validate_NetworkOffering(native_tiernet_off, state="Enabled") - - acl_list = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc) - - self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list) - self.create_NetworkAclRule( - self.test_data["icmprule"], acl_list=acl_list) - - self.debug("Creating a VPC tier network with Static NAT service") - vpc_tier = self.create_Network(native_tiernet_off, - gateway='10.1.0.1', - vpc=vpc, - acl_list=acl_list) - self.validate_Network(vpc_tier, state="Implemented") - - self.debug("Creating 2nd VPC tier network with Static NAT service") - vpc_2ndtier = self.create_Network(native_tiernet_off, - gateway='10.1.128.1', - vpc=vpc, - acl_list=acl_list) - self.validate_Network(vpc_2ndtier, state="Implemented") - - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.native_vpc_network_offering.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": self.native_vpc_network_offering.id}] - - self.migrate_vpc(vpc, self.native_vpc_offering, - network_offering_map, resume=False) - - self.debug("Deploying a VM in the created VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm1" - self.test_data["virtual_machine"]["name"] = "vpcvm1" - vpc_vm_1 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_1, state="Running") - - self.debug("Deploying another VM in the created VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm2" - self.test_data["virtual_machine"]["name"] = "vpcvm2" - vpc_vm_2 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_2, state="Running") - - self.debug("Deploying a VM in the 2nd VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm12" - self.test_data["virtual_machine"]["name"] = "vpcvm12" - self.create_VM(vpc_2ndtier) - self.check_VM_state(vpc_vm_2, state="Running") - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - - self.debug("Creating Static NAT rule for the deployed VM " - "in the created VPC network...") - public_ip_1 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_1, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm_1, public_ip_1, vpc_tier) - self.validate_PublicIPAddress( - public_ip_1, vpc_tier, static_nat=True, vm=vpc_vm_1) - - network_offering_map = \ - [{"networkid": vpc_tier.id, - "networkofferingid": self.native_vpc_network_offering.id}, - {"networkid": vpc_2ndtier.id, - "networkofferingid": self.native_vpc_network_offering.id}] - self.migrate_vpc(vpc, self.native_vpc_offering, - network_offering_map, resume=False) diff --git a/test/integration/plugins/nuagevsp/test_nuage_non_public_sharednetwork_ip_range.py b/test/integration/plugins/nuagevsp/test_nuage_non_public_sharednetwork_ip_range.py deleted file mode 100644 index a3d550a4e9a..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_non_public_sharednetwork_ip_range.py +++ /dev/null @@ -1,654 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Shared Network functionality with Nuage VSP SDN plugin: -Non Public Shared Network IP Range -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.utils import cleanup_resources -from marvin.lib.base import Account, Domain, User, Network, NetworkOffering -from marvin.lib.common import list_virtual_machines -from marvin.cloudstackAPI import (createVlanIpRange, - listVlanIpRanges, - deleteVlanIpRange, - updateVmNicIp) -# Import System Modules -from nose.plugins.attrib import attr - - -class TestNuageSharedNetworkNonPublicIPRange(nuageTestCase): - """Test Shared Network functionality with Nuage VSP SDN plugin: - Non Public Shared Network IP Range - """ - - @classmethod - def setUpClass(cls): - """ - Create the following domain tree and accounts that are required for - executing Nuage VSP SDN plugin test cases for shared networks: - Under ROOT - create domain D1 - Under domain D1 - Create two subdomains D11 and D12 - Under each of the domains - create one admin user and couple of - regular users. - Create shared network with the following scope: - 1. Network with scope="all" - 2. Network with scope="domain" with no subdomain access - 3. Network with scope="domain" with subdomain access - 4. Network with scope="account" - """ - - super(TestNuageSharedNetworkNonPublicIPRange, cls).setUpClass() - cls.sharednetworkdata = cls.test_data["acl"] - cls.nuagenetworkdata = cls.test_data["nuagevsp"] - - cls.domain_1 = None - cls.domain_2 = None - - try: - # backup default apikey and secretkey - cls.default_apikey = cls.api_client.connection.apiKey - cls.default_secretkey = cls.api_client.connection.securityKey - - # Create domains - cls.domain_1 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain1"] - ) - cls.domain_11 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain11"], - parentdomainid=cls.domain_1.id - ) - cls.domain_12 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain12"], - parentdomainid=cls.domain_1.id - ) - # Create 1 admin account and 2 user accounts for domain_1 - cls.account_d1 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1"], - admin=True, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1) - cls.user_d1_apikey = user.apikey - cls.user_d1_secretkey = user.secretkey - - cls.account_d1a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1A"], - admin=False, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) - cls.user_d1a_apikey = user.apikey - cls.user_d1a_secretkey = user.secretkey - - cls.account_d1b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1B"], - admin=False, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) - cls.user_d1b_apikey = user.apikey - cls.user_d1b_secretkey = user.secretkey - - # Create 1 admin and 2 user accounts for doamin_11 - cls.account_d11 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11"], - admin=True, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11) - cls.user_d11_apikey = user.apikey - cls.user_d11_secretkey = user.secretkey - - cls.account_d11a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11A"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) - cls.user_d11a_apikey = user.apikey - cls.user_d11a_secretkey = user.secretkey - - cls.account_d11b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11B"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) - cls.user_d11b_apikey = user.apikey - cls.user_d11b_secretkey = user.secretkey - - # Create 2 user accounts for doamin_12 - cls.account_d12a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12A"], - admin=False, - domainid=cls.domain_12.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) - cls.user_d12a_apikey = user.apikey - cls.user_d12a_secretkey = user.secretkey - - cls.account_d12b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12B"], - admin=False, - domainid=cls.domain_12.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) - cls.user_d12b_apikey = user.apikey - cls.user_d12b_secretkey = user.secretkey - - # Create 1 user account and admin account in "ROOT" domain - - cls.account_roota = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=False, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_roota) - cls.user_roota_apikey = user.apikey - cls.user_roota_secretkey = user.secretkey - - cls.account_root = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=True, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_root) - cls.user_root_apikey = user.apikey - cls.user_root_secretkey = user.secretkey - - # service offering is already created in Nuagetestcase - cls.sharednetworkdata['mode'] = cls.zone.networktype - - # As admin user, create shared network with scope "all", "domain" - # with subdomain access, "domain" without subdomain access and - # "account" - - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - - cls.shared_network_offering = NetworkOffering.create( - cls.api_client, - cls.nuagenetworkdata["shared_nuage_network_offering"], - conservemode=False - ) - # Enable Network offering - cls.shared_network_offering.update(cls.api_client, state='Enabled') - cls.shared_network_offering_id = cls.shared_network_offering.id - - cls.shared_network_all = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id - ) - - cls.shared_network_domain_d11 = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=False - ) - - cls.shared_network_domain_with_subdomain_d11 = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=True - ) - - cls.shared_network_account_d111a = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - accountid=cls.account_d11a.user[0].username - ) - - cls._cleanup = [ - cls.account_root, - cls.account_roota, - cls.shared_network_all, - cls.shared_network_offering, - cls.service_offering, - ] - except Exception as e: - cls.domain_1.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - raise Exception("Failed to create the setup required to execute " - "the test cases: %s" % e) - - return - - @classmethod - def tearDownClass(cls): - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cls.domain_1.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - return - - def setUp(self): - self.api_client = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - self.cleanup = [] - - def tearDown(self): - # restore back default apikey and secretkey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - return - - def add_subnet_verify(self, network, services): - """verify required nic is present in the VM""" - - self.debug("Going to add new ip range in shared network %s" % - network.name) - cmd = createVlanIpRange.createVlanIpRangeCmd() - cmd.networkid = network.id - cmd.gateway = services["gateway"] - cmd.netmask = services["netmask"] - cmd.startip = services["startip"] - cmd.endip = services["endip"] - cmd.forVirtualNetwork = services["forvirtualnetwork"] - addedsubnet = self.api_client.createVlanIpRange(cmd) - - self.debug("verify above iprange is successfully added in shared " - "network %s or not" % network.name) - - cmd1 = listVlanIpRanges.listVlanIpRangesCmd() - cmd1.networkid = network.id - cmd1.id = addedsubnet.vlan.id - - allsubnets = self.api_client.listVlanIpRanges(cmd1) - self.assertEqual( - allsubnets[0].id, - addedsubnet.vlan.id, - "Check New subnet is successfully added to the shared Network" - ) - return addedsubnet - - def delete_subnet_verify(self, network, subnet): - """verify required nic is present in the VM""" - - self.debug("Going to delete ip range in shared network %s" % - network.name) - cmd = deleteVlanIpRange.deleteVlanIpRangeCmd() - cmd.id = subnet.vlan.id - self.api_client.deleteVlanIpRange(cmd) - - self.debug("verify above iprange is successfully deleted from shared " - "network %s or not" % network.name) - - cmd1 = listVlanIpRanges.listVlanIpRangesCmd() - cmd1.networkid = network.id - cmd1.id = subnet.vlan.id - - try: - allsubnets = self.api_client.listVlanIpRanges(cmd1) - self.assertEqual( - allsubnets[0].id, - subnet.vlan.id, - "Check Subnet is not present to the shared Network" - ) - self.fail("iprange is not successfully deleted from shared " - "network %s" % network.name) - except Exception as e: - self.debug("iprange is not successfully deleted from shared " - "network %s" % network.name) - self.debug("exception msg is %s" % e) - - def shared_subnet_not_present(self, network, subnetid): - shared_resources = self.vsd.get_shared_network_resource( - filter=self.get_externalID_filter(subnetid)) - try: - self.assertEqual(shared_resources.description, network.name, - "VSD shared resources description should match " - "network name in CloudStack" - ) - self.fail("still shared resource are present on VSD") - except Exception as e: - self.debug("sharedNetwork resources is successfully deleted from " - "VSD") - self.debug("exception msg is %s" % e) - - # Test cases relating to add/delete Shared Network IP ranges - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_add_delete_Subnet_in_sharednetwork_scope_all(self): - """Validate that subnet of same and different public gateway can be - added to shared network with scope=all - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as all") - subnet1 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_1, - sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network scope " - "as all") - subnet2 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_2, - sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_all, subnet1) - self.delete_subnet_verify(self.shared_network_all, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_add_delete_Subnet_in_sharednetwork_scope_domain(self): - """Validate subnet of same and different gateway can be added to public - shared network scope=domain with subdomain access - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope domain " - "with subdomain access") - subnet1 = self.add_subnet_verify( - self.shared_network_domain_with_subdomain_d11, - self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, vm_1, - sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network") - subnet2 = self.add_subnet_verify( - self.shared_network_domain_with_subdomain_d11, - self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, vm_2, - sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify( - self.shared_network_domain_with_subdomain_d11, subnet1) - self.delete_subnet_verify( - self.shared_network_domain_with_subdomain_d11, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_add_delete_Subnet_in_sharednetwork_scope_nosubdomain(self): - """Validate subnet of same and different gateway can added to public - shared network scope=domain without subdomain access - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope domain " - "without subdomain access") - subnet1 = self.add_subnet_verify( - self.shared_network_domain_d11, - self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_domain_d11, vm_1, - sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network") - subnet2 = self.add_subnet_verify( - self.shared_network_domain_d11, - self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_domain_d11, vm_2, - sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_domain_d11, subnet1) - self.delete_subnet_verify(self.shared_network_domain_d11, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_add_delete_Subnet_in_sharednetwork_scope_account(self): - """Validate subnet of same and different gateway can be added to shared - network scope=Account - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as " - "Account") - subnet1 = self.add_subnet_verify( - self.shared_network_account_d111a, - self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_account_d111a, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_account_d111a.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_account_d111a, - vm_1, sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network") - subnet2 = self.add_subnet_verify( - self.shared_network_account_d111a, - self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_account_d111a, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_account_d111a.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_account_d111a, - vm_2, sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_account_d111a, subnet1) - self.delete_subnet_verify(self.shared_network_account_d111a, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_05_change_ip_from_different_Subnet_in_sharednetwork(self): - """Validate that ip of a vm can be changed to a different subnet ip for - shared_network_scope_all - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as all") - subnet1 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_1, - sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network scope " - "as all") - subnet2 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange2"]) - - # stop VM to update the ipaddress - try: - vm_1.stop(self.api_client) - except Exception as e: - self.fail("Failed to stop the virtual instances, %s" % e) - vm_list = list_virtual_machines(self.api_client, id=vm_1.id) - nics = [x for x in vm_list[0].nic - if x.networkid == self.shared_network_all.id] - self.debug("Filtered nics list: %s:" % nics) - - cmd = updateVmNicIp.updateVmNicIpCmd() - for x in vm_list[0].nic: - cmd.nicid = x.id - cmd.ipaddress = self.nuagenetworkdata["publiciprange2"]["startip"] - self.api_client.updateVmNicIp(cmd) - - try: - vm_1.start(self.api_client) - except Exception as e: - self.fail("Failed to start the virtual instances, %s" % e) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_1, - sharedsubnetid=subnet_id) - - self.delete_VM(vm_1) - self.delete_subnet_verify(self.shared_network_all, subnet1) - self.delete_subnet_verify(self.shared_network_all, subnet2) - - @staticmethod - def generateKeysForUser(api_client, account): - user = User.list( - api_client, - account=account.name, - domainid=account.domainid)[0] - return (User.registerUserKeys( - api_client, - user.id)) diff --git a/test/integration/plugins/nuagevsp/test_nuage_password_reset.py b/test/integration/plugins/nuagevsp/test_nuage_password_reset.py deleted file mode 100644 index f6f5f8b89a3..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_password_reset.py +++ /dev/null @@ -1,364 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for user data and password reset functionality with -Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import (Account, - Template, - VirtualMachine, - Volume) -from marvin.lib.common import list_templates -from marvin.cloudstackAPI import updateTemplate -# Import System Modules -from nose.plugins.attrib import attr -import base64 - - -class TestNuagePasswordReset(nuageTestCase): - """Test user data and password reset functionality with - Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls): - super(TestNuagePasswordReset, cls).setUpClass() - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - # create_template - Creates guest VM template with the given VM object - def create_template(self, vm): - self.debug("Creating guest VM template") - list_volume = Volume.list(self.api_client, - virtualmachineid=vm.id, - type='ROOT', - listall=True - ) - if isinstance(list_volume, list): - self.volume = list_volume[0] - else: - raise Exception("Exception: Unable to find root volume for VM " - "with ID - %s" % vm.id) - self.pw_enabled_template = Template.create( - self.api_client, - self.test_data["template"], - self.volume.id, - account=self.account.name, - domainid=self.account.domainid - ) - self.assertEqual(self.pw_enabled_template.passwordenabled, True, - "Template is not password enabled" - ) - self.cleanup.append(self.pw_enabled_template) - self.debug("Created guest VM template") - - # updateTemplate - Updates value of the guest VM template's password - # enabled setting - def updateTemplate(self, value): - self.debug("Updating value of guest VM template's password enabled " - "setting") - cmd = updateTemplate.updateTemplateCmd() - cmd.id = self.template.id - cmd.passwordenabled = value - self.api_client.updateTemplate(cmd) - list_template_response = list_templates(self.api_client, - templatefilter="all", - id=self.template.id - ) - self.template = list_template_response[0] - self.debug("Updated guest VM template") - - # get_userdata_url - Returns user data URL for the given VM object - def get_userdata_url(self, vm): - self.debug("Getting user data url") - nic = vm.nic[0] - gateway = str(nic.gateway) - self.debug("Gateway: " + gateway) - user_data_url = 'curl "http://' + gateway + ':80/latest/user-data"' - return user_data_url - - # create_and_verify_fw - Creates and verifies (Ingress) firewall rule with - # a Static NAT rule enabled public IP - def create_and_verify_fw(self, vm, public_ip, network): - self.debug("Creating and verifying firewall rule") - self.create_StaticNatRule_For_VM(vm, public_ip, network) - - # VSD verification - self.verify_vsd_floating_ip(network, vm, public_ip.ipaddress) - - fw_rule = self.create_FirewallRule( - public_ip, self.test_data["ingress_rule"]) - - # VSD verification - self.verify_vsd_firewall_rule(fw_rule) - self.debug("Successfully created and verified firewall rule") - - # stop_vm - Stops the given VM, and verifies its state - def stop_vm(self, vm): - self.debug("Stopping VM") - vm.stop(self.api_client) - list_vm_response = VirtualMachine.list(self.api_client, - id=vm.id - ) - if isinstance(list_vm_response, list): - vm = list_vm_response[0] - if vm.state != 'Stopped': - raise Exception("Failed to stop VM (ID: %s) " % self.vm.id) - else: - raise Exception("Invalid response from list_virtual_machines VM " - "(ID: %s) " % self.vm.id) - self.debug("Stopped VM") - - # install_cloud_set_guest_password_script - Installs the - # cloud-set-guest-password script from people.apache.org in the given VM - # (SSH client) - def install_cloud_set_guest_password_script(self, ssh_client): - if self.isSimulator: - self.debug("Simulator Environment: Skipping installing" - " cloud-set-guest-password script") - return - self.debug("Installing cloud-set-guest-password script") - cmd = "cd /etc/init.d;wget http://people.apache.org/~tsp/" \ - "cloud-set-guest-password" - result = self.execute_cmd(ssh_client, cmd) - self.debug("wget file cloud-set-guest-password: " + result) - if "200 OK" not in result: - self.fail("failed to wget file cloud-set-guest-password") - cmds = ["chmod +x /etc/init.d/cloud-set-guest-password", - "chkconfig --add cloud-set-guest-password" - ] - for c in cmds: - result = self.execute_cmd(ssh_client, c) - self.debug("get_set_password_file cmd " + c) - self.debug("get_set_password_file result " + result) - self.debug("Installed cloud-set-guest-password script") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_nuage_UserDataPasswordReset(self): - """Test user data and password reset functionality with - Nuage VSP SDN plugin - """ - - # 1. Create an Isolated Network with Nuage VSP Isolated Network - # offering, check if it is successfully created and is in the - # "Allocated" state. - # 2. Set password enabled to false in the guest VM template. - # 3. Deploy a VM in the created Isolated network with user data, check - # if the Isolated network state is changed to "Implemented", and - # both the VM & VR are successfully deployed and are in the - # "Running" state. - # 4. Verify that the guest VM template is not password enabled by - # checking the deployed VM's password (password == "password"). - # 5. SSH into the deployed VM and verify its user data - # (expected user data == actual user data). - # 6. Check for cloud-set-guest-password script in the deployed VM for - # testing password reset functionality. - # 7. if cloud-set-guest-password script does not exist in the deployed - # VM: - # 7.1 Install the cloud-set-guest-password script from - # people.apache.org in the deployed VM. - # 7.2 Stop the deployed VM, and create a new password enabled - # guest VM template with it. - # 7.3 Deploy a new VM in the created Isolated network with the - # newly created guest VM template, check if the VM is - # successfully deployed and is in the "Running" state. - # 7.4 Verify that the new guest VM template is password enabled - # by checking the newly deployed VM's password - # (password != "password"). - # 7.5 SSH into the newly deployed VM for verifying its password. - # 8. else cloud-set-guest-password script exists in the deployed VM: - # 8.1 Change password enabled to true in the guest VM template. - # 8.2 Verify that the guest VM template is password enabled. - # 9. Reset VM password, and start the VM. - # 10. Verify that the new guest VM template is password enabled by - # checking the VM's password (password != "password"). - # 11. SSH into the VM for verifying its new password after its password - # reset. - # 12. Set password enabled to the default value in the guest VM - # template. - # 13. Delete all the created objects (cleanup). - - for zone in self.zones: - self.debug("Zone - %s" % zone.name) - # Get Zone details - self.getZoneDetails(zone=zone) - # Configure VSD sessions - self.configureVSDSessions() - - self.debug("Testing user data & password reset functionality in " - "an Isolated network...") - - self.debug("Creating an Isolated network...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.network = self.create_Network(net_off) - self.validate_Network(self.network, state="Allocated") - - self.debug("Setting password enabled to false in the guest VM " - "template...") - self.defaultTemplateVal = self.template.passwordenabled - if self.template.passwordenabled: - self.updateTemplate(False) - - self.debug("Deploying a VM in the created Isolated network with " - "user data...") - expected_user_data = "hello world vm1" - user_data = base64.b64encode(expected_user_data) - self.test_data["virtual_machine_userdata"]["userdata"] = user_data - self.vm_1 = self.create_VM( - self.network, - testdata=self.test_data["virtual_machine_userdata"]) - self.validate_Network(self.network, state="Implemented") - vr = self.get_Router(self.network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(self.vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, self.network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(self.vm_1) - - self.debug("verifying that the guest VM template is not password " - "enabled...") - self.debug("VM - %s password - %s !" % - (self.vm_1.name, self.vm_1.password)) - self.assertEqual( - self.vm_1.password, - self.test_data["virtual_machine_userdata"]["password"], - "Password is enabled for the VM (vm_1)" - ) - - self.debug("SSHing into the VM for verifying its user data...") - public_ip_1 = self.acquire_PublicIPAddress(self.network) - self.create_and_verify_fw(self.vm_1, public_ip_1, self.network) - ssh = self.ssh_into_VM(self.vm_1, public_ip_1) - user_data_cmd = self.get_userdata_url(self.vm_1) - if self.isSimulator: - self.debug("Simulator Environment: ending test early " - "because we don't have real vms") - return - self.debug("Getting user data with command: " + user_data_cmd) - actual_user_data = base64.b64decode(self.execute_cmd - (ssh, user_data_cmd)) - self.debug("Actual user data - " + actual_user_data + - ", Expected user data - " + expected_user_data) - self.assertEqual(actual_user_data, expected_user_data, - "Un-expected VM (VM_1) user data") - - self.debug("Checking for cloud-set-guest-password script in the " - "VM for testing password reset functionality...") - ls_cmd = "ls /etc/init.d/cloud-set-guest-password" - ls_result = self.execute_cmd(ssh, ls_cmd) - ls_result = ls_result.lower() - self.debug("Response from ls_cmd: " + ls_result) - - if "no such file" in ls_result: - self.debug("No cloud-set-guest-password script in the VM") - self.debug("Installing the cloud-set-guest-password script " - "from people.apache.org in the VM...") - self.install_cloud_set_guest_password_script(ssh) - self.debug("Stopping the VM, and creating a new password " - "enabled guest VM template with it...") - self.stop_vm(self.vm_1) - self.create_template(self.vm_1) - - self.debug("Deploying a new VM in the created Isolated " - "network with the newly created guest VM " - "template...") - self.vm_2 = self.create_VM( - self.network, - testdata=self.test_data["virtual_machine_userdata"]) - self.debug("Starting the VM...") - vm_2a = self.vm_2.start(self.api_client) - self.vm_2.password = vm_2a.password.strip() - self.vm_2.nic = vm_2a.nic - - # VSD verification - self.verify_vsd_vm(self.vm_2) - - self.debug("verifying that the guest VM template is password " - "enabled...") - self.debug("VM - %s password - %s !" % - (self.vm_2.name, self.vm_2.password)) - self.assertNotEqual( - self.vm_2.password, - self.test_data["virtual_machine_userdata"]["password"], - "Password is not enabled for the VM" - ) - - self.debug("SSHing into the VM for verifying its password...") - public_ip_2 = self.acquire_PublicIPAddress(self.network) - self.create_and_verify_fw(self.vm_2, public_ip_2, self.network) - self.ssh_into_VM(self.vm_2, public_ip_2) - - vm_test = self.vm_2 - vm_test_public_ip = public_ip_2 - else: - self.debug("Updating the guest VM template to password " - "enabled") - self.updateTemplate(True) - self.assertEqual(self.template.passwordenabled, True, - "Guest VM template is not password enabled" - ) - vm_test = self.vm_1 - vm_test_public_ip = public_ip_1 - - self.debug("Resetting password for VM - %s" % vm_test.name) - self.stop_vm(vm_test) - vm_test.password = vm_test.resetPassword(self.api_client) - self.debug("Password reset to - %s" % vm_test.password) - - self.debug("Starting the VM") - vm_test.start(self.api_client) - - self.debug("until CLOUDSTACK-10380 is fixed, redo resetPassword") - self.stop_vm(vm_test) - self.debug("Resetting password again for VM - %s" % vm_test.name) - vm_test.password = vm_test.resetPassword(self.api_client) - self.debug("VM - %s password - %s !" % - (vm_test.name, vm_test.password)) - self.debug("Starting the VM again") - vm_test.start(self.api_client) - - self.debug("verifying that the guest VM template is password " - "enabled...") - self.debug("VM - %s password - %s !" % - (vm_test.name, vm_test.password)) - self.assertNotEqual( - vm_test.password, - self.test_data["virtual_machine_userdata"]["password"], - "Password is not enabled for the VM" - ) - - self.debug("SSHing into the VM for verifying its new password " - "after its password reset...") - self.ssh_into_VM(vm_test, vm_test_public_ip) - - self.debug("Setting password enabled to the default value in the " - "guest VM template...") - self.updateTemplate(self.defaultTemplateVal) diff --git a/test/integration/plugins/nuagevsp/test_nuage_public_sharednetwork_ip_range.py b/test/integration/plugins/nuagevsp/test_nuage_public_sharednetwork_ip_range.py deleted file mode 100644 index b0a5ae9426c..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_public_sharednetwork_ip_range.py +++ /dev/null @@ -1,823 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Shared Network functionality with Nuage VSP SDN plugin: -Public Shared Network IP Range -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.utils import cleanup_resources, validateList -from marvin.lib.base import (Account, - Domain, - User, - VirtualMachine, - Network, - NetworkOffering) -from marvin.lib.common import list_virtual_machines -from marvin.cloudstackAPI import (createVlanIpRange, - listVlanIpRanges, - deleteVlanIpRange, - updateVmNicIp) -from marvin.codes import PASS -# Import System Modules -from nose.plugins.attrib import attr - - -class TestNuageSharedNetworkPublicIPRange(nuageTestCase): - """Test Shared Network functionality with Nuage VSP SDN plugin: - Public Shared Network IP Range - """ - - @classmethod - def setUpClass(cls): - """ - Create the following domain tree and accounts that are required for - executing Nuage VSP SDN plugin test cases for shared networks: - Under ROOT - create domain D1 - Under domain D1 - Create two subdomains D11 and D12 - Under each of the domains - create one admin user and couple of - regular users. - Create shared network with the following scope: - 1. Network with scope="all" - 2. Network with scope="domain" with no subdomain access - 3. Network with scope="domain" with subdomain access - 4. Network with scope="account" - """ - - super(TestNuageSharedNetworkPublicIPRange, cls).setUpClass() - cls.sharednetworkdata = cls.test_data["acl"] - cls.nuagenetworkdata = cls.test_data["nuagevsp"] - - cls.domain_1 = None - cls.domain_2 = None - - try: - # backup default apikey and secretkey - cls.default_apikey = cls.api_client.connection.apiKey - cls.default_secretkey = cls.api_client.connection.securityKey - - # Create domains - cls.domain_1 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain1"] - ) - cls.domain_11 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain11"], - parentdomainid=cls.domain_1.id - ) - cls.domain_12 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain12"], - parentdomainid=cls.domain_1.id - ) - # Create 1 admin account and 2 user accounts for doamin_1 - cls.account_d1 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1"], - admin=True, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1) - cls.user_d1_apikey = user.apikey - cls.user_d1_secretkey = user.secretkey - - cls.account_d1a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1A"], - admin=False, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) - cls.user_d1a_apikey = user.apikey - cls.user_d1a_secretkey = user.secretkey - - cls.account_d1b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1B"], - admin=False, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) - cls.user_d1b_apikey = user.apikey - cls.user_d1b_secretkey = user.secretkey - - # Create 1 admin and 2 user accounts for doamin_11 - cls.account_d11 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11"], - admin=True, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11) - cls.user_d11_apikey = user.apikey - cls.user_d11_secretkey = user.secretkey - - cls.account_d11a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11A"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) - cls.user_d11a_apikey = user.apikey - cls.user_d11a_secretkey = user.secretkey - - cls.account_d11b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11B"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) - cls.user_d11b_apikey = user.apikey - cls.user_d11b_secretkey = user.secretkey - - # Create 2 user accounts for doamin_12 - cls.account_d12a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12A"], - admin=False, - domainid=cls.domain_12.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) - cls.user_d12a_apikey = user.apikey - cls.user_d12a_secretkey = user.secretkey - - cls.account_d12b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12B"], - admin=False, - domainid=cls.domain_12.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) - cls.user_d12b_apikey = user.apikey - cls.user_d12b_secretkey = user.secretkey - - # Create 1 user account and admin account in "ROOT" domain - - cls.account_roota = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=False, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_roota) - cls.user_roota_apikey = user.apikey - cls.user_roota_secretkey = user.secretkey - - cls.account_root = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=True, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_root) - cls.user_root_apikey = user.apikey - cls.user_root_secretkey = user.secretkey - - # service offering is already created in Nuagetestcase - cls.sharednetworkdata['mode'] = cls.zone.networktype - - # As admin user , create shared network with scope "all", "domain" - # with subdomain access ,"domain" without subdomain access and - # "account" - - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - - cls.shared_network_offering = NetworkOffering.create( - cls.api_client, - cls.nuagenetworkdata["shared_nuage_public_network_offering"], - conservemode=False - ) - - # Enable Network offering - cls.shared_network_offering.update(cls.api_client, state='Enabled') - cls.shared_network_offering_id = cls.shared_network_offering.id - - cls.shared_network_all = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id - ) - - cls.shared_network_domain_d11 = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=False - ) - - cls.shared_network_domain_with_subdomain_d11 = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=True - ) - - cls.shared_network_account_d111a = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - accountid=cls.account_d11a.user[0].username - ) - - cls._cleanup = [ - cls.account_root, - cls.account_roota, - cls.shared_network_all, - cls.shared_network_offering, - cls.service_offering, - ] - except Exception as e: - cls.domain_1.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - raise Exception("Failed to create the setup required to execute " - "the test cases: %s" % e) - - return - - @classmethod - def tearDownClass(cls): - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cleanup_resources(cls.api_client, cls._cleanup) - return - - def setUp(self): - self.api_client = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - self.cleanup = [] - - def tearDown(self): - # restore back default apikey and secretkey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.debug("Cleaning up the resources") - for obj in reversed(self.cleanup): - try: - if isinstance(obj, VirtualMachine): - obj.delete(self.api_client, expunge=True) - else: - obj.delete(self.api_client) - except Exception as e: - self.error("Failed to cleanup %s, got %s" % (obj, e)) - # cleanup_resources(self.api_client, self.cleanup) - self.cleanup = [] - self.debug("Cleanup complete!") - return - - def add_subnet_verify(self, network, services): - """verify required nic is present in the VM""" - - self.debug("Going to add new ip range in shared network %s" % - network.name) - cmd = createVlanIpRange.createVlanIpRangeCmd() - cmd.networkid = network.id - cmd.gateway = services["gateway"] - cmd.netmask = services["netmask"] - cmd.startip = services["startip"] - cmd.endip = services["endip"] - cmd.forVirtualNetwork = services["forvirtualnetwork"] - addedsubnet = self.api_client.createVlanIpRange(cmd) - - self.debug("verify above iprange is successfully added in shared " - "network %s or not" % network.name) - - cmd1 = listVlanIpRanges.listVlanIpRangesCmd() - cmd1.networkid = network.id - cmd1.id = addedsubnet.vlan.id - - allsubnets = self.api_client.listVlanIpRanges(cmd1) - self.assertEqual( - allsubnets[0].id, - addedsubnet.vlan.id, - "Check New subnet is successfully added to the shared Network" - ) - return addedsubnet - - def delete_subnet_verify(self, network, subnet): - """verify required nic is present in the VM""" - - self.debug("Going to delete ip range in shared network %s" % - network.name) - cmd = deleteVlanIpRange.deleteVlanIpRangeCmd() - cmd.id = subnet.vlan.id - self.api_client.deleteVlanIpRange(cmd) - - self.debug("verify above iprange is successfully deleted from shared " - "network %s or not" % network.name) - - cmd1 = listVlanIpRanges.listVlanIpRangesCmd() - cmd1.networkid = network.id - cmd1.id = subnet.vlan.id - - try: - allsubnets = self.api_client.listVlanIpRanges(cmd1) - self.assertEqual( - allsubnets[0].id, - subnet.vlan.id, - "Check Subnet is not present to the shared Network" - ) - self.fail("iprange is not successfully deleted from shared " - "network %s" % network.name) - except Exception as e: - self.debug("iprange is not successfully deleted from shared " - "network %s" % network.name) - self.debug("exception msg is %s" % e) - - def shared_subnet_not_present(self, network, subnetid): - shared_resources = self.vsd.get_shared_network_resource( - filter=self.get_externalID_filter(subnetid)) - try: - self.assertEqual(shared_resources.description, network.name, - "VSD shared resources description should match " - "network name in CloudStack" - ) - self.fail("still shared resource are present on VSD") - except Exception as e: - self.debug("sharedNetwork resources is successfully deleted from " - "VSD") - self.debug("exception msg is %s" % e) - - # Test cases relating to add/delete Shared Network IP ranges - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_add_delete_Subnet_in_public_sharednetwork_scope_all(self): - """Validate that subnet of same and different public gateway can be - added to shared network with scope=all - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as all") - subnet1 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_1, - sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network scope " - "as all") - subnet2 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_2, - sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_all, subnet1) - self.delete_subnet_verify(self.shared_network_all, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_add_delete_Subnet_in_public_sharednetwork_scope_domain(self): - """Validate subnet of same and different gateway can be added to public - shared network scope=domain with subdomain access - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope domain " - "with subdomain access") - subnet1 = self.add_subnet_verify( - self.shared_network_domain_with_subdomain_d11, - self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, vm_1, - sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network") - subnet2 = self.add_subnet_verify( - self.shared_network_domain_with_subdomain_d11, - self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, vm_2, - sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify( - self.shared_network_domain_with_subdomain_d11, subnet1) - self.delete_subnet_verify( - self.shared_network_domain_with_subdomain_d11, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_add_delete_Subnet_in_pub_sharednetwork_scope_nosubdomain(self): - """Validate subnet of same and different gateway can added to public - shared network scope=domain without subdomain access - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope domain " - "without subdomain access") - subnet1 = self.add_subnet_verify( - self.shared_network_domain_d11, - self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_domain_d11, vm_1, - sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network") - subnet2 = self.add_subnet_verify( - self.shared_network_domain_d11, - self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_domain_d11, vm_2, - sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_domain_d11, subnet1) - self.delete_subnet_verify(self.shared_network_domain_d11, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_add_delete_Subnet_in_public_sharednetwork_scope_account(self): - """Validate subnet of same and different gateway can be added to shared - network scope=Account - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as " - "Account") - subnet1 = self.add_subnet_verify( - self.shared_network_account_d111a, - self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_account_d111a, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_account_d111a.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_account_d111a, - vm_1, sharedsubnetid=subnet_id) - - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network") - subnet2 = self.add_subnet_verify( - self.shared_network_account_d111a, - self.nuagenetworkdata["publiciprange2"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange2"]["startip"] - vm_2 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_account_d111a, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_account_d111a.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_account_d111a, - vm_2, sharedsubnetid=subnet_id) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_account_d111a, subnet1) - self.delete_subnet_verify(self.shared_network_account_d111a, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_05_change_ip_from_different_Subnet_public_shared(self): - """Validate that ip of a vm can be changed to a different subnet ip for - shared_network_scope_all - """ - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as all") - subnet1 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange1"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_1, - sharedsubnetid=subnet_id) - # Add subnet with different cidr - self.debug("Adding subnet of different cidr to shared Network scope " - "as all") - subnet2 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange2"]) - - # stop VM to update the ipaddress - try: - vm_1.stop(self.api_client) - except Exception as e: - self.fail("Failed to stop the virtual instances, %s" % e) - vm_list = list_virtual_machines(self.api_client, id=vm_1.id) - nics = [x for x in vm_list[0].nic - if x.networkid == self.shared_network_all.id] - self.debug("Filtered nics list: %s:" % nics) - - cmd = updateVmNicIp.updateVmNicIpCmd() - for x in vm_list[0].nic: - cmd.nicid = x.id - cmd.ipaddress = self.nuagenetworkdata["publiciprange2"]["startip"] - self.api_client.updateVmNicIp(cmd) - - try: - vm_1.start(self.api_client) - except Exception as e: - self.fail("Failed to start the virtual instances, %s" % e) - - vm_list = list_virtual_machines(self.api_client, id=vm_1.id) - vm_list_validation_result = validateList(vm_list) - self.assertEqual(vm_list_validation_result[0], PASS, - "vm list validation failed due to %s" % - vm_list_validation_result[2]) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_list[0], - sharedsubnetid=subnet_id) - - self.delete_VM(vm_1) - self.delete_subnet_verify(self.shared_network_all, subnet1) - self.delete_subnet_verify(self.shared_network_all, subnet2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_06_restart_public_sharedNetwork_scope_all(self): - """Validate that restart Shared Network is done successfully without - any Error - """ - - self.debug("Adding subnet of same cidr to shared Network scope as all") - try: - self.add_subnet_verify( - self.shared_network_all, - self.nuagenetworkdata["publiciprange1"]) - except Exception as e: - self.debug("seems above test case is not able to clean the subnet") - self.debug("exception msg is %s" % e) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange1"]["startip"] - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_1, - sharedsubnetid=subnet_id) - - # Restart network with cleanup - self.debug("Restarting shared Network with cleanup") - self.shared_network_all.restart(self.api_client, cleanup=True) - - self.debug("validating SharedNetwork on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange1"]["gateway"]) - self.delete_VM(vm_1) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_07_delete_first_subnet_public_sharednetwork_scope_all(self): - """Validate that when first subnet is removed then deletion of Network - works fine - """ - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["startip"] - vm_2 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_2, - sharedsubnetid=subnet_id) - # Restart network with cleanup - cmd = listVlanIpRanges.listVlanIpRangesCmd() - cmd.networkid = self.shared_network_all.id - allsubnets = self.api_client.listVlanIpRanges(cmd) - self.delete_VM(vm_2) - firstsubnet = None - for subnet in allsubnets: - if subnet.endip == self.nuagenetworkdata["network_all"]["endip"]: - firstsubnet = subnet - - self.debug("cleanning first subnet") - try: - cmd = deleteVlanIpRange.deleteVlanIpRangeCmd() - cmd.id = firstsubnet.id - self.api_client.deleteVlanIpRange(cmd) - except Exception as e: - self.fail("Fail to delete the first subnet of shared Network") - self.debug("exception msg is %s" % e) - - self.shared_network_all.delete(self.api_client) - if self.shared_network_all in self._cleanup: - self._cleanup.remove(self.shared_network_all) - self.shared_subnet_not_present(self.shared_network_all, subnet_id) - - def test_08_public_sharednetwork_domain_cleanup(self): - """Validate that sharedNetwork Parent domain is cleaned up properly - """ - - try: - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["startip"] - vm_1 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id_subdomain = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm_1, sharedsubnetid=subnet_id_subdomain) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_2 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id_nosubdomain = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_domain_d11, - vm_2, sharedsubnetid=subnet_id_nosubdomain) - subnet_id_nosubdomain1 = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - subnet_id_subdomain1 = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.domain_1.delete(self.api_client, cleanup="true") - except Exception as e: - self.debug("test case Fail") - self.debug("exception msg is %s" % e) - self.domain_1.delete(self.api_client, cleanup="true") - self.fail("Fail to delete the Parent domain") - - self.shared_subnet_not_present( - self.shared_network_domain_with_subdomain_d11, - subnet_id_subdomain) - self.shared_subnet_not_present( - self.shared_network_domain_d11, subnet_id_nosubdomain) - self.shared_subnet_not_present( - self.shared_network_domain_with_subdomain_d11, - subnet_id_subdomain1) - self.shared_subnet_not_present( - self.shared_network_domain_d11, subnet_id_nosubdomain1) - - @staticmethod - def generateKeysForUser(api_client, account): - user = User.list( - api_client, - account=account.name, - domainid=account.domainid)[0] - - return (User.registerUserKeys( - api_client, - user.id)) diff --git a/test/integration/plugins/nuagevsp/test_nuage_public_sharednetwork_userdata.py b/test/integration/plugins/nuagevsp/test_nuage_public_sharednetwork_userdata.py deleted file mode 100644 index afd99416647..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_public_sharednetwork_userdata.py +++ /dev/null @@ -1,943 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Shared Network functionality with Nuage VSP SDN plugin: -Public Shared Network IP Range -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.utils import cleanup_resources -from marvin.lib.common import list_templates -from marvin.lib.base import (Account, - Domain, - User, - VirtualMachine, - Network, - NetworkOffering) -from marvin.cloudstackAPI import (createVlanIpRange, - listVlanIpRanges, - deleteVlanIpRange, - updateTemplate) -# Import System Modules -from nose.plugins.attrib import attr -import random -import string - - -class TestNuageSharedNetworkUserdata(nuageTestCase): - """Test Shared Network functionality with Nuage VSP SDN plugin: - Public Shared Network IP Range - """ - - @classmethod - def setUpClass(cls): - """ - Create the following domain tree and accounts that are required for - executing Nuage VSP SDN plugin test cases for shared networks: - Under ROOT - create domain D1 - Under domain D1 - Create two subdomains D11 and D12 - Under each of the domains - create one admin user and couple of - regular users. - Create shared network with the following scope: - 1. Network with scope="all" - 2. Network with scope="domain" with no subdomain access - 3. Network with scope="domain" with subdomain access - 4. Network with scope="account" - """ - - super(TestNuageSharedNetworkUserdata, cls).setUpClass() - cls.sharednetworkdata = cls.test_data["acl"] - cls.nuagenetworkdata = cls.test_data["nuagevsp"] - - cls.domain_1 = None - cls.domain_2 = None - - try: - # backup default apikey and secretkey - cls.default_apikey = cls.api_client.connection.apiKey - cls.default_secretkey = cls.api_client.connection.securityKey - - # Create domains - cls.domain_1 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain1"] - ) - cls.domain_11 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain11"], - parentdomainid=cls.domain_1.id - ) - cls.domain_12 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain12"], - parentdomainid=cls.domain_1.id - ) - # Create 1 admin account and 2 user accounts for doamin_1 - cls.account_d1 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1"], - admin=True, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1) - cls.user_d1_apikey = user.apikey - cls.user_d1_secretkey = user.secretkey - - cls.account_d1a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1A"], - admin=False, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) - cls.user_d1a_apikey = user.apikey - cls.user_d1a_secretkey = user.secretkey - - cls.account_d1b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1B"], - admin=False, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) - cls.user_d1b_apikey = user.apikey - cls.user_d1b_secretkey = user.secretkey - - # Create 1 admin and 2 user accounts for doamin_11 - cls.account_d11 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11"], - admin=True, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11) - cls.user_d11_apikey = user.apikey - cls.user_d11_secretkey = user.secretkey - - cls.account_d11a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11A"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) - cls.user_d11a_apikey = user.apikey - cls.user_d11a_secretkey = user.secretkey - - cls.account_d11b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11B"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) - cls.user_d11b_apikey = user.apikey - cls.user_d11b_secretkey = user.secretkey - - # Create 2 user accounts for doamin_12 - cls.account_d12a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12A"], - admin=False, - domainid=cls.domain_12.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) - cls.user_d12a_apikey = user.apikey - cls.user_d12a_secretkey = user.secretkey - - cls.account_d12b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12B"], - admin=False, - domainid=cls.domain_12.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) - cls.user_d12b_apikey = user.apikey - cls.user_d12b_secretkey = user.secretkey - - # Create 1 user account and admin account in "ROOT" domain - - cls.account_roota = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=False, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_roota) - cls.user_roota_apikey = user.apikey - cls.user_roota_secretkey = user.secretkey - - cls.account_root = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=True, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_root) - cls.user_root_apikey = user.apikey - cls.user_root_secretkey = user.secretkey - - # service offering is already created in Nuagetestcase - cls.sharednetworkdata['mode'] = cls.zone.networktype - - # As admin user , create shared network with scope "all", "domain" - # with subdomain access ,"domain" without subdomain access and - # "account" - - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cls.nuagenetworkdata["shared_nuage_public_network_offering"][ - "serviceProviderList"].update({"UserData": 'VirtualRouter'}) - cls.nuagenetworkdata["shared_nuage_public_network_offering"][ - "supportedservices"] = 'Dhcp,Connectivity,UserData' - for key, value in cls.test_data["nuagevsp"][ - "shared_nuage_public_network_offering"]["serviceProviderList"]\ - .iteritems(): - cls.debug("elements are %s and value is %s" % (key, value)) - - cls.shared_network_offering = NetworkOffering.create( - cls.api_client, - cls.nuagenetworkdata["shared_nuage_public_network_offering"], - conservemode=False - ) - - # Enable Network offering - cls.shared_network_offering.update(cls.api_client, state='Enabled') - cls.shared_network_offering_id = cls.shared_network_offering.id - - cls.shared_network_all = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id - ) - - cls.shared_network_domain_d11 = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=False - ) - - cls.shared_network_domain_with_subdomain_d11 = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=True - ) - - cls.shared_network_account_d111a = Network.create( - cls.api_client, - cls.nuagenetworkdata["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - accountid=cls.account_d11a.user[0].username - ) - - cls._cleanup = [ - cls.account_root, - cls.account_roota, - cls.shared_network_all, - cls.shared_network_offering, - cls.service_offering, - ] - user_data = ''.join(random.choice( - string.ascii_uppercase + string.digits) for x in range(2500)) - cls.test_data["virtual_machine"]["userdata"] = user_data - except Exception as e: - cls.domain_1.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - raise Exception("Failed to create the setup required to execute " - "the test cases: %s" % e) - - return - - @classmethod - def tearDownClass(cls): - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cleanup_resources(cls.api_client, cls._cleanup) - return - - def setUp(self): - self.api_client = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - self.cleanup = [] - - def tearDown(self): - # restore back default apikey and secretkey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.debug("Cleaning up the resources") - for obj in reversed(self.cleanup): - try: - if isinstance(obj, VirtualMachine): - obj.delete(self.api_client, expunge=True) - else: - obj.delete(self.api_client) - except Exception as e: - self.error("Failed to cleanup %s, got %s" % (obj, e)) - # cleanup_resources(self.api_client, self.cleanup) - self.cleanup = [] - self.debug("Cleanup complete!") - self.updateTemplate(False) - return - - def add_subnet_verify(self, network, services): - """verify required nic is present in the VM""" - - self.debug("Going to add new ip range in shared network %s" % - network.name) - cmd = createVlanIpRange.createVlanIpRangeCmd() - cmd.networkid = network.id - cmd.gateway = services["gateway"] - cmd.netmask = services["netmask"] - cmd.startip = services["startip"] - cmd.endip = services["endip"] - cmd.forVirtualNetwork = services["forvirtualnetwork"] - addedsubnet = self.api_client.createVlanIpRange(cmd) - - self.debug("verify above iprange is successfully added in shared " - "network %s or not" % network.name) - - cmd1 = listVlanIpRanges.listVlanIpRangesCmd() - cmd1.networkid = network.id - cmd1.id = addedsubnet.vlan.id - - allsubnets = self.api_client.listVlanIpRanges(cmd1) - self.assertEqual( - allsubnets[0].id, - addedsubnet.vlan.id, - "Check New subnet is successfully added to the shared Network" - ) - return addedsubnet - - def delete_subnet_verify(self, network, subnet): - """verify required nic is present in the VM""" - - self.debug("Going to delete ip range in shared network %s" % - network.name) - cmd = deleteVlanIpRange.deleteVlanIpRangeCmd() - cmd.id = subnet.vlan.id - self.api_client.deleteVlanIpRange(cmd) - - self.debug("verify above iprange is successfully deleted from shared " - "network %s or not" % network.name) - - cmd1 = listVlanIpRanges.listVlanIpRangesCmd() - cmd1.networkid = network.id - cmd1.id = subnet.vlan.id - - try: - allsubnets = self.api_client.listVlanIpRanges(cmd1) - self.assertEqual( - allsubnets[0].id, - subnet.vlan.id, - "Check Subnet is not present to the shared Network" - ) - self.fail("iprange is not successfully deleted from shared " - "network %s" % network.name) - except Exception as e: - self.debug("iprange is successfully deleted from shared " - "network %s" % network.name) - self.debug("exception msg is %s" % e) - - def shared_subnet_not_present(self, network, subnetid): - shared_resources = self.vsd.get_shared_network_resource( - filter=self.get_externalID_filter(subnetid)) - try: - self.assertEqual(shared_resources.description, network.name, - "VSD shared resources description should match " - "network name in CloudStack" - ) - self.fail("still shared resource are present on VSD") - except Exception as e: - self.debug("sharedNetwork resources is successfully deleted from " - "VSD") - self.debug("exception msg is %s" % e) - - # updateTemplate - Updates value of the guest VM template's password - # enabled setting - def updateTemplate(self, value): - self.debug("Updating value of guest VM template's password enabled " - "setting") - cmd = updateTemplate.updateTemplateCmd() - cmd.id = self.template.id - cmd.passwordenabled = value - self.api_client.updateTemplate(cmd) - list_template_response = list_templates(self.api_client, - templatefilter="all", - id=self.template.id) - self.template = list_template_response[0] - self.debug("Updated guest VM template") - - # Test cases relating to VR IP check on Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_verify_deployvm_fail_startip_sharednetwork_scope_all(self): - """Validate that deploy vm fails if user specify the first ip of subnet - because that is reserved for VR shared network with scope=all - """ - # Add vm as start ip of subnet - self.debug("Adding VM as start IP of Subnet") - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["startip"] - try: - self.create_VM(self.shared_network_all, account=self.account_d11a) - self.fail("VM with subnet start IP is deployed successfully") - except Exception as e: - self.debug("Deploy vm fails as expected with exception %s" % e) - self.debug("Going to verify the exception message") - exceptionmsg = "Unable to start a VM due to insufficient capacity" - if exceptionmsg in str(e): - self.debug("correct exception is raised") - else: - self.fail("correct exception is not raised") - - # Test cases relating to add/delete Shared Network IP ranges - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_add_delete_Subnet_restart_public_sharednetwork_scope_all(self): - """Validate that subnet of same gateway can be added to shared network - with scope=all and restart network with clean up works - """ - self.debug("Deploy VM to shared Network scope as all") - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_1, - sharedsubnetid=subnet_id) - # verify VR - vr = self.get_Router(self.shared_network_all) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as all") - subnet1 = self.add_subnet_verify( - self.shared_network_all, self.nuagenetworkdata["publiciprange3"]) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange3"]["startip"] - vm_2 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - # verify on VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["publiciprange3"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["publiciprange3"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_all, vm_2, - sharedsubnetid=subnet_id) - # Restart network with cleanup - self.debug("Restarting shared Network with cleanup") - self.shared_network_all.restart(self.api_client, cleanup=True) - - self.debug("validating SharedNetwork on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - # verify VR - vr = self.get_Router(self.shared_network_all) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_all, subnet1) - - # Test cases relating to add/delete Shared Network IP ranges - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_add_delete_Subnet_restart_sharednetwork_scope_domain(self): - """Validate that subnet of same gateway can be added to shared network - with scope=all and restart network with clean up works - """ - self.debug("Deploy VM to shared Network scope domain as all") - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, vm_1, - sharedsubnetid=subnet_id) - # verify VR - vr = self.get_Router(self.shared_network_domain_with_subdomain_d11) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as all") - subnet1 = self.add_subnet_verify( - self.shared_network_domain_with_subdomain_d11, - self.nuagenetworkdata["publiciprange3"]) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange3"]["startip"] - vm_2 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - # VSD check points - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["publiciprange3"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["publiciprange3"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, vm_2, - sharedsubnetid=subnet_id) - # Restart network with cleanup - self.debug("Restarting shared Network with cleanup") - self.shared_network_domain_with_subdomain_d11.restart(self.api_client, - cleanup=True) - - self.debug("validating SharedNetwork on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - # verify VR - vr = self.get_Router(self.shared_network_domain_with_subdomain_d11) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify( - self.shared_network_domain_with_subdomain_d11, subnet1) - - # Test cases relating to add/delete Shared Network IP ranges - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_add_delete_Subnet_restart_scope_domain_nosubdomain(self): - """Validate that subnet of same gateway can be added to shared network - with scope domain nosubdomain and restart network with clean up works - """ - - self.debug("Deploy VM to shared Network scope domain no subdomain") - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_domain_d11, vm_1, - sharedsubnetid=subnet_id) - # verify VR - vr = self.get_Router(self.shared_network_domain_d11) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - - # Add subnet with same cidr - self.debug("Adding subnet of same cidr to shared Network scope as all") - subnet1 = self.add_subnet_verify( - self.shared_network_domain_d11, - self.nuagenetworkdata["publiciprange3"]) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange3"]["startip"] - vm_2 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["publiciprange3"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata["publiciprange3"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_domain_d11, vm_2, - sharedsubnetid=subnet_id) - # Restart network with cleanup - self.debug("Restarting shared Network with cleanup") - self.shared_network_domain_d11.restart(self.api_client, cleanup=True) - - self.debug("validating SharedNetwork on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_domain_d11, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - # verify VR - vr = self.get_Router(self.shared_network_domain_d11) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_domain_d11, subnet1) - - # Test cases relating to add/delete Shared Network IP ranges - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_05_add_delete_Subnet_restart_scope_account(self): - """Validate that subnet of same gateway can be added to shared network - with scope as account and restart network with clean up works - """ - - self.debug("Deploy VM to shared Network scope as account") - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - - # Verify shared Network and VM in VSD - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_account_d111a, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_account_d111a.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_account_d111a, - vm_1, sharedsubnetid=subnet_id) - # verify VR - vr = self.get_Router(self.shared_network_account_d111a) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - - # Add subnet with same cidr - self.debug("Add subnet of same cidr shared Network scope as account") - subnet1 = self.add_subnet_verify( - self.shared_network_account_d111a, - self.nuagenetworkdata["publiciprange3"]) - - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["publiciprange3"]["startip"] - vm_2 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_account_d111a, - gateway=self.nuagenetworkdata["publiciprange3"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_account_d111a.id, - self.nuagenetworkdata["publiciprange3"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, self.shared_network_account_d111a, - vm_2, sharedsubnetid=subnet_id) - # Restart network with cleanup - self.debug("Restarting shared Network with cleanup") - self.shared_network_account_d111a.restart(self.api_client, - cleanup=True) - - self.debug("validating SharedNetwork on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, self.shared_network_account_d111a, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - # verify VR - vr = self.get_Router(self.shared_network_account_d111a) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - # put ping here - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_subnet_verify(self.shared_network_account_d111a, subnet1) - - # Test cases relating to VR IP check on Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_06_verify_different_gateway_subnet_fails_sharednetwork_all(self): - """Validate that Different gateway subnet fail as it is not supported - for userdata service shared network with scope=all - """ - # Add subnet of different gateway - self.debug("Adding subnet of different gateway") - - try: - subnet2 = self.add_subnet_verify( - self.shared_network_all, - self.nuagenetworkdata["publiciprange2"]) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - self.delete_VM(vm_1) - self.delete_subnet_verify(self.shared_network_all, subnet2) - self.fail("VM is successfully added which is not expected") - except Exception as e: - self.debug("different gateway subnet " - "fails as expected with exception %s" % e) - self.debug("Going to verify the exception message") - self.delete_subnet_verify(self.shared_network_all, subnet2) - exceptionmsg = "Unable to start VM instance" - if exceptionmsg in str(e): - self.debug("correct exception is raised") - else: - self.fail("correct exception is not raised") - - # Test cases relating to different gateway subnet check on Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_07_different_gateway_subnet_fails_sharednetwork_domain(self): - """Validate that Different gateway subnet fail as it is not supported - for userdata service shared network with scope domain - """ - # Add subnet of different gateway - self.debug("Adding subnet of different gateway") - - try: - subnet2 = self.add_subnet_verify( - self.shared_network_domain_with_subdomain_d11, - self.nuagenetworkdata["publiciprange2"]) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - self.delete_VM(vm_1) - self.delete_subnet_verify( - self.shared_network_domain_with_subdomain_d11, subnet2) - self.fail("VM is successfully added which is not expected") - except Exception as e: - self.debug("different gateway subnet " - "fails as expected with exception %s" % e) - self.debug("Going to verify the exception message") - self.delete_subnet_verify( - self.shared_network_domain_with_subdomain_d11, subnet2) - exceptionmsg = "Unable to start VM instance" - if exceptionmsg in str(e): - self.debug("correct exception is raised") - else: - self.fail("correct exception is not raised") - - # Test cases relating to different gateway subnet check on Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_08_different_gateway_subnet_fails_sharednetwork_nosubdomain(self): - """Validate that Different gateway subnet fail as it is not supported - for userdata service shared network with scope nosubdomain - """ - # Add subnet of different gateway - self.debug("Adding subnet of different gateway") - - try: - subnet2 = self.add_subnet_verify( - self.shared_network_domain_d11, - self.nuagenetworkdata["publiciprange2"]) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_domain_d11, account=self.account_d11a) - self.delete_VM(vm_1) - self.delete_subnet_verify( - self.shared_network_domain_d11, subnet2) - self.fail("VM is successfully added which is not expected") - except Exception as e: - self.debug("different gateway subnet" - " fails as expected with exception %s" % e) - self.debug("Going to verify the exception message") - self.delete_subnet_verify( - self.shared_network_domain_d11, subnet2) - exceptionmsg = "Unable to start VM instance" - if exceptionmsg in str(e): - self.debug("correct exception is raised") - else: - self.fail("correct exception is not raised") - - # Test cases relating to different gateway subnet check on Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_09_different_gateway_subnet_fails_sharednetwork_account(self): - """Validate that Different gateway subnet fail as it is not supported - for userdata service shared network with scope account - """ - # Add subnet of different gateway - self.debug("Adding subnet of different gateway") - - try: - subnet2 = self.add_subnet_verify( - self.shared_network_account_d111a, - self.nuagenetworkdata["publiciprange2"]) - self.test_data["virtual_machine"]["ipaddress"] = \ - self.nuagenetworkdata["network_all"]["endip"] - vm_1 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - self.delete_VM(vm_1) - self.delete_subnet_verify( - self.shared_network_account_d111a, subnet2) - self.fail("VM is successfully added which is not expected") - except Exception as e: - self.debug("different gateway subnet" - " fails as expected with exception %s" % e) - self.debug("Going to verify the exception message") - self.delete_subnet_verify( - self.shared_network_account_d111a, subnet2) - exceptionmsg = "Unable to start VM instance" - if exceptionmsg in str(e): - self.debug("correct exception is raised") - else: - self.fail("correct exception is not raised") - - # Test cases relating to reset password in Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_10_password_reset_public_sharednetwork_scope_all(self): - """Validate that reset password works fine in shared network - with scope=all - """ - self.updateTemplate(True) - self.debug("Deploy VM to shared Network scope as all") - self.test_data["virtual_machine"]["ipaddress"] = None - vm_1 = self.create_VM( - self.shared_network_all, account=self.account_d11a) - - # verify VR - vr = self.get_Router(self.shared_network_all) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - - self.debug("Stopping VM: %s" % vm_1.name) - vm_1.stop(self.api_client) - self.debug("Resetting VM password for VM: %s" % vm_1.name) - password = vm_1.resetPassword(self.api_client) - self.debug("Password reset to: %s" % password) - vm_1.start(self.api_client) - - # put login to vm here - self.delete_VM(vm_1) - - # Test cases relating to reset password in Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_11_password_reset_public_sharednetwork_scope_domain(self): - """Validate that reset password works fine in shared network - with scope as domain with subdomain access - """ - self.updateTemplate(True) - self.debug("Deploy VM to shared Network scope as all") - self.test_data["virtual_machine"]["ipaddress"] = None - vm_1 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - # verify VR - vr = self.get_Router(self.shared_network_domain_with_subdomain_d11) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - - self.debug("Stopping VM: %s" % vm_1.name) - vm_1.stop(self.api_client) - self.debug("Resetting VM password for VM: %s" % vm_1.name) - password = vm_1.resetPassword(self.api_client) - self.debug("Password reset to: %s" % password) - vm_1.start(self.api_client) - - # put login to vm here - self.delete_VM(vm_1) - - # Test cases relating to reset password in Shared Network - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_12_password_reset_public_sharednetwork_scope_account(self): - """Validate that reset password works fine in shared network - with scope as Account - """ - self.updateTemplate(True) - self.debug("Deploy VM to shared Network scope as all") - self.test_data["virtual_machine"]["ipaddress"] = None - vm_1 = self.create_VM( - self.shared_network_account_d111a, account=self.account_d11a) - - # verify VR - vr = self.get_Router(self.shared_network_account_d111a) - self.check_Router_state(vr, state="Running") - self.verify_vsd_router(vr) - - self.debug("Stopping VM: %s" % vm_1.name) - vm_1.stop(self.api_client) - self.debug("Resetting VM password for VM: %s" % vm_1.name) - password = vm_1.resetPassword(self.api_client) - self.debug("Password reset to: %s" % password) - vm_1.start(self.api_client) - - # put login to vm here - self.delete_VM(vm_1) - - def test_13_public_sharednetwork_domain_cleanup(self): - """Validate that sharedNetwork Parent domain is cleaned up properly - """ - - try: - vm_1 = self.create_VM( - self.shared_network_domain_with_subdomain_d11, - account=self.account_d11a) - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id_subdomain = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm_1, sharedsubnetid=subnet_id_subdomain) - - subnet_id_subdomain1 = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata["publiciprange2"]["gateway"]) - self.domain_1.delete(self.api_client, cleanup="true") - except Exception as e: - self.debug("test case Fail") - self.debug("exception msg is %s" % e) - self.domain_1.delete(self.api_client, cleanup="true") - self.fail("Fail to delete the Parent domain") - - self.shared_subnet_not_present( - self.shared_network_domain_with_subdomain_d11, - subnet_id_subdomain) - self.shared_subnet_not_present( - self.shared_network_domain_with_subdomain_d11, - subnet_id_subdomain1) - - @staticmethod - def generateKeysForUser(api_client, account): - user = User.list( - api_client, - account=account.name, - domainid=account.domainid)[0] - - return (User.registerUserKeys( - api_client, - user.id)) diff --git a/test/integration/plugins/nuagevsp/test_nuage_publicsharednetwork.py b/test/integration/plugins/nuagevsp/test_nuage_publicsharednetwork.py deleted file mode 100644 index dca034e2508..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_publicsharednetwork.py +++ /dev/null @@ -1,2575 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Shared Network functionality with Nuage VSP SDN plugin: -Public Shared Network -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.utils import cleanup_resources -from marvin.lib.base import (Account, - Domain, - User, - VirtualMachine, - Network, - NetworkOffering) -from marvin.cloudstackException import CloudstackAclException -# Import System modules -from nose.plugins.attrib import attr -import random -import string - - -class TestNuagePublicSharedNetwork(nuageTestCase): - """Test Shared Network functionality with Nuage VSP SDN plugin: - Public Shared Network - """ - - @classmethod - def setUpClass(cls): - """ - Create the following domain tree and accounts that are required for - executing Nuage VSP SDN plugin test cases for shared networks: - Under ROOT - create domain D1 - Under domain D1 - Create two subdomains D11 and D12 - Under each of the domains - create one admin user and couple of - regular users. - Create shared network with the following scope: - 1. Network with scope="all" - 2. Network with scope="domain" with no subdomain access - 3. Network with scope="domain" with subdomain access - 4. Network with scope="account" - """ - - super(TestNuagePublicSharedNetwork, cls).setUpClass() - cls.sharednetworkdata = cls.test_data["acl"] - cls.nuagenetworkdata = cls.test_data["nuagevsp"] - - cls.domain_1 = None - cls.domain_2 = None - - try: - # backup default apikey and secretkey - cls.default_apikey = cls.api_client.connection.apiKey - cls.default_secretkey = cls.api_client.connection.securityKey - - # Create domains - cls.domain_1 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain1"] - ) - cls.domain_11 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain11"], - parentdomainid=cls.domain_1.id - ) - cls.domain_111 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain111"], - parentdomainid=cls.domain_11.id, - ) - cls.domain_12 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain12"], - parentdomainid=cls.domain_1.id - ) - cls.domain_2 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain2"] - ) - # Create 1 admin account and 2 user accounts for doamin_1 - cls.account_d1 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1"], - admin=True, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1) - cls.user_d1_apikey = user.apikey - cls.user_d1_secretkey = user.secretkey - - cls.account_d1a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1A"], - admin=False, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) - cls.user_d1a_apikey = user.apikey - cls.user_d1a_secretkey = user.secretkey - - cls.account_d1b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1B"], - admin=False, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) - cls.user_d1b_apikey = user.apikey - cls.user_d1b_secretkey = user.secretkey - - # Create 1 admin and 2 user accounts for doamin_11 - cls.account_d11 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11"], - admin=True, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11) - cls.user_d11_apikey = user.apikey - cls.user_d11_secretkey = user.secretkey - - cls.account_d11a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11A"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) - cls.user_d11a_apikey = user.apikey - cls.user_d11a_secretkey = user.secretkey - - cls.account_d11b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11B"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) - cls.user_d11b_apikey = user.apikey - cls.user_d11b_secretkey = user.secretkey - - # Create 2 user accounts and 1 admin account for doamin_111 - - cls.account_d111 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD111"], - admin=True, - domainid=cls.domain_111.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d111) - cls.user_d111_apikey = user.apikey - cls.user_d111_secretkey = user.secretkey - - cls.account_d111a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD111A"], - admin=False, - domainid=cls.domain_111.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d111a) - cls.user_d111a_apikey = user.apikey - cls.user_d111a_secretkey = user.secretkey - - cls.account_d111b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD111B"], - admin=False, - domainid=cls.domain_111.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d111b) - cls.user_d111b_apikey = user.apikey - cls.user_d111b_secretkey = user.secretkey - - # Create 2 user accounts for doamin_12 - cls.account_d12a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12A"], - admin=False, - domainid=cls.domain_12.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) - cls.user_d12a_apikey = user.apikey - cls.user_d12a_secretkey = user.secretkey - - cls.account_d12b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12B"], - admin=False, - domainid=cls.domain_12.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) - cls.user_d12b_apikey = user.apikey - cls.user_d12b_secretkey = user.secretkey - - # Create 1 user account for domain_2 - - cls.account_d2a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD2"], - admin=False, - domainid=cls.domain_2.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d2a) - cls.user_d2a_apikey = user.apikey - cls.user_d2a_secretkey = user.secretkey - - # Create 1 user account and admin account in "ROOT" domain - - cls.account_roota = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=False, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_roota) - cls.user_roota_apikey = user.apikey - cls.user_roota_secretkey = user.secretkey - - cls.account_root = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=True, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_root) - cls.user_root_apikey = user.apikey - cls.user_root_secretkey = user.secretkey - - # service offering is already created in Nuagetestcase - cls.sharednetworkdata['mode'] = cls.zone.networktype - - # As admin user , create shared network with scope "all", - # "domain" with subdomain access, - # "domain" without subdomain access and "account" - - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cls.test_data["nuagevsp"]["shared_nuage_public_network_offering"][ - "serviceProviderList"].update({"UserData": 'VirtualRouter'}) - cls.test_data["nuagevsp"]["shared_nuage_public_network_offering"][ - "supportedservices"] = 'Dhcp,Connectivity,UserData' - - cls.shared_network_offering = NetworkOffering.create( - cls.api_client, - cls.test_data["nuagevsp"][ - "shared_nuage_public_network_offering"], - conservemode=False - ) - # Enable Network offering - cls.shared_network_offering.update(cls.api_client, state='Enabled') - cls.shared_network_offering_id = cls.shared_network_offering.id - - cls.shared_network_all = Network.create( - cls.api_client, - cls.test_data["nuagevsp"]["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id - ) - - cls.shared_network_domain_d11 = Network.create( - cls.api_client, - cls.test_data["nuagevsp"][ - "network_domain_with_no_subdomain_access"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=False - ) - - cls.shared_network_domain_with_subdomain_d11 = Network.create( - cls.api_client, - cls.test_data["nuagevsp"][ - "network_domain_with_subdomain_access"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=True - ) - - cls.shared_network_account_d111a = Network.create( - cls.api_client, - cls.test_data["nuagevsp"]["network_account"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_111.id, - accountid=cls.account_d111a.user[0].username - ) - cls.vmdata = {"name": "test", - "displayname": "test" - } - - cls._cleanup = [ - cls.account_root, - cls.account_roota, - cls.shared_network_all, - cls.shared_network_offering, - cls.service_offering, - ] - user_data = ''.join(random.choice( - string.ascii_uppercase + string.digits) for x in range(2500)) - cls.vmdata["userdata"] = user_data - except Exception as e: - cls.domain_1.delete(cls.api_client, cleanup="true") - cls.domain_2.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - raise Exception( - "Failed to create the setup required to execute the test " - "cases: %s" % e) - - return - - @classmethod - def tearDownClass(cls): - - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cls.domain_1.delete(cls.api_client, cleanup="true") - cls.domain_2.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - return - - def setUp(self): - self.api_client = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - - def tearDown(self): - # restore back default apikey and secretkey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - return - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=all - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_domainuser(self): - """Validate that ROOT admin is able to deploy a VM for other users in - a shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1a.name and - vm.domainid == self.account_d1a.domainid, - True, - "ROOT admin is not able to deploy a VM for other users in a " - "shared network with scope=all") - subnet_id = self.get_subnet_id(self.shared_network_all.id, - self.nuagenetworkdata["network_all"][ - "gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_domainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for a domain admin - users in a shared network with scope=all - """ - - # Deploy VM for an admin user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1.name and - vm.domainid == self.account_d1.domainid, - True, - "ROOT admin is not able to deploy a VM " - "for a domain admin users in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d1.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_all.id, - self.nuagenetworkdata["network_all"][ - "gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_subdomainuser(self): - """Validate that ROOT admin is able to deploy a VM for any user in a - subdomain in a shared network with scope=all - """ - # Deploy VM as user in a subdomain under ROOT - - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "ROOT admin is not able to deploy a VM" - " for any user in a subdomain in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_all.id, - self.nuagenetworkdata["network_all"][ - "gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_subdomainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for admin user in a - domain in a shared network with scope=all - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "ROOT admin is not able to deploy a VM for admin user in a domain " - "in a shared network with scope=all") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_all.id, - self.nuagenetworkdata["network_all"][ - "gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_ROOTuser(self): - """Validate that ROOT admin is able to deploy a VM for user in ROOT - domain in a shared network with scope=all - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_roota, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_roota.name and - vm.domainid == self.account_roota.domainid, - True, - "ROOT admin is not able to deploy a VM for user in ROOT domain " - "in a shared network with scope=all") - self.verify_vsd_shared_network( - self.account_roota.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_all.id, - self.nuagenetworkdata["network_all"][ - "gateway"]) - self.verify_vsd_enterprise_vm(self.account_roota.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=Domain and no subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomaccess_domainuser( - self): - """Validate that ROOT admin is able to deploy a VM for domain user in a - shared network with scope=domain with no subdomain access - """ - - # Deploy VM as user in a domain that has shared network with no - # subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "ROOT admin is not able to deploy a VM for domain user in a " - "shared network with scope=domain with no subdomain access") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomaccess_domainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for domain admin - user in a shared network with scope=domain with no subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "ROOT admin is not able to deploy VM for domain admin user in " - "shared network with scope=domain with no subdomain access") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomaccess_subdomainuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for sub domain - user in a shared network with scope=domain with no subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111a.name, - domainid=self.account_d111a.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for sub domain user in a " - "shared network with scope=domain with no subdomain access") - - except Exception as e: - self.debug( - "When a user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for sub domain user in a shared network with " - "scope=domain with no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomaccess_subdomainadmin( - self): - """Validate that ROOT admin is NOT able to deploy a VM for sub domain - admin user in a shared network with scope=domain with no subdomain - access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for sub domain admin user in " - "a shared network with scope=domain with no subdomain access") - except Exception as e: - self.debug( - "When a admin user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for sub domain admin user in a shared " - "network with scope=domain with no subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomaccess_parentdomuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain user in a shared network with scope=domain with no subdomain - access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - " ROOT admin is able to deploy a VM for parent domain user in " - "a shared network with scope=domain with no subdomain access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries " - "to deploy a VM for parent domain user in a shared " - "network with scope=domain with no subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomaccess_parentdomadmin( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain admin user in a shared network with scope=domain with no - subdomain access - """ - - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for parent domain admin " - "user in a shared network with scope=domain with no subdomain " - "access") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain admin user in a shared " - "network with scope=domain with no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomaccess_ROOTuser(self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain admin user in a shared network with scope=domain with no - subdomain access - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for parent domain admin " - "user in a shared network with scope=domain with no subdomain " - "access") - except Exception as e: - self.debug( - "When a regular user from ROOT domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain admin user in a shared " - "network with scope=domain with no subdomain access") - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=Domain and with subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_domainuser( - self): - """Validate that ROOT admin is able to deploy a VM for domain user in a - shared network with scope=domain with subdomain access - """ - - # Deploy VM as user in a domain that has shared network with subdomain - # access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "ROOT admin is NOT able to deploy a VM for domain user in a " - "shared network with scope=domain with subdomain access") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_domainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for domain admin - user in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "ROOT admin is not able to deploy a VM for domain admin user in a " - "shared network with scope=domain with subdomain access") - - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_subdomainuser( - self): - """Validate that ROOT admin is able to deploy a VM for subdomain user - in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "ROOT admin is not able to deploy a VM for subdomain user in a " - "shared network with scope=domain with subdomain access") - - self.verify_vsd_shared_network( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_subdomainadmin( - self): - """Validate that ROOT admin is able to deploy a VM for subdomain admin - user in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111.name and - vm.domainid == self.account_d111.domainid, - True, - "ROOT admin is not able to deploy VM for subdomain admin user in " - "a shared network with scope=domain subdomain access") - - self.verify_vsd_shared_network( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_parentdomainuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain user in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - "ROOT admin is NOT able to deploy a VM for parent domain user " - "in a shared network with scope=domain with subdomain access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain user in a shared network " - "with scope=domain with subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_parentdomainadmin( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain admin user in a shared network with scope=domain with subdomain - access - """ - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for parent domain admin user " - "in a shared network with scope=domain subdomain access ") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with subdomain access %s" % - e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain admin user in a shared " - "network with scope=domain with subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_ROOTuser(self): - """Validate that ROOT admin is NOT able to deploy a VM for user in ROOT - domain in a shared network with scope=domain with subdomain access - """ - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_roota_apikey - self.api_client.connection.securityKey = self.user_roota_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for user in ROOT domain in " - "a shared network with scope=domain with subdomain access") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for user in ROOT domain in a shared network " - "with scope=domain with subdomain access") - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=account - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_domainuser(self): - """Validate that ROOT admin is NOT able to deploy a VM for user in the - same domain but in a different account in a shared network with - scope=account - """ - - # Deploy VM as user in a domain under the same domain but different - # account from the account that has a shared network with scope=account - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111B"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111B"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111b.name, - domainid=self.account_d111b.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for user in the same domain " - "but in different account in shared network scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys a " - "VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for user in the same domain but in a " - "different account in a shared network with scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_domainadminuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for admin user - in the same domain but in a different account in a shared network with - scope=account - """ - - # Deploy VM as admin user for a domain that has an account with shared - # network with scope=account - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for admin user in same " - "domain but in different account in shared network with " - "scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys a " - "VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for admin user in the same domain but in a " - "different account in a shared network with scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_user(self): - """Validate that ROOT admin is able to deploy a VM for regular user in - a shared network with scope=account - """ - - # Deploy VM as account with shared network with scope=account - - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_account_d111a, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "ROOT admin is not able to deploy a VM for regular user in a " - "shared network with scope=account") - - self.verify_vsd_shared_network(self.account_d111a.domainid, - self.shared_network_account_d111a, - gateway=self.nuagenetworkdata[ - "network_account"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_account_d111a.id, - self.nuagenetworkdata[ - "network_account"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d111a.domainid, - self.shared_network_account_d111a, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_differentdomain( - self): - """Validate that ROOT admin is NOT able to deploy a VM for a admin user - in a shared network with scope=account which the admin user does not - have access to - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD2A"]["name"] + \ - "-shared-scope-account-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD2A"]["displayname"] + \ - "-shared-scope-account-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for admin user in shared " - "network scope=account which admin user does not have access") - except Exception as e: - self.debug("account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for a admin user in a shared network with " - "scope=account which the admin user does not have access " - "to ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_ROOTuser(self): - """Validate that ROOT admin is NOT able to deploy a VM for a user in - ROOT domain in a shared network with scope=account which the user does - not have access to - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-account-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-account-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for a user in ROOT domain in " - "shared network scope=account which user does not have access") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for a user in ROOT domain in a shared " - "network with scope=account which the user does not have " - "access to ") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=all - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_domainuser( - self): - """Validate that Domain admin is able to deploy a VM for a domain user - in a shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1a.name and - vm.domainid == self.account_d1a.domainid, - True, - "Domain admin is not able to deploy a VM for a domain user in a " - "shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d1a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_domadminuser( - self): - """Validate that Domain admin is able to deploy a VM for a domain admin - user in a shared network with scope=all - """ - - # Deploy VM for an admin user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-all-domain-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1.name and - vm.domainid == self.account_d1.domainid, - True, - "Domain admin is not able to deploy a VM for a domain admin user " - "in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d1.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_subdomainuser( - self): - """Validate that Domain admin is able to deploy a VM for a sub domain - user in a shared network with scope=all - """ - - # Deploy VM as user in a subdomain under ROOT - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "Domain admin is not able to deploy a VM for a sub domain user in " - "a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_subdomadmin( - self): - """Validate that Domain admin is able to deploy a VM for a sub domain - admin user in a shared network with scope=all - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-all-domain-admin" - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "Domain admin is not able to deploy a VM for a sub domain admin " - "user in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_ROOTuser(self): - """Validate that Domain admin is NOT able to deploy a VM for user in - ROOT domain in a shared network with scope=all - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-all" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-all" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is NOT able to deploy a VM for user in ROOT " - "domain in a shared network with scope=all") - except Exception as e: - self.debug( - "When a Domain admin user deploys a VM for ROOT user in a " - "shared network with scope=all %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin is NOT " - "able to deploy a VM for user in ROOT domain in a shared " - "network with scope=all") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_crossdomuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - other domain in a shared network with scope=all - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + "-shared-scope-all" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-all" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "Domain admin user is able to Deploy VM for a domain user he " - "does not have access to in a shared network with " - "scope=domain with no subdomain access ") - except Exception as e: - self.debug( - "When a Domain admin user deploys a VM for a domain user he " - "does not have access to in a shared network with " - "scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error mesage validation failed when Domain admin user " - "tries to Deploy VM for a domain user he does not have " - "access to in a shared network with scope=domain with no " - "subdomain access ") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=Domain and no subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_domuser( - self): - """Validate that Domain admin is able to deploy a VM for domain user in - a shared network with scope=Domain and no subdomain access - """ - - # Deploy VM as user in a domain that has shared network with no - # subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "Domain admin is not able to deploy a VM for domain user in a " - "shared network with scope=Domain and no subdomain access") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_domadmin( - self): - """Validate that Domain admin is able to deploy a VM for domain admin - user in a shared network with scope=Domain and no subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "Admin User in a domain that has a shared network with no " - "subdomain access failed to Deploy VM in a shared network with " - "scope=domain with no subdomain access") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_subdomusr( - self): - """Validate that Domain admin is NOT able to deploy a VM for sub domain - user in a shared network with scope=Domain and no subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111a.name, - domainid=self.account_d111a.domainid - ) - self.fail( - "Domain admin is able to deploy VM for sub domain user in a " - "shared network with scope=Domain and no subdomain access") - except Exception as e: - self.debug( - "When a user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for sub domain user in a shared network " - "with scope=Domain and no subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_subdomadm( - self): - """Valiadte that Domain admin is NOT able to deploy a VM for sub domain - admin user in a shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for sub domain admin " - "user in a shared network with scope=Domain no subdomain " - "access") - except Exception as e: - self.debug( - "When a admin user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for sub domain admin user in a shared " - "network with scope=Domain and no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_pardomusr( - self): - """Validate that Domain admin is NOT able to deploy a VM for parent - domain user in a shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for parent domain user " - "in a shared network with scope=Domain and no subdomain " - "access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for parent domain user in a shared " - "network with scope=Domain and no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_pardomadm( - self): - """Validate that Domain admin is NOT able to deploy VM for parent - domain admin user in shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "Domain admin is able to deploy VM for parent domain admin " - "user in a shared network with scope=Domain no subdomain " - "access") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for parent domain admin user in a shared " - "network with scope=Domain and no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_ROOTuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - ROOT domain in a shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in ROOT domain " - "in a shared network with scope=Domain and no subdomain " - "access") - except Exception as e: - self.debug( - "When a regular user from ROOT domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in ROOT domain in a shared " - "network with scope=Domain and no subdomain access") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=Domain and with subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_domainuser( - self): - """Validate that Domain admin is able to deploy a VM for regular user - in domain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as user in a domain that has shared network with subdomain - # access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "Domain admin is not able to deploy VM for regular user in domain " - "in a shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_domainadmin( - self): - """Validate that Domain admin is able to deploy a VM for admin user in - domain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "Domain admin is not able to deploy a VM for admin user in domain " - "in a shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_subdomuser( - self): - """Validate that Domain admin is able to deploy a VM for regular user - in subdomain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "Domain admin not able to deploy VM for regular user in subdomain " - "in shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_subdomadmin( - self): - """Validate that Domain admin is able to deploy a VM for admin user in - subdomain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111.name and - vm.domainid == self.account_d111.domainid, - True, - "Domain admin is not able to deploy VM for admin user in " - "subdomain in a shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_pardomuser( - self): - """Validate that Domain admin NOT able to deploy VM for regular user in - parent domain in shared network with scope=Domain subdomain access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - " Domain admin is able to deploy VM for regular user in " - "parent domain in a shared network with scope=Domain " - "subdomain access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for regular user in parent domain in a " - "shared network with scope=Domain and subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_pardomadmin( - self): - """Validate that Domain admin is NOT able to deploy VM for admin user - in parent domain in shared network with scope=Domain subdomain access - """ - - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for admin user in parent " - "domain in a shared network with scope=Domain subdomain " - "access") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with subdomain access %s" % - e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for admin user in parent domain in a " - "shared network with scope=Domain and subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomainaccess_ROOTuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - ROOT domain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in ROOT domain " - "in a shared network with scope=Domain and subdomain access") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in ROOT domain in a shared " - "network with scope=Domain and subdomain access") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=account - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_domainuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - the same domain but belonging to a different account in a shared - network with scope=account - """ - - # Deploy VM as user in a domain under the same domain but different - # account from the acount that has a shared network with scope=account - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111B"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111B"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111b.name, - domainid=self.account_d111b.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in the same " - "domain but belonging to a different account in a shared " - "network with scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys a " - "VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in the same domain but belonging " - "to a different account in a shared network with " - "scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_domadmin( - self): - """Validate that Domain admin is NOT able to deploy a VM for an admin - user in the same domain but belonging to a different account in a - shared network with scope=account - """ - - # Deploy VM as admin user for a domain that has an account with shared - # network with scope=account - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in the same " - "domain but belonging to a different account in a shared " - "network with scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys a " - "VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in the same domain but belonging " - "to a different account in a shared network with " - "scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_user(self): - """Validate that Domain admin is able to deploy a VM for an regular - user in a shared network with scope=account - """ - - # Deploy VM as account with shared network with scope=account - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_account_d111a, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "Domain admin is not able to deploy a VM for an regular user in a " - "shared network with scope=account") - self.verify_vsd_shared_network(self.account_d111a.domainid, - self.shared_network_account_d111a, - gateway=self.nuagenetworkdata[ - "network_account"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_account_d111a.id, - self.nuagenetworkdata[ - "network_account"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d111a.domainid, - self.shared_network_account_d111a, vm, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_diffdomain( - self): - """Validate that Domain admin is NOT able to deploy a VM for an - regular user from a different domain in a shared network with - scope=account - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD2A"]["name"] + \ - "-shared-scope-account-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD2A"]["displayname"] + \ - "-shared-scope-account-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "Domain admin is able able to deploy a VM for an regular user " - "from a differnt domain in a shared network with " - "scope=account") - except Exception as e: - self.debug( - "When a user from different domain deploys a VM in a shared " - "network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for an regular user from a differnt " - "domain in a shared network with scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_ROOTuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for an regular - user in ROOT domain in a shared network with scope=account - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-account-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-account-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for an regular user in " - "ROOT domain in a shared network with scope=account") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for an regular user in ROOT domain in a " - "shared network with scope=account") - - # Test cases relating to deploying Virtual Machine as Regular user for - # other users in shared network with scope=all - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_regularuser_scope_all_anotherusers( - self): - """Validate that regular user is NOT able to deploy a VM for - another user in the same domain in a shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_d12a.name, - domainid=self.account_d12a.domainid - ) - self.fail( - "Regular user is allowed to deploy a VM for another user in " - "the same domain in a shared network with scope=all") - except Exception as e: - self.debug( - "When a regular user deploys a VM for another user in the " - "same domain in a shared network with scope=all %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_ACCOUNT): - self.fail( - "Error message validation failed when Regular user tries " - "to deploy a VM for another user in the same domain in a " - "shared network with scope=all") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_regularuser_scope_all_crossdomain( - self): - """Validate that regular user is NOT able to deploy a VM for - another user in a different domain in a shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.vmdata["name"] = self.sharednetworkdata["vmD11A"][ - "name"] + "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "Regular user is allowed to deploy a VM for another user in " - "the same domain in a shared network with scope=all") - except Exception as e: - self.debug( - "When a regular user deploys a VM for another user in the " - "same domain in a shared network with scope=all %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_ACCOUNT): - self.fail( - "Error message validation failed when Regular user tries " - "to deploy a VM for another user in the same domain in a " - "shared network with scope=all") - - @staticmethod - def generateKeysForUser(api_client, account): - user = User.list( - api_client, - account=account.name, - domainid=account.domainid - )[0] - - return (User.registerUserKeys( - api_client, - user.id - )) diff --git a/test/integration/plugins/nuagevsp/test_nuage_sharednetwork_deployVM.py b/test/integration/plugins/nuagevsp/test_nuage_sharednetwork_deployVM.py deleted file mode 100644 index 1433cf024ad..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_sharednetwork_deployVM.py +++ /dev/null @@ -1,2573 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -"""Component tests for Shared Network functionality with Nuage VSP SDN plugin: -Deploying Virtual Machines using impersonation -(passing account and domainId parameters) -""" -# Import Local Modules -from marvin.lib.utils import cleanup_resources -from marvin.lib.base import (Account, - Domain, - User, - VirtualMachine, - Network, - NetworkOffering) -from marvin.cloudstackException import CloudstackAclException -from nuageTestCase import nuageTestCase -# Import System modules -from nose.plugins.attrib import attr -import random -import string - - -class TestNuageSharedNetworkDeployVm(nuageTestCase): - @classmethod - def setUpClass(cls): - """ - Create the following domain tree and accounts that are required for - executing Nuage VSP SDN plugin test cases for shared networks: - Under ROOT - create domain D1 - Under domain D1 - Create two subdomains D11 and D12 - Under each of the domains - create one admin user and couple of - regular users. - Create shared network with the following scope: - 1. Network with scope="all" - 2. Network with scope="domain" with no subdomain access - 3. Network with scope="domain" with subdomain access - 4. Network with scope="account" - """ - - super(TestNuageSharedNetworkDeployVm, cls).setUpClass() - cls.sharednetworkdata = cls.test_data["acl"] - cls.nuagenetworkdata = cls.test_data["nuagevsp"] - - cls.domain_1 = None - cls.domain_2 = None - - try: - # backup default apikey and secretkey - cls.default_apikey = cls.api_client.connection.apiKey - cls.default_secretkey = cls.api_client.connection.securityKey - - # Create domains - cls.domain_1 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain1"] - ) - cls.domain_11 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain11"], - parentdomainid=cls.domain_1.id - ) - cls.domain_111 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain111"], - parentdomainid=cls.domain_11.id, - ) - cls.domain_12 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain12"], - parentdomainid=cls.domain_1.id - ) - cls.domain_2 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain2"] - ) - # Create 1 admin account and 2 user accounts for doamin_1 - cls.account_d1 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1"], - admin=True, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1) - cls.user_d1_apikey = user.apikey - cls.user_d1_secretkey = user.secretkey - - cls.account_d1a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1A"], - admin=False, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) - cls.user_d1a_apikey = user.apikey - cls.user_d1a_secretkey = user.secretkey - - cls.account_d1b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1B"], - admin=False, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) - cls.user_d1b_apikey = user.apikey - cls.user_d1b_secretkey = user.secretkey - - # Create 1 admin and 2 user accounts for doamin_11 - cls.account_d11 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11"], - admin=True, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11) - cls.user_d11_apikey = user.apikey - cls.user_d11_secretkey = user.secretkey - - cls.account_d11a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11A"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) - cls.user_d11a_apikey = user.apikey - cls.user_d11a_secretkey = user.secretkey - - cls.account_d11b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11B"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) - cls.user_d11b_apikey = user.apikey - cls.user_d11b_secretkey = user.secretkey - - # Create 2 user accounts and 1 admin account for doamin_111 - - cls.account_d111 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD111"], - admin=True, - domainid=cls.domain_111.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d111) - cls.user_d111_apikey = user.apikey - cls.user_d111_secretkey = user.secretkey - - cls.account_d111a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD111A"], - admin=False, - domainid=cls.domain_111.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d111a) - cls.user_d111a_apikey = user.apikey - cls.user_d111a_secretkey = user.secretkey - - cls.account_d111b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD111B"], - admin=False, - domainid=cls.domain_111.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d111b) - cls.user_d111b_apikey = user.apikey - cls.user_d111b_secretkey = user.secretkey - - # Create 2 user accounts for doamin_12 - cls.account_d12a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12A"], - admin=False, - domainid=cls.domain_12.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) - cls.user_d12a_apikey = user.apikey - cls.user_d12a_secretkey = user.secretkey - - cls.account_d12b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12B"], - admin=False, - domainid=cls.domain_12.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) - cls.user_d12b_apikey = user.apikey - cls.user_d12b_secretkey = user.secretkey - - # Create 1 user account for domain_2 - - cls.account_d2a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD2"], - admin=False, - domainid=cls.domain_2.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d2a) - cls.user_d2a_apikey = user.apikey - cls.user_d2a_secretkey = user.secretkey - - # Create 1 user account and admin account in "ROOT" domain - - cls.account_roota = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=False, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_roota) - cls.user_roota_apikey = user.apikey - cls.user_roota_secretkey = user.secretkey - - cls.account_root = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=True, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_root) - cls.user_root_apikey = user.apikey - cls.user_root_secretkey = user.secretkey - - # service offering is already created in Nuagetestcase - cls.sharednetworkdata['mode'] = cls.zone.networktype - - # As admin user , create shared network with scope "all", "domain" - # with subdomain access , "domain" without subdomain access and - # "account" - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - - cls.test_data["nuagevsp"][ - "shared_nuage_network_offering"]["serviceProviderList"]\ - .update({"UserData": 'VirtualRouter'}) - cls.test_data["nuagevsp"]["shared_nuage_network_offering"][ - "supportedservices"] = 'Dhcp,Connectivity,UserData' - for key, value in cls.test_data["nuagevsp"][ - "shared_nuage_network_offering"]["serviceProviderList"]\ - .iteritems(): - cls.debug("elements are %s and value is %s" % (key, value)) - - cls.shared_network_offering = NetworkOffering.create( - cls.api_client, - cls.test_data["nuagevsp"]["shared_nuage_network_offering"], - conservemode=False - ) - # Enable Network offering - cls.shared_network_offering.update(cls.api_client, state='Enabled') - cls.shared_network_offering_id = cls.shared_network_offering.id - - cls.shared_network_all = Network.create( - cls.api_client, - cls.test_data["nuagevsp"]["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id - ) - - cls.shared_network_domain_d11 = Network.create( - cls.api_client, - cls.test_data["nuagevsp"][ - "network_domain_with_no_subdomain_access"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=False - ) - - cls.shared_network_domain_with_subdomain_d11 = Network.create( - cls.api_client, - cls.test_data["nuagevsp"][ - "network_domain_with_subdomain_access"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=True - ) - - cls.shared_network_account_d111a = Network.create( - cls.api_client, - cls.test_data["nuagevsp"]["network_account"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_111.id, - accountid=cls.account_d111a.user[0].username - ) - cls.vmdata = {"name": "test", - "displayname": "test" - } - - cls._cleanup = [ - cls.account_root, - cls.account_roota, - cls.shared_network_all, - cls.shared_network_offering, - cls.service_offering, - ] - user_data = ''.join(random.choice( - string.ascii_uppercase + string.digits) for x in range(2500)) - cls.vmdata["userdata"] = user_data - except Exception as e: - cls.domain_1.delete(cls.api_client, cleanup="true") - cls.domain_2.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - raise Exception( - "Failed to create the setup required to execute the test " - "cases: %s" % e) - - return - - @classmethod - def tearDownClass(cls): - - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cls.domain_1.delete(cls.api_client, cleanup="true") - cls.domain_2.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - return - - def setUp(self): - self.api_client = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - - def tearDown(self): - # restore back default apikey and secretkey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - return - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=all - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_domainuser(self): - """Validate that ROOT admin is able to deploy a VM for other users in a - shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1a.name and - vm.domainid == self.account_d1a.domainid, - True, - "ROOT admin is not able to deploy a VM for other users in a " - "shared network with scope=all") - subnet_id = self.get_subnet_id(self.shared_network_all.id, - self.nuagenetworkdata["network_all"][ - "gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_domainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for a domain admin - users in a shared network with scope=all - """ - - # Deploy VM for an admin user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1.name and - vm.domainid == self.account_d1.domainid, - True, - "ROOT admin is not able to deploy a VM " - "for a domain admin users in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d1.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_subdomainuser(self): - """Validate that ROOT admin is able to deploy a VM for any user in a - subdomain in a shared network with scope=all - """ - - # Deploy VM as user in a subdomain under ROOT - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "ROOT admin is not able to deploy a VM" - " for any user in a subdomain in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_subdomainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for admin user in a - domain in a shared network with scope=all - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "ROOT admin is not able to deploy a VM for admin user in a domain " - "in a shared network with scope=all") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_all_ROOTuser(self): - """Validate that ROOT admin is able to deploy a VM for user in ROOT - domain in a shared network with scope=all - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-all-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-all-root-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_roota, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_roota.name and - vm.domainid == self.account_roota.domainid, - True, - "ROOT admin is not able to deploy a VM for user in ROOT domain in " - "a shared network with scope=all") - self.verify_vsd_shared_network( - self.account_roota.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_roota.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=Domain and no subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomccess_domainuser(self): - """Validate that ROOT admin is able to deploy a VM for domain user in - a shared network with scope=domain with no subdomain access - """ - - # Deploy VM as user in a domain that has shared network with no - # subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "ROOT admin is not able to deploy a VM for domain user in a " - "shared network with scope=domain with no subdomain access") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomccess_domainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for domain admin - user in a shared network with scope=domain with no subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "ROOT admin is not able to deploy VM for domain admin user in " - "shared network with scope=domain with no subdomain access") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomccess_subdomainuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for sub domain - user in a shared network with scope=domain with no subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111a.name, - domainid=self.account_d111a.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for sub domain user in a " - "shared network with scope=domain with no subdomain access") - - except Exception as e: - self.debug( - "When a user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for sub domain user in a shared network with " - "scope=domain with no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomccess_subdomainadmin( - self): - """Validate that ROOT admin is NOT able to deploy a VM for sub domain - admin user in a shared network with scope=domain with no subdomain - access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for sub domain admin user in " - "a shared network with scope=domain with no subdomain access") - except Exception as e: - self.debug( - "When a admin user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for sub domain admin user in a shared " - "network with scope=domain with no subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomccess_parentdomainuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain user in a shared network with scope=domain with no subdomain - access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - " ROOT admin is able to deploy a VM for parent domain user in " - "a shared network with scope=domain with no subdomain access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries " - "to deploy a VM for parent domain user in a shared " - "network with scope=domain with no subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomccess_parentdomadmin( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain admin user in a shared network with scope=domain with no - subdomain access - """ - - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for parent domain admin " - "user in a shared network with scope=domain with no subdomain " - "access") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain " - "admin user in a shared network with scope=domain with no " - "subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_nosubdomccess_ROOTuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain admin user in a shared network with scope=domain with no - subdomain access - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for parent domain admin " - "user in a shared network with scope=domain with no subdomain " - "access") - except Exception as e: - self.debug( - "When a regular user from ROOT domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain admin user in a shared " - "network with scope=domain with no subdomain access") - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=Domain and with subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_domainuser(self): - """Validate that ROOT admin is able to deploy a VM for domain user in a - shared network with scope=domain with subdomain access - """ - - # Deploy VM as user in a domain that has shared network with subdomain - # access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "ROOT admin is NOT able to deploy a VM for domain user in a " - "shared network with scope=domain with subdomain access") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_domainadminuser( - self): - """Validate that ROOT admin is able to deploy a VM for domain admin - user in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "ROOT admin is not able to deploy a VM for domain admin user in a " - "shared network with scope=domain with subdomain access") - - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_subdomainuser( - self): - """Validate that ROOT admin is able to deploy a VM for subdomain user - in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "ROOT admin is not able to deploy a VM for subdomain user in a " - "shared network with scope=domain with subdomain access") - - self.verify_vsd_shared_network( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_subdomainadmin( - self): - """Validate that ROOT admin is able to deploy a VM for subdomain admin - user in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111.name and - vm.domainid == self.account_d111.domainid, - True, - "ROOT admin is not able to deploy VM for subdomain admin user in " - "a shared network with scope=domain subdomain access") - - self.verify_vsd_shared_network( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_parentdomainuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain user in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - "ROOT admin is NOT able to deploy a VM for parent domain user " - "in a shared network with scope=domain with subdomain access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain user in a shared network " - "with scope=domain with subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_parentdomainadmin( - self): - """Validate that ROOT admin is NOT able to deploy a VM for parent - domain admin user in a shared network with scope=domain with subdomain - access - """ - - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for parent domain admin user " - "in a shared network with scope=domain subdomain access ") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for parent domain admin user in a shared " - "network with scope=domain with subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_subdomaccess_ROOTuser(self): - """Validate that ROOT admin is NOT able to deploy a VM for user in ROOT - domain in a shared network with scope=domain with subdomain access - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_roota_apikey - self.api_client.connection.securityKey = self.user_roota_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "ROOT admin is able to deploy a VM for user in ROOT domain in " - "a shared network with scope=domain with subdomain access") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for user in ROOT domain in a shared network " - "with scope=domain with subdomain access") - - # Test cases relating to deploying Virtual Machine as ROOT admin for other - # users in shared network with scope=account - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_domainuser(self): - """ - Valiate that ROOT admin is NOT able to deploy a VM for user in the same - domain but in a different account in a shared network with - scope=account - """ - - # Deploy VM as user in a domain under the same domain but different - # account from the account that has a shared network with scope=account - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111B"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111B"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111b.name, - domainid=self.account_d111b.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for user in the same domain " - "but in different account in shared network scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys " - "a VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for user in the same domain but in a " - "different account in a shared network with scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_domainadminuser( - self): - """Validate that ROOT admin is NOT able to deploy a VM for admin user - in the same domain but in a different account in a shared network with - scope=account - """ - - # Deploy VM as admin user for a domain that has an account with shared - # network with scope=account - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for admin user in same " - "domain but in different account in shared network with " - "scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys a " - "VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for admin user in the same domain but in a " - "different account in a shared network with scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_user(self): - """Validate that ROOT admin is able to deploy a VM for regular user in - a shared network with scope=account - """ - - # Deploy VM as account with shared network with scope=account - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-root-admin" - - vm = self.create_VM(self.shared_network_account_d111a, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "ROOT admin is not able to deploy a VM for regular user in a " - "shared network with scope=account") - - self.verify_vsd_shared_network(self.account_d111a.domainid, - self.shared_network_account_d111a, - gateway=self.nuagenetworkdata[ - "network_account"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_account_d111a.id, - self.nuagenetworkdata[ - "network_account"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d111a.domainid, - self.shared_network_account_d111a, vm, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_differentdomain( - self): - """Validate that ROOT admin is NOT able to deploy a VM for a admin user - in a shared network with scope=account which the admin user does not - have access to - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD2A"]["name"] + \ - "-shared-scope-account-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD2A"]["displayname"] + \ - "-shared-scope-account-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for admin user in shared " - "network scope=account which admin user does not have access") - except Exception as e: - self.debug("account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for a admin user in a shared network with " - "scope=account which the admin user does not have access " - "to ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_admin_scope_account_ROOTuser(self): - """Validate that ROOT admin is NOT able to deploy a VM for a user in - ROOT domain in a shared network with scope=account which the user does - not have access to - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-account-root-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-account-root-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "ROOT admin is able to deploy VM for a user in ROOT domain in " - "shared network scope=account which user does not have access") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when ROOT admin tries to " - "deploy a VM for a user in ROOT domain in a shared " - "network with scope=account which the user does not have " - "access to ") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=all - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_domainuser( - self): - """Validate that Domain admin is able to deploy a VM for a domain user - in a shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1a.name and - vm.domainid == self.account_d1a.domainid, - True, - "Domain admin is not able to deploy a VM for a domain user in a " - "shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d1a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_all.id, - self.nuagenetworkdata["network_all"][ - "gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_domainadmin( - self): - """Validate that Domain admin is able to deploy a VM for a domain admin - user in a shared network with scope=all - """ - - # Deploy VM for an admin user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-all-domain-admin" - - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d1, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d1.name and - vm.domainid == self.account_d1.domainid, - True, - "Domain admin is not able to deploy a VM for a domain admin user " - "in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d1.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d1.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_subdomainuser( - self): - """Validate that Domain admin is able to deploy a VM for a sub domain - user in a shared network with scope=all - """ - - # Deploy VM as user in a subdomain under ROOT - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11a, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "Domain admin is not able to deploy a VM for a sub domain user in " - "a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_subdomainadmin( - self): - """Validate that Domain admin is able to deploy a VM for a sub domain - admin user in a shared network with scope=all - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-all-domain-admin" - vm = self.create_VM(self.shared_network_all, testdata=self.vmdata, - account=self.account_d11, cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "Domain admin is not able to deploy a VM for a sub domain admin " - "user in a shared network with scope=all") - - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_all, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_ROOTuser(self): - """Validate that Domain admin is NOT able to deploy a VM for user in - ROOT domain in a shared network with scope=all - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-all" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-all" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is NOT able to deploy a VM for user in ROOT " - "domain in a shared network with scope=all") - except Exception as e: - self.debug( - "When a Domain admin user deploys a VM for ROOT user in a " - "shared network with scope=all %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin is NOT " - "able to deploy a VM for user in ROOT domain in a shared " - "network with scope=all") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_all_crossdomuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - other domain in a shared network with scope=all - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-all" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-all" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "Domain admin user is able to Deploy VM for a domain user he " - "does not have access to in a shared network with " - "scope=domain with no subdomain access ") - except Exception as e: - self.debug( - "When a Domain admin user deploys a VM for a domain user he " - "does not have access to in a shared network with " - "scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error mesage validation failed when Domain admin user " - "tries to Deploy VM for a domain user he does not have " - "access to in a shared network with scope=domain with no " - "subdomain access ") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=Domain and no subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_domuser( - self): - """Validate that Domain admin is able to deploy a VM for domain user in - a shared network with scope=Domain and no subdomain access - """ - - # Deploy VM as user in a domain that has shared network with no - # subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "Domain admin is not able to deploy a VM for domain user in a " - "shared network with scope=Domain and no subdomain access") - - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_domadmin( - self): - """Validate that Domain admin is able to deploy a VM for domain admin - user in a shared network with scope=Domain and no subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - vm = self.create_VM(self.shared_network_domain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "Admin User in a domain that has a shared network with no " - "subdomain access failed to Deploy VM in a shared network with " - "scope=domain with no subdomain access") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11.domainid, - self.shared_network_domain_d11, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_subdomain( - self): - """Validate that Domain admin is NOT able to deploy a VM for sub domain - user in a shared network with scope=Domain and no subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111a.name, - domainid=self.account_d111a.domainid - ) - self.fail( - "Domain admin is able to deploy VM for sub domain user in a " - "shared network with scope=Domain and no subdomain access") - except Exception as e: - self.debug( - "When a user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for sub domain user in a shared network " - "with scope=Domain and no subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_subdomadm( - self): - """Validate that Domain admin is NOT able to deploy a VM for sub domain - admin user in a shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for sub domain admin " - "user in a shared network with scope=Domain no subdomain " - "access") - except Exception as e: - self.debug( - "When a admin user from a subdomain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for sub domain admin user in a shared " - "network with scope=Domain and no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_parentdom( - self): - """Validate that Domain admin is NOT able to deploy a VM for parent - domain user in a shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for parent domain user " - "in a shared network with scope=Domain and no subdomain " - "access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with no subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for parent domain user in a shared " - "network with scope=Domain and no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_pardomadm( - self): - """Validate that Domain admin is NOT able to deploy VM for parent - domain admin user in shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with no subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "Domain admin is able to deploy VM for parent domain admin " - "user in a shared network with scope=Domain no subdomain " - "access") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for parent domain admin user in a shared " - "network with scope=Domain and no subdomain access ") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_nosubdomaccess_ROOTuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - ROOT domain in a shared network with scope=Domain and no subdomain - access - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-nosubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in ROOT domain " - "in a shared network with scope=Domain and no subdomain " - "access") - except Exception as e: - self.debug( - "When a regular user from ROOT domain deploys a VM in a " - "shared network with scope=domain with no subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in ROOT domain in a shared " - "network with scope=Domain and no subdomain access") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=Domain and with subdomain access - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_domainuser( - self): - """Validate that Domain admin is able to deploy a VM for regular user - in domain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as user in a domain that has shared network with subdomain - # access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11a.name and - vm.domainid == self.account_d11a.domainid, - True, - "Domain admin is not able to deploy VM for regular user in domain " - "in a shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_domainadmin( - self): - """Validate that Domain admin is able to deploy a VM for admin user in - domain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as an admin user in a domain that has shared network with - # subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d11, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d11.name and - vm.domainid == self.account_d11.domainid, - True, - "Domain admin is not able to deploy a VM for admin user in " - "domain in a shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_subdomain( - self): - """Validate that Domain admin is able to deploy a VM for regular user - in subdomain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as user in a subdomain under a domain that has shared - # network with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "Domain admin not able to deploy VM for regular user in subdomain " - "in shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111a.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_subdomadm( - self): - """Validate that Domain admin is able to deploy a VM for admin user in - subdomain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as an admin user in a subdomain under a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_domain_with_subdomain_d11, - testdata=self.vmdata, account=self.account_d111, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111.name and - vm.domainid == self.account_d111.domainid, - True, - "Domain admin is not able to deploy VM for admin user in " - "subdomain in a shared network with scope=Domain subdomain access") - self.verify_vsd_shared_network( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d111.domainid, - self.shared_network_domain_with_subdomain_d11, - vm, sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_parentdom( - self): - """Validate that Domain admin NOT able to deploy VM for regular user in - parent domain in shared network with scope=Domain subdomain access - """ - - # Deploy VM as user in parentdomain of a domain that has shared network - # with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1a.name, - domainid=self.account_d1a.domainid - ) - self.fail( - " Domain admin is able to deploy VM for regular user in " - "parent domain in a shared network with scope=Domain " - "subdomain access") - except Exception as e: - self.debug( - "When a user from parent domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for regular user in parent domain in a " - "shared network with scope=Domain and subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_pardomadmin( - self): - """Validate that Domain admin is NOT able to deploy VM for admin user - in parent domain in shared network with scope=Domain subdomain access - """ - - # Deploy VM as an admin user in parentdomain of a domain that has - # shared network with subdomain access - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD1"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD1"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_d1.name, - domainid=self.account_d1.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for admin user in parent " - "domain in a shared network with scope=Domain subdomain " - "access") - except Exception as e: - self.debug( - "When an admin user from parent domain deploys a VM in a " - "shared network with scope=domain with subdomain access %s" - % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NOT_AVAILABLE_IN_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for admin user in parent domain in a " - "shared network with scope=Domain and subdomain access") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_subdomaccess_ROOTuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - ROOT domain in a shared network with scope=Domain and subdomain access - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_domain_with_subdomain_d11.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in ROOT domain " - "in a shared network with scope=Domain and subdomain access") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=domain with subdomain access %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in ROOT domain in a shared " - "network with scope=Domain and subdomain access") - - # Test cases relating to deploying Virtual Machine as Domain admin for - # other users in shared network with scope=account - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_domainuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for user in - the same domain but belonging to a different account in a shared - network with scope=account - """ - - # Deploy VM as user in a domain under the same domain but different - # account from the acount that has a shared network with scope=account - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111B"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111B"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111b.name, - domainid=self.account_d111b.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in the same " - "domain but belonging to a different account in a shared " - "network with scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys " - "a VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in the same domain but belonging " - "to a different account in a shared network with " - "scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_domainadm( - self): - """Validate that Domain admin is NOT able to deploy a VM for an admin - user in the same domain but belonging to a different account in a - shared network with scope=account - """ - - # Deploy VM as admin user for a domain that has an account with shared - # network with scope=account - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d111.name, - domainid=self.account_d111.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for user in the same " - "domain but belonging to a different account in a shared " - "network with scope=account") - except Exception as e: - self.debug( - "When a user from same domain but different account deploys a " - "VM in a shared network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.UNABLE_TO_USE_NETWORK): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for user in the same domain but belonging " - "to a different account in a shared network with " - "scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_user(self): - """Validate that Domain admin is able to deploy a VM for an regular - user in a shared network with scope=account - """ - - # Deploy VM as account with shared network with scope=account - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD111A"]["name"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD111A"]["displayname"] + \ - "-shared-scope-domain-withsubdomainaccess-domain-admin" - - vm = self.create_VM(self.shared_network_account_d111a, - testdata=self.vmdata, account=self.account_d111a, - cleanup=False) - - self.assertEqual( - vm.state == "Running" and vm.account == self.account_d111a.name and - vm.domainid == self.account_d111a.domainid, - True, - "Domain admin is not able to deploy a VM for an regular user in " - "a shared network with scope=account") - self.verify_vsd_shared_network(self.account_d111a.domainid, - self.shared_network_account_d111a, - gateway=self.nuagenetworkdata[ - "network_account"]["gateway"]) - subnet_id = self.get_subnet_id(self.shared_network_account_d111a.id, - self.nuagenetworkdata[ - "network_account"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d111a.domainid, - self.shared_network_account_d111a, vm, - sharedsubnetid=subnet_id) - - # Deleting the VM - vm.delete(self.api_client, expunge=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_diffdom( - self): - """Validate that Domain admin is NOT able to deploy a VM for an - regular user from a differnt domain in a shared network with - scope=account - """ - - # Deploy VM as an admin user in a subdomain under ROOT - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD2A"]["name"] + \ - "-shared-scope-account-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD2A"]["displayname"] + \ - "-shared-scope-account-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "Domain admin is able able to deploy a VM for an regular " - "user from a differnt domain in a shared network with " - "scope=account") - except Exception as e: - self.debug( - "When a user from different domain deploys a VM in a shared " - "network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for an regular user from a differnt " - "domain in a shared network with scope=account") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_domainadmin_scope_account_ROOTuser( - self): - """Validate that Domain admin is NOT able to deploy a VM for an regular - user in ROOT domain in a shared network with scope=account - """ - - # Deploy VM as user in ROOT domain - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmROOTA"]["name"] + \ - "-shared-scope-account-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmROOTA"]["displayname"] + \ - "-shared-scope-account-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_account_d111a.id, - accountid=self.account_roota.name, - domainid=self.account_roota.domainid - ) - self.fail( - "Domain admin is able to deploy a VM for an regular user in " - "ROOT domain in a shared network with scope=account") - except Exception as e: - self.debug( - "When a user from ROOT domain deploys a VM in a shared " - "network with scope=account %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_DOMAIN): - self.fail( - "Error message validation failed when Domain admin tries " - "to deploy a VM for an regular user in ROOT domain in a " - "shared network with scope=account") - - # Test cases relating to deploying Virtual Machine as Regular user for - # other users in shared network with scope=all - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_regularuser_scope_all_anotheruser( - self): - """Validate that regular user is NOT able to deploy a VM for - another user in the same domain in a shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_d12a.name, - domainid=self.account_d12a.domainid - ) - self.fail( - "Regular user is allowed to deploy a VM for another user in " - "the same domain in a shared network with scope=all") - except Exception as e: - self.debug( - "When a regular user deploys a VM for another user in the " - "same domain in a shared network with scope=all %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_ACCOUNT): - self.fail( - "Error message validation failed when Regular user tries " - "to deploy a VM for another user in the same domain in a " - "shared network with scope=all") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_deployVM_in_sharedNetwork_as_regularuser_scope_all_crossdomain( - self): - """Validate that regular user is NOT able to deploy a VM for - another user in a different domain in a shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.vmdata["name"] = \ - self.sharednetworkdata["vmD11A"]["name"] + \ - "-shared-scope-all-domain-admin" - self.vmdata["displayname"] = \ - self.sharednetworkdata["vmD11A"]["displayname"] + \ - "-shared-scope-all-domain-admin" - try: - VirtualMachine.create( - self.api_client, - self.vmdata, - zoneid=self.zone.id, - serviceofferingid=self.service_offering.id, - templateid=self.template.id, - networkids=self.shared_network_all.id, - accountid=self.account_d2a.name, - domainid=self.account_d2a.domainid - ) - self.fail( - "Regular user is allowed to deploy a VM for another user in " - "the same domain in a shared network with scope=all") - except Exception as e: - self.debug( - "When a regular user deploys a VM for another user in the " - "same domain in a shared network with scope=all %s" % e) - if not CloudstackAclException.verifyMsginException( - e, - CloudstackAclException.NO_PERMISSION_TO_OPERATE_ACCOUNT): - self.fail( - "Error message validation failed when Regular user tries " - "to deploy a VM for another user in the same domain in a " - "shared network with scope=all") - - @staticmethod - def generateKeysForUser(api_client, account): - user = User.list( - api_client, - account=account.name, - domainid=account.domainid - )[0] - - return (User.registerUserKeys( - api_client, - user.id - )) diff --git a/test/integration/plugins/nuagevsp/test_nuage_sharednetwork_vpc_vm_monitor.py b/test/integration/plugins/nuagevsp/test_nuage_sharednetwork_vpc_vm_monitor.py deleted file mode 100644 index d8ca41ff100..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_sharednetwork_vpc_vm_monitor.py +++ /dev/null @@ -1,704 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -"""Component tests for Shared Network functionality with Nuage VSP SDN plugin: -VPC Virtual Machine Monitoring -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.utils import cleanup_resources, validateList -from marvin.lib.base import (VPC, - Account, - Domain, - User, - VirtualMachine, - Network, - NetworkOffering, - VpcOffering) -from marvin.lib.common import list_virtual_machines -from marvin.codes import PASS -# Import System modules -from nose.plugins.attrib import attr - - -class TestNuageSharedNetworkVpcVmMonitor(nuageTestCase): - @classmethod - def setUpClass(cls): - """ - Create the following domain tree and accounts that are required for - executing Nuage VSP SDN plugin test cases for shared networks: - Under ROOT - create domain D1 - Under domain D1 - Create two subdomains D11 and D12 - Under each of the domains - create one admin user and couple of - regular users. - Create shared network with the following scope: - 1. Network with scope="all" - 2. Network with scope="domain" with no subdomain access - 3. Network with scope="domain" with subdomain access - 4. Network with scope="account" - """ - - super(TestNuageSharedNetworkVpcVmMonitor, cls).setUpClass() - cls.sharednetworkdata = cls.test_data["acl"] - cls.nuagenetworkdata = cls.test_data["nuagevsp"] - - cls.domain_1 = None - cls.domain_2 = None - - try: - # backup default apikey and secretkey - cls.default_apikey = cls.api_client.connection.apiKey - cls.default_secretkey = cls.api_client.connection.securityKey - - # Create domains - cls.domain_1 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain1"] - ) - cls.domain_11 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain11"], - parentdomainid=cls.domain_1.id - ) - cls.domain_12 = Domain.create( - cls.api_client, - cls.sharednetworkdata["domain12"], - parentdomainid=cls.domain_1.id - ) - # Create 1 admin account and 2 user accounts for doamin_1 - cls.account_d1 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1"], - admin=True, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1) - cls.user_d1_apikey = user.apikey - cls.user_d1_secretkey = user.secretkey - - cls.account_d1a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1A"], - admin=False, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) - cls.user_d1a_apikey = user.apikey - cls.user_d1a_secretkey = user.secretkey - - cls.account_d1b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD1B"], - admin=False, - domainid=cls.domain_1.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d1b) - cls.user_d1b_apikey = user.apikey - cls.user_d1b_secretkey = user.secretkey - - # Create 1 admin and 2 user accounts for doamin_11 - cls.account_d11 = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11"], - admin=True, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11) - cls.user_d11_apikey = user.apikey - cls.user_d11_secretkey = user.secretkey - - cls.account_d11a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11A"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) - cls.user_d11a_apikey = user.apikey - cls.user_d11a_secretkey = user.secretkey - - cls.account_d11b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD11B"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11b) - cls.user_d11b_apikey = user.apikey - cls.user_d11b_secretkey = user.secretkey - - # Create 2 user accounts for doamin_12 - cls.account_d12a = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12A"], - admin=False, - domainid=cls.domain_12.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d12a) - cls.user_d12a_apikey = user.apikey - cls.user_d12a_secretkey = user.secretkey - - cls.account_d12b = Account.create( - cls.api_client, - cls.sharednetworkdata["accountD12B"], - admin=False, - domainid=cls.domain_12.id - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_d12b) - cls.user_d12b_apikey = user.apikey - cls.user_d12b_secretkey = user.secretkey - - # Create 1 user account and admin account in "ROOT" domain - - cls.account_roota = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=False, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_roota) - cls.user_roota_apikey = user.apikey - cls.user_roota_secretkey = user.secretkey - - cls.account_root = Account.create( - cls.api_client, - cls.sharednetworkdata["accountROOTA"], - admin=True, - ) - - user = cls.generateKeysForUser(cls.api_client, cls.account_root) - cls.user_root_apikey = user.apikey - cls.user_root_secretkey = user.secretkey - - # service offering is already created in Nuagetestcase - cls.sharednetworkdata['mode'] = cls.zone.networktype - - # As admin user , create shared network with scope "all", "domain" - # with subdomain access , "domain" without subdomain access and - # "account" - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - - cls.shared_network_offering = NetworkOffering.create( - cls.api_client, - cls.test_data["nuagevsp"]["shared_nuage_network_offering"], - conservemode=False - ) - # Enable Network offering - cls.shared_network_offering.update(cls.api_client, state='Enabled') - cls.shared_network_offering_id = cls.shared_network_offering.id - - cls.shared_network_all = Network.create( - cls.api_client, - cls.test_data["nuagevsp"]["network_all"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id - ) - - cls.shared_network_domain_d11 = Network.create( - cls.api_client, - cls.test_data["nuagevsp"][ - "network_domain_with_no_subdomain_access"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=False - ) - - cls.shared_network_domain_with_subdomain_d11 = Network.create( - cls.api_client, - cls.test_data["nuagevsp"][ - "network_domain_with_subdomain_access"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - subdomainaccess=True - ) - - cls.shared_network_account_d111a = Network.create( - cls.api_client, - cls.test_data["nuagevsp"]["network_account"], - networkofferingid=cls.shared_network_offering_id, - zoneid=cls.zone.id, - domainid=cls.domain_11.id, - accountid=cls.account_d11a.user[0].username - ) - - cls.debug("Creating Nuage VSP VPC offering...") - cls.vpc_offering = VpcOffering.create(cls.api_client, - cls.test_data["nuagevsp"][ - "vpc_offering"] - ) - - cls.vpc_offering.update(cls.api_client, state="Enabled") - - # Creating a VPC - cls.debug("Creating a VPC with Nuage VSP VPC offering...") - cls.test_data["vpc"]["cidr"] = '10.1.0.0/16' - cls.vpcd11 = VPC.create(cls.api_client, - cls.test_data["vpc"], - vpcofferingid=cls.vpc_offering.id, - zoneid=cls.zone.id, - account=cls.account_d11a.name, - domainid=cls.account_d11a.domainid - ) - - # Creating a network offering - cls.debug("Creating Nuage Vsp VPC Network offering...") - cls.network_offering = NetworkOffering.create( - cls.api_client, - cls.test_data["nuagevsp"]["vpc_network_offering"], - conservemode=False - ) - cls.network_offering.update(cls.api_client, state="Enabled") - - # Creating two VPC network in the VPC - cls.debug( - "Creating a VPC network with Nuage Vsp VPC Network " - "offering...") - cls.test_data["network"]["netmask"] = "255.255.255.0" - cls.vpc_network1 = Network.create( - cls.api_client, - cls.test_data["network"], - accountid=cls.account_d11a.name, - domainid=cls.account_d11a.domainid, - networkofferingid=cls.network_offering.id, - zoneid=cls.zone.id, - gateway="10.1.1.1", - vpcid=cls.vpcd11.id - ) - - cls.debug( - "Creating a VPC Tier2 network with Nuage Vsp VPC Network " - "offering...") - cls.test_data["network"]["name"] = "Tier2" - cls.vpc_network2 = Network.create( - cls.api_client, - cls.test_data["network"], - accountid=cls.account_d11a.name, - domainid=cls.account_d11a.domainid, - networkofferingid=cls.network_offering.id, - zoneid=cls.zone.id, - gateway="10.1.2.1", - vpcid=cls.vpcd11.id - ) - - cls.vmdata = {"name": "vmvpc1", - "displayname": "vmvpc1" - } - - # Deploying a VM in the VPC network - cls.vmvpc1 = VirtualMachine.create( - cls.api_client, - cls.vmdata, - zoneid=cls.zone.id, - serviceofferingid=cls.service_offering.id, - templateid=cls.template.id, - networkids=cls.vpc_network1.id, - accountid=cls.account_d11a.name, - domainid=cls.account_d11a.domainid - ) - - cls.vmdata = {"name": "vmvpc2", - "displayname": "vmvpc2" - } - - cls.vmvpc2 = VirtualMachine.create( - cls.api_client, - cls.vmdata, - zoneid=cls.zone.id, - serviceofferingid=cls.service_offering.id, - templateid=cls.template.id, - networkids=cls.vpc_network2.id, - accountid=cls.account_d11a.name, - domainid=cls.account_d11a.domainid - ) - - cls._cleanup = [ - cls.account_root, - cls.account_roota, - cls.shared_network_all, - cls.shared_network_offering, - cls.network_offering, - cls.vpc_offering, - cls.service_offering, - ] - except Exception as e: - cls.domain_1.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - raise Exception( - "Failed to create the setup required to execute the test " - "cases: %s" % e) - - return - - @classmethod - def tearDownClass(cls): - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - cls.domain_1.delete(cls.api_client, cleanup="true") - cleanup_resources(cls.api_client, cls._cleanup) - return - - def setUp(self): - self.api_client = self.testClient.getApiClient() - self.dbclient = self.testClient.getDbConnection() - - def tearDown(self): - # restore back default apikey and secretkey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - return - - def verify_nic(self, network, vm): - """verify required nic is present in the VM""" - self.debug( - "Going to verify if %s Network nic is present in virtual machine " - "%s" % (network.name, vm.id)) - vm_list = list_virtual_machines(self.api_client, id=vm.id) - vm_list_validation_result = validateList(vm_list) - self.assertEqual(vm_list_validation_result[0], PASS, - "vm list validation failed due to %s" % - vm_list_validation_result[2]) - self.debug("virtual machine nics: %s" % vm_list[0].nic) - # filter nic of virtual machine based on Network - nics = [x for x in vm_list[0].nic if x.networkid == network.id] - self.debug("Filtered nics list: %s:" % nics) - if len(nics) == 1: - return True - else: - return False - - # Test cases relating to MonitorVM through SharedNetwork - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_addNic_in_sharedNetwork_scope_all_as_domainuser(self): - """Validate that Normal user in the same domain able to add NIC in a - shared network with scope=all - """ - - # Deploy VM for a user in a domain under ROOT as admin - - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.debug("Adding NIC of shared Network as user d11a") - - self.vmvpc1.add_nic(self.api_client, self.shared_network_all.id) - - if self.verify_nic(self.shared_network_all, self.vmvpc1): - self.debug( - "virtual machine has NIC is SharedNetwork: %s" % - self.shared_network_all.name) - else: - self.fail( - "Expected network %s NIC is not present in the virtual " - "Machine %s" % - (self.shared_network_all.name, self.vmvpc1.id)) - - self.debug("validating Network and VM on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, self.vmvpc1, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_addNic_in_sharedNetwork_scope_all_as_domain_parentAdmin(self): - """Validate that Parent domain admin is able to add a NIC in a shared - network with scope=all - """ - - # Add NIC as D1 user - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.debug("Adding NIC of shared Network as user d1") - - self.vmvpc2.add_nic(self.api_client, self.shared_network_all.id) - - if self.verify_nic(self.shared_network_all, self.vmvpc2): - self.debug( - "virtual machine has NIC is SharedNetwork: %s" % - self.shared_network_all.name) - else: - self.fail( - "Expected network %s NIC is not present in the virtual " - "Machine %s" % - (self.shared_network_all.name, self.vmvpc2.id)) - - self.debug("validating Network and VM on VSD") - self.verify_vsd_shared_network( - self.account_d1.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, self.vmvpc2, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_staticNat_in_VPC_secondNic_sharedNetwork_scope_all(self): - """Validate that User can enable staticNat on VPC NIC where second nic - is in a shared network with scope=all - """ - - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.debug("Enabling StaticNat as user d11a") - public_ip_1 = self.acquire_PublicIPAddress(self.vpc_network1, - self.vpcd11, - account=self.account_d11a) - self.create_StaticNatRule_For_VM(self.vmvpc1, public_ip_1, - self.vpc_network1) - self.validate_PublicIPAddress(public_ip_1, self.vpc_network1, - static_nat=True, vm=self.vmvpc1) - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, self.vmvpc2, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_rebootVM_after_sharedNetwork_nic(self): - """Validate that reboot VM is done successfully without any Error - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - - self.debug("Rebooting VMs as user d1") - - try: - self.vmvpc1.reboot(self.api_client) - self.vmvpc2.reboot(self.api_client) - except Exception as e: - self.fail("Failed to reboot the virtual instances, %s" % e) - - self.debug("validating VM on VSD") - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, self.vmvpc1, - sharedsubnetid=subnet_id) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, self.vmvpc2, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_05_restart_Tier_VPC_Network_sharedNetwork_nic(self): - """Validate that restart Tier Network is done successfully with cleanup - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - - self.debug("Restarting Tier Networks and VPC") - - self.vpc_network1.restart(self.api_client, cleanup=True) - self.vpc_network2.restart(self.api_client, cleanup=True) - self.restart_Vpc(self.vpcd11, cleanup=False) - - self.debug("validating VM on VSD") - subnet_id = self.get_subnet_id( - self.shared_network_all.id, - self.nuagenetworkdata["network_all"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, self.vmvpc1, - sharedsubnetid=subnet_id) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_all, self.vmvpc2, - sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_06_restart_sharedNetwork_scope_all(self): - """Validate that restart Shared Network is done successfully without - any Error - """ - - self.debug("Restarting shared Network with cleanup") - self.shared_network_all.restart(self.api_client, cleanup=True) - - self.debug("validating SharedNetwork on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_all, - gateway=self.nuagenetworkdata["network_all"]["gateway"]) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_07_removeNic_in_sharedNetwork_scope_all_as_domainuser(self): - """Validate that Normal user in the same domain able to remove NIC in a - shared network which is added by Parent Domain Admin - """ - - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - - self.debug("Removing NIC of shared Network as user d11a") - - vm_list = list_virtual_machines(self.api_client, id=self.vmvpc2.id) - vm_list_validation_result = validateList(vm_list) - self.assertEqual(vm_list_validation_result[0], PASS, - "vm list validation failed due to %s" % - vm_list_validation_result[2]) - self.debug("virtual machine nics: %s" % vm_list[0].nic) - for nic in vm_list[0].nic: - if nic.networkid == self.shared_network_all.id: - reqNic = nic - - self.vmvpc2.remove_nic(self.api_client, reqNic.id) - if not self.verify_nic(self.shared_network_all, self.vmvpc2): - self.debug( - "virtual machine has NIC is SharedNetwork: %s" % - self.shared_network_all.name) - else: - self.fail("network %s NIC is present in the virtual Machine %s" % - (self.shared_network_all.name, self.vmvpc2.id)) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_08_removeNic_in_sharedNetwork_scope_all_as_domain_parentAdmin( - self): - """Validate that Parent domain admin is able to remove a NIC which is - added by child domain user - """ - - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - self.debug("Removing NIC od shared Network as user d1") - - vm_list = list_virtual_machines(self.api_client, id=self.vmvpc1.id) - vm_list_validation_result = validateList(vm_list) - self.assertEqual(vm_list_validation_result[0], PASS, - "vm list validation failed due to %s" % - vm_list_validation_result[2]) - self.debug("virtual machine nics: %s" % vm_list[0].nic) - for nic in vm_list[0].nic: - if nic.networkid == self.shared_network_all.id: - reqNic = nic - - self.vmvpc1.remove_nic(self.api_client, reqNic.id) - - if not self.verify_nic(self.shared_network_all, self.vmvpc1): - self.debug( - "virtual machine has mot NIC is SharedNetwork: %s" % - self.shared_network_all.name) - else: - self.fail("network %s NIC is present in the virtual Machine %s" % - (self.shared_network_all.name, self.vmvpc1.id)) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_09_addNic_in_sharedNetwork_scope_domain_as_domainuser(self): - """Validate that Normal user in the same domain able to add NIC in a - shared network with scope=domain without subdomain Access - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.debug("Adding NIC of shared Network as user d11a") - - self.vmvpc1.add_nic(self.api_client, self.shared_network_domain_d11.id) - - if self.verify_nic(self.shared_network_domain_d11, self.vmvpc1): - self.debug( - "virtual machine has NIC is SharedNetwork: %s" % - self.shared_network_domain_d11.name) - else: - self.fail( - "Expected network %s NIC is not present in the virtual " - "Machine %s" % - (self.shared_network_domain_d11.name, self.vmvpc1.id)) - - self.debug("validating Network and VM on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_no_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm(self.account_d11a.domainid, - self.shared_network_domain_d11, - self.vmvpc1, sharedsubnetid=subnet_id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_10_addNic_in_sharedNetwork_scope_domain_subdomain_as_domainuser( - self): - """Validate that Normal user in the same domain able to add NIC in a - shared network with scope=domain with subdomain Access - """ - - # Deploy VM for a user in a domain under ROOT as admin - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - self.debug("Adding NIC of shared Network as user d11a") - - self.vmvpc2.add_nic(self.api_client, - self.shared_network_domain_with_subdomain_d11.id) - - if self.verify_nic(self.shared_network_domain_with_subdomain_d11, - self.vmvpc2): - self.debug( - "virtual machine has NIC is SharedNetwork: %s" % - self.shared_network_domain_with_subdomain_d11.name) - else: - self.fail( - "Expected network %s NIC is not present in the virtual " - "Machine %s" % - (self.shared_network_domain_with_subdomain_d11.name, - self.vmvpc2.id)) - - self.debug("validating Network and VM on VSD") - self.verify_vsd_shared_network( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - gateway=self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - subnet_id = self.get_subnet_id( - self.shared_network_domain_with_subdomain_d11.id, - self.nuagenetworkdata[ - "network_domain_with_subdomain_access"]["gateway"]) - self.verify_vsd_enterprise_vm( - self.account_d11a.domainid, - self.shared_network_domain_with_subdomain_d11, - self.vmvpc2, sharedsubnetid=subnet_id) - - @staticmethod - def generateKeysForUser(api_client, account): - user = User.list( - api_client, - account=account.name, - domainid=account.domainid - )[0] - - return (User.registerUserKeys( - api_client, - user.id - )) diff --git a/test/integration/plugins/nuagevsp/test_nuage_source_nat.py b/test/integration/plugins/nuagevsp/test_nuage_source_nat.py deleted file mode 100644 index b31d5ecaafe..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_source_nat.py +++ /dev/null @@ -1,1461 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Source NAT functionality with Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import (Account, - Network, - VirtualMachine) -# Import System Modules -from nose.plugins.attrib import attr -import copy -import time - - -class TestNuageSourceNat(nuageTestCase): - """Test Source NAT functionality with Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls): - super(TestNuageSourceNat, cls).setUpClass() - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - # verify_vsd_SourceNAT_network - Verifies if Source NAT functionality of - # the given network is enabled in VSD - def verify_vsd_SourceNAT_network(self, network, vpc=None): - self.debug("Verifying if Source NAT functionality of Network - %s is " - "enabled in VSD" % network.name) - ext_network_id_filter = self.get_externalID_filter(vpc.id) if vpc \ - else self.get_externalID_filter(network.id) - vsd_domain = self.vsd.get_domain(filter=ext_network_id_filter) - self.assertEqual(vsd_domain.pat_enabled, "ENABLED", - "VSD domain address translation support " - "(pat_enabled flag) should be enabled for Source NAT " - "service enabled network in CloudStack" - ) - self.assertEqual(vsd_domain.underlay_enabled, "ENABLED", - "VSD domain underlay support (underlay_enabled flag) " - "should be enabled for Source NAT service enabled " - "network in CloudStack" - ) - self.debug("Successfully verified that Source NAT functionality of " - "Network - %s is enabled in VSD" % network.name) - - # verify_SourceNAT_VM_traffic - Verifies Source NAT traffic - # (wget www.google.com) to the Internet from the given VM. This Source NAT - # traffic test is done through a custom init script in the guest VM - # template upon the VM boot up. - def verify_SourceNAT_VM_traffic(self, vm, network, vpc=None, - negative_test=False): - self.debug("Verifying Source NAT traffic (wget www.google.com) to the " - "Internet from VM - %s" % vm.name) - if self.isInternetConnectivityAvailable: - # Adding Egress Network ACL rule - if vpc and self.http_proxy and not negative_test: - self.debug("Adding Egress Network ACL rule in the created VPC " - "network to allow access to the configured " - "Internet proxy servers...") - proxy_rule = copy.deepcopy(self.test_data["http_rule"]) - proxy_rule["privateport"] = 1080 - proxy_rule["publicport"] = 1080 - proxy_rule["startport"] = 1080 - proxy_rule["endport"] = 1080 - internet_proxy_server_rule = self.create_NetworkAclRule( - proxy_rule, traffic_type="Egress", network=network) - - # VSD verification - self.verify_vsd_firewall_rule( - internet_proxy_server_rule, traffic_type="Egress") - - # Triggering Source NAT traffic test - # Rebooting (stop - start) VM - self.debug("Triggering the Source NAT traffic test by rebooting " - "the given VM...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_vm(vm) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network, vpc) - - self.debug("Waiting for the VM to perform the Source NAT traffic " - "test (wget www.google.com) to the Internet...") - time.sleep(180) if negative_test else time.sleep(300) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule to SSH into the VM for " - "verifying its Source NAT traffic test...") - public_ip = self.acquire_PublicIPAddress(network, vpc=vpc) - self.validate_PublicIPAddress(public_ip, network) - self.create_StaticNatRule_For_VM(vm, public_ip, network) - self.validate_PublicIPAddress( - public_ip, network, static_nat=True, vm=vm) - - # VSD verification - updated_vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - self.verify_vsd_floating_ip( - network, updated_vm_info, public_ip.ipaddress, vpc=vpc) - - # Adding Ingress Firewall/Network ACL rule - self.debug("Adding Ingress Firewall/Network ACL rule to make the " - "created Static NAT rule (SSH) accessible...") - if vpc: - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=network) - else: - public_ssh_rule = self.create_FirewallRule( - public_ip, self.test_data["ingress_rule"]) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - - # Checking for wget file - is_in_file_list = None - if not self.isSimulator: - ssh_client = self.ssh_into_VM(vm, public_ip) - cmd = "ls /" - file_list = self.execute_cmd(ssh_client, cmd) - is_in_file_list = "index.html" in str(file_list) - if is_in_file_list: - cmd = "rm -rf /index.html*" - self.execute_cmd(ssh_client, cmd) - - # Removing Ingress Firewall/Network ACL rule - self.debug("Removing the created Ingress Firewall/Network ACL " - "rule in the network...") - public_ssh_rule.delete(self.api_client) - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(public_ssh_rule) - self.debug("Ingress Firewall/Network ACL rule successfully " - "deleted in VSD") - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the VM...") - self.delete_StaticNatRule_For_VM(public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip, network, static_nat=True, vm=vm) - self.debug("Static NAT Rule for the VM successfully deleted in " - "CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip( - network, updated_vm_info, public_ip.ipaddress, vpc=vpc) - self.debug("Floating IP for the VM successfully deleted in VSD") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network) - self.debug("Acquired public IP in the network successfully " - "released in CloudStack") - - # Removing Egress Network ACL rule - if vpc and self.http_proxy: - self.debug("Removing the created Egress Network ACL rule in " - "the VPC network...") - internet_proxy_server_rule.delete(self.api_client) - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(internet_proxy_server_rule) - self.debug("Egress Network ACL rule successfully deleted in " - "VSD") - - # Final test result - if is_in_file_list: - self.debug("Successfully verified Source NAT traffic " - "(wget www.google.com) to the Internet from VM - %s" - % vm.name) - elif not self.isSimulator: - self.fail("Failed to verify Source NAT traffic " - "(wget www.google.com) to the Internet from VM - %s" - % vm.name) - else: - if negative_test: - self.fail("Skipping Source NAT traffic (wget www.google.com) " - "verification to the Internet from VM as there is " - "no Internet connectivity in the data center") - else: - self.debug("Skipping Source NAT traffic (wget www.google.com) " - "verification to the Internet from VM as there is " - "no Internet connectivity in the data center") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_nuage_SourceNAT_isolated_networks(self): - """Test Nuage VSP Isolated networks with different combinations of - Source NAT service providers - """ - - # 1. Create Nuage VSP Isolated Network offerings and corresponding - # Isolated networks with different combinations of Source NAT - # service providers (NuageVsp, VirtualRouter, no SourceNat service), - # check if only the Isolated networks with Source NAT service - # provider as NuageVsp are successfully created. - # 2. Recreate the above created Network offering with ispersistent flag - # set to True, check if the network offering is successfully created - # and enabled. - # 3. Recreate the above created Network offering with conserve mode On - # (conserve_mode flag set to True), check if the network offering is - # successfully created and enabled. - # 4. Recreate the above created Network offering with Source NAT - # Service Capability SupportedSourceNatTypes as per account, check - # if the network offering creation failed as Nuage VSP supports only - # SupportedSourceNatTypes as per zone. - # 5. Create an Isolated network with Source NAT service provider as - # NuageVsp and spawn a VM, check if the network is successfully - # created, and the VM along with the VR is deployed successfully in - # the network. Verify if the Source NAT functionality for this - # network is successfully enabled in VSD. - # 6. Create a persistent Isolated network with Source NAT service - # provider as NuageVsp and spawn a VM, check if the network is - # successfully created, and the VM along with the VR is deployed - # successfully in the network. Verify if the Source NAT - # functionality for this network is successfully enabled in VSD. - # 7. Create a conserved Isolated network (conserve mode On) with Source - # NAT service provider as NuageVsp and spawn a VM, check if the - # network is successfully created, and the VM along with the VR is - # deployed successfully in the network. Verify if the Source NAT - # functionality for this network is successfully enabled in VSD. - # 8. Delete all the created objects (cleanup). - - # Creating network offerings - self.debug("Creating Nuage VSP Isolated Network offering with Source " - "NAT service provider as NuageVsp...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Recreating above Network offering with ispersistent " - "True...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["ispersistent"] = "True" - net_off_2 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - self.debug("Recreating above Network offering with conserve mode " - "On...") - net_off_3 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"], - conserve_mode=True) - self.validate_NetworkOffering(net_off_3, state="Enabled") - - self.debug("Recreating above Network offering with Source NAT Service " - "Capability SupportedSourceNatTypes as per account...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - service_list = network_offering["serviceCapabilityList"] - service_list["SourceNat"]["SupportedSourceNatTypes"] = "peraccount" - network_offering["serviceCapabilityList"] = service_list - with self.assertRaises(Exception): - self.create_NetworkOffering(network_offering) - self.debug("Nuage VSP does not support Network offerings with Source " - "NAT Service Capability " - "SupportedSourceNatTypes as per account") - - self.debug("Creating Nuage VSP Isolated Network offering with Source " - "NAT service provider as VirtualRouter...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["serviceProviderList"]["SourceNat"] = "VirtualRouter" - with self.assertRaises(Exception): - self.create_NetworkOffering(network_offering) - self.debug("Nuage VSP does not support Network offerings with Source " - "NAT service provider as VirtualRouter") - - self.debug("Creating Nuage VSP Isolated Network offering without " - "Source NAT service...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["supportedservices"] = \ - 'Dhcp,Connectivity,StaticNat,UserData,Firewall,Dns' - del network_offering["serviceProviderList"]["SourceNat"] - del network_offering["serviceCapabilityList"] - net_off_4 = self.create_NetworkOffering(network_offering) - - # Creating Isolated networks, and deploying VMs - self.debug("Creating an Isolated network with Source NAT service " - "provider as NuageVsp...") - network_1 = self.create_Network(net_off_1, gateway='10.1.1.1') - self.validate_Network(network_1, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(network_1) - self.validate_Network(network_1, state="Implemented") - vr_1 = self.get_Router(network_1) - self.check_Router_state(vr_1, state="Running") - self.check_VM_state(vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(vm_1) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_1) - - # Bug CLOUDSTACK-9398 - """ - self.debug("Creating a persistent Isolated network with Source NAT " - "service...") - network_2 = self.create_Network(net_off_2, gateway='10.1.2.1') - self.validate_Network(network_2, state="Implemented") - vr_2 = self.get_Router(network_2) - self.check_Router_state(vr_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_2) - self.verify_vsd_router(vr_2) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_2) - - self.debug("Deploying a VM in the created Isolated network...") - vm_2 = self.create_VM(network_2) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vm_2) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_2) - """ - - self.debug("Creating an Isolated network with Source NAT service and " - "conserve mode On...") - network_3 = self.create_Network(net_off_3, gateway='10.1.3.1') - self.validate_Network(network_3, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_3 = self.create_VM(network_3) - self.validate_Network(network_3, state="Implemented") - vr_3 = self.get_Router(network_3) - self.check_Router_state(vr_3, state="Running") - self.check_VM_state(vm_3, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_3) - self.verify_vsd_router(vr_3) - self.verify_vsd_vm(vm_3) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_3) - - self.debug("Creating an Isolated network without Source NAT " - "service...") - with self.assertRaises(Exception): - self.create_Network(net_off_4, gateway='10.1.4.1') - self.debug("Nuage VSP does not support creation of Isolated networks " - "without Source NAT service") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_nuage_SourceNAT_vpc_networks(self): - """Test Nuage VSP VPC networks with different combinations of Source - NAT service providers - """ - - # 1. Create Nuage VSP VPC offering with different combinations of - # Source NAT service providers - # (NuageVsp, VirtualRouter, no SourceNat service), check if all the - # VPC offerings are successfully created and enabled. - # 2. Create VPCs with different combinations of Source NAT service - # providers (NuageVsp, VirtualRouter, no SourceNat service), check - # if only the VPCs with Source NAT service provider as NuageVsp and - # no SourceNat service are successfully created and enabled. - # 3. Create Nuage VSP VPC Network offering with different combinations - # of Source NAT service providers - # (NuageVsp, VirtualRouter, no SourceNat service), check if only the - # network offering with Source NAT service provider as NuageVsp is - # successfully created and enabled. - # 4. Recreate the above created Network offering with ispersistent flag - # set to False, check if the network offering is successfully - # created and enabled. - # 5. Recreate the above created Network offering with conserve mode On - # (conserve_mode flag set to True), check if the network offering - # creation failed as only networks with conserve mode Off can belong - # to VPC. - # 6. Recreate the above created Network offering with with Source NAT - # Service Capability SupportedSourceNatTypes as per account, check - # if the network offering creation failed as Nuage VSP supports only - # SupportedSourceNatTypes as per zone. - # 7. Create a VPC network with Source NAT service provider as NuageVsp - # in the VPC with SourceNat service and spawn a VM, check if the - # tier is added to the VPC VR, and the VM is deployed successfully - # in the tier. Verify if the Source NAT functionality for this - # network is successfully enabled in VSD. - # 8. Create a non persistent VPC network with Source NAT service - # provider as NuageVsp in the VPC with SourceNat service and spawn a - # VM, check if the tier creation failed as Nuage VSP does not - # support non persistent VPC networks. - # 9. Create another VPC network with Source NAT service provider as - # NuageVsp in the VPC with SourceNat service and spawn a VM, check - # if the tier is added to the VPC VR, and the VM is deployed - # successfully in the tier. Verify if the Source NAT functionality - # for this network is successfully enabled in VSD. - # 10. Create a VPC network with Source NAT service provider as NuageVsp - # in the VPC without SourceNat service, check if the tier creation - # failed as the VPC does not support Source NAT service. - # 11. Delete all the created objects (cleanup). - - # Creating VPC offerings - self.debug("Creating Nuage VSP VPC offering with Source NAT service " - "provider as NuageVsp...") - vpc_off_1 = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering with Source NAT service " - "provider as VpcVirtualRouter...") - vpc_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_offering"]) - vpc_offering["serviceProviderList"]["SourceNat"] = "VpcVirtualRouter" - vpc_off_2 = self.create_VpcOffering(vpc_offering) - self.validate_VpcOffering(vpc_off_2, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering without Source NAT " - "service...") - vpc_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_offering"]) - vpc_offering["supportedservices"] = \ - 'Dhcp,StaticNat,NetworkACL,Connectivity,UserData,Dns' - del vpc_offering["serviceProviderList"]["SourceNat"] - vpc_off_3 = self.create_VpcOffering(vpc_offering) - self.validate_VpcOffering(vpc_off_3, state="Enabled") - - # Creating VPCs - self.debug("Creating a VPC with Source NAT service provider as " - "NuageVsp...") - vpc_1 = self.create_vpc(vpc_off_1, cidr='10.1.0.0/16') - self.validate_vpc(vpc_1, state="Enabled") - - self.debug("Creating a VPC with Source NAT service provider as " - "VpcVirtualRouter...") - with self.assertRaises(Exception): - self.create_vpc(vpc_off_2, cidr='10.1.0.0/16') - self.debug("Nuage VSP does not support provider VpcVirtualRouter for " - "service Source NAT for VPCs") - - self.debug("Creating a VPC without Source NAT service...") - with self.assertRaises(Exception): - self.create_vpc(vpc_off_3, cidr='10.1.0.0/16') - self.debug("Nuage VSP does not support VPCs without Source NAT " - "service") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Source NAT " - "service provider as NuageVsp...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Recreating above Network offering with ispersistent " - "False...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - network_offering["ispersistent"] = "False" - net_off_2 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - self.debug("Recreating above Network offering with conserve mode " - "On...") - with self.assertRaises(Exception): - self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"], - conserve_mode=True) - self.debug("Network offering creation failed as only networks with " - "conserve mode Off can belong to VPC") - - self.debug("Recreating above Network offering with Source NAT Service " - "Capability SupportedSourceNatTypes as per account...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - service_list = network_offering["serviceCapabilityList"] - service_list["SourceNat"]["SupportedSourceNatTypes"] = "peraccount" - network_offering["serviceCapabilityList"] = service_list - with self.assertRaises(Exception): - self.create_NetworkOffering(network_offering) - self.debug("Nuage VSP does not support Network offerings with Source " - "NAT Service Capability SupportedSourceNatTypes as per " - "account") - - self.debug("Creating Nuage VSP VPC Network offering with Source NAT " - "service provider as VpcVirtualRouter...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - network_offering["serviceProviderList"]["SourceNat"] = \ - "VpcVirtualRouter" - with self.assertRaises(Exception): - self.create_NetworkOffering(network_offering) - self.debug("Nuage VSP does not support Network offerings with Source " - "NAT service provider as VpcVirtualRouter") - - self.debug("Creating Nuage VSP VPC Network offering without Source " - "NAT service...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - network_offering["supportedservices"] = \ - 'Dhcp,StaticNat,NetworkACL,Connectivity,UserData,Dns' - del network_offering["serviceProviderList"]["SourceNat"] - del network_offering["serviceCapabilityList"] - with self.assertRaises(Exception): - self.create_NetworkOffering(network_offering) - self.debug("Nuage VSP does not support Network offerings without " - "Source NAT service") - - # Creating VPC networks in the VPCs, and deploying VMs - self.debug("Creating a VPC network with Source NAT service provider " - "as NuageVsp in vpc_1...") - vpc_tier_1 = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc_1) - self.validate_Network(vpc_tier_1, state="Implemented") - vpc_vr = self.get_Router(vpc_tier_1) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier_1, vpc_1) - self.verify_vsd_router(vpc_vr) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier_1, vpc=vpc_1) - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm_1 = self.create_VM(vpc_tier_1) - self.check_VM_state(vpc_vm_1, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_1) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier_1, vpc=vpc_1) - - self.debug("Creating a non persistent VPC network with Source NAT " - "service in vpc_1...") - with self.assertRaises(Exception): - self.create_Network(net_off_2, gateway='10.1.2.1', vpc=vpc_1) - self.debug("Nuage VSP does not support non persistent VPC networks") - - self.debug("Creating another VPC network with Source NAT service in " - "vpc_1...") - vpc_tier_2 = self.create_Network( - net_off_1, gateway='10.1.2.1', vpc=vpc_1) - self.validate_Network(vpc_tier_2, state="Implemented") - vpc_vr = self.get_Router(vpc_tier_2) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier_2, vpc_1) - self.verify_vsd_router(vpc_vr) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier_2, vpc=vpc_1) - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm_2 = self.create_VM(vpc_tier_2) - self.check_VM_state(vpc_vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_2) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier_2, vpc=vpc_1) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_03_nuage_SourceNAT_isolated_network_traffic(self): - """Test Nuage VSP Source NAT functionality for Isolated network by - performing (wget) traffic tests to the Internet - """ - - # 1. Check if the configured Nuage VSP SDN platform infrastructure - # supports underlay networking, if not, skip this test. - # 2. Create an Isolated network with Source NAT service provider as - # NuageVsp and spawn a VM, check if the network is successfully - # created, and the VM along with the VR is deployed successfully in - # the network. Verify if the Source NAT functionality for this - # network is successfully enabled in VSD. - # 3. Verify Source NAT traffic test (wget www.google.com) to the - # Internet from the deployed VM. - # 4. Deploy another VM in the created Isolated network, check if the VM - # is deployed successfully in the network. Verify if the Source NAT - # functionality for this network is successfully enabled in VSD. - # 5. Verify Source NAT traffic test (wget www.google.com) to the - # Internet from the deployed VM. - # 6. Delete all the created objects (cleanup). - # Note: Above mentioned Source NAT traffic tests are done through a - # custom init script in the guest VM template upon the VM boot - # up. This traffic tests are verified by SSHing into the VM - # using a Static NAT rule. - - if not self.isNuageInfraUnderlay: - self.skipTest("Configured Nuage VSP SDN platform infrastructure " - "does not support underlay networking: " - "skipping test") - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Source " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating Isolated networks, deploying VMs, and verifying Source NAT - # traffic - self.debug("Creating an Isolated network with Source NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm_1, network) - - self.debug("Deploying another VM in the created Isolated network...") - vm_2 = self.create_VM(network) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vm_2) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm_2, network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_04_nuage_SourceNAT_vpc_network_traffic(self): - """Test Nuage VSP Source NAT functionality for VPC network by - performing (wget) traffic tests to the Internet - """ - - # 1. Check if the configured Nuage VSP SDN platform infrastructure - # supports underlay networking, if not, skip this test. - # 2. Create a VPC network with Source NAT service provider as NuageVsp - # in the VPC with SourceNat service and spawn a VM, check if the - # tier is added to the VPC VR, and the VM is deployed successfully - # in the tier. Verify if the Source NAT functionality for this - # network is successfully enabled in VSD. - # 3. Verify Source NAT traffic test (wget www.google.com) to the - # Internet from the deployed VM. - # 4. Deploy another VM in the created VPC network, check if the VM is - # deployed successfully in the network. Verify if the Source NAT - # functionality for this network is successfully enabled in VSD. - # 5. Verify Source NAT traffic test (wget www.google.com) to the - # Internet from the deployed VM. - # 6. Delete all the created objects (cleanup). - # Note: Above mentioned Source NAT traffic tests are done through a - # custom init script in the guest VM template upon the VM boot - # up. This traffic tests are verified by SSHing into the VM using - # a Static NAT rule. - - if not self.isNuageInfraUnderlay: - self.skipTest("Configured Nuage VSP SDN platform infrastructure " - "does not support underlay networking: " - "skipping test") - - # Creating VPC offering - self.debug("Creating Nuage VSP VPC offering with Source NAT service " - "provider as NuageVsp...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating VPC - self.debug("Creating a VPC with Source NAT service provider as " - "NuageVsp...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offering - self.debug("Creating Nuage VSP VPC Network offering with Source NAT " - "service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating VPC networks in the VPC, deploying VMs, and verifying - # Source NAT traffic - self.debug("Creating a VPC network with Source NAT service...") - vpc_tier = self.create_Network(net_off, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier, vpc=vpc) - - # Adding Egress Network ACL rules - self.debug("Adding Egress Network ACL rules in the created VPC " - "network to allow Source NAT (DNS & HTTP) traffic to the " - "Internet from the VMs in the network...") - dns_rule = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for added Egress Network ACL rules - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm_1 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_1, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_1) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier, vpc=vpc) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm_1, vpc_tier, vpc=vpc) - - self.debug("Deploying another VM in the created VPC network...") - vpc_vm_2 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_2) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier, vpc=vpc) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm_2, vpc_tier, vpc=vpc) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_05_nuage_SourceNAT_acl_rules_traffic(self): - """Test Nuage VSP Source NAT functionality with different Egress - Firewall/Network ACL rules by performing (wget) traffic tests to the - Internet - """ - - # Check if the configured Nuage VSP SDN platform infrastructure - # supports underlay networking, if not, skip this test. - # Repeat the tests in the testcases - # "test_03_nuage_SourceNAT_isolated_network_traffic" and - # "test_04_nuage_SourceNAT_vpc_network_traffic" with different Egress - # Firewall/Network ACL rules: - # 1. Allow and block Egress Firewall rules - # 2. Allow and block Egress Network ACL rules - # Verify the above Egress Firewall/Network ACL rules by verifying its - # Source NAT traffic test (wget www.google.com) to the Internet. - # Delete all the created objects (cleanup). - - if not self.isNuageInfraUnderlay: - self.skipTest("Configured Nuage VSP SDN platform infrastructure " - "does not support underlay networking: " - "skipping test") - - # Creating Isolated network offering - self.debug("Creating Nuage VSP Isolated Network offering with Source " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating an Isolated network, deploying a VM, and verifying Source - # NAT traffic with Egress Firewall rules - self.debug("Creating an Isolated network with Source NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network) - - # Adding Egress Firewall rule - self.debug("Adding an Egress Firewall rule in the created Isolated " - "network to block/drop Source NAT (DNS) traffic to the " - "Internet from the VMs in the network...") - dns_rule_1 = self.create_EgressFirewallRule( - network, self.test_data["dns_rule"]) - - # VSD verification for added Egress Firewall rule - self.verify_vsd_firewall_rule(dns_rule_1, traffic_type="Egress") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - with self.assertRaises(Exception): - self.verify_SourceNAT_VM_traffic(vm, network, negative_test=True) - self.debug("Source NAT (DNS) traffic to the Internet from the " - "deployed VM is blocked/dropped by the added Egress " - "Firewall rule") - - # Removing Egress Firewall rule - self.debug("Removing the added Egress Firewall rule in the created " - "Isolated network to allow Source NAT (DNS) traffic to " - "the Internet from the VMs in the network " - "(Default Egress Firewall rule)...") - dns_rule_1.delete(self.api_client) - - # VSD verification for removed Egress Firewall rule - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(dns_rule_1, traffic_type="Egress") - self.debug("Egress Firewall rule successfully deleted in VSD") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network) - - # Creating VPC offering - self.debug("Creating Nuage VSP VPC offering with Source NAT service " - "provider as NuageVsp...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating VPC - self.debug("Creating a VPC with Source NAT service provider as " - "NuageVsp...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating VPC network offering - self.debug("Creating Nuage VSP VPC Network offering with Source NAT " - "service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating a VPC network in the VPC, deploying a VM, and verifying - # Source NAT traffic with Network ACl rules - self.debug("Creating a VPC network with Source NAT service...") - vpc_tier = self.create_Network(net_off, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier, vpc=vpc) - - # Adding Egress Network ACL rules - self.debug("Adding Egress Network ACL rules in the created VPC " - "network to allow Source NAT (DNS & HTTP) traffic to the " - "Internet from the VMs in the network...") - dns_rule_2 = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for added Egress Network ACL rules - self.verify_vsd_firewall_rule(dns_rule_2, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier, vpc=vpc) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc) - - # Removing Egress Network ACL rule - self.debug("Removing the added Egress Network ACL rule in the created " - "VPC network to block Source NAT (DNS) traffic to the " - "Internet from the VMs in the network " - "(Default Egress Network ACL rule)...") - dns_rule_2.delete(self.api_client) - - # VSD verification for removed Egress Network ACL rule - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(dns_rule_2, traffic_type="Egress") - self.debug("Egress Network ACL rule successfully deleted in VSD") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - with self.assertRaises(Exception): - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc, - negative_test=True) - self.debug("Source NAT (DNS) traffic to the Internet from the " - "deployed VM is blocked by the Default Egress Network ACL " - "rule") - - # Re-adding Egress Network ACL rule - self.debug("Re-adding the Egress Network ACL rule in the created VPC " - "network to allow Source NAT (DNS) traffic to the " - "Internet from the VMs in the network...") - dns_rule_2 = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for re-added Egress Network ACL rule - self.verify_vsd_firewall_rule(dns_rule_2, traffic_type="Egress") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_06_nuage_SourceNAT_vm_nic_operations_traffic(self): - """Test Nuage VSP Source NAT functionality with VM NIC operations by - performing (wget) traffic tests to the - Internet - """ - - # Check if the configured Nuage VSP SDN platform infrastructure - # supports underlay networking, if not, skip this test. - # Repeat the tests in the testcase "test_03_nuage_SourceNAT_isolated_ - # network_traffic" with VM NIC operations: - # 1. Updating default VM NIC - # 2. Removing non-default VM NIC - # 3. Adding and updating default VM NIC - # Verify the above VM NIC operations by verifying its Source NAT - # traffic test (wget www.google.com) to the Internet. - # Delete all the created objects (cleanup). - - if not self.isNuageInfraUnderlay: - self.skipTest("Configured Nuage VSP SDN platform infrastructure " - "does not support underlay networking: " - "skipping test") - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Source " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating Isolated networks, deploying a multi-nic VM, and verifying - # Source NAT traffic with VM NIC operations - self.debug("Creating an Isolated network with Source NAT service...") - network_1 = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network_1, state="Allocated") - - self.debug("Creating another Isolated network with Source NAT " - "service...") - network_2 = self.create_Network(net_off, gateway='10.1.2.1') - self.validate_Network(network_2, state="Allocated") - - self.debug("Deploying a multi-nic VM in the created Isolated " - "networks...") - vm = self.create_VM([network_1, network_2]) - self.validate_Network(network_1, state="Implemented") - vr_1 = self.get_Router(network_1) - self.check_Router_state(vr_1, state="Running") - self.validate_Network(network_2, state="Implemented") - vr_2 = self.get_Router(network_2) - self.check_Router_state(vr_2, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_network(self.domain.id, network_2) - self.verify_vsd_router(vr_2) - self.verify_vsd_vm(vm) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_1) - self.verify_vsd_SourceNAT_network(network_2) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network_1) - - # Updating default VM NIC - # This VM NIC operation has no effect on the Source NAT functionality - self.debug("Updating the default nic of the multi-nic VM...") - self.nic_operation_VM(vm, network_2, operation="update") - - # Rebooting (stop - start) VM - self.debug("Rebooting the multi-nic VM after updating its default nic " - "for changes to apply to the VM...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.check_VM_state(vm, state="Running") - - # VSD verification - updated_vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - self.verify_vsd_vm(updated_vm_info) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_1) - self.verify_vsd_SourceNAT_network(network_2) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network_2) - - # Removing non-default VM NIC - # This VM NIC operation has no effect on the Source NAT functionality - self.debug("Removing the non-default nic of the multi-nic VM...") - self.nic_operation_VM(vm, network_1, operation="remove") - - # Rebooting (stop - start) VM - self.debug("Rebooting the multi-nic VM after removing its non-default " - "nic for changes to apply to the VM...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.check_VM_state(vm, state="Running") - - # VSD verification - updated_vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - self.verify_vsd_vm(updated_vm_info) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_1) - self.verify_vsd_SourceNAT_network(network_2) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network_2) - - # Adding and updating default VM NIC - # This VM NIC operation has no effect on the Source NAT functionality - self.debug("Re-adding the non-default nic and updating the default " - "nic of the multi-nic VM...") - self.nic_operation_VM(vm, network_1, operation="add") - self.nic_operation_VM(vm, network_1, operation="update") - - # Rebooting (stop - start) VM - self.debug("Rebooting the multi-nic VM after re-adding its " - "non-default nic for changes to apply to the VM...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.check_VM_state(vm, state="Running") - - # VSD verification - updated_vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - self.verify_vsd_vm(updated_vm_info) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network_1) - self.verify_vsd_SourceNAT_network(network_2) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network_1) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_07_nuage_SourceNAT_vm_migration_traffic(self): - """Test Nuage VSP Source NAT functionality with VM migration by - performing (wget) traffic tests to the Internet - """ - - # Check if the configured Nuage VSP SDN platform infrastructure - # supports underlay networking, if not, skip this test. - # Repeat the tests in the testcase - # "test_03_nuage_SourceNAT_isolated_network_traffic" with migration of - # one of the VMs to another host (if available). - # Verify the above VM migration by verifying its Source NAT traffic - # test (wget www.google.com) to the Internet. - # Delete all the created objects (cleanup). - - if not self.isNuageInfraUnderlay: - self.skipTest("Configured Nuage VSP SDN platform infrastructure " - "does not support underlay networking: " - "skipping test") - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Source " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating an Isolated network, deploying VMs, and verifying Source NAT - # traffic with VM migrations - self.debug("Creating an Isolated network with Source NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm_1, network) - - self.debug("Deploying another VM in the created Isolated network...") - vm_2 = self.create_VM(network) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vm_2) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm_2, network) - - # VM migration - # This VM migration has no effect on the Source NAT functionality - self.debug("Migrating one of the VMs in the created Isolated network " - "to another host, if available...") - self.migrate_VM(vm_1) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm_1, network) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm_2, network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_08_nuage_SourceNAT_network_restarts_traffic(self): - """Test Nuage VSP Source NAT functionality with network restarts by - performing (wget) traffic tests to the Internet - """ - - # Check if the configured Nuage VSP SDN platform infrastructure - # supports underlay networking, if not, skip this test. - # Repeat the tests in the testcases - # "test_03_nuage_SourceNAT_isolated_network_traffic" and - # "test_04_nuage_SourceNAT_vpc_network_traffic" with network restarts: - # 1. Restart Isolated Network (cleanup = false) - # 2. Restart Isolated Network (cleanup = true) - # 3. Reboot VM in the Isolated Network - # 4. Restart VPC Network (cleanup = false) - # 5. Restart VPC Network (cleanup = true) - # 6. Reboot VM in the VPC Network - # 7. Restart VPC (cleanup = false) - # 8. Restart VPC (cleanup = true) - # Verify the above with network restarts by verifying its Source NAT - # traffic test (wget www.google.com) to the Internet. - # Delete all the created objects (cleanup). - - if not self.isNuageInfraUnderlay: - self.skipTest("Configured Nuage VSP SDN platform infrastructure " - "does not support underlay networking: " - "skipping test") - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Source " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating an Isolated network, deploying a VM, and verifying Source - # NAT traffic with Isolated network restarts - self.debug("Creating an Isolated network with Source NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(network) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network) - - # Restarting Isolated network (cleanup = false) - # VR gets destroyed and deployed again in the Isolated network - # This restart has no effect on the Source NAT functionality - self.debug("Restarting the created Isolated network without " - "cleanup...") - Network.restart(network, self.api_client, cleanup=False) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network) - - # Restarting Isolated network (cleanup = true) - # VR gets destroyed and deployed again in the Isolated network - # This restart has no effect on the Source NAT functionality - self.debug("Restarting the created Isolated network with cleanup...") - Network.restart(network, self.api_client, cleanup=True) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vm, network) - - # Creating VPC offering - self.debug("Creating Nuage VSP VPC offering with Source NAT service " - "provider as NuageVsp...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating VPC - self.debug("Creating a VPC with Source NAT service provider as " - "NuageVsp...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating VPC network offering - self.debug("Creating Nuage VSP VPC Network offering with Source NAT " - "service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating a VPC network in the VPC, deploying a VM, and verifying - # Source NAT traffic with VPC network restarts - self.debug("Creating a VPC network with Source NAT service...") - vpc_tier = self.create_Network(net_off, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier, vpc=vpc) - - # Adding Egress Network ACL rules - self.debug("Adding Egress Network ACL rules in the created VPC " - "network to allow Source NAT (DNS & HTTP) traffic to the " - "Internet from the VMs in the network...") - dns_rule = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for added Egress Network ACL rules - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm) - - # VSD verification for Source NAT functionality - self.verify_vsd_SourceNAT_network(vpc_tier, vpc=vpc) - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc) - - # Restarting VPC network (cleanup = false) - # This restart has no effect on the Source NAT functionality - self.debug("Restarting the created VPC network without cleanup...") - Network.restart(vpc_tier, self.api_client, cleanup=False) - self.validate_Network(vpc_tier, state="Implemented") - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc) - - # Restarting VPC network (cleanup = true) - # This restart has no effect on the Source NAT functionality - self.debug("Restarting the created VPC network with cleanup...") - Network.restart(vpc_tier, self.api_client, cleanup=True) - self.validate_Network(vpc_tier, state="Implemented") - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc) - - # Restarting VPC (cleanup = false) - # VPC VR gets destroyed and deployed again in the VPC - # This restart has no effect on the Source NAT functionality - self.debug("Restarting the VPC without cleanup...") - self.restart_Vpc(vpc, cleanup=False) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc) - - # Restarting VPC (cleanup = true) - # VPC VR gets destroyed and deployed again in the VPC - # This restart has no effect on the Source NAT functionality - self.debug("Restarting the VPC with cleanup...") - self.restart_Vpc(vpc, cleanup=True) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # Verifying Source NAT traffic (wget www.google.com) to the Internet - # from the deployed VM. This Source NAT traffic test is done through a - # custom init script in the guest VM template upon the VM boot up. - self.verify_SourceNAT_VM_traffic(vpc_vm, vpc_tier, vpc=vpc) diff --git a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py b/test/integration/plugins/nuagevsp/test_nuage_static_nat.py deleted file mode 100644 index b1b0d60a225..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_static_nat.py +++ /dev/null @@ -1,2270 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Static NAT functionality with Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import (Account, - PublicIpRange, - Network, - VirtualMachine) -from marvin.lib.common import list_virtual_machines -from marvin.lib.common import list_virtual_machines - -# Import System Modules -from nose.plugins.attrib import attr -import threading -import copy -import time - - -class TestNuageStaticNat(nuageTestCase): - """Test Static NAT functionality with Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls): - super(TestNuageStaticNat, cls).setUpClass() - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - # create_PublicIpRange - Creates public IP range - def create_PublicIpRange(self): - self.debug("Creating public IP range") - self.test_data["vlan_ip_range"]["startip"] = "20.200.200.100" - self.test_data["vlan_ip_range"]["endip"] = "20.200.200.200" - self.test_data["vlan_ip_range"]["netmask"] = "255.255.255.0" - self.test_data["vlan_ip_range"]["gateway"] = "20.200.200.1" - self.test_data["vlan_ip_range"]["forvirtualnetwork"] = "true" - self.test_data["vlan_ip_range"]["zoneid"] = self.zone.id - public_ip_range = PublicIpRange.create(self.api_client, - self.test_data["vlan_ip_range"] - ) - self.debug("Created public IP range") - return public_ip_range - - # validate_PublicIpRange - Validates public IP range creation and state - def validate_PublicIpRange(self, public_ip_range): - public_ip_ranges = PublicIpRange.list(self.api_client, - id=public_ip_range.vlan.id - ) - self.assertEqual(isinstance(public_ip_ranges, list), True, - "List Public IP Range should return a valid list" - ) - self.assertEqual(public_ip_range.vlan.startip, - public_ip_ranges[0].startip, - "Start IP of the public IP range should match with " - "the returned list data" - ) - self.assertEqual(public_ip_range.vlan.endip, public_ip_ranges[0].endip, - "End IP of the public IP range should match with the " - "returned list data" - ) - - # validate_NuageUnderlayPublicIpRange - Validates Nuage underlay enabled - # public IP range creation and state - def validate_NuageUnderlayPublicIpRange(self, public_ip_range): - self.nuage_underlay_public_ip_ranges = \ - self.list_NuageUnderlayPublicIpRanges(public_ip_range) - self.assertEqual(isinstance(self.nuage_underlay_public_ip_ranges, - list), - True, - "List Nuage Underlay Public IP Range should return " - "a valid list" - ) - self.assertEqual(public_ip_range.vlan.startip, - self.nuage_underlay_public_ip_ranges[0].startip, - "Start IP of the public IP range should match with " - "the returned list data" - ) - self.assertEqual(public_ip_range.vlan.endip, - self.nuage_underlay_public_ip_ranges[0].endip, - "End IP of the public IP range should match with the " - "returned list data" - ) - - # verify_StaticNAT_traffic - Verifies Static NAT traffic by performing - # wget traffic test with the given Static NAT enabled public IP, http web - # server running on the corresponding VM in the given network - def verify_StaticNAT_traffic(self, network, public_ip, vpc=None, - non_default_nic=False): - if self.isSimulator: - self.debug("Simulator Environment: skipping static nat" - "traffic tests.") - return - # Adding Ingress Firewall/Network ACL rule - self.debug("Adding Ingress Firewall/Network ACL rule to make the " - "created Static NAT rule (wget) accessible...") - if vpc: - public_http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], network=network) - else: - public_http_rule = self.create_FirewallRule( - public_ip, self.test_data["http_rule"]) - - # VSD verification - self.verify_vsd_firewall_rule(public_http_rule) - - # wget from VM - tries = 0 - max_tries = 3 if non_default_nic else 120 - filename = None - headers = None - while tries < max_tries: - try: - filename, headers = self.wget_from_server(public_ip) - if filename and headers: - self.debug("wget from VM is successful") - break - except Exception as e: - self.debug("Failed to wget from VM - %s" % e) - self.debug("Retrying wget from VM after some time...") - time.sleep(5) - tries += 1 - - try: - if not filename and not headers: - if non_default_nic: - self.debug("Failed to wget from VM via this NIC as it " - "is not the default NIC") - else: - self.fail("Failed to wget from VM") - finally: - # Removing Ingress Firewall/Network ACL rule - self.debug("Removing the created Ingress Firewall/Network ACL " - "rule in the network...") - public_http_rule.delete(self.api_client) - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(public_http_rule) - self.debug("Ingress Firewall/Network ACL rule successfully " - "deleted in VSD") - - self.debug("Successfully verified Static NAT traffic by " - "performing wget traffic test with the given Static " - "NAT enabled public IP - %s" % public_ip) - - # wget_from_internet - From within the given VM (ssh client), - # fetches index.html file of an Internet web server, wget www.google.com - def wget_from_Internet(self, ssh_client, timeout): - if self.http_proxy: - cmd = "wget --no-cache --output-document=index.html " \ - "http://www.google.com/ -e use_proxy=yes -e http_proxy=" + \ - self.http_proxy + " --timeout=" + str(timeout) - else: - cmd = "wget --no-cache --output-document=index.html " \ - "http://www.google.com/ --timeout=" + str(timeout) - test_result = self.execute_cmd(ssh_client, cmd) - if "200 OK" in test_result: - cmd = "rm -rf index.html*" - self.execute_cmd(ssh_client, cmd) - return test_result - - # verify_StaticNAT_Internet_traffic - Verifies Static NAT traffic to the - # Internet (wget www.google.com) from the given VM - def verify_StaticNAT_Internet_traffic(self, vm, network, public_ip, - vpc=None, non_default_nic=False, - negative_test=False): - if self.isSimulator and not negative_test: - self.debug("Simulator Environment: not verifying internet traffic") - return - elif self.isSimulator: - raise Exception("Simulator simulating exception") - # Adding Ingress Firewall/Network ACL rule - self.debug("Adding Ingress Firewall/Network ACL rule to make the " - "created Static NAT rule (SSH) accessible...") - if vpc: - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=network) - else: - public_ssh_rule = self.create_FirewallRule( - public_ip, self.test_data["ingress_rule"]) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - - # Adding Egress Network ACL rule - if vpc and self.http_proxy and not negative_test: - self.debug("Adding Egress Network ACL rule in the created VPC " - "network to allow access to the configured Internet " - "proxy servers...") - proxy_rule = copy.deepcopy(self.test_data["http_rule"]) - proxy_rule["privateport"] = 1080 - proxy_rule["publicport"] = 1080 - proxy_rule["startport"] = 1080 - proxy_rule["endport"] = 1080 - internet_proxy_server_rule = self.create_NetworkAclRule( - proxy_rule, traffic_type="Egress", network=network) - - # VSD verification - self.verify_vsd_firewall_rule( - internet_proxy_server_rule, traffic_type="Egress") - - # SSH into VM - ssh_client = None - try: - if non_default_nic: - with self.assertRaises(Exception): - self.ssh_into_VM(vm, public_ip, negative_test=True) - self.debug("Can not SSH into the VM via this NIC as it is " - "not the default NIC") - else: - ssh_client = self.ssh_into_VM(vm, public_ip) - - # wget from Internet - test_result = None - if ssh_client and self.isInternetConnectivityAvailable: - timeout = 100 if negative_test else 300 - test_result = self.wget_from_Internet(ssh_client, timeout) - finally: - # Removing Ingress Firewall/Network ACL rule - self.debug("Removing the created Ingress Firewall/Network ACL " - "rule in the network...") - public_ssh_rule.delete(self.api_client) - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(public_ssh_rule) - self.debug("Ingress Firewall/Network ACL rule successfully " - "deleted in VSD") - - # Removing Egress Network ACL rule - if vpc and self.http_proxy: - self.debug("Removing the created Egress Network ACL rule in the " - "VPC network...") - internet_proxy_server_rule.delete(self.api_client) - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(internet_proxy_server_rule) - self.debug("Egress Network ACL rule successfully deleted in VSD") - - if test_result: - if "200 OK" in test_result: - self.debug("Successfully verified Static NAT Internet traffic " - "(wget www.google.com) from VM - %s" % vm.name) - else: - self.fail("Failed to verify Static NAT Internet traffic " - "(wget www.google.com) from VM - %s" % vm.name) - else: - if negative_test: - self.fail("Skipped Static NAT Internet traffic " - "(wget www.google.com) test from VM as there is no " - "Internet connectivity in the data center") - else: - self.debug("Skipped Static NAT Internet traffic " - "(wget www.google.com) test from VM as there is no " - "Internet connectivity in the data center") - - # enable_staticNat_on_a_starting_vm - Enables Static Nat on a starting VM - # in the given network with the given public IP. - def enable_staticNat_on_a_starting_vm(self): - self.debug("Enables Static Nat on a starting VM in the network - %s " - "with the given public IP - %s" % - (self.network, self.public_ip)) - time.sleep(15) - vm_list = list_virtual_machines(self.api_client, listall=True) - self.create_StaticNatRule_For_VM( - vm_list[0], self.public_ip, self.network) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_nuage_StaticNAT_public_ip_range(self): - """Test Nuage VSP Public IP Range creation and deletion - """ - - # 1. Create a public IP range (VLAN IP range), check if it is - # successfully created in the zone and the physical network. - # 2. Delete the created public IP range (VLAN IP range), check if it is - # successfully deleted from the zone and the physical network. - # 3. Delete all the created objects (cleanup). - - self.debug("Creating a public IP range...") - public_ip_range = self.create_PublicIpRange() - self.validate_PublicIpRange(public_ip_range) - self.debug("Public IP range successfully created") - - self.debug("Deleting the created public IP range...") - public_ip_range.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIpRange(public_ip_range) - self.debug("Public IP range successfully deleted") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_nuage_StaticNAT_underlay_public_ip_range(self): - """Test Nuage VSP Nuage Underlay (underlay networking) enabled Public - IP Range creation and deletion - """ - - # 1. Create a public IP range (VLAN IP range), check if it is - # successfully created in the zone and the physical network. - # 2. Enable Nuage underlay capability (underlay networking) for the - # created public IP range (VLAN IP range), check if the Nuage - # underlay (underlay networking) capability is successfully enabled - # for the created public IP range (VLAN IP range). - # 3. Disable Nuage underlay capability (underlay networking) for the - # created public IP range (VLAN IP range), check if the Nuage - # underlay (underlay networking) capability is successfully disabled - # for the created public IP range (VLAN IP range). - # 4. Delete the created public IP range (VLAN IP range), check if it is - # successfully deleted from the zone and the physical network. - # 5. Delete all the created objects (cleanup). - - self.debug("Creating a public IP range...") - public_ip_range = self.create_PublicIpRange() - self.validate_PublicIpRange(public_ip_range) - self.debug("Public IP range successfully created") - - self.debug("Enabling Nuage underlay capability (underlay networking) " - "for the created public IP range...") - self.enable_NuageUnderlayPublicIpRange(public_ip_range.vlan.id) - self.validate_NuageUnderlayPublicIpRange(public_ip_range) - self.debug("Nuage underlay capability (underlay networking) for the " - "created public IP range is successfully enabled") - - self.debug("Disabling Nuage underlay capability (underlay networking) " - "for the created public IP range...") - self.disable_NuageUnderlayPublicIpRange(public_ip_range) - with self.assertRaises(Exception): - self.validate_NuageUnderlayPublicIpRange(public_ip_range) - self.debug("Nuage underlay capability (underlay networking) for the " - "created public IP range is successfully disabled") - - self.debug("Deleting the created public IP range...") - public_ip_range.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIpRange(public_ip_range) - self.debug("Public IP range successfully deleted") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_nuage_StaticNAT_isolated_networks(self): - """Test Nuage VSP Isolated networks with different combinations of - Static NAT service providers - """ - - # 1. Create Nuage VSP Isolated Network offering with different - # combinations of Static NAT service providers - # (NuageVsp, VirtualRouter, no StaticNat service), check if all the - # network offerings are successfully created and enabled. - # 2. Recreate the above created Network offering - # (Static NAT service provider as NuageVsp) with ispersistent flag - # set to True, check if the network offering is successfully created - # and enabled. - # 3. Recreate the above created Network offering - # (Static NAT service provider as NuageVsp) with conserve mode On - # (conserve_mode flag set to True), check if the network offering is - # successfully created and enabled. - # 4. Create an Isolated network with Static NAT service provider as - # NuageVsp, spawn a VM, and create a Static NAT rule. Check if the - # network is successfully created, and the VM along with the VR is - # deployed successfully in the network, verify if the Static NAT - # functionality for this network is successfully enabled in VSD. - # 5. Create a persistent Isolated network with Static NAT service - # provider as NuageVsp, spawn a VM, and create a Static NAT rule. - # Check if the network is successfully created, and the VM along - # with the VR is deployed successfully in the network, verify if the - # Static NAT functionality for this network is successfully enabled - # in VSD. - # 6. Create a conserved Isolated network (conserve mode On) with Static - # NAT service provider as NuageVsp, spawn a VM, and create a Static - # NAT rule. Check if the network is successfully created, and the VM - # along with the VR is deployed successfully in the network, verify - # if the Static NAT functionality for this network is successfully - # enabled in VSD. - # 7. Create an Isolated network with Static NAT service provider as - # VirtualRouter, spawn a VM, and create a Static NAT rule. Check if - # the network is successfully created, and the VM along with the VR - # is deployed successfully in the network, verify if the Static NAT - # functionality for this network is not enabled in VSD as Nuage VSP - # does not support VirtualRouter as the Static NAT service provider. - # 8. Create an Isolated network with no Static NAT service, spawn a VM, - # and create a Static NAT rule. Check if the network is successfully - # created, and the VM along with the VR is deployed successfully in - # the network, verify if the Static NAT functionality for this - # network is not enabled in both CloudStack and VSD as the network - # does not support Static NAT service. - # 9. Delete all the created objects (cleanup). - - # Creating network offerings - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as NuageVsp...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Recreating above Network offering with ispersistent " - "True...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["ispersistent"] = "True" - net_off_2 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - self.debug("Recreating above Network offering with conserve mode " - "On...") - net_off_3 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"], - conserve_mode=True) - self.validate_NetworkOffering(net_off_3, state="Enabled") - - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as VirtualRouter...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["serviceProviderList"]["StaticNat"] = "VirtualRouter" - net_off_4 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_4, state="Enabled") - - self.debug("Creating Nuage VSP Isolated Network offering without " - "Static NAT service...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["supportedservices"] = \ - 'Dhcp,SourceNat,Connectivity,UserData,Firewall,Dns' - del network_offering["serviceProviderList"]["StaticNat"] - net_off_5 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_5, state="Enabled") - - self.debug("Creating persistent Nuage VSP Isolated Network offering " - "without VR so no userData and Dns...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["ispersistent"] = "True" - network_offering["supportedservices"] = \ - 'Dhcp,SourceNat,Connectivity,StaticNat,Firewall' - del network_offering["serviceProviderList"]["UserData"] - del network_offering["serviceProviderList"]["Dns"] - net_off_6 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_6, state="Enabled") - - # Creating Isolated networks, and deploying VMs - self.debug("Creating an Isolated network with Static NAT service " - "provider as NuageVsp...") - network_1 = self.create_Network(net_off_1, gateway='10.1.1.1') - self.validate_Network(network_1, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(network_1) - self.validate_Network(network_1, state="Implemented") - vr_1 = self.get_Router(network_1) - self.check_Router_state(vr_1, state="Running") - self.check_VM_state(vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(vm_1) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip = self.acquire_PublicIPAddress(network_1) - self.validate_PublicIPAddress(public_ip, network_1) - self.create_StaticNatRule_For_VM(vm_1, public_ip, network_1) - self.validate_PublicIPAddress( - public_ip, network_1, static_nat=True, vm=vm_1) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_1, vm_1, public_ip.ipaddress) - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the deployed VM...") - self.delete_StaticNatRule_For_VM(public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip, network_1, static_nat=True, vm=vm_1) - self.debug("Static NAT Rule for the deployed VM successfully deleted " - "in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip(network_1, vm_1, public_ip.ipaddress) - self.debug("Floating IP for the deployed VM successfully deleted in " - "VSD") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created Isolated " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network_1) - self.debug("Acquired public IP in the created Isolated network " - "successfully released in CloudStack") - self.delete_VM(vm_1) - - # Bug CLOUDSTACK-9398 - """ - self.debug("Creating a persistent Isolated network with Static NAT " - "service...") - network_2 = self.create_Network(net_off_2, gateway='10.1.1.1') - self.validate_Network(network_2, state="Implemented") - vr_2 = self.get_Router(network_2) - self.check_Router_state(vr_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_2) - self.verify_vsd_router(vr_2) - - self.debug("Deploying a VM in the created Isolated network...") - vm_2 = self.create_VM(network_2) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vm_2) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule in the created Isolated network " - "with its deployed VM...") - public_ip = self.acquire_PublicIPAddress(network_2) - self.validate_PublicIPAddress(public_ip, network_2) - self.create_StaticNatRule_For_VM(vm_2, public_ip, network_2) - self.validate_PublicIPAddress( - public_ip, network_2, static_nat=True, vm=vm_2) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_2, vm_2, public_ip.ipaddress) - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the deployed VM...") - self.delete_StaticNatRule_For_VM(public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip, network_2, static_nat=True, vm=vm_2) - self.debug("Static NAT Rule for the deployed VM successfully deleted " - "in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip(network_2, vm_2, public_ip.ipaddress) - self.debug("Floating IP for the deployed VM successfully deleted in " - "VSD") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created Isolated " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network_2) - self.debug("Acquired public IP in the created Isolated network " - "successfully released in CloudStack") - self.delete_VM(vm_2) - """ - - self.debug("Creating an Isolated network with Static NAT service and " - "conserve mode On...") - network_3 = self.create_Network(net_off_3, gateway='10.1.1.1') - self.validate_Network(network_3, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_3 = self.create_VM(network_3) - self.validate_Network(network_3, state="Implemented") - vr_3 = self.get_Router(network_3) - self.check_Router_state(vr_3, state="Running") - self.check_VM_state(vm_3, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_3) - self.verify_vsd_router(vr_3) - self.verify_vsd_vm(vm_3) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule in the created Isolated network " - "with its deployed VM...") - public_ip = self.acquire_PublicIPAddress(network_3) - self.validate_PublicIPAddress(public_ip, network_3) - self.create_StaticNatRule_For_VM(vm_3, public_ip, network_3) - self.validate_PublicIPAddress( - public_ip, network_3, static_nat=True, vm=vm_3) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_3, vm_3, public_ip.ipaddress) - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the deployed VM...") - self.delete_StaticNatRule_For_VM(public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip, network_3, static_nat=True, vm=vm_3) - self.debug("Static NAT Rule for the deployed VM successfully deleted " - "in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip(network_3, vm_3, public_ip.ipaddress) - self.debug("Floating IP for the deployed VM successfully deleted in " - "VSD") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created Isolated " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network_3) - self.debug("Acquired public IP in the created Isolated network " - "successfully released in CloudStack") - self.delete_VM(vm_3) - - self.debug("Creating an Isolated network with Static NAT service " - "provider as VirtualRouter...") - network_4 = self.create_Network(net_off_4, gateway='10.1.1.1') - self.validate_Network(network_4, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_4 = self.create_VM(network_4) - self.validate_Network(network_4, state="Implemented") - vr_4 = self.get_Router(network_4) - self.check_Router_state(vr_4, state="Running") - self.check_VM_state(vm_4, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_4) - self.verify_vsd_router(vr_4) - self.verify_vsd_vm(vm_4) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule in the created Isolated network " - "with its deployed VM...") - public_ip = self.acquire_PublicIPAddress(network_4) - self.validate_PublicIPAddress(public_ip, network_4) - self.create_StaticNatRule_For_VM(vm_4, public_ip, network_4) - self.validate_PublicIPAddress( - public_ip, network_4, static_nat=True, vm=vm_4) - - # VSD verification for Static NAT functionality - with self.assertRaises(Exception): - self.verify_vsd_floating_ip(network_4, vm_4, public_ip.ipaddress) - self.debug("Nuage VSP does not support VirtualRouter as the Static " - "NAT service provider") - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the deployed VM...") - self.delete_StaticNatRule_For_VM(public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip, network_4, static_nat=True, vm=vm_4) - self.debug("Static NAT Rule for the deployed VM successfully deleted " - "in CloudStack") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created Isolated " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network_4) - self.debug("Acquired public IP in the created Isolated network " - "successfully released in CloudStack") - self.delete_VM(vm_4) - - self.debug("Creating an Isolated network with no Static NAT " - "service...") - network_5 = self.create_Network(net_off_5, gateway='10.1.1.1') - self.validate_Network(network_5, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_5 = self.create_VM(network_5) - self.validate_Network(network_5, state="Implemented") - vr_5 = self.get_Router(network_5) - self.check_Router_state(vr_5, state="Running") - self.check_VM_state(vm_5, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_5) - self.verify_vsd_router(vr_5) - self.verify_vsd_vm(vm_5) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule in the created Isolated network " - "with its deployed VM...") - public_ip = self.acquire_PublicIPAddress(network_5) - self.validate_PublicIPAddress(public_ip, network_5) - with self.assertRaises(Exception): - self.create_StaticNatRule_For_VM(vm_5, public_ip, network_5) - self.debug("Static NAT rule creation failed as the network does not " - "support Static NAT service") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created Isolated " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network_5) - self.debug("Acquired public IP in the created Isolated network " - "successfully released in CloudStack") - self.delete_VM(vm_5) - - self.debug("Creating a persistent Isolated network with Static NAT " - "service without UserData Dns, so without VR") - network_6 = self.create_Network(net_off_6, gateway='10.6.1.1') - self.validate_Network(network_6, state="Implemented") - - self.debug("Deploying a VM in the created Isolated network...") - vm_6 = self.create_VM(network_6) - self.validate_Network(network_6, state="Implemented") - - with self.assertRaises(Exception): - self.get_Router(network_6) - - # VSD verification - self.verify_vsd_network(self.domain.id, network_6) - self.verify_vsd_vm(vm_6) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule in the created Isolated network " - "with its deployed VM...") - public_ip = self.acquire_PublicIPAddress(network_6) - self.validate_PublicIPAddress(public_ip, network_6) - self.create_StaticNatRule_For_VM(vm_6, public_ip, network_6) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_6, vm_6, public_ip.ipaddress) - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the deployed VM...") - self.delete_StaticNatRule_For_VM(public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip, network_6, static_nat=True, vm=vm_6) - self.debug("Static NAT Rule for the deployed VM successfully deleted " - "in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip(network_6, vm_6, public_ip.ipaddress) - self.debug("Floating IP for the deployed VM successfully deleted in " - "VSD") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created Isolated " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, network_6) - self.debug("Acquired public IP in the created Isolated network " - "successfully released in CloudStack") - self.delete_VM(vm_6) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_nuage_StaticNAT_vpc_networks(self): - """Test Nuage VSP VPC networks with different combinations of Static - NAT service providers - """ - - # 1. Create Nuage VSP VPC offering with different combinations of - # Static NAT service providers - # (NuageVsp, VirtualRouter, no StaticNat service), check if all the - # VPC offerings are successfully created and enabled. - # 2. Create VPCs with different combinations of Static NAT service - # providers (NuageVsp, VirtualRouter, no StaticNat service), check - # if only the VPCs with Static NAT service provider as NuageVsp and - # no StaticNat service are successfully created and enabled. - # 3. Create Nuage VSP VPC Network offering with different combinations - # of Static NAT service providers - # (NuageVsp, VirtualRouter, no StaticNat service), check if all the - # network offerings are successfully created and enabled. - # 4. Recreate the above created Network offering - # (Static NAT service provider as NuageVsp) with ispersistent flag - # set to False, check if the network offering is successfully - # created and enabled. - # 5. Recreate the above created Network offering - # (Static NAT service provider as NuageVsp) with conserve mode On - # (conserve_mode flag set to True), check if the network offering - # creation failed as only networks with conserve mode Off can belong - # to VPC. - # 6. Create a VPC network with Static NAT service provider as NuageVsp - # in the VPC with StaticNat service, spawn a VM, and create a Static - # NAT rule. Check if the tier is added to the VPC VR, and the VM is - # deployed successfully in the tier, verify if the Static NAT - # functionality for this network is successfully enabled in VSD. - # 7. Create a non persistent VPC network with Static NAT service - # provider as NuageVsp in the VPC with StaticNat service, spawn a - # VM, and create a Static NAT rule. Check if the tier creation - # failed as Nuage VSP does not support non persistent VPC networks. - # 8. Create a VPC network with Static NAT service provider as - # VpcVirtualRouter in the VPC with StaticNat service, spawn a VM, - # and create a Static NAT rule. Check if the tier is added to the - # VPC VR, and the VM is deployed successfully in the tier, verify if - # the Static NAT functionality for this network is not enabled in - # VSD as Nuage VSP does not support VirtualRouter as the Static NAT - # service provider. - # 9. Create a VPC network with no Static NAT service in the VPC with - # StaticNat service, spawn a VM, and create a Static NAT rule. Check - # if the tier is added to the VPC VR, and the VM is deployed - # successfully in the tier, verify if the Static NAT functionality - # for this network is not enabled in both CloudStack and VSD as the - # network does not support Static NAT service. - # 10. Create a VPC network with Static NAT service provider as NuageVsp - # in the VPC without StaticNat service, check if the tier creation - # failed as the VPC does not support Static NAT service. - # 11. Delete all the created objects (cleanup). - - # Creating VPC offerings - self.debug("Creating Nuage VSP VPC offering with Static NAT service " - "provider as NuageVsp...") - vpc_off_1 = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering with Static NAT service " - "provider as VpcVirtualRouter...") - vpc_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_offering"]) - vpc_offering["serviceProviderList"]["StaticNat"] = "VpcVirtualRouter" - vpc_off_2 = self.create_VpcOffering(vpc_offering) - self.validate_VpcOffering(vpc_off_2, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering without Static NAT " - "service...") - vpc_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_offering"]) - vpc_offering["supportedservices"] = \ - 'Dhcp,SourceNat,NetworkACL,Connectivity,UserData,Dns' - del vpc_offering["serviceProviderList"]["StaticNat"] - vpc_off_3 = self.create_VpcOffering(vpc_offering) - self.validate_VpcOffering(vpc_off_3, state="Enabled") - - # Creating VPCs - self.debug("Creating a VPC with Static NAT service provider as " - "NuageVsp...") - vpc_1 = self.create_vpc(vpc_off_1, cidr='10.1.0.0/16') - self.validate_vpc(vpc_1, state="Enabled") - - self.debug("Creating a VPC with Static NAT service provider as " - "VpcVirtualRouter...") - with self.assertRaises(Exception): - self.create_vpc(vpc_off_2, cidr='10.1.0.0/16') - self.debug("Nuage VSP does not support provider VpcVirtualRouter for " - "service Static NAT for VPCs") - - self.debug("Creating a VPC without Static NAT service...") - vpc_2 = self.create_vpc(vpc_off_3, cidr='10.1.0.0/16') - self.validate_vpc(vpc_2, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Static NAT " - "service provider as NuageVsp...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Recreating above Network offering with ispersistent " - "False...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - network_offering["ispersistent"] = "False" - net_off_2 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - self.debug("Recreating above Network offering with conserve mode " - "On...") - with self.assertRaises(Exception): - self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"], - conserve_mode=True) - self.debug("Network offering creation failed as only networks with " - "conserve mode Off can belong to VPC") - - self.debug("Creating Nuage VSP VPC Network offering with Static NAT " - "service provider as VpcVirtualRouter...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - network_offering["serviceProviderList"]["StaticNat"] = \ - "VpcVirtualRouter" - net_off_3 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_3, state="Enabled") - - self.debug("Creating Nuage VSP VPC Network offering without Static " - "NAT service...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - network_offering["supportedservices"] = \ - 'Dhcp,SourceNat,NetworkACL,Connectivity,UserData,Dns' - del network_offering["serviceProviderList"]["StaticNat"] - net_off_4 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_4, state="Enabled") - - # Creating VPC networks in the VPCs, and deploying VMs - self.debug("Creating a VPC network with Static NAT service provider " - "as NuageVsp in vpc_1...") - vpc_tier_1 = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc_1) - self.validate_Network(vpc_tier_1, state="Implemented") - vpc_vr = self.get_Router(vpc_tier_1) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier_1, vpc_1) - self.verify_vsd_router(vpc_vr) - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm_1 = self.create_VM(vpc_tier_1) - self.check_VM_state(vpc_vm_1, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_1) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule in the created VPC network with " - "its deployed VM...") - public_ip = self.acquire_PublicIPAddress(vpc_tier_1, vpc=vpc_1) - self.validate_PublicIPAddress(public_ip, vpc_tier_1) - self.create_StaticNatRule_For_VM(vpc_vm_1, public_ip, vpc_tier_1) - self.validate_PublicIPAddress( - public_ip, vpc_tier_1, static_nat=True, vm=vpc_vm_1) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier_1, vpc_vm_1, public_ip.ipaddress, vpc=vpc_1) - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the deployed VM...") - self.delete_StaticNatRule_For_VM(public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip, vpc_tier_1, static_nat=True, vm=vpc_vm_1) - self.debug("Static NAT Rule for the deployed VM successfully deleted " - "in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip( - vpc_tier_1, vpc_vm_1, public_ip.ipaddress, vpc=vpc_1) - self.debug("Floating IP for the deployed VM successfully deleted in " - "VSD") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created VPC " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, vpc_tier_1) - self.debug("Acquired public IP in the created VPC network " - "successfully released in CloudStack") - - self.debug("Creating a non persistent VPC network with Static NAT " - "service in vpc_1...") - with self.assertRaises(Exception): - self.create_Network(net_off_2, gateway='10.1.2.1', vpc=vpc_1) - self.debug("Nuage VSP does not support non persistent VPC networks") - - self.debug("Creating a VPC network with Static NAT service provider " - "as VpcVirtualRouter in vpc_1...") - with self.assertRaises(Exception): - self.create_Network(net_off_3, gateway='10.1.2.1', vpc=vpc_1) - self.debug("Provider VpcVirtualRouter is not supported for Static NAT " - "service in VPC vpc_1") - - self.debug("Creating a VPC network with no Static NAT service in " - "vpc_1...") - vpc_tier_2 = self.create_Network( - net_off_4, gateway='10.1.2.1', vpc=vpc_1) - self.validate_Network(vpc_tier_2, state="Implemented") - vpc_vr = self.get_Router(vpc_tier_2) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier_2, vpc_1) - self.verify_vsd_router(vpc_vr) - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm_2 = self.create_VM(vpc_tier_2) - self.check_VM_state(vpc_vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_2) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule in the created VPC network with " - "its deployed VM...") - public_ip = self.acquire_PublicIPAddress(vpc_tier_2, vpc=vpc_1) - self.validate_PublicIPAddress(public_ip, vpc_tier_2) - with self.assertRaises(Exception): - self.create_StaticNatRule_For_VM(vpc_vm_2, public_ip, vpc_tier_2) - self.debug("Static NAT rule creation failed as the network does not " - "support Static NAT service") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP in the created VPC " - "network...") - public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(public_ip, vpc_tier_2) - self.debug("Acquired public IP in the created VPC network " - "successfully released in CloudStack") - - self.debug("Creating a VPC network with Static NAT service provider " - "as NuageVsp in vpc_2...") - with self.assertRaises(Exception): - self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc_2) - self.debug("VPC Network creation failed as vpc_2 does not support " - "Static NAT service") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_05_nuage_StaticNAT_isolated_networks_traffic(self): - """Test Nuage VSP Static NAT functionality for Isolated network by - performing (wget) traffic tests to the Internet - """ - - # 1. Create an Isolated network with Static NAT service provider as - # NuageVsp, spawn a VM, and create a Static NAT rule. Check if the - # network is successfully created, and the VM along with the VR is - # deployed successfully in the network, verify if the Static NAT - # functionality for this network is successfully enabled in VSD. - # 2. Perform and verify Static NAT traffic test (wget www.google.com) - # to the Internet from the deployed VM. - # 3. Deploy another VM in the created Isolated network and create a - # Static NAT rule. Check if the VM is deployed successfully in the - # network, verify if the Static NAT functionality for this network - # is successfully enabled in VSD. - # 4. Perform and verify Static NAT traffic test (wget www.google.com) - # to the Internet from the deployed VM. - # 5. Delete all the created objects (cleanup). - # Note: Above mentioned Static NAT traffic test is done by SSHing into - # the VM using a Static NAT rule, and performing wget traffic - # test (wget www.google.com) to the Internet from the VM. - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - self.debug("Creating persistent Nuage VSP Isolated Network offering " - "without VR so no userData and Dns...") - network_offering = copy.deepcopy( - self.test_data["nuagevsp"]["isolated_network_offering"]) - network_offering["ispersistent"] = "True" - network_offering["supportedservices"] = \ - 'Dhcp,SourceNat,Connectivity,StaticNat,Firewall' - del network_offering["serviceProviderList"]["UserData"] - del network_offering["serviceProviderList"]["Dns"] - net_off_2 = self.create_NetworkOffering(network_offering) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - # Creating Isolated network, deploying VMs, and verifying Static NAT - # traffic - self.debug("Creating an Isolated network with Static NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Creating a persistent Isolated network with Static NAT " - "service without UserData Dns, so without VR") - network_2 = self.create_Network(net_off_2, gateway='10.2.1.1') - self.validate_Network(network_2, state="Implemented") - - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - vm_21 = self.create_VM(network_2) - self.validate_Network(network_2, state="Implemented") - - with self.assertRaises(Exception): - self.get_Router(network_2) - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - self.verify_vsd_network(self.domain.id, network_2) - self.verify_vsd_vm(vm_21) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_1 = self.acquire_PublicIPAddress(network) - self.validate_PublicIPAddress(public_ip_1, network) - self.create_StaticNatRule_For_VM(vm_1, public_ip_1, network) - self.validate_PublicIPAddress( - public_ip_1, network, static_nat=True, vm=vm_1) - public_ip_21 = self.acquire_PublicIPAddress(network_2) - self.validate_PublicIPAddress(public_ip_21, network_2) - self.create_StaticNatRule_For_VM(vm_21, public_ip_21, network_2) - self.validate_PublicIPAddress( - public_ip_21, network_2, static_nat=True, vm=vm_21) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm_1, public_ip_1.ipaddress) - self.verify_vsd_floating_ip(network_2, vm_21, public_ip_21.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - self.verify_StaticNAT_traffic(network_2, public_ip_21) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm_1, network, public_ip_1) - self.verify_StaticNAT_Internet_traffic(vm_21, network_2, public_ip_21) - - self.debug("Deploying another VM in the created Isolated network...") - vm_2 = self.create_VM(network) - self.check_VM_state(vm_2, state="Running") - vm_22 = self.create_VM(network_2) - self.check_VM_state(vm_22, state="Running") - - # VSD verification - self.verify_vsd_vm(vm_2) - self.verify_vsd_vm(vm_22) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_2 = self.acquire_PublicIPAddress(network) - self.validate_PublicIPAddress(public_ip_2, network) - self.create_StaticNatRule_For_VM(vm_2, public_ip_2, network) - self.validate_PublicIPAddress( - public_ip_2, network, static_nat=True, vm=vm_2) - - public_ip_22 = self.acquire_PublicIPAddress(network_2) - self.validate_PublicIPAddress(public_ip_22, network_2) - self.create_StaticNatRule_For_VM(vm_22, public_ip_22, network_2) - self.validate_PublicIPAddress( - public_ip_22, network_2, static_nat=True, vm=vm_22) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm_2, public_ip_2.ipaddress) - self.verify_vsd_floating_ip(network_2, vm_22, public_ip_22.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_2) - self.verify_StaticNAT_traffic(network_2, public_ip_22) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm_2, network, public_ip_2) - self.verify_StaticNAT_Internet_traffic(vm_22, network_2, public_ip_22) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_06_nuage_StaticNAT_vpc_network_traffic(self): - """Test Nuage VSP Static NAT functionality for VPC network by - performing (wget) traffic tests to the Internet - """ - - # 1. Create a VPC network with Static NAT service provider as NuageVsp - # in the VPC with StaticNat service, spawn a VM, and create a Static - # NAT rule. Check if the tier is added to the VPC VR, and the VM is - # deployed successfully in the tier, verify if the Static NAT - # functionality for this network is successfully enabled in VSD. - # 2. Perform and verify Static NAT traffic test (wget www.google.com) - # to the Internet from the deployed VM. - # 3. Deploy another VM in the created VPC network and create a Static - # NAT rule. Check if the VM is deployed successfully in the network, - # verify if the Static NAT functionality for this network is - # successfully enabled in VSD. - # 4. Perform and verify Static NAT traffic test (wget www.google.com) - # to the Internet from the deployed VM. - # 5. Delete all the created objects (cleanup). - # Note: Above mentioned Static NAT traffic test is done by SSHing into - # the VM using a Static NAT rule, and performing wget traffic - # test (wget www.google.com) to the Internet from the VM. - - # Creating VPC offering - self.debug("Creating Nuage VSP VPC offering with Static NAT service " - "provider as NuageVsp...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating VPC - self.debug("Creating a VPC with Static NAT service provider as " - "NuageVsp...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offering - self.debug("Creating Nuage VSP VPC Network offering with Static NAT " - "service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating VPC network in the VPC, deploying VMs, and verifying Static - # NAT traffic - self.debug("Creating a VPC network with Static NAT service...") - vpc_tier = self.create_Network(net_off, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - - # Adding Egress Network ACL rules - self.debug("Adding Egress Network ACL rules in the created VPC " - "network to allow Static NAT (DNS & HTTP) traffic to the " - "Internet from the VMs in the network...") - dns_rule = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for added Egress Network ACL rules - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm_1 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_1, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_1) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created VPC network...") - public_ip_1 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_1, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm_1, public_ip_1, vpc_tier) - self.validate_PublicIPAddress( - public_ip_1, vpc_tier, static_nat=True, vm=vpc_vm_1) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm_1, public_ip_1.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_1, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm_1, vpc_tier, public_ip_1, vpc=vpc) - - self.debug("Deploying another VM in the created VPC network...") - vpc_vm_2 = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm_2) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created VPC network...") - public_ip_2 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_2, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm_2, public_ip_2, vpc_tier) - self.validate_PublicIPAddress( - public_ip_2, vpc_tier, static_nat=True, vm=vpc_vm_2) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm_2, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm_2, vpc_tier, public_ip_2, vpc=vpc) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_07_nuage_StaticNAT_acl_rules_traffic(self): - """Test Nuage VSP Static NAT functionality with different Egress - Firewall/Network ACL rules by performing (wget) traffic tests to the - Internet - """ - - # Repeat the tests in the testcases - # "test_05_nuage_StaticNAT_isolated_networks_traffic" and - # "test_06_nuage_StaticNAT_vpc_network_traffic" with different Egress - # Firewall/Network ACL rules: - # 1. Allow and block Egress Firewall rules - # 2. Allow and block Egress Network ACL rules - # Verify the above Egress Firewall/Network ACL rules by performing and - # verifying Static NAT traffic test (wget www.google.com) to the - # Internet from the VM. - # Delete all the created objects (cleanup). - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating Isolated network, deploying VMs, and verifying Static NAT - # traffic with Egress Firewall rules - self.debug("Creating an Isolated network with Static NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_1 = self.acquire_PublicIPAddress(network) - self.validate_PublicIPAddress(public_ip_1, network) - self.create_StaticNatRule_For_VM(vm, public_ip_1, network) - self.validate_PublicIPAddress( - public_ip_1, network, static_nat=True, vm=vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network, public_ip_1) - - # Adding Egress Firewall rule - self.debug("Adding an Egress Firewall rule in the created Isolated " - "network to block/drop Static NAT (DNS) traffic to the " - "Internet from the VMs in the network...") - dns_rule_1 = self.create_EgressFirewallRule( - network, self.test_data["dns_rule"]) - - # VSD verification for added Egress Firewall rule - self.verify_vsd_firewall_rule(dns_rule_1, traffic_type="Egress") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - with self.assertRaises(Exception): - self.verify_StaticNAT_Internet_traffic( - vm, network, public_ip_1, negative_test=True) - self.debug("Static NAT (DNS) traffic to the Internet from the " - "deployed VM is blocked/dropped by the added Egress " - "Firewall rule") - - # Removing Egress Firewall rule - self.debug("Removing the added Egress Firewall rule in the created " - "Isolated network to allow Static NAT (DNS) traffic to " - "the Internet from the VMs in the network " - "(Default Egress Firewall rule)...") - dns_rule_1.delete(self.api_client) - - # VSD verification for removed Egress Firewall rule - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(dns_rule_1, traffic_type="Egress") - self.debug("Egress Firewall rule successfully deleted in VSD") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network, public_ip_1) - - # Creating VPC offering - self.debug("Creating Nuage VSP VPC offering with Static NAT service " - "provider as NuageVsp...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating VPC - self.debug("Creating a VPC with Static NAT service provider as " - "NuageVsp...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offering - self.debug("Creating Nuage VSP VPC Network offering with Static NAT " - "service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating VPC network in the VPC, deploying VMs, and verifying Static - # NAT traffic with Network ACl rules - self.debug("Creating a VPC network with Static NAT service...") - vpc_tier = self.create_Network(net_off, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - - # Adding Egress Network ACL rules - self.debug("Adding Egress Network ACL rules in the created VPC " - "network to allow Static NAT (DNS & HTTP) traffic to the " - "Internet from the VMs in the network...") - dns_rule_2 = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for added Egress Network ACL rules - self.verify_vsd_firewall_rule(dns_rule_2, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created VPC network...") - public_ip_2 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_2, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm, public_ip_2, vpc_tier) - self.validate_PublicIPAddress( - public_ip_2, vpc_tier, static_nat=True, vm=vpc_vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - # Removing Egress Network ACL rule - self.debug("Removing the added Egress Network ACL rule in the created " - "VPC network to block Static NAT (DNS) traffic to the " - "Internet from the VMs in the network " - "(Default Egress Network ACL rule)...") - dns_rule_2.delete(self.api_client) - - # VSD verification for removed Egress Network ACL rule - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(dns_rule_2, traffic_type="Egress") - self.debug("Egress Network ACL rule successfully deleted in VSD") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - with self.assertRaises(Exception): - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc, negative_test=True) - self.debug("Static NAT (DNS) traffic to the Internet from the " - "deployed VM is blocked by the Default Egress Network ACL " - "rule") - - # Re-adding Egress Network ACL rule - self.debug("Re-adding the Egress Network ACL rule in the created VPC " - "network to allow Static NAT (DNS) traffic to the " - "Internet from the VMs in the network...") - dns_rule_2 = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for re-added Egress Network ACL rule - self.verify_vsd_firewall_rule(dns_rule_2, traffic_type="Egress") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_08_nuage_StaticNAT_vm_nic_operations_traffic(self): - """Test Nuage VSP Static NAT functionality with VM NIC operations by - performing (wget) traffic tests to the Internet - """ - - # Repeat the tests in the testcase - # "test_05_nuage_StaticNAT_isolated_networks_traffic" with VM NIC - # operations: - # 1. Updating default VM NIC - # 2. Removing non-default VM NIC - # 3. Adding and updating default VM NIC - # Verify the above VM NIC operations by performing and verifying Static - # NAT traffic test (wget www.google.com) to the Internet from the VM. - # Delete all the created objects (cleanup). - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating Isolated networks, deploying a multi-nic VM, and verifying - # Static NAT traffic with VM NIC operations - self.debug("Creating an Isolated network with Static NAT service...") - network_1 = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network_1, state="Allocated") - - self.debug("Creating another Isolated network with Static NAT " - "service...") - network_2 = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network_2, state="Allocated") - - self.debug("Deploying a multi-nic VM in the created Isolated " - "networks...") - vm = self.create_VM([network_1, network_2]) - self.validate_Network(network_1, state="Implemented") - vr_1 = self.get_Router(network_1) - self.check_Router_state(vr_1, state="Running") - self.validate_Network(network_2, state="Implemented") - vr_2 = self.get_Router(network_2) - self.check_Router_state(vr_2, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_network(self.domain.id, network_2) - self.verify_vsd_router(vr_2) - self.verify_vsd_vm(vm) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_1 = self.acquire_PublicIPAddress(network_1) - self.validate_PublicIPAddress(public_ip_1, network_1) - self.create_StaticNatRule_For_VM(vm, public_ip_1, network_1) - self.validate_PublicIPAddress( - public_ip_1, network_1, static_nat=True, vm=vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_1, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network_1, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network_1, public_ip_1) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_2 = self.acquire_PublicIPAddress(network_2) - self.validate_PublicIPAddress(public_ip_2, network_2) - self.create_StaticNatRule_For_VM(vm, public_ip_2, network_2) - self.validate_PublicIPAddress( - public_ip_2, network_2, static_nat=True, vm=vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_2, vm, public_ip_2.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic( - network_2, public_ip_2, non_default_nic=True) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vm, network_2, public_ip_2, non_default_nic=True) - - # Updating default VM NIC - self.debug("Updating the default nic of the multi-nic VM...") - self.nic_operation_VM(vm, network_2, operation="update") - - # Rebooting (stop - start) VM - self.debug("Rebooting the multi-nic VM after updating its default nic " - "for changes to apply to the VM...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.check_VM_state(vm, state="Running") - - # VSD verification - updated_vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - self.verify_vsd_vm(updated_vm_info) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_1, vm, public_ip_1.ipaddress) - self.verify_vsd_floating_ip(network_2, vm, public_ip_2.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic( - network_1, public_ip_1, non_default_nic=True) - self.verify_StaticNAT_traffic(network_2, public_ip_2) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vm, network_1, public_ip_1, non_default_nic=True) - self.verify_StaticNAT_Internet_traffic(vm, network_2, public_ip_2) - - # Removing non-default VM NIC - self.debug("Removing the non-default nic of the multi-nic VM...") - with self.assertRaises(Exception): - self.nic_operation_VM(vm, network_1, operation="remove") - self.debug("Can not remove this NIC as Static NAT rule is enabled on " - "it") - - # Deleting Static NAT Rule - self.debug("Deleting Static NAT Rule for the deployed VM...") - self.delete_StaticNatRule_For_VM(public_ip_1) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - public_ip_1, network_1, static_nat=True, vm=vm) - self.debug("Static NAT Rule for the deployed VM successfully deleted " - "in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip(network_1, vm, public_ip_1.ipaddress) - self.debug("Floating IP for the deployed VM successfully deleted in " - "VSD") - - self.nic_operation_VM(vm, network_1, operation="remove") - - # Rebooting (stop - start) VM - self.debug("Rebooting the multi-nic VM after removing its non-default " - "nic for changes to apply to the VM...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.check_VM_state(vm, state="Running") - - # VSD verification - updated_vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - self.verify_vsd_vm(updated_vm_info) - - # VSD verification for Static NAT functionality - with self.assertRaises(Exception): - self.verify_vsd_floating_ip(network_1, vm, public_ip_1.ipaddress) - self.debug("Static NAT rule not enabled in this VM NIC") - self.verify_vsd_floating_ip(network_2, vm, public_ip_2.ipaddress) - - # Verifying Static NAT traffic - if not self.isSimulator: - with self.assertRaises(AssertionError): - self.verify_StaticNAT_traffic(network_1, public_ip_1) - self.debug("Static NAT rule not enabled in this VM NIC") - self.verify_StaticNAT_traffic(network_2, public_ip_2) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - if not self.isSimulator: - with self.assertRaises(Exception): - self.verify_StaticNAT_Internet_traffic(vm, network_1, - public_ip_1) - self.debug("Static NAT rule not enabled in this VM NIC") - self.verify_StaticNAT_Internet_traffic(vm, network_2, public_ip_2) - - # Adding and updating default VM NIC - self.debug("Re-adding the non-default nic and updating the default " - "nic of the multi-nic VM...") - self.nic_operation_VM(vm, network_1, operation="add") - self.nic_operation_VM(vm, network_1, operation="update") - - # Rebooting (stop - start) VM - self.debug("Rebooting the multi-nic VM after re-adding its " - "non-default nic for changes to apply to the VM...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.check_VM_state(vm, state="Running") - - # VSD verification - updated_vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - self.verify_vsd_vm(updated_vm_info) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - self.create_StaticNatRule_For_VM(vm, public_ip_1, network_1) - self.validate_PublicIPAddress( - public_ip_1, network_1, static_nat=True, vm=vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network_1, vm, public_ip_1.ipaddress) - self.verify_vsd_floating_ip(network_2, vm, public_ip_2.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network_1, public_ip_1) - self.verify_StaticNAT_traffic( - network_2, public_ip_2, non_default_nic=True) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network_1, public_ip_1) - self.verify_StaticNAT_Internet_traffic( - vm, network_2, public_ip_2, non_default_nic=True) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_09_nuage_StaticNAT_vm_migration_traffic(self): - """Test Nuage VSP Static NAT functionality with VM migration by - performing (wget) traffic tests to the Internet - """ - - # Repeat the tests in the testcase - # "test_05_nuage_StaticNAT_isolated_networks_traffic" with migration of - # one of the VMs to another host (if available). - # Verify the above VM migration by performing and verifying Static NAT - # traffic test (wget www.google.com) to the Internet from the VM. - # Delete all the created objects (cleanup). - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating an Isolated network, deploying VMs, and verifying Static - # NAT traffic with VM migrations - self.debug("Creating an Isolated network with Static NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm_1 = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_1 = self.acquire_PublicIPAddress(network) - self.validate_PublicIPAddress(public_ip_1, network) - self.create_StaticNatRule_For_VM(vm_1, public_ip_1, network) - self.validate_PublicIPAddress( - public_ip_1, network, static_nat=True, vm=vm_1) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm_1, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm_1, network, public_ip_1) - - self.debug("Deploying another VM in the created Isolated network...") - vm_2 = self.create_VM(network) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vm_2) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_2 = self.acquire_PublicIPAddress(network) - self.validate_PublicIPAddress(public_ip_2, network) - self.create_StaticNatRule_For_VM(vm_2, public_ip_2, network) - self.validate_PublicIPAddress( - public_ip_2, network, static_nat=True, vm=vm_2) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm_2, public_ip_2.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_2) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm_2, network, public_ip_2) - - # VM migration - # This VM migration has no effect on the Static NAT functionality - self.debug("Migrating one of the VMs in the created Isolated network " - "to another host, if available...") - self.migrate_VM(vm_1) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm_1, public_ip_1.ipaddress) - self.verify_vsd_floating_ip(network, vm_2, public_ip_2.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - self.verify_StaticNAT_traffic(network, public_ip_2) - - # VSD verification for Static NAT functionality - self.verify_StaticNAT_Internet_traffic(vm_1, network, public_ip_1) - self.verify_StaticNAT_Internet_traffic(vm_2, network, public_ip_2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_10_nuage_StaticNAT_network_restarts_traffic(self): - """Test Nuage VSP Static NAT functionality with network restarts by - performing (wget) traffic tests to the Internet - """ - - # Repeat the tests in the testcases - # "test_05_nuage_StaticNAT_isolated_networks_traffic" and - # "test_06_nuage_StaticNAT_vpc_network_traffic" with network restarts: - # 1. Restart Isolated Network (cleanup = false) - # 2. Restart Isolated Network (cleanup = true) - # 3. Reboot VM in the Isolated Network - # 4. Restart VPC Network (cleanup = false) - # 5. Restart VPC Network (cleanup = true) - # 6. Reboot VM in the VPC Network - # 7. Restart VPC (cleanup = false) - # 8. Restart VPC (cleanup = true) - # Verify the above network restarts by performing and verifying Static - # NAT traffic test (wget www.google.com) to the Internet from the VM. - # Delete all the created objects (cleanup). - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating an Isolated network, deploying a VM, and verifying Static - # NAT traffic with Isolated network restarts - self.debug("Creating an Isolated network with Static NAT service...") - network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(network, state="Allocated") - - self.debug("Deploying a VM in the created Isolated network...") - vm = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created Isolated network...") - public_ip_1 = self.acquire_PublicIPAddress(network) - self.validate_PublicIPAddress(public_ip_1, network) - self.create_StaticNatRule_For_VM(vm, public_ip_1, network) - self.validate_PublicIPAddress( - public_ip_1, network, static_nat=True, vm=vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network, public_ip_1) - - # Restarting Isolated network (cleanup = false) - # VR gets destroyed and deployed again in the Isolated network - # This restart has no effect on the Static NAT functionality - self.debug("Restarting the created Isolated network without " - "cleanup...") - Network.restart(network, self.api_client, cleanup=False) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network, public_ip_1) - - # Restarting Isolated network (cleanup = true) - # VR gets destroyed and deployed again in the Isolated network - # This restart has no effect on the Static NAT functionality - self.debug("Restarting the created Isolated network with cleanup...") - Network.restart(network, self.api_client, cleanup=True) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network, public_ip_1) - - # Rebooting (stop - start) VM - # This reboot has no effect on the Static NAT functionality - self.debug("Rebooting the deployed VM in the created Isolated " - "network...") - vm.stop(self.api_client) - vm.start(self.api_client) - self.validate_Network(network, state="Implemented") - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(network, vm, public_ip_1.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(network, public_ip_1) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic(vm, network, public_ip_1) - - # Creating VPC offering - self.debug("Creating Nuage VSP VPC offering with Static NAT service " - "provider as NuageVsp...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating VPC - self.debug("Creating a VPC with Static NAT service provider as " - "NuageVsp...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating VPC network offering - self.debug("Creating Nuage VSP VPC Network offering with Static NAT " - "service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating a VPC network in the VPC, deploying a VM, and verifying - # Static NAT traffic with VPC network restarts - self.debug("Creating a VPC network with Static NAT service...") - vpc_tier = self.create_Network(net_off, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - - # Adding Egress Network ACL rules - self.debug("Adding Egress Network ACL rules in the created VPC " - "network to allow Static NAT (DNS & HTTP) traffic to the " - "Internet from the VMs in the network...") - dns_rule = self.create_NetworkAclRule( - self.test_data["dns_rule"], traffic_type="Egress", - network=vpc_tier) - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], traffic_type="Egress", - network=vpc_tier) - - # VSD verification for added Egress Network ACL rules - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - self.debug("Deploying a VM in the created VPC network...") - vpc_vm = self.create_VM(vpc_tier) - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_vm(vpc_vm) - - # Creating Static NAT rule - self.debug("Creating Static NAT rule for the deployed VM in the " - "created VPC network...") - public_ip_2 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_2, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm, public_ip_2, vpc_tier) - self.validate_PublicIPAddress( - public_ip_2, vpc_tier, static_nat=True, vm=vpc_vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - # Restarting VPC network (cleanup = false) - # This restart has no effect on the Static NAT functionality - self.debug("Restarting the created VPC network without cleanup...") - Network.restart(vpc_tier, self.api_client, cleanup=False) - self.validate_Network(vpc_tier, state="Implemented") - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - # Restarting VPC network (cleanup = true) - # This restart has no effect on the Static NAT functionality - self.debug("Restarting the created VPC network with cleanup...") - Network.restart(vpc_tier, self.api_client, cleanup=True) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - # Rebooting (stop - start) VM - # This reboot has no effect on the Static NAT functionality - self.debug("Rebooting the deployed VM in the created VPC network...") - vpc_vm.stop(self.api_client) - vpc_vm.start(self.api_client) - self.validate_Network(vpc_tier, state="Implemented") - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - # Restarting VPC (cleanup = false) - # VPC VR gets destroyed and deployed again in the VPC - # This restart has no effect on the Static NAT functionality - self.debug("Restarting the VPC without cleanup...") - self.restart_Vpc(vpc, cleanup=False) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - # Restarting VPC (cleanup = true) - # VPC VR gets destroyed and deployed again in the VPC - # This restart has no effect on the Static NAT functionality - self.debug("Restarting the VPC with cleanup...") - self.restart_Vpc(vpc, cleanup=True) - self.validate_Network(vpc_tier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - self.check_VM_state(vpc_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_tier, vpc) - self.verify_vsd_router(vpc_vr) - self.verify_vsd_vm(vpc_vm) - self.verify_vsd_firewall_rule(dns_rule, traffic_type="Egress") - self.verify_vsd_firewall_rule(http_rule, traffic_type="Egress") - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip( - vpc_tier, vpc_vm, public_ip_2.ipaddress, vpc=vpc) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(vpc_tier, public_ip_2, vpc=vpc) - - # Verifying Static NAT traffic (wget www.google.com) to the Internet - # from the deployed VM - self.verify_StaticNAT_Internet_traffic( - vpc_vm, vpc_tier, public_ip_2, vpc=vpc) - - # Bug CLOUDSTACK-9751 - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_11_nuage_enable_staticNat_when_vr_is_in_starting_state(self): - """Test Nuage VSP Static NAT functionality by enabling Static Nat when - VR is in starting state - """ - - # 1. Create a Nuage VSP Isolated network offering. - # 2. Create an Isolated network with above created offering. - # 3. Deploy a VM in the above created Isolated network, - # which starts a VR. - # 4. While VR is in the starting state, acquire a public IP and enable - # static nat in another thread. - # 5. Verify that Static NAT is successfully enabled in both CloudStack - # and VSD. - # 6. Delete all the created objects (cleanup). - - # Creating network offering - self.debug("Creating Nuage VSP Isolated Network offering with Static " - "NAT service provider as NuageVsp...") - net_off = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(net_off, state="Enabled") - - # Creating an Isolated network - self.debug("Creating an Isolated network with Static NAT service...") - self.network = self.create_Network(net_off, gateway='10.1.1.1') - self.validate_Network(self.network, state="Allocated") - - # Acquiring a Public IP - self.debug("Acquiring a Public IP in the created Isolated network...") - self.public_ip = self.acquire_PublicIPAddress(self.network) - self.validate_PublicIPAddress(self.public_ip, self.network) - - # Enabling Static NAT on a starting VM - self.debug("Creating a thread for enabling Static Nat on a starting " - "VM...") - static_nat_thread = threading.Thread( - name='enable_static_nat', - target=self.enable_staticNat_on_a_starting_vm) - static_nat_thread.start() - - vm = self.create_VM(self.network) - - # Check the status of Static Nat thread and if it is not finished then - # below command will wait for it to finish - self.debug("Waiting for for enabling Static Nat on a starting VM " - "thread to finish...") - static_nat_thread.join() - - # CloudStack verification for the implemented Isolated Network - self.validate_Network(self.network, state="Implemented") - vr = self.get_Router(self.network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm, state="Running") - - # VSD verification for the implemented Isolated Network - self.verify_vsd_network(self.domain.id, self.network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # CloudStack verification for Static NAT functionality - self.validate_PublicIPAddress( - self.public_ip, self.network, static_nat=True, vm=vm) - - # VSD verification for Static NAT functionality - self.verify_vsd_floating_ip(self.network, vm, self.public_ip.ipaddress) - - # Verifying Static NAT traffic - self.verify_StaticNAT_traffic(self.network, self.public_ip) diff --git a/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py b/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py deleted file mode 100644 index 9ccb2f3e3f8..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_vpc_internal_lb.py +++ /dev/null @@ -1,2590 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for VPC Internal Load Balancer functionality with -Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import (Account, - ApplicationLoadBalancer, - Network, - Router) -from marvin.cloudstackAPI import (listInternalLoadBalancerVMs, - stopInternalLoadBalancerVM, - startInternalLoadBalancerVM) -# Import System Modules -from nose.plugins.attrib import attr -from unittest import skip -import copy -import time - - -class TestNuageInternalLb(nuageTestCase): - """Test VPC Internal LB functionality with Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls): - super(TestNuageInternalLb, cls).setUpClass() - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - # create_Internal_LB_Rule - Creates Internal LB rule in the given - # VPC network - def create_Internal_LB_Rule(self, network, vm_array=None, services=None, - source_ip=None): - self.debug("Creating Internal LB rule in VPC network with ID - %s" % - network.id) - if not services: - services = self.test_data["internal_lbrule"] - int_lb_rule = ApplicationLoadBalancer.create( - self.api_client, - services=services, - sourcenetworkid=network.id, - networkid=network.id, - sourceipaddress=source_ip - ) - self.debug("Created Internal LB rule") - # Assigning VMs to the created Internal Load Balancer rule - if vm_array: - self.debug("Assigning virtual machines - %s to the created " - "Internal LB rule" % vm_array) - int_lb_rule.assign(self.api_client, vms=vm_array) - self.debug("Assigned VMs to the created Internal LB rule") - return int_lb_rule - - # validate_Internal_LB_Rule - Validates the given Internal LB rule, - # matches the given Internal LB rule name and state against the list of - # Internal LB rules fetched - def validate_Internal_LB_Rule(self, int_lb_rule, state=None, - vm_array=None): - """Validates the Internal LB Rule""" - self.debug("Check if the Internal LB Rule is created successfully ?") - int_lb_rules = ApplicationLoadBalancer.list(self.api_client, - id=int_lb_rule.id - ) - self.assertEqual(isinstance(int_lb_rules, list), True, - "List Internal LB Rule should return a valid list" - ) - self.assertEqual(int_lb_rule.name, int_lb_rules[0].name, - "Name of the Internal LB Rule should match with the " - "returned list data" - ) - if state: - self.assertEqual(int_lb_rules[0].loadbalancerrule[0].state, state, - "Internal LB Rule state should be '%s'" % state - ) - if vm_array: - instance_ids = [instance.id for instance in - int_lb_rules[0].loadbalancerinstance] - for vm in vm_array: - self.assertEqual(vm.id in instance_ids, True, - "Internal LB instance list should have the " - "VM with ID - %s" % vm.id - ) - self.debug("Internal LB Rule creation successfully validated for %s" % - int_lb_rule.name) - - # list_InternalLbVms - Lists deployed Internal LB VM instances - def list_InternalLbVms(self, network_id=None, source_ip=None): - listInternalLoadBalancerVMsCmd = \ - listInternalLoadBalancerVMs.listInternalLoadBalancerVMsCmd() - listInternalLoadBalancerVMsCmd.account = self.account.name - listInternalLoadBalancerVMsCmd.domainid = self.account.domainid - if network_id: - listInternalLoadBalancerVMsCmd.networkid = network_id - internal_lb_vms = self.api_client.listInternalLoadBalancerVMs( - listInternalLoadBalancerVMsCmd) - if source_ip: - return [internal_lb_vm for internal_lb_vm in internal_lb_vms - if str(internal_lb_vm.guestipaddress) == source_ip] - else: - return internal_lb_vms - - # get_InternalLbVm - Returns Internal LB VM instance for the given VPC - # network and source ip - def get_InternalLbVm(self, network, source_ip): - self.debug("Finding the InternalLbVm for network with ID - %s and " - "source IP address - %s" % (network.id, source_ip)) - internal_lb_vms = self.list_InternalLbVms(network.id, source_ip) - self.assertEqual(isinstance(internal_lb_vms, list), True, - "List InternalLbVms should return a valid list" - ) - return internal_lb_vms[0] - - # stop_InternalLbVm - Stops the given Internal LB VM instance - def stop_InternalLbVm(self, int_lb_vm, force=False): - self.debug("Stopping InternalLbVm with ID - %s" % int_lb_vm.id) - cmd = stopInternalLoadBalancerVM.stopInternalLoadBalancerVMCmd() - cmd.id = int_lb_vm.id - if force: - cmd.forced = force - self.api_client.stopInternalLoadBalancerVM(cmd) - - # start_InternalLbVm - Starts the given Internal LB VM instance - def start_InternalLbVm(self, int_lb_vm): - self.debug("Starting InternalLbVm with ID - %s" % int_lb_vm.id) - cmd = startInternalLoadBalancerVM.startInternalLoadBalancerVMCmd() - cmd.id = int_lb_vm.id - self.api_client.startInternalLoadBalancerVM(cmd) - - # check_InternalLbVm_state - Checks if the Internal LB VM instance of the - # given VPC network and source IP is in the expected state form the list of - # fetched Internal LB VM instances - def check_InternalLbVm_state(self, network, source_ip, state=None): - self.debug("Check if the InternalLbVm is in state - %s" % state) - internal_lb_vms = self.list_InternalLbVms(network.id, source_ip) - self.assertEqual(isinstance(internal_lb_vms, list), True, - "List InternalLbVm should return a valid list" - ) - if state: - self.assertEqual(internal_lb_vms[0].state, state, - "InternalLbVm is not in the expected state" - ) - self.debug("InternalLbVm instance - %s is in the expected state - %s" % - (internal_lb_vms[0].name, state)) - - # verify_vpc_vm_ingress_traffic - Verifies ingress traffic to the given VM - # (SSH into VM) via a created Static NAT rule in the given VPC network - def verify_vpc_vm_ingress_traffic(self, vm, network, vpc): - if self.isSimulator: - self.debug("Simulator Environment: " - "skipping vpc vm ingress traffic tests.") - return - self.debug("Verifying ingress traffic to the VM (SSH into VM) - %s " - "via a created Static NAT rule in the VPC network - %s" % - (vm, network)) - - # Creating Static NAT rule for the given VM in the given VPC network - self.debug("Creating Static NAT Rule...") - test_public_ip = self.acquire_PublicIPAddress(network, vpc) - self.validate_PublicIPAddress(test_public_ip, network) - self.create_StaticNatRule_For_VM(vm, test_public_ip, network) - self.validate_PublicIPAddress( - test_public_ip, network, static_nat=True, vm=vm) - - # VSD verification - self.verify_vsd_floating_ip(network, vm, test_public_ip.ipaddress, vpc) - - # Adding Network ACL rule in the given VPC network - self.debug("Creating Network ACL rule ...") - test_public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=network) - - # VSD verification - self.verify_vsd_firewall_rule(test_public_ssh_rule) - - # SSH into VM - self.debug("Verifying VM ingress traffic (SSH into VM)...") - self.ssh_into_VM(vm, test_public_ip) - - # Removing Network ACL rule in the given VPC network - self.debug("Removing the created Network ACL rule...") - test_public_ssh_rule.delete(self.api_client) - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_firewall_rule(test_public_ssh_rule) - self.debug("Network ACL rule successfully deleted in VSD") - - # Deleting Static NAT Rule - self.debug("Deleting the created Static NAT Rule...") - self.delete_StaticNatRule_For_VM(test_public_ip) - with self.assertRaises(Exception): - self.validate_PublicIPAddress( - test_public_ip, network, static_nat=True, vm=vm) - self.debug("Static NAT Rule successfully deleted in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_floating_ip( - network, vm, test_public_ip.ipaddress, vpc=vpc) - self.debug("Floating IP successfully deleted in VSD") - - # Releasing acquired public IP - self.debug("Releasing the acquired public IP...") - test_public_ip.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_PublicIPAddress(test_public_ip, network) - self.debug("Acquired public IP in the network successfully released " - "in CloudStack") - - self.debug("Successfully verified ingress traffic to the VM " - "(SSH into VM) - %s via a created Static NAT rule in the " - "VPC network - %s" % (vm, network)) - - # wget_from_vm_cmd - From within the given VM (ssh client), - # fetches index.html file of web server running with the given public IP - def wget_from_vm_cmd(self, ssh_client, ip_address, port): - if self.isSimulator: - self.debug("Simulator Environment: not wgeting from vm cmd.") - return - wget_file = "" - cmd = "rm -rf index.html*" - self.execute_cmd(ssh_client, cmd) - cmd = "wget --no-cache -t 1 http://" + ip_address + ":" + str(port) + \ - "/" - response = self.execute_cmd(ssh_client, cmd) - if "200 OK" in response: - self.debug("wget from a VM with http server IP address " - "- %s is successful" % ip_address) - # Reading the wget file - cmd = "cat index.html" - wget_file = self.execute_cmd(ssh_client, cmd) - # Removing the wget file - cmd = "rm -rf index.html*" - self.execute_cmd(ssh_client, cmd) - else: - self.debug("Failed to wget from a VM with http server IP address " - "- %s" % ip_address) - return wget_file - - # verify_lb_wget_file - Verifies that the given wget file (index.html) - # belongs to the given Internal LB rule - # assigned VMs (vm array) - def verify_lb_wget_file(self, wget_file, vm_array): - if self.isSimulator: - self.debug("Simulator Environment: not verifying file on vm.") - return - wget_server_ip = None - for vm in vm_array: - for nic in vm.nic: - if str(nic.ipaddress) in str(wget_file): - wget_server_ip = str(nic.ipaddress) - if wget_server_ip: - self.debug("Verified wget file from Internal Load Balanced VMs - " - "%s" % vm_array) - else: - self.fail("Failed to verify wget file from Internal Load Balanced " - "VMs - %s" % vm_array) - return wget_server_ip - - # validate_internallb_algorithm_traffic - Validates Internal LB algorithms - # by performing multiple wget traffic tests against the given Internal LB - # VM instance (source port) - def validate_internallb_algorithm_traffic(self, ssh_client, source_ip, - port, vm_array, algorithm): - # Internal LB (wget) traffic tests - iterations = 2 * len(vm_array) - wget_files = [] - for i in range(iterations): - wget_files.append( - self.wget_from_vm_cmd(ssh_client, source_ip, port)) - # Verifying Internal LB (wget) traffic tests - wget_servers_ip_list = [] - for i in range(iterations): - wget_servers_ip_list.append( - self.verify_lb_wget_file(wget_files[i], vm_array)) - # Validating Internal LB algorithm - if algorithm == "roundrobin" or algorithm == "leastconn": - for i in range(iterations): - if wget_servers_ip_list.count(wget_servers_ip_list[i]) \ - is not 2: - self.fail("Round Robin Internal LB algorithm validation " - "failed - %s" % wget_servers_ip_list) - self.debug("Successfully validated Round Robin/Least connections " - "Internal LB algorithm - %s" % wget_servers_ip_list) - if algorithm == "source": - for i in range(iterations): - if wget_servers_ip_list.count(wget_servers_ip_list[i]) \ - is not iterations: - self.fail("Source Internal LB algorithm validation failed " - "- %s" % wget_servers_ip_list) - self.debug("Successfully validated Source Internal LB algorithm - " - "%s" % wget_servers_ip_list) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_nuage_internallb_vpc_Offering(self): - """Test Nuage VSP VPC Offering with different combinations of LB - service providers - """ - - # 1. Verify that the network service providers supported by Nuage VSP - # for VPC Internal LB functionality are all successfully created and - # enabled. - # 2. Create Nuage VSP VPC offering with LB service provider as - # "InternalLbVm", check if it is successfully created and enabled. - # Verify that the VPC creation succeeds with this VPC offering. - # 3. Create Nuage VSP VPC offering with LB service provider as - # "VpcVirtualRouter", check if it is successfully created and - # enabled. Verify that the VPC creation fails with this VPC offering - # as Nuage VSP does not support provider "VpcVirtualRouter" for - # service LB. - # 4. Create Nuage VSP VPC offering with LB service provider as - # "Netscaler", check if it is successfully created and enabled. - # Verify that the VPC creation fails with this VPC offering as Nuage - # VSP does not support provider "Netscaler" for service LB. - # 5. Delete all the created objects (cleanup). - - self.debug("Validating network service providers supported by Nuage " - "VSP for VPC Internal LB functionality") - providers = ["NuageVsp", "VpcVirtualRouter", "InternalLbVm"] - for provider in providers: - self.validate_NetworkServiceProvider(provider, state="Enabled") - - # Creating VPC offerings - self.debug("Creating Nuage VSP VPC offering with LB service provider " - "as InternalLbVm...") - vpc_off_1 = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering with LB service provider " - "as VpcVirtualRouter...") - vpc_offering_lb = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - vpc_offering_lb["serviceProviderList"]["Lb"] = "VpcVirtualRouter" - vpc_off_2 = self.create_VpcOffering(vpc_offering_lb) - self.validate_VpcOffering(vpc_off_2, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering with LB service provider " - "as Netscaler...") - vpc_offering_lb["serviceProviderList"]["Lb"] = "Netscaler" - vpc_off_3 = self.create_VpcOffering(vpc_offering_lb) - self.validate_VpcOffering(vpc_off_3, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering without LB service...") - vpc_off_4 = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off_4, state="Enabled") - - # Creating VPCs - self.debug("Creating a VPC with LB service provider as " - "InternalLbVm...") - vpc_1 = self.create_vpc(vpc_off_1, cidr='10.1.0.0/16') - self.validate_vpc(vpc_1, state="Enabled") - - self.debug("Creating a VPC with LB service provider as " - "VpcVirtualRouter...") - with self.assertRaises(Exception): - self.create_vpc(vpc_off_2, cidr='10.1.0.0/16') - self.debug("Nuage VSP does not support provider VpcVirtualRouter for " - "service LB for VPCs") - - self.debug("Creating a VPC with LB service provider as Netscaler...") - with self.assertRaises(Exception): - self.create_vpc(vpc_off_3, cidr='10.1.0.0/16') - self.debug("Nuage VSP does not support provider Netscaler for service " - "LB for VPCs") - - self.debug("Creating a VPC without LB service...") - vpc_2 = self.create_vpc(vpc_off_4, cidr='10.1.0.0/16') - self.validate_vpc(vpc_2, state="Enabled") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_nuage_internallb_vpc_network_offering(self): - """Test Nuage VSP VPC Network Offering with and without Internal LB - service - """ - - # 1. Create Nuage VSP VPC Network offering with LB Service Provider as - # "InternalLbVm" and LB Service Capability "lbSchemes" as - # "internal", check if it is successfully created and enabled. - # Verify that the VPC network creation succeeds with this Network - # offering. - # 2. Recreate above Network offering with ispersistent False, check if - # it is successfully created and enabled.Verify that the VPC network - # creation fails with this Network offering as Nuage VSP does not - # support non persistent VPC networks. - # 3. Recreate above Network offering with conserve mode On, check if - # the network offering creation failed as only networks with - # conserve mode Off can belong to VPC. - # 4. Create Nuage VSP VPC Network offering with LB Service Provider as - # "InternalLbVm" and LB Service Capability "lbSchemes" as "public", - # check if the network offering creation failed as "public" lbScheme - # is not supported for LB Service Provider "InternalLbVm". - # 5. Create Nuage VSP VPC Network offering without Internal LB Service, - # check if it is successfully created and enabled. Verify that the - # VPC network creation succeeds with this Network offering. - # 6. Recreate above Network offering with ispersistent False, check if - # it is successfully created and enabled. Verify that the VPC - # network creation fails with this Network offering as Nuage VSP - # does not support non persistent VPC networks. - # 7. Recreate the above Network offering with conserve mode On, check - # if the network offering creation failed as only networks with - # conserve mode Off can belong to VPC. - # 8. Delete all the created objects (cleanup). - - # Creating VPC offering - self.debug("Creating Nuage VSP VPC offering with Internal LB " - "service...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating VPC - self.debug("Creating a VPC with Internal LB service...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with LB Service " - "Provider as InternalLbVm and LB Service Capability " - "lbSchemes as internal...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Recreating above Network offering with ispersistent " - "False...") - vpc_net_off_lb_non_persistent = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - vpc_net_off_lb_non_persistent["ispersistent"] = "False" - net_off_2 = self.create_NetworkOffering(vpc_net_off_lb_non_persistent) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - self.debug("Recreating above Network offering with conserve mode " - "On...") - with self.assertRaises(Exception): - self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"], - conserve_mode=True) - self.debug("Network offering creation failed as only networks with " - "conserve mode Off can belong to VPC") - - self.debug("Creating Nuage VSP VPC Network offering with LB Service " - "Provider as InternalLbVm and LB Service Capability " - "lbSchemes as public...") - network_offering_internal_lb = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - service_list = network_offering_internal_lb["serviceCapabilityList"] - service_list["Lb"]["lbSchemes"] = "public" - network_offering_internal_lb["serviceCapabilityList"] = service_list - with self.assertRaises(Exception): - self.create_NetworkOffering(network_offering_internal_lb) - self.debug("Network offering creation failed as public lbScheme is " - "not supported for LB Service Provider InternalLbVm") - - self.debug("Creating Nuage VSP VPC Network offering without Internal " - "LB service...") - net_off_3 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_3, state="Enabled") - - self.debug("Recreating above Network offering with ispersistent " - "False...") - vpc_net_off_non_persistent = copy.deepcopy( - self.test_data["nuagevsp"]["vpc_network_offering"]) - vpc_net_off_non_persistent["ispersistent"] = "False" - net_off_4 = self.create_NetworkOffering(vpc_net_off_non_persistent) - self.validate_NetworkOffering(net_off_4, state="Enabled") - - self.debug("Recreating above Network offering with conserve mode " - "On...") - with self.assertRaises(Exception): - self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"], - conserve_mode=True) - self.debug("Network offering creation failed as only networks with " - "conserve mode Off can belong to VPC") - - # Creating VPC networks in the VPC - self.debug("Creating a persistent VPC network with Internal LB " - "service...") - internal_tier = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(internal_tier) - self.check_Router_state(vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - - self.debug("Creating a non persistent VPC network with Internal LB " - "service...") - with self.assertRaises(Exception): - self.create_Network(net_off_2, gateway='10.1.2.1', vpc=vpc) - self.debug("Nuage VSP does not support non persistent VPC networks") - - self.debug("Creating a persistent VPC network without Internal LB " - "service...") - public_tier = self.create_Network( - net_off_3, gateway='10.1.3.1', vpc=vpc) - self.validate_Network(public_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - - self.debug("Creating a non persistent VPC network without Internal LB " - "service...") - with self.assertRaises(Exception): - self.create_Network(net_off_4, gateway='10.1.4.1', vpc=vpc) - self.debug("Nuage VSP does not support non persistent VPC networks") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_nuage_internallb_vpc_networks(self): - """Test Nuage VSP VPC Networks with and without Internal LB service - """ - - # 1. Create Nuage VSP VPC offering with Internal LB service, check if - # it is successfully created and enabled. - # 2. Create Nuage VSP VPC offering without Internal LB service, check - # if it is successfully created and enabled. - # 3. Create a VPC "vpc_1" with Internal LB service, check if it is - # successfully created and enabled. - # 4. Create a VPC "vpc_2" without Internal LB service, check if it is - # successfully created and enabled. - # 5. Create Nuage VSP VPC Network offering with Internal LB service, - # check if it is successfully created and enabled. - # 6. Create Nuage VSP VPC Network offering without Internal LB service, - # check if it is successfully created and enabled. - # 7. Create a VPC network in vpc_1 with Internal LB service and spawn a - # VM, check if the tier is added to the VPC VR, and the VM is - # deployed successfully in the tier. - # 8. Create one more VPC network in vpc_1 with Internal LB service and - # spawn a VM, check if the tier is added to the VPC VR, and the VM - # is deployed successfully in the tier. - # 9. Create a VPC network in vpc_2 with Internal LB service, check if - # the tier creation failed. - # 10. Create a VPC network in vpc_1 without Internal LB service and - # spawn a VM, check if the tier is added to the VPC VR, and the VM - # is deployed successfully in the tier. - # 11. Create a VPC network in vpc_2 without Internal LB service and - # spawn a VM, check if the tier is added to the VPC VR, and the VM - # is deployed successfully in the tier. - # 12. Upgrade the VPC network with Internal LB service to one with no - # Internal LB service and vice-versa, check if the VPC Network - # offering upgrade passed in both directions. - # 13. Delete the VPC network with Internal LB service, check if the - # tier is successfully deleted. - # 14. Recreate the VPC network with Internal LB service, check if the - # tier is successfully re-created. - # 15. Delete all the created objects (cleanup). - - # Creating VPC offerings - self.debug("Creating Nuage VSP VPC offering with Internal LB " - "service...") - vpc_off_1 = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC offering without Internal LB " - "service...") - vpc_off_2 = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_off_2, state="Enabled") - - # Creating VPCs - self.debug("Creating a VPC with Internal LB service...") - vpc_1 = self.create_vpc(vpc_off_1, cidr='10.1.0.0/16') - self.validate_vpc(vpc_1, state="Enabled") - - self.debug("Creating a VPC without Internal LB service...") - vpc_2 = self.create_vpc(vpc_off_2, cidr='10.1.0.0/16') - self.validate_vpc(vpc_2, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Internal LB " - "service...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC Network offering without Internal " - "LB service...") - net_off_2 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - # Creating VPC networks in VPCs, and deploying VMs - self.debug("Creating a VPC network in vpc_1 with Internal LB " - "service...") - internal_tier_1 = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc_1) - self.validate_Network(internal_tier_1, state="Implemented") - vr_1 = self.get_Router(internal_tier_1) - self.check_Router_state(vr_1, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm_1 = self.create_VM(internal_tier_1) - self.check_VM_state(internal_vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier_1, vpc_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(internal_vm_1) - - self.debug("Creating one more VPC network in vpc_1 with Internal LB " - "service...") - internal_tier_2 = self.create_Network( - net_off_1, gateway='10.1.2.1', vpc=vpc_1) - self.validate_Network(internal_tier_2, state="Implemented") - vr_1 = self.get_Router(internal_tier_2) - self.check_Router_state(vr_1, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm_2 = self.create_VM(internal_tier_2) - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier_2, vpc_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(internal_vm_2) - - self.debug("Creating a VPC network in vpc_2 with Internal LB " - "service...") - with self.assertRaises(Exception): - self.create_Network(net_off_1, gateway='10.1.1.1', vpc=vpc_2) - self.debug("VPC Network creation failed as vpc_2 does not support " - "Internal Lb service") - - self.debug("Creating a VPC network in vpc_1 without Internal LB " - "service...") - public_tier_1 = self.create_Network( - net_off_2, gateway='10.1.3.1', vpc=vpc_1) - self.validate_Network(public_tier_1, state="Implemented") - vr_1 = self.get_Router(public_tier_1) - self.check_Router_state(vr_1, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - public_vm_1 = self.create_VM(public_tier_1) - self.check_VM_state(public_vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier_1, vpc_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(public_vm_1) - - self.debug("Creating a VPC network in vpc_2 without Internal LB " - "service...") - public_tier_2 = self.create_Network( - net_off_2, gateway='10.1.1.1', vpc=vpc_2) - self.validate_Network(public_tier_2, state="Implemented") - vr_2 = self.get_Router(public_tier_2) - self.check_Router_state(vr_2, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - public_vm_2 = self.create_VM(public_tier_2) - self.check_VM_state(public_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier_2, vpc_2) - self.verify_vsd_router(vr_2) - self.verify_vsd_vm(public_vm_2) - - # Upgrading a VPC network - self.debug("Upgrading a VPC network with Internal LB Service to one " - "without Internal LB Service...") - self.upgrade_Network(net_off_2, internal_tier_2) - self.validate_Network(internal_tier_2, state="Implemented") - vr_1 = self.get_Router(internal_tier_2) - self.check_Router_state(vr_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier_2, vpc_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(internal_vm_2) - - self.debug("Upgrading a VPC network without Internal LB Service to " - "one with Internal LB Service...") - self.upgrade_Network(net_off_1, internal_tier_2) - self.validate_Network(internal_tier_2, state="Implemented") - vr_1 = self.get_Router(internal_tier_2) - self.check_Router_state(vr_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier_2, vpc_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(internal_vm_2) - - # Deleting and re-creating a VPC network - self.debug("Deleting a VPC network with Internal LB Service...") - self.delete_VM(internal_vm_2) - self.delete_Network(internal_tier_2) - with self.assertRaises(Exception): - self.validate_Network(internal_tier_2) - self.debug("VPC network successfully deleted in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_network(self.domain.id, internal_tier_2, vpc_1) - self.debug("VPC network successfully deleted in VSD") - - self.debug("Recreating a VPC network with Internal LB Service...") - internal_tier_2 = self.create_Network( - net_off_1, gateway='10.1.2.1', vpc=vpc_1) - internal_vm_2 = self.create_VM(internal_tier_2) - self.validate_Network(internal_tier_2, state="Implemented") - vr_1 = self.get_Router(internal_tier_2) - self.check_Router_state(vr_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier_2, vpc_1) - self.verify_vsd_router(vr_1) - self.verify_vsd_vm(internal_vm_2) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_nuage_internallb_rules(self): - """Test Nuage VSP VPC Internal LB functionality with different - combinations of Internal LB rules - """ - - # 1. Create an Internal LB Rule with source IP Address specified, check - # if the Internal LB Rule is successfully created. - # 2. Create an Internal LB Rule without source IP Address specified, - # check if the Internal LB Rule is successfully created. - # 3. Create an Internal LB Rule when the specified source IP Address is - # outside the VPC network (tier) CIDR range, check if the Internal - # LB Rule creation failed as the requested source IP is not in the - # network's CIDR subnet. - # 4. Create an Internal LB Rule when the specified source IP Address is - # outside the VPC super CIDR range, check if the Internal LB Rule - # creation failed as the requested source IP is not in the network's - # CIDR subnet. - # 5. Create an Internal LB Rule in the tier with LB service provider as - # VpcInlineLbVm, check if the Internal LB Rule creation failed as - # Scheme Internal is not supported by this network offering. - # 6. Create multiple Internal LB Rules using different Load Balancing - # source IP Addresses, check if the Internal LB Rules are - # successfully created. - # 7. Create multiple Internal LB Rules with different ports but using - # the same Load Balancing source IP Address, check if the Internal - # LB Rules are successfully created. - # 8. Create multiple Internal LB Rules with same ports and using the - # same Load Balancing source IP Address, check if the second - # Internal LB Rule creation failed as it conflicts with the first - # Internal LB rule. - # 9. Attach a VM to the above created Internal LB Rules, check if the - # VM is successfully attached to the Internal LB Rules. - # 10. Verify the InternalLbVm deployment after successfully creating - # the first Internal LB Rule and attaching a VM to it. - # 11. Verify the failure of attaching a VM from a different tier to an - # Internal LB Rule created on a tier. - # 12. Delete the above created Internal LB Rules, check if the Internal - # LB Rules are successfully deleted. - # 13. Delete all the created objects (cleanup). - - # Creating a VPC offering - self.debug("Creating Nuage VSP VPC offering with Internal LB " - "service...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating a VPC - self.debug("Creating a VPC with Internal LB service...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Internal LB " - "service...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC Network offering without Internal " - "LB service...") - net_off_2 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - # Creating VPC networks in the VPC, and deploying VMs - self.debug("Creating a VPC network with Internal LB service...") - internal_tier = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(internal_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm = self.create_VM(internal_tier) - self.check_VM_state(internal_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm) - - self.debug("Creating a VPC network without Internal LB service...") - public_tier = self.create_Network( - net_off_2, gateway='10.1.2.1', vpc=vpc) - self.validate_Network(public_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - public_vm = self.create_VM(public_tier) - self.check_VM_state(public_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - - # Creating Internal LB Rules - self.debug("Creating an Internal LB Rule without source IP Address " - "specified...") - int_lb_rule = self.create_Internal_LB_Rule(internal_tier) - self.validate_Internal_LB_Rule(int_lb_rule, state="Add") - - # Validating InternalLbVm deployment - with self.assertRaises(Exception): - self.check_InternalLbVm_state( - internal_tier, int_lb_rule.sourceipaddress) - self.debug("InternalLbVm is not deployed in the network as there are " - "no VMs assigned to this Internal LB Rule") - - self.debug('Deleting the Internal LB Rule - %s' % int_lb_rule.name) - int_lb_rule.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule) - self.debug("Internal LB Rule successfully deleted in CloudStack") - - free_source_ip = int_lb_rule.sourceipaddress - - self.debug("Creating an Internal LB Rule with source IP Address " - "specified...") - int_lb_rule = self.create_Internal_LB_Rule( - internal_tier, source_ip=free_source_ip) - self.validate_Internal_LB_Rule(int_lb_rule, state="Add") - - # Validating InternalLbVm deployment - with self.assertRaises(Exception): - self.check_InternalLbVm_state( - internal_tier, int_lb_rule.sourceipaddress) - self.debug("InternalLbVm is not deployed in the network as there are " - "no VMs assigned to this Internal LB Rule") - - self.debug('Deleting the Internal LB Rule - %s' % int_lb_rule.name) - int_lb_rule.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule) - self.debug("Internal LB Rule successfully deleted in CloudStack") - - self.debug("Creating an Internal LB Rule when the specified source IP " - "Address is outside the VPC network CIDR range...") - with self.assertRaises(Exception): - self.create_Internal_LB_Rule(internal_tier, source_ip="10.1.1.256") - self.debug("Internal LB Rule creation failed as the requested IP is " - "not in the network's CIDR subnet") - - self.debug("Creating an Internal LB Rule when the specified source IP " - "Address is outside the VPC super CIDR range...") - with self.assertRaises(Exception): - self.create_Internal_LB_Rule(internal_tier, source_ip="10.2.1.256") - self.debug("Internal LB Rule creation failed as the requested IP is " - "not in the network's CIDR subnet") - - self.debug("Creating an Internal LB Rule in a VPC network without " - "Internal Lb service...") - with self.assertRaises(Exception): - self.create_Internal_LB_Rule(public_tier) - self.debug("Internal LB Rule creation failed as Scheme Internal is " - "not supported by this network offering") - - self.debug("Creating multiple Internal LB Rules using different Load " - "Balancing source IP Addresses...") - int_lb_rule_1 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", vm_array=[internal_vm]) - int_lb_rule_2 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm]) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", vm_array=[internal_vm]) - - # Validating InternalLbVms deployment and state - int_lb_vm_1 = self.get_InternalLbVm( - internal_tier, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - int_lb_vm_2 = self.get_InternalLbVm( - internal_tier, int_lb_rule_2.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_2.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_1) - self.verify_vsd_lb_device(int_lb_vm_2) - - self.debug('Removing VMs from the Internal LB Rules - %s, %s' % - (int_lb_rule_1.name, int_lb_rule_2.name)) - int_lb_rule_1.remove(self.api_client, vms=[internal_vm]) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule( - int_lb_rule_1, vm_array=[internal_vm]) - self.debug("VMs successfully removed from the Internal LB Rule in " - "CloudStack") - int_lb_rule_2.remove(self.api_client, vms=[internal_vm]) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule( - int_lb_rule_2, vm_array=[internal_vm]) - self.debug("VMs successfully removed from the Internal LB Rule in " - "CloudStack") - - # Validating InternalLbVms state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_2.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_1) - self.verify_vsd_lb_device(int_lb_vm_2) - - self.debug('Deleting the Internal LB Rules - %s, %s' % - (int_lb_rule_1.name, int_lb_rule_2.name)) - int_lb_rule_1.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule_1) - self.debug("Internal LB Rule successfully deleted in CloudStack") - int_lb_rule_2.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule_2) - self.debug("Internal LB Rule successfully deleted in CloudStack") - - # Validating InternalLbVms un-deployment - with self.assertRaises(Exception): - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress) - self.debug("InternalLbVm successfully destroyed in CloudStack") - with self.assertRaises(Exception): - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_2.sourceipaddress) - self.debug("InternalLbVm successfully destroyed in CloudStack") - - # VSD Verification - with self.assertRaises(Exception): - self.verify_vsd_lb_device(int_lb_vm_1) - self.debug("InternalLbVm successfully destroyed in VSD") - with self.assertRaises(Exception): - self.verify_vsd_lb_device(int_lb_vm_2) - self.debug("InternalLbVm successfully destroyed in VSD") - - self.debug("Creating multiple Internal LB Rules with different ports " - "but using the same Load Balancing source IP Address...") - int_lb_rule_1 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", vm_array=[internal_vm]) - int_lb_rule_2 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_1.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", vm_array=[internal_vm]) - - # Validating InternalLbVm deployment and state - int_lb_vm = self.get_InternalLbVm( - internal_tier, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - self.debug('Removing VMs from the Internal LB Rules - %s, %s' % - (int_lb_rule_1.name, int_lb_rule_2.name)) - int_lb_rule_1.remove(self.api_client, vms=[internal_vm]) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule( - int_lb_rule_1, vm_array=[internal_vm]) - self.debug("VMs successfully removed from the Internal LB Rule in " - "CloudStack") - int_lb_rule_2.remove(self.api_client, vms=[internal_vm]) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule( - int_lb_rule_2, vm_array=[internal_vm]) - self.debug("VMs successfully removed from the Internal LB Rule in " - "CloudStack") - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - self.debug('Deleting the Internal LB Rules - %s, %s' % - (int_lb_rule_1.name, int_lb_rule_2.name)) - int_lb_rule_1.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule_1) - self.debug("Internal LB Rule successfully deleted in CloudStack") - int_lb_rule_2.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule_2) - self.debug("Internal LB Rule successfully deleted in CloudStack") - - # Validating InternalLbVm un-deployment - with self.assertRaises(Exception): - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress) - self.debug("InternalLbVm successfully destroyed in CloudStack") - - # VSD Verification - with self.assertRaises(Exception): - self.verify_vsd_lb_device(int_lb_vm) - self.debug("InternalLbVm successfully destroyed in VSD") - - self.debug("Creating multiple Internal LB Rules with same ports and " - "using the same Load Balancing source IP Address...") - int_lb_rule = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm]) - self.validate_Internal_LB_Rule( - int_lb_rule, state="Active", vm_array=[internal_vm]) - with self.assertRaises(Exception): - self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm], - source_ip=int_lb_rule.sourceipaddress) - self.debug("Internal LB Rule creation failed as it conflicts with the " - "existing rule") - - # Validating InternalLbVm deployment and state - int_lb_vm = self.get_InternalLbVm( - internal_tier, int_lb_rule.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - self.debug('Removing VMs from the Internal LB Rule - %s' % - int_lb_rule.name) - int_lb_rule.remove(self.api_client, vms=[internal_vm]) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule, vm_array=[internal_vm]) - self.debug("VMs successfully removed from the Internal LB Rule in " - "CloudStack") - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - self.debug('Deleting the Internal LB Rule - %s' % int_lb_rule.name) - int_lb_rule.delete(self.api_client) - with self.assertRaises(Exception): - self.validate_Internal_LB_Rule(int_lb_rule) - self.debug("Internal LB Rule successfully deleted in CloudStack") - - # Validating InternalLbVm un-deployment - with self.assertRaises(Exception): - self.check_InternalLbVm_state( - internal_tier, int_lb_rule.sourceipaddress) - self.debug("InternalLbVm successfully destroyed in CloudStack") - - # VSD Verification - with self.assertRaises(Exception): - self.verify_vsd_lb_device(int_lb_vm) - self.debug("InternalLbVm successfully destroyed in VSD") - - self.debug("Attaching a VM from a different tier to an Internal LB " - "Rule created on a tier...") - with self.assertRaises(Exception): - self.create_Internal_LB_Rule(internal_tier, vm_array=[public_vm]) - self.debug("Internal LB Rule creation failed as the VM belongs to a " - "different network") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_05_nuage_internallb_traffic(self): - """Test Nuage VSP VPC Internal LB functionality by performing (wget) - traffic tests within a VPC - """ - - # 1. Create three different Internal LB Rules with a single source IP - # Address specified on the Internal tier, check if the Internal LB - # Rules are created successfully. - # 2. Attach a VM to the above created Internal LB Rules, check if the - # InternalLbVm is successfully deployed in the Internal tier. - # 3. Deploy two more VMs in the Internal tier, check if the VMs are - # successfully deployed. - # 4. Attach the newly deployed VMs to the above created Internal LB - # Rules, verify the validity of the above created Internal LB Rules - # over three Load Balanced VMs in the Internal tier. - # 5. Create the corresponding Network ACL rules to make the created - # Internal LB rules (SSH & HTTP) accessible, check if the Network - # ACL rules are successfully added to the internal tier. - # 6. Validate the Internal LB functionality by performing (wget) - # traffic tests from a VM in the Public tier to the Internal load - # balanced guest VMs in the Internal tier, using Static NAT - # functionality to access (ssh) the VM on the Public tier. - # 7. Verify that the InternalLbVm gets destroyed when the last Internal - # LB rule is removed from the Internal tier. - # 8. Repeat the above steps for one more Internal tier as well, - # validate the Internal LB functionality. - # 9. Delete all the created objects (cleanup). - - # Creating a VPC offering - self.debug("Creating Nuage VSP VPC offering with Internal LB " - "service...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating a VPC - self.debug("Creating a VPC with Internal LB service...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Internal LB " - "service...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC Network offering without Internal " - "LB service...") - net_off_2 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - # Creating VPC networks in the VPC, and deploying VMs - self.debug("Creating a VPC network with Internal LB service...") - internal_tier_1 = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(internal_tier_1, state="Implemented") - vr = self.get_Router(internal_tier_1) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm_1 = self.create_VM(internal_tier_1) - self.check_VM_state(internal_vm_1, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier_1, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm_1) - - self.debug("Creating one more VPC network with Internal LB service...") - internal_tier_2 = self.create_Network( - net_off_1, gateway='10.1.2.1', vpc=vpc) - self.validate_Network(internal_tier_2, state="Implemented") - vr = self.get_Router(internal_tier_2) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm_2 = self.create_VM(internal_tier_2) - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier_2, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm_2) - - self.debug("Creating a VPC network without Internal LB service...") - public_tier = self.create_Network( - net_off_2, gateway='10.1.3.1', vpc=vpc) - self.validate_Network(public_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - public_vm = self.create_VM(public_tier) - self.check_VM_state(public_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - - # Creating Internal LB Rules in the Internal tiers - self.debug("Creating three Internal LB Rules (SSH & HTTP) using the " - "same Load Balancing source IP Address...") - int_lb_rule_1 = self.create_Internal_LB_Rule( - internal_tier_1, vm_array=[internal_vm_1]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", vm_array=[internal_vm_1]) - int_lb_rule_2 = self.create_Internal_LB_Rule( - internal_tier_1, vm_array=[internal_vm_1], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_1.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", vm_array=[internal_vm_1]) - internal_lbrule_http = copy.deepcopy( - self.test_data["internal_lbrule_http"]) - internal_lbrule_http["sourceport"] = 8080 - internal_lbrule_http["instanceport"] = 8080 - int_lb_rule_3 = self.create_Internal_LB_Rule( - internal_tier_1, - vm_array=[internal_vm_1], - services=internal_lbrule_http, - source_ip=int_lb_rule_1.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_3, state="Active", vm_array=[internal_vm_1]) - - # Validating InternalLbVm deployment and state - int_lb_vm_1 = self.get_InternalLbVm( - internal_tier_1, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier_1, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_1) - - # Deploying more VMs in the Internal tier - self.debug("Deploying two more VMs in network - %s" % - internal_tier_1.name) - internal_vm_1_1 = self.create_VM(internal_tier_1) - internal_vm_1_2 = self.create_VM(internal_tier_1) - - # VSD verification - self.verify_vsd_vm(internal_vm_1_1) - self.verify_vsd_vm(internal_vm_1_2) - - # Adding newly deployed VMs to the created Internal LB rules - self.debug("Adding two more virtual machines to the created Internal " - "LB rules...") - int_lb_rule_1.assign( - self.api_client, [internal_vm_1_1, internal_vm_1_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", - vm_array=[internal_vm_1, internal_vm_1_1, internal_vm_1_2]) - int_lb_rule_2.assign( - self.api_client, [internal_vm_1_1, internal_vm_1_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", - vm_array=[internal_vm_1, internal_vm_1_1, internal_vm_1_2]) - int_lb_rule_3.assign( - self.api_client, [internal_vm_1_1, internal_vm_1_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_3, state="Active", - vm_array=[internal_vm_1, internal_vm_1_1, internal_vm_1_2]) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier_1, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_1) - - # Adding Network ACL rules in the Internal tier - self.debug("Adding Network ACL rules to make the created Internal LB " - "rules (HTTP) accessible...") - http_rule_1 = self.create_NetworkAclRule( - self.test_data["http_rule"], network=internal_tier_1) - http_rule = copy.deepcopy(self.test_data["http_rule"]) - http_rule["privateport"] = 8080 - http_rule["publicport"] = 8080 - http_rule["startport"] = 8080 - http_rule["endport"] = 8080 - http_rule_2 = self.create_NetworkAclRule( - http_rule, network=internal_tier_1) - - # VSD verification - self.verify_vsd_firewall_rule(http_rule_1) - self.verify_vsd_firewall_rule(http_rule_2) - - # Creating Internal LB Rules in the Internal tier - self.debug("Creating three Internal LB Rules (SSH & HTTP) using the " - "same Load Balancing source IP Address...") - int_lb_rule_4 = self.create_Internal_LB_Rule( - internal_tier_2, vm_array=[internal_vm_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_4, state="Active", vm_array=[internal_vm_2]) - int_lb_rule_5 = self.create_Internal_LB_Rule( - internal_tier_2, - vm_array=[internal_vm_2], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_4.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_5, state="Active", vm_array=[internal_vm_2]) - int_lb_rule_6 = self.create_Internal_LB_Rule( - internal_tier_2, - vm_array=[internal_vm_2], - services=internal_lbrule_http, - source_ip=int_lb_rule_4.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_6, state="Active", vm_array=[internal_vm_2]) - - # Validating InternalLbVm deployment and state - int_lb_vm_2 = self.get_InternalLbVm( - internal_tier_2, int_lb_rule_4.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier_2, int_lb_rule_4.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_2) - - # Deploying more VMs in the Internal tier - self.debug("Deploying two more VMs in network - %s" % - internal_tier_2.name) - internal_vm_2_1 = self.create_VM(internal_tier_2) - internal_vm_2_2 = self.create_VM(internal_tier_2) - - # VSD verification - self.verify_vsd_vm(internal_vm_2_1) - self.verify_vsd_vm(internal_vm_2_2) - - # Adding newly deployed VMs to the created Internal LB rules - self.debug("Adding two more virtual machines to the created Internal " - "LB rules...") - int_lb_rule_4.assign( - self.api_client, [internal_vm_2_1, internal_vm_2_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_4, state="Active", - vm_array=[internal_vm_2, internal_vm_2_1, internal_vm_2_2]) - int_lb_rule_5.assign( - self.api_client, [internal_vm_2_1, internal_vm_2_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_5, state="Active", - vm_array=[internal_vm_2, internal_vm_2_1, internal_vm_2_2]) - int_lb_rule_6.assign( - self.api_client, [internal_vm_2_1, internal_vm_2_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_6, state="Active", - vm_array=[internal_vm_2, internal_vm_2_1, internal_vm_2_2]) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier_2, int_lb_rule_4.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_2) - - # Adding Network ACL rules in the Internal tier - self.debug("Adding Network ACL rules to make the created Internal LB " - "rules (HTTP) accessible...") - http_rule_1 = self.create_NetworkAclRule( - self.test_data["http_rule"], network=internal_tier_2) - http_rule_2 = self.create_NetworkAclRule( - http_rule, network=internal_tier_2) - - # VSD verification - self.verify_vsd_firewall_rule(http_rule_1) - self.verify_vsd_firewall_rule(http_rule_2) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic( - internal_vm_1, internal_tier_1, vpc) - self.verify_vpc_vm_ingress_traffic( - internal_vm_1_1, internal_tier_1, vpc) - self.verify_vpc_vm_ingress_traffic( - internal_vm_1_2, internal_tier_1, vpc) - self.verify_vpc_vm_ingress_traffic( - internal_vm_2, internal_tier_2, vpc) - self.verify_vpc_vm_ingress_traffic( - internal_vm_2_1, internal_tier_2, vpc) - self.verify_vpc_vm_ingress_traffic( - internal_vm_2_2, internal_tier_2, vpc) - - # Creating Static NAT rule for the VM in the Public tier - public_ip = self.acquire_PublicIPAddress(public_tier, vpc) - self.validate_PublicIPAddress(public_ip, public_tier) - self.create_StaticNatRule_For_VM(public_vm, public_ip, public_tier) - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - - # Adding Network ACL rule in the Public tier - self.debug("Adding Network ACL rule to make the created NAT rule " - "(SSH) accessible...") - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=public_tier) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - - if self.isSimulator: - self.debug("Simulator Environment: skipping traffic tests.") - return - - # Internal LB (wget) traffic tests - ssh_client = self.ssh_into_VM(public_vm, public_ip) - wget_file_1 = self.wget_from_vm_cmd( - ssh_client, - int_lb_rule_1.sourceipaddress, - self.test_data["http_rule"]["publicport"]) - ssh_client = self.ssh_into_VM(public_vm, public_ip) - wget_file_2 = self.wget_from_vm_cmd( - ssh_client, - int_lb_rule_1.sourceipaddress, - http_rule["publicport"]) - ssh_client = self.ssh_into_VM(public_vm, public_ip) - wget_file_3 = self.wget_from_vm_cmd( - ssh_client, - int_lb_rule_4.sourceipaddress, - self.test_data["http_rule"]["publicport"]) - ssh_client = self.ssh_into_VM(public_vm, public_ip) - wget_file_4 = self.wget_from_vm_cmd( - ssh_client, - int_lb_rule_4.sourceipaddress, - http_rule["publicport"]) - - # Verifying Internal LB (wget) traffic tests - # Bug CLOUDSTACK-9749 - self.verify_lb_wget_file( - wget_file_1, [internal_vm_1, internal_vm_1_1, internal_vm_1_2]) - self.verify_lb_wget_file( - wget_file_2, [internal_vm_1, internal_vm_1_1, internal_vm_1_2]) - self.verify_lb_wget_file( - wget_file_3, [internal_vm_2, internal_vm_2_1, internal_vm_2_2]) - self.verify_lb_wget_file( - wget_file_4, [internal_vm_2, internal_vm_2_1, internal_vm_2_2]) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_06_nuage_internallb_algorithms_traffic(self): - """Test Nuage VSP VPC Internal LB functionality with different LB - algorithms by performing (wget) traffic tests within a VPC - """ - - # Repeat the tests in the testcase "test_05_nuage_internallb_traffic" - # with different Internal LB algorithms: - # 1. Round Robin - # 2. Least connections - # 3. Source - # Verify the above Internal LB algorithms by performing multiple (wget) - # traffic tests within a VPC. - # Delete all the created objects (cleanup). - - # Creating a VPC offering - self.debug("Creating Nuage VSP VPC offering with Internal LB " - "service...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating a VPC - self.debug("Creating a VPC with Internal LB service...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Internal LB " - "service...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC Network offering without Internal " - "LB service...") - net_off_2 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - # Creating VPC networks in the VPC, and deploying VMs - self.debug("Creating a VPC network with Internal LB service...") - internal_tier = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(internal_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm = self.create_VM(internal_tier) - self.check_VM_state(internal_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm) - - self.debug("Creating a VPC network without Internal LB service...") - public_tier = self.create_Network( - net_off_2, gateway='10.1.2.1', vpc=vpc) - self.validate_Network(public_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - public_vm = self.create_VM(public_tier) - self.check_VM_state(public_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - - # Creating Internal LB Rules in the Internal tier with Round Robin - # Algorithm - self.debug("Creating two Internal LB Rules (SSH & HTTP) with Round " - "Robin Algorithm...") - int_lb_rule_1 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", vm_array=[internal_vm]) - int_lb_rule_2 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_1.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", vm_array=[internal_vm]) - - # Validating InternalLbVm deployment and state - int_lb_vm_1 = self.get_InternalLbVm( - internal_tier, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_1) - - # Deploying more VMs in the Internal tier - self.debug("Deploying two more VMs in network - %s" % - internal_tier.name) - internal_vm_1 = self.create_VM(internal_tier) - internal_vm_2 = self.create_VM(internal_tier) - - # VSD verification - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - - # Adding newly deployed VMs to the created Internal LB rules - self.debug("Adding two more virtual machines to the created Internal " - "LB rules...") - int_lb_rule_1.assign(self.api_client, [internal_vm_1, internal_vm_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - int_lb_rule_2.assign(self.api_client, [internal_vm_1, internal_vm_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_1) - - # Creating Internal LB Rules in the Internal tier with Least - # connections Algorithm - self.debug("Creating two Internal LB Rules (SSH & HTTP) with Least " - "connections Algorithm...") - self.test_data["internal_lbrule"]["algorithm"] = "leastconn" - int_lb_rule_3 = self.create_Internal_LB_Rule( - internal_tier, - vm_array=[internal_vm, internal_vm_1, internal_vm_2], - services=self.test_data["internal_lbrule"]) - self.validate_Internal_LB_Rule( - int_lb_rule_3, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - self.test_data["internal_lbrule_http"]["algorithm"] = "leastconn" - int_lb_rule_4 = self.create_Internal_LB_Rule( - internal_tier, - vm_array=[internal_vm, internal_vm_1, internal_vm_2], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_3.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_4, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - - # Validating InternalLbVm deployment and state - int_lb_vm_2 = self.get_InternalLbVm( - internal_tier, int_lb_rule_3.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_3.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_2) - - # Creating Internal LB Rules in the Internal tier with Source Algorithm - self.debug("Creating two Internal LB Rules (SSH & HTTP) with Source " - "Algorithm...") - self.test_data["internal_lbrule"]["algorithm"] = "source" - int_lb_rule_5 = self.create_Internal_LB_Rule( - internal_tier, - vm_array=[internal_vm, internal_vm_1, internal_vm_2], - services=self.test_data["internal_lbrule"]) - self.validate_Internal_LB_Rule( - int_lb_rule_5, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - self.test_data["internal_lbrule_http"]["algorithm"] = "source" - int_lb_rule_6 = self.create_Internal_LB_Rule( - internal_tier, - vm_array=[internal_vm, internal_vm_1, internal_vm_2], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_5.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_6, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - - # Validating InternalLbVm deployment and state - int_lb_vm_3 = self.get_InternalLbVm( - internal_tier, int_lb_rule_5.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_5.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm_3) - - # Adding Network ACL rules in the Internal tier - self.debug("Adding Network ACL rules to make the created Internal LB " - "rules (HTTP) accessible...") - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], network=internal_tier) - - # VSD verification - self.verify_vsd_firewall_rule(http_rule) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Creating Static NAT rule for the VM in the Public tier - public_ip = self.acquire_PublicIPAddress(public_tier, vpc) - self.validate_PublicIPAddress(public_ip, public_tier) - self.create_StaticNatRule_For_VM(public_vm, public_ip, public_tier) - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - - # Adding Network ACL rule in the Public tier - self.debug("Adding Network ACL rule to make the created NAT rule " - "(SSH) accessible...") - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=public_tier) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - - if self.isSimulator: - self.debug("Simulator Environment: skipping traffic tests.") - return - - # Internal LB (wget) traffic tests with Round Robin Algorithm - ssh_client = self.ssh_into_VM(public_vm, public_ip) - self.validate_internallb_algorithm_traffic( - ssh_client, int_lb_rule_1.sourceipaddress, - self.test_data["http_rule"]["publicport"], - [internal_vm, internal_vm_1, internal_vm_2], "roundrobin") - - # Internal LB (wget) traffic tests with Least connections Algorithm - ssh_client = self.ssh_into_VM(public_vm, public_ip) - self.validate_internallb_algorithm_traffic( - ssh_client, int_lb_rule_3.sourceipaddress, - self.test_data["http_rule"]["publicport"], - [internal_vm, internal_vm_1, internal_vm_2], "leastconn") - - # Internal LB (wget) traffic tests with Source Algorithm - ssh_client = self.ssh_into_VM(public_vm, public_ip) - self.validate_internallb_algorithm_traffic( - ssh_client, int_lb_rule_5.sourceipaddress, - self.test_data["http_rule"]["publicport"], - [internal_vm, internal_vm_1, internal_vm_2], "source") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_07_nuage_internallb_vpc_network_restarts_traffic(self): - """Test Nuage VSP VPC Internal LB functionality with restarts of VPC - network components by performing (wget) traffic tests within a VPC - """ - - # Repeat the tests in the testcase "test_05_nuage_internallb_traffic" - # with restarts of VPC networks (tiers): - # 1. Restart tier with InternalLbVm (cleanup = false), verify that the - # InternalLbVm gets destroyed and deployed again in the Internal - # tier. - # 2. Restart tier with InternalLbVm (cleanup = true), verify that the - # InternalLbVm gets destroyed and deployed again in the Internal - # tier. - # 3. Restart tier without InternalLbVm (cleanup = false), verify that - # this restart has no effect on the InternalLbVm functionality. - # 4. Restart tier without InternalLbVm (cleanup = true), verify that - # this restart has no effect on the InternalLbVm functionality. - # 5. Stop all the VMs configured with InternalLbVm, verify that the - # InternalLbVm gets destroyed in the Internal tier. - # 6. Start all the VMs configured with InternalLbVm, verify that the - # InternalLbVm gets deployed again in the Internal tier. - # 7. Restart VPC (cleanup = false), verify that the VPC VR gets - # rebooted and this restart has no effect on the InternalLbVm - # functionality. - # 7. Restart VPC (cleanup = true), verify that the VPC VR gets rebooted - # and this restart has no effect on the InternalLbVm functionality. - # Verify the above restarts of VPC networks (tiers) by performing - # (wget) traffic tests within a VPC. - # Delete all the created objects (cleanup). - - # Creating a VPC offering - self.debug("Creating Nuage VSP VPC offering with Internal LB " - "service...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating a VPC - self.debug("Creating a VPC with Internal LB service...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Internal LB " - "service...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC Network offering without Internal " - "LB service...") - net_off_2 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - # Creating VPC networks in the VPC, and deploying VMs - self.debug("Creating a VPC network with Internal LB service...") - internal_tier = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(internal_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm = self.create_VM(internal_tier) - self.check_VM_state(internal_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm) - - self.debug("Creating a VPC network without Internal LB service...") - public_tier = self.create_Network( - net_off_2, gateway='10.1.2.1', vpc=vpc) - self.validate_Network(public_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - public_vm = self.create_VM(public_tier) - self.check_VM_state(public_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - - # Creating Internal LB Rules in the Internal tier - self.debug("Creating two Internal LB Rules (SSH & HTTP) using the " - "same Load Balancing source IP Address...") - int_lb_rule_1 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", vm_array=[internal_vm]) - int_lb_rule_2 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_1.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", vm_array=[internal_vm]) - - # Validating InternalLbVm deployment and state - int_lb_vm = self.get_InternalLbVm( - internal_tier, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Deploying more VMs in the Internal tier - self.debug("Deploying two more VMs in network - %s" % - internal_tier.name) - internal_vm_1 = self.create_VM(internal_tier) - internal_vm_2 = self.create_VM(internal_tier) - - # VSD verification - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - - # Adding newly deployed VMs to the created Internal LB rules - self.debug("Adding two more virtual machines to the created Internal " - "LB rules...") - int_lb_rule_1.assign(self.api_client, [internal_vm_1, internal_vm_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - int_lb_rule_2.assign(self.api_client, [internal_vm_1, internal_vm_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Adding Network ACL rules in the Internal tier - self.debug("Adding Network ACL rules to make the created Internal LB " - "rules (HTTP) accessible...") - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], network=internal_tier) - - # VSD verification - self.verify_vsd_firewall_rule(http_rule) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Creating Static NAT rule for the VM in the Public tier - public_ip = self.acquire_PublicIPAddress(public_tier, vpc) - self.validate_PublicIPAddress(public_ip, public_tier) - self.create_StaticNatRule_For_VM(public_vm, public_ip, public_tier) - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - - # Adding Network ACL rule in the Public tier - self.debug("Adding Network ACL rule to make the created NAT rule " - "(SSH) accessible...") - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=public_tier) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # Restart Internal tier (cleanup = false) - # InternalLbVm gets destroyed and deployed again in the Internal tier - self.debug("Restarting the Internal tier without cleanup...") - Network.restart(internal_tier, self.api_client, cleanup=False) - self.validate_Network(internal_tier, state="Implemented") - self.check_Router_state(vr, state="Running") - self.check_VM_state(internal_vm, state="Running") - self.check_VM_state(internal_vm_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm) - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - self.verify_vsd_firewall_rule(http_rule) - - # Validating InternalLbVm state - # InternalLbVm gets destroyed and deployed again in the Internal tier - int_lb_vm = self.get_InternalLbVm( - internal_tier, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - # Restart Internal tier (cleanup = true) - # InternalLbVm gets destroyed and deployed again in the Internal tier - self.debug("Restarting the Internal tier with cleanup...") - Network.restart(internal_tier, self.api_client, cleanup=True) - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(internal_tier) - self.check_Router_state(vr, state="Running") - self.check_VM_state(internal_vm, state="Running") - self.check_VM_state(internal_vm_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm) - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - self.verify_vsd_firewall_rule(http_rule) - - # Validating InternalLbVm state - # InternalLbVm gets destroyed and deployed again in the Internal tier - int_lb_vm = self.get_InternalLbVm( - internal_tier, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # Restart Public tier (cleanup = false) - # This restart has no effect on the InternalLbVm functionality - self.debug("Restarting the Public tier without cleanup...") - Network.restart(public_tier, self.api_client, cleanup=False) - self.validate_Network(public_tier, state="Implemented") - self.check_Router_state(vr, state="Running") - self.check_VM_state(public_vm, state="Running") - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - self.verify_vsd_firewall_rule(public_ssh_rule) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - ssh_client = self.ssh_into_VM(public_vm, public_ip) - wget_file = self.wget_from_vm_cmd( - ssh_client, int_lb_rule_1.sourceipaddress, - self.test_data["http_rule"]["publicport"]) - - # Verifying Internal LB (wget) traffic test - self.verify_lb_wget_file( - wget_file, [internal_vm, internal_vm_1, internal_vm_2]) - - # Restart Public tier (cleanup = true) - # This restart has no effect on the InternalLbVm functionality - self.debug("Restarting the Public tier with cleanup...") - Network.restart(public_tier, self.api_client, cleanup=True) - self.validate_Network(public_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - self.check_VM_state(public_vm, state="Running") - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - self.verify_vsd_firewall_rule(public_ssh_rule) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # Stopping VMs in the Internal tier - # wget traffic test fails as all the VMs in the Internal tier are in - # stopped state - self.debug("Stopping all the VMs in the Internal tier...") - internal_vm.stop(self.api_client) - internal_vm_1.stop(self.api_client) - internal_vm_2.stop(self.api_client) - self.validate_Network(internal_tier, state="Implemented") - self.check_Router_state(vr, state="Running") - self.check_VM_state(internal_vm, state="Stopped") - self.check_VM_state(internal_vm_1, state="Stopped") - self.check_VM_state(internal_vm_2, state="Stopped") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm, stopped=True) - self.verify_vsd_vm(internal_vm_1, stopped=True) - self.verify_vsd_vm(internal_vm_2, stopped=True) - self.verify_vsd_firewall_rule(http_rule) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm, - should_fail=True) - - # Starting VMs in the Internal tier - # wget traffic test succeeds as all the VMs in the Internal tier are - # back in running state - self.debug("Starting all the VMs in the Internal tier...") - internal_vm.start(self.api_client) - internal_vm_1.start(self.api_client) - internal_vm_2.start(self.api_client) - self.validate_Network(internal_tier, state="Implemented") - self.check_Router_state(vr, state="Running") - self.check_VM_state(internal_vm, state="Running") - self.check_VM_state(internal_vm_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm) - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - self.verify_vsd_firewall_rule(http_rule) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # Restarting VPC (cleanup = false) - # VPC VR gets destroyed and deployed again in the VPC - # This restart has no effect on the InternalLbVm functionality - self.debug("Restarting the VPC without cleanup...") - self.restart_Vpc(vpc, cleanup=False) - self.validate_Network(public_tier, state="Implemented") - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - self.check_VM_state(public_vm, state="Running") - self.check_VM_state(internal_vm, state="Running") - self.check_VM_state(internal_vm_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - self.verify_vsd_vm(internal_vm) - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - self.verify_vsd_firewall_rule(public_ssh_rule) - self.verify_vsd_firewall_rule(http_rule) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # Restarting VPC (cleanup = true) - # VPC VR gets destroyed and deployed again in the VPC - # This restart has no effect on the InternalLbVm functionality - self.debug("Restarting the VPC with cleanup...") - self.restart_Vpc(vpc, cleanup=True) - self.validate_Network(public_tier, state="Implemented") - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - self.check_VM_state(public_vm, state="Running") - self.check_VM_state(internal_vm, state="Running") - self.check_VM_state(internal_vm_1, state="Running") - self.check_VM_state(internal_vm_2, state="Running") - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - self.verify_vsd_vm(internal_vm) - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - self.verify_vsd_firewall_rule(public_ssh_rule) - self.verify_vsd_firewall_rule(http_rule) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - ssh_client = self.ssh_into_VM(public_vm, public_ip) - wget_file = self.wget_from_vm_cmd( - ssh_client, int_lb_rule_1.sourceipaddress, - self.test_data["http_rule"]["publicport"]) - - # Verifying Internal LB (wget) traffic test - self.verify_lb_wget_file( - wget_file, [internal_vm, internal_vm_1, internal_vm_2]) - - def verify_internal_lb_wget_traffic(self, int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm, - should_fail=False): - if self.isSimulator: - self.debug("Simulator Environment: " - "not running wget traffic tests.") - return - ssh_client = self.ssh_into_VM(public_vm, public_ip) - tries = 0 - wget_file = None - while tries < 120: - wget_file = self.wget_from_vm_cmd( - ssh_client, int_lb_rule_1.sourceipaddress, - self.test_data["http_rule"]["publicport"]) - if wget_file != "": - break - self.debug("Waiting for the InternalLbVm in the Internal tier to " - "be fully resolved for (wget) traffic test...") - time.sleep(5) - tries += 1 - - # Verifying Internal LB (wget) traffic test - if should_fail: - with self.assertRaises(Exception): - self.verify_lb_wget_file( - wget_file, [internal_vm, internal_vm_1, internal_vm_2]) - self.debug("Failed to wget file as all the VMs in the Internal " - "tier are in stopped state") - else: - self.verify_lb_wget_file( - wget_file, [internal_vm, internal_vm_1, internal_vm_2]) - - @skip - # Skip until CLOUDSTACK-9837 is fixed - @attr(tags=["advanced", "nuagevsp"], required_hardware="true") - def test_08_nuage_internallb_appliance_operations_traffic(self): - """Test Nuage VSP VPC Internal LB functionality with InternalLbVm - appliance operations by performing (wget) traffic tests within a VPC - """ - - # Repeat the tests in the testcase "test_05_nuage_internallb_traffic" - # with InternalLbVm appliance operations: - # 1. Verify the InternalLbVm deployment by creating the Internal LB - # Rules when the VPC VR is in Stopped state, VPC VR has no effect on - # the InternalLbVm functionality. - # 2. Stop the InternalLbVm when the VPC VR is in Stopped State - # 3. Start the InternalLbVm when the VPC VR is in Stopped state - # 4. Stop the InternalLbVm when the VPC VR is in Running State - # 5. Start the InternalLbVm when the VPC VR is in Running state - # 6. Force stop the InternalLbVm when the VPC VR is in Running State - # 7. Start the InternalLbVm when the VPC VR is in Running state - # Verify the above restarts of VPC networks by performing (wget) - # traffic tests within a VPC. - # Delete all the created objects (cleanup). - - # Creating a VPC offering - self.debug("Creating Nuage VSP VPC offering with Internal LB " - "service...") - vpc_off = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering_lb"]) - self.validate_VpcOffering(vpc_off, state="Enabled") - - # Creating a VPC - self.debug("Creating a VPC with Internal LB service...") - vpc = self.create_vpc(vpc_off, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating network offerings - self.debug("Creating Nuage VSP VPC Network offering with Internal LB " - "service...") - net_off_1 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering_internal_lb"]) - self.validate_NetworkOffering(net_off_1, state="Enabled") - - self.debug("Creating Nuage VSP VPC Network offering without Internal " - "LB service...") - net_off_2 = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(net_off_2, state="Enabled") - - # Creating VPC networks in the VPC, and deploying VMs - self.debug("Creating a VPC network with Internal LB service...") - internal_tier = self.create_Network( - net_off_1, gateway='10.1.1.1', vpc=vpc) - self.validate_Network(internal_tier, state="Implemented") - vr = self.get_Router(internal_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - internal_vm = self.create_VM(internal_tier) - self.check_VM_state(internal_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(internal_vm) - - self.debug("Creating a VPC network without Internal LB service...") - public_tier = self.create_Network( - net_off_2, gateway='10.1.2.1', vpc=vpc) - self.validate_Network(public_tier, state="Implemented") - vr = self.get_Router(public_tier) - self.check_Router_state(vr, state="Running") - - self.debug("Deploying a VM in the created VPC network...") - public_vm = self.create_VM(public_tier) - self.check_VM_state(public_vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(public_vm) - - # Stopping the VPC VR - # VPC VR has no effect on the InternalLbVm functionality - Router.stop(self.api_client, id=vr.id) - self.check_Router_state(vr, state="Stopped") - self.validate_Network(public_tier, state="Implemented") - self.validate_Network(internal_tier, state="Implemented") - - # VSD verification - self.verify_vsd_router(vr, stopped=True) - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - - # Creating Internal LB Rules in the Internal tier - self.debug("Creating two Internal LB Rules (SSH & HTTP) using the " - "same Load Balancing source IP Address...") - int_lb_rule_1 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", vm_array=[internal_vm]) - int_lb_rule_2 = self.create_Internal_LB_Rule( - internal_tier, vm_array=[internal_vm], - services=self.test_data["internal_lbrule_http"], - source_ip=int_lb_rule_1.sourceipaddress) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", vm_array=[internal_vm]) - - # Validating InternalLbVm deployment and state - int_lb_vm = self.get_InternalLbVm( - internal_tier, int_lb_rule_1.sourceipaddress) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Deploying more VMs in the Internal tier - self.debug("Deploying two more VMs in network - %s" % - internal_tier.name) - internal_vm_1 = self.create_VM(internal_tier) - internal_vm_2 = self.create_VM(internal_tier) - - # VSD verification - self.verify_vsd_vm(internal_vm_1) - self.verify_vsd_vm(internal_vm_2) - - # Adding newly deployed VMs to the created Internal LB rules - self.debug("Adding two more virtual machines to the created Internal " - "LB rules...") - int_lb_rule_1.assign(self.api_client, [internal_vm_1, internal_vm_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_1, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - int_lb_rule_2.assign(self.api_client, [internal_vm_1, internal_vm_2]) - self.validate_Internal_LB_Rule( - int_lb_rule_2, state="Active", - vm_array=[internal_vm, internal_vm_1, internal_vm_2]) - - # Validating InternalLbVm state - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Adding Network ACL rules in the Internal tier - self.debug("Adding Network ACL rules to make the created Internal LB " - "rules (HTTP) accessible...") - http_rule = self.create_NetworkAclRule( - self.test_data["http_rule"], network=internal_tier) - - # VSD verification - self.verify_vsd_firewall_rule(http_rule) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Creating Static NAT rule for the VM in the Public tier - public_ip = self.acquire_PublicIPAddress(public_tier, vpc) - self.validate_PublicIPAddress(public_ip, public_tier) - self.create_StaticNatRule_For_VM(public_vm, public_ip, public_tier) - self.validate_PublicIPAddress( - public_ip, public_tier, static_nat=True, vm=public_vm) - - # VSD verification - self.verify_vsd_floating_ip( - public_tier, public_vm, public_ip.ipaddress, vpc) - - # Adding Network ACL rule in the Public tier - self.debug("Adding Network ACL rule to make the created NAT rule " - "(SSH) accessible...") - public_ssh_rule = self.create_NetworkAclRule( - self.test_data["ingress_rule"], network=public_tier) - - # VSD verification - self.verify_vsd_firewall_rule(public_ssh_rule) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # # Stopping the InternalLbVm when the VPC VR is in Stopped state - self.stop_InternalLbVm(int_lb_vm) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Stopped") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm, stopped=True) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm, - should_fail=True) - - # # Starting the InternalLbVm when the VPC VR is in Stopped state - self.start_InternalLbVm(int_lb_vm) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - # Bug CLOUDSTACK-9837 - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # Starting the VPC VR - # VPC VR has no effect on the InternalLbVm functionality - Router.start(self.api_client, id=vr.id) - self.check_Router_state(vr) - self.validate_Network(public_tier, state="Implemented") - self.validate_Network(internal_tier, state="Implemented") - - # VSD verification - self.verify_vsd_router(vr) - self.verify_vsd_network(self.domain.id, public_tier, vpc) - self.verify_vsd_network(self.domain.id, internal_tier, vpc) - - # # Stopping the InternalLbVm when the VPC VR is in Running state - self.stop_InternalLbVm(int_lb_vm) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Stopped") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm, stopped=True) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm, - should_fail=True) - - # # Starting the InternalLbVm when the VPC VR is in Running state - self.start_InternalLbVm(int_lb_vm) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) - - # # Force Stopping the InternalLbVm when the VPC VR is in Running state - self.stop_InternalLbVm(int_lb_vm, force=True) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Stopped") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm, stopped=True) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm, - should_fail=True) - - # # Starting the InternalLbVm when the VPC VR is in Running state - self.start_InternalLbVm(int_lb_vm) - self.check_InternalLbVm_state( - internal_tier, int_lb_rule_1.sourceipaddress, state="Running") - - # VSD Verification - self.verify_vsd_lb_device(int_lb_vm) - - # Verifying Internal Load Balanced VMs ingress traffic - # (SSH into VM via Static NAT rule) - self.debug("Verifying Internal Load Balanced VMs ingress traffic " - "(SSH into VM via Static NAT rule)...") - self.verify_vpc_vm_ingress_traffic(internal_vm, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_1, internal_tier, vpc) - self.verify_vpc_vm_ingress_traffic(internal_vm_2, internal_tier, vpc) - - # Internal LB (wget) traffic test - self.verify_internal_lb_wget_traffic(int_lb_rule_1, internal_vm, - internal_vm_1, internal_vm_2, - public_ip, public_vm) diff --git a/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py b/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py deleted file mode 100644 index c75159e1741..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_vpc_network.py +++ /dev/null @@ -1,147 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for basic VPC Network functionality with -Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import Account -# Import System Modules -from nose.plugins.attrib import attr - - -class TestNuageVpcNetwork(nuageTestCase): - """ Test basic VPC Network functionality with Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls, zone=None): - super(TestNuageVpcNetwork, cls).setUpClass() - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_nuage_vpc_network(self): - """ Test basic VPC Network functionality with Nuage VSP SDN plugin - """ - - # 1. Create Nuage VSP VPC offering, check if it is successfully - # created and enabled. - # 2. Create a VPC with Nuage VSP VPC offering, check if it is - # successfully created and enabled. - # 3. Create Nuage VSP VPC Network offering, check if it is successfully - # created and enabled. - # 4. Create an ACL list in the created VPC, and add an ACL item to it. - # 5. Create a VPC Network with Nuage VSP VPC Network offering and the - # created ACL list, check if it is successfully created, is in the - # "Implemented" state, and is added to the VPC VR. - # 6. Verify that the VPC VR has no Public IP and NIC as it is not the - # Source NAT service provider. - # 7. Deploy a VM in the created VPC network, check if the VM is - # successfully deployed and is in the "Running" state. - # 8. Verify that the created ACL item is successfully implemented in - # Nuage VSP. - # 9. Delete all the created objects (cleanup). - - # Creating a VPC offering - self.debug("Creating Nuage VSP VPC offering...") - vpc_offering = self.create_VpcOffering( - self.test_data["nuagevsp"]["vpc_offering"]) - self.validate_VpcOffering(vpc_offering, state="Enabled") - - # Creating a VPC - self.debug("Creating a VPC with Nuage VSP VPC offering...") - vpc = self.create_vpc(vpc_offering, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - - # Creating a network offering - self.debug("Creating Nuage VSP VPC Network offering...") - network_offering = self.create_NetworkOffering( - self.test_data["nuagevsp"]["vpc_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - # Creating an ACL list - acl_list = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc) - - # Creating an ACL item - acl_item = self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list) - - # Creating a VPC network in the VPC - self.debug("Creating a VPC network with Nuage VSP VPC Network " - "offering...") - vpc_network = self.create_Network( - network_offering, vpc=vpc, acl_list=acl_list) - self.validate_Network(vpc_network, state="Implemented") - vr = self.get_Router(vpc_network) - self.check_Router_state(vr, state="Running") - - # Verifying that the VPC VR has no public IP and NIC - self.verify_VRWithoutPublicIPNIC(vr) - # Verifying that the VPC has no src NAT ip - self.verify_vpc_has_no_src_nat(vpc) - - # Deploying a VM in the VPC network - vm = self.create_VM(vpc_network) - self.check_VM_state(vm, state="Running") - - # VSD verification - self.verify_vsd_network(self.domain.id, vpc_network, vpc) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm) - - # VSD verification for ACL item - self.verify_vsd_firewall_rule(acl_item) - - self.restart_Vpc(vpc, cleanup=True) - - self.validate_Network(vpc_network, state="Implemented") - vr = self.get_Router(vpc_network) - self.verify_vsd_router(vr) - - @attr( - tags=["advanced", "nuagevsp", "multizone"], required_hardware="false") - def test_nuage_vpc_network_multizone(self): - """ Test basic VPC Network functionality with Nuage VSP SDN plugin on - multiple zones - """ - - # Repeat the tests in the above testcase "test_nuage_vpc_network" on - # multiple zones - - self.debug("Testing basic VPC Network functionality with Nuage VSP " - "SDN plugin on multiple zones...") - if len(self.zones) == 1: - self.skipTest("There is only one Zone configured: skipping test") - for zone in self.zones: - self.debug("Zone - %s" % zone.name) - # Get Zone details - self.getZoneDetails(zone=zone) - # Configure VSD sessions - self.configureVSDSessions() - self.test_nuage_vpc_network() diff --git a/test/integration/plugins/nuagevsp/test_nuage_vsp.py b/test/integration/plugins/nuagevsp/test_nuage_vsp.py deleted file mode 100644 index 82160f03a26..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_vsp.py +++ /dev/null @@ -1,245 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" P1 tests for Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import Account, Nuage, Network -from marvin.cloudstackAPI import deleteNuageVspDevice -# Import System Modules -from nose.plugins.attrib import attr -import copy - - -class TestNuageVsp(nuageTestCase): - """ Test Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls): - super(TestNuageVsp, cls).setUpClass() - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - # validate_NuageVspDevice - Validates the addition of Nuage VSP device in - # the Nuage VSP Physical Network - def validate_NuageVspDevice(self): - """Validates the addition of Nuage VSP device in the - Nuage VSP Physical Network""" - self.debug("Validating the addition of Nuage VSP device in the Nuage " - "VSP Physical Network - %s" % self.vsp_physical_network.id) - nuage_vsp_device = Nuage.list( - self.api_client, - physicalnetworkid=self.vsp_physical_network.id - ) - self.assertEqual(isinstance(nuage_vsp_device, list), True, - "List Nuage VSP device should return a valid list" - ) - self.debug("Successfully validated the addition of Nuage VSP device " - "in the Nuage VSP Physical Network - %s" % - self.vsp_physical_network.id) - - # delete_NuageVspDevice - Deletes the Nuage VSP device in the Nuage VSP - # Physical Network - def delete_NuageVspDevice(self): - """Deletes the Nuage VSP device in the Nuage VSP Physical Network""" - self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical " - "Network - %s" % self.vsp_physical_network.id) - nuage_vsp_device = Nuage.list( - self.api_client, - physicalnetworkid=self.vsp_physical_network.id)[0] - cmd = deleteNuageVspDevice.deleteNuageVspDeviceCmd() - cmd.vspdeviceid = nuage_vsp_device.vspdeviceid - self.api_client.deleteNuageVspDevice(cmd) - self.debug("Successfully deleted the Nuage VSP device in the Nuage " - "VSP Physical Network - %s" % self.vsp_physical_network.id) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_nuage_vsp_device(self): - """ Test Nuage VSP device in the Nuage VSP Physical Network - """ - - # 1. Verify that the Nuage VSP network service provider is successfully - # created and enabled in the Nuage VSP Physical Network. - # 2. Verify that the Nuage VSP device is successfully created in the - # Nuage VSP Physical Network. - # 3. Delete the Nuage VSP device in the Nuage VSP Physical Network, - # verify that the Nuage VSP device is successfully deleted in the - # Nuage VSP Physical Network. - # 4. Add the Nuage VSP device in the Nuage VSP Physical Network with - # invalid VSD credentials, verify that the Nuage VSP device failed - # to add in the Nuage VSP Physical Network. - # 5. Add the Nuage VSP device in the Nuage VSP Physical Network with - # valid VSD credentials, verify that the Nuage VSP device is - # successfully added in the Nuage VSP Physical Network. - - for zone in self.zones: - self.debug("Zone - %s" % zone.name) - # Get Zone details - self.getZoneDetails(zone=zone) - # Configure VSD sessions - self.configureVSDSessions() - - # Nuage VSP network service provider validation - self.debug("Validating the Nuage VSP network service provider in " - "the Nuage VSP Physical Network...") - self.validate_NetworkServiceProvider("NuageVsp", state="Enabled") - - # Nuage VSP device validation - self.debug("Validating the Nuage VSP device in the Nuage VSP " - "Physical Network...") - self.validate_NuageVspDevice() - - # Nuage VSP device deletion - self.debug("Deleting the Nuage VSP device in the Nuage VSP " - "Physical Network...") - self.delete_NuageVspDevice() - - # Nuage VSP device validation - self.debug("Validating the Nuage VSP device in the Nuage VSP " - "Physical Network...") - with self.assertRaises(Exception): - self.validate_NuageVspDevice() - self.debug("Successfully deleted the Nuage VSP device in the " - "Nuage VSP Physical Network") - - # Adding the Nuage VSP device with invalid VSD credentials - self.debug("Adding the Nuage VSP device in the Nuage VSP Physical " - "Network with invalid VSD credentials...") - vsd_info = self.nuage_vsp_device.__dict__ - invalid_vsd_info = copy.deepcopy(vsd_info) - invalid_vsd_info["password"] = "" - with self.assertRaises(Exception): - Nuage.add( - self.api_client, invalid_vsd_info, - self.vsp_physical_network.id) - self.debug("Failed to add the Nuage VSP device in the Nuage VSP " - "Physical Network due to invalid VSD credentials") - - # Nuage VSP device validation - self.debug("Validating the Nuage VSP device in the Nuage VSP " - "Physical Network...") - with self.assertRaises(Exception): - self.validate_NuageVspDevice() - self.debug("The Nuage VSP device is not added in the Nuage VSP " - "Physical Network") - - # Adding the Nuage VSP device with valid VSD credentials - self.debug("Adding the Nuage VSP device in the Nuage VSP Physical " - "Network with valid VSD credentials...") - Nuage.add(self.api_client, vsd_info, self.vsp_physical_network.id) - - # Nuage VSP device validation - self.debug("Validating the Nuage VSP device in the Nuage VSP " - "Physical Network...") - self.validate_NuageVspDevice() - - @attr(tags=["advanced", "nuagevsp", "isolated"], required_hardware="false") - def test_nuage_vsp(self): - """ Test Nuage VSP SDN plugin with basic Isolated Network functionality - """ - - # 1. Verify that the Nuage VSP network service provider is successfully - # created and enabled. - # 2. Create and enable Nuage VSP Isolated Network offering, check if it - # is successfully created and enabled. - # 3. Create an Isolated Network with Nuage VSP Isolated Network - # offering, check if it is successfully created and is in the - # "Allocated" state. - # 4. Deploy a VM in the created Isolated network, check if the Isolated - # network state is changed to "Implemented", and both the VM & VR - # are successfully deployed and are in the "Running" state. - # 5. Verify that the VPC VR has no Public IP and NIC as it is not the - # Source NAT service provider. - # 6. Deploy one more VM in the created Isolated network, check if the - # VM is successfully deployed and is in the "Running" state. - # 7. Delete the created Isolated Network after destroying its VMs, - # check if the Isolated network is successfully deleted. - # 8. Delete all the created objects (cleanup). - - for zone in self.zones: - self.debug("Zone - %s" % zone.name) - # Get Zone details - self.getZoneDetails(zone=zone) - # Configure VSD sessions - self.configureVSDSessions() - - # Creating a network offering - self.debug("Creating and enabling Nuage VSP Isolated Network " - "offering...") - network_offering = self.create_NetworkOffering( - self.test_data["nuagevsp"]["isolated_network_offering"]) - self.validate_NetworkOffering(network_offering, state="Enabled") - - # Creating a network - self.debug("Creating an Isolated Network with Nuage VSP Isolated " - "Network offering...") - network = self.create_Network(network_offering) - self.validate_Network(network, state="Allocated") - - # Deploying a VM in the network - vm_1 = self.create_VM(network) - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.check_Router_state(vr, state="Running") - self.check_VM_state(vm_1, state="Running") - - # Verifying that the VR has no public IP and NIC - self.verify_VRWithoutPublicIPNIC(vr) - - # VSD verification - self.verify_vsd_network(self.domain.id, network) - self.verify_vsd_router(vr) - self.verify_vsd_vm(vm_1) - - # Deploying one more VM in the network - vm_2 = self.create_VM(network) - self.check_VM_state(vm_2, state="Running") - - # VSD verification - self.verify_vsd_vm(vm_2) - - Network.restart(network, self.api_client, cleanup=True) - - self.validate_Network(network, state="Implemented") - vr = self.get_Router(network) - self.verify_vsd_router(vr) - - # Deleting the network - self.debug("Deleting the Isolated Network with Nuage VSP Isolated " - "Network offering...") - self.delete_VM(vm_1) - self.delete_VM(vm_2) - self.delete_Network(network) - with self.assertRaises(Exception): - self.validate_Network(network) - self.debug("Isolated Network successfully deleted in CloudStack") - - # VSD verification - with self.assertRaises(Exception): - self.verify_vsd_network(self.domain.id, network) - self.debug("Isolated Network successfully deleted in VSD") diff --git a/test/integration/plugins/nuagevsp/test_nuage_vsp_domain_template.py b/test/integration/plugins/nuagevsp/test_nuage_vsp_domain_template.py deleted file mode 100644 index dcc2025705d..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_vsp_domain_template.py +++ /dev/null @@ -1,835 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for Nuage VSP SDN plugin's Domain Template feature -""" -# Import Local Modules -from nuageTestCase import nuageTestCase -from marvin.lib.base import (Account, - Configurations, - Domain, - Network, - User, - VirtualMachine) -from marvin.cloudstackAPI import (associateNuageVspDomainTemplate, - listNuageVspDomainTemplates, - listNuageVspGlobalDomainTemplate) -# Import System Modules -from nose.plugins.attrib import attr - - -class TestNuageDomainTemplate(nuageTestCase): - """Test Nuage VSP SDN plugin's Domain Template feature - """ - - @classmethod - def setUpClass(cls): - """ - Create the following domain tree and accounts that are required for - executing Nuage VSP SDN plugin's Domain Template feature test cases: - Under ROOT - Create a domain D1 - Under domain D1 - Create a subdomain D11 - Under each of the domains - create an admin user and a regular - user account. - Create Nuage VSP VPC and network (tier) offerings - Create a VPC with a VPC network (tier) under each of the admin accounts - of the above domains - Create three pre-configured Nuage VSP domain templates per enterprise - in VSD corresponding to each of the above domains - """ - - super(TestNuageDomainTemplate, cls).setUpClass() - cls.domains_accounts_data = cls.test_data["acl"] - - try: - # Backup default (ROOT admin user) apikey and secretkey - cls.default_apikey = cls.api_client.connection.apiKey - cls.default_secretkey = cls.api_client.connection.securityKey - - # Create domains - cls.domain_1 = Domain.create( - cls.api_client, - cls.domains_accounts_data["domain1"] - ) - cls._cleanup.append(cls.domain_1) - - cls.domain_11 = Domain.create( - cls.api_client, - cls.domains_accounts_data["domain11"], - parentdomainid=cls.domain_1.id - ) - cls._cleanup.append(cls.domain_11) - - # Create an admin and an user account under ROOT domain - cls.account_root = Account.create( - cls.api_client, - cls.domains_accounts_data["accountROOT"], - admin=True, - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_root) - cls.user_root_apikey = user.apikey - cls.user_root_secretkey = user.secretkey - cls._cleanup.append(cls.account_root) - - cls.account_roota = Account.create( - cls.api_client, - cls.domains_accounts_data["accountROOTA"], - admin=False, - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_roota) - cls.user_roota_apikey = user.apikey - cls.user_roota_secretkey = user.secretkey - cls._cleanup.append(cls.account_roota) - - # Create an admin and an user account under domain D1 - cls.account_d1 = Account.create( - cls.api_client, - cls.domains_accounts_data["accountD1"], - admin=True, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1) - cls.user_d1_apikey = user.apikey - cls.user_d1_secretkey = user.secretkey - cls._cleanup.append(cls.account_d1) - - cls.account_d1a = Account.create( - cls.api_client, - cls.domains_accounts_data["accountD1A"], - admin=False, - domainid=cls.domain_1.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d1a) - cls.user_d1a_apikey = user.apikey - cls.user_d1a_secretkey = user.secretkey - cls._cleanup.append(cls.account_d1a) - - # Create an admin and an user account under subdomain D11 - cls.account_d11 = Account.create( - cls.api_client, - cls.domains_accounts_data["accountD11"], - admin=True, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11) - cls.user_d11_apikey = user.apikey - cls.user_d11_secretkey = user.secretkey - cls._cleanup.append(cls.account_d11) - - cls.account_d11a = Account.create( - cls.api_client, - cls.domains_accounts_data["accountD11A"], - admin=False, - domainid=cls.domain_11.id - ) - user = cls.generateKeysForUser(cls.api_client, cls.account_d11a) - cls.user_d11a_apikey = user.apikey - cls.user_d11a_secretkey = user.secretkey - cls._cleanup.append(cls.account_d11a) - - # Create VPC offering - cls.vpc_offering = cls.create_VpcOffering( - cls.test_data["nuagevsp"]["vpc_offering"]) - - # Create VPC network (tier) offering - cls.network_offering = cls.create_NetworkOffering( - cls.test_data["nuagevsp"]["vpc_network_offering"]) - - # Create a VPC with a VPC network (tier) under each of the admin - # accounts of ROOT domain, domain D1, and subdomain D11 - # Create 500 pre-configured Nuage VSP domain templates per - # enterprise in VSD corresponding to each of the above domains - cls.cleanup_domain_templates = [] - cls.domain_template_list = [] - for i in range(0, 3): - cls.domain_template_list.append("domain_template_" + str(i)) - for account in [cls.account_root, cls.account_d1, cls.account_d11]: - vpc = cls.create_vpc( - cls.vpc_offering, cidr='10.1.0.0/16', account=account) - cls.create_Network( - cls.network_offering, - vpc=vpc, - account=account) - for domain_template in cls.domain_template_list: - new_domain_template = cls.vsdk.NUDomainTemplate( - name=domain_template, - description=domain_template) - enterprise = cls._session.user.enterprises.get_first( - filter="externalID BEGINSWITH '%s'" % account.domainid) - enterprise.create_child(new_domain_template) - cls.cleanup_domain_templates.append( - enterprise.domain_templates.get_first( - filter="name is '%s'" % domain_template)) - except Exception as e: - cls.tearDownClass() - raise Exception("Failed to create the setup required to execute " - "the test cases: %s" % e) - return - - @classmethod - def tearDownClass(cls): - # Restore back default (ROOT admin user) apikey and secretkey - cls.api_client.connection.apiKey = cls.default_apikey - cls.api_client.connection.securityKey = cls.default_secretkey - # Cleanup resources used - cls.debug("Cleaning up the resources") - for domain_template in cls.cleanup_domain_templates: - try: - domain_template.delete() - except Exception as e: - cls.error("Failed to cleanup domain template %s in VSD, got " - "%s" % (domain_template, e)) - cls.cleanup_domain_templates = [] - for obj in reversed(cls._cleanup): - try: - if isinstance(obj, VirtualMachine): - obj.delete(cls.api_client, expunge=True) - else: - obj.delete(cls.api_client) - except Exception as e: - cls.error("Failed to cleanup %s, got %s" % (obj, e)) - try: - cls.vpc_offering.delete(cls.api_client) - cls.network_offering.delete(cls.api_client) - cls.service_offering.delete(cls.api_client) - except Exception as e: - cls.error("Failed to cleanup offerings - %s" % e) - # cleanup_resources(cls.api_client, cls._cleanup) - cls._cleanup = [] - cls.debug("Cleanup complete!") - return - - def setUp(self): - self.account = self.account_root - self.cleanup = [] - return - - def tearDown(self): - # Restore back default (ROOT admin user) apikey and secretkey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - # Cleanup resources used - self.debug("Cleaning up the resources") - for obj in reversed(self.cleanup): - try: - if isinstance(obj, VirtualMachine): - obj.delete(self.api_client, expunge=True) - else: - obj.delete(self.api_client) - except Exception as e: - self.error("Failed to cleanup %s, got %s" % (obj, e)) - # cleanup_resources(self.api_client, self.cleanup) - self.cleanup = [] - self.debug("Cleanup complete!") - return - - @staticmethod - def generateKeysForUser(api_client, account): - user = User.list( - api_client, - account=account.name, - domainid=account.domainid - )[0] - - return (User.registerUserKeys( - api_client, - user.id - )) - - # list_NuageVspDomainTemplates - Lists pre-configured Nuage VSP domain - # template(s) for the given domain/account user - def list_NuageVspDomainTemplates(self, account=None, name=None): - if not account: - account = self.account - cmd = listNuageVspDomainTemplates.listNuageVspDomainTemplatesCmd() - cmd.domainid = account.domainid - cmd.zoneid = self.zone.id - domain_templates = self.api_client.listNuageVspDomainTemplates(cmd) - if name: - return [domain_template for domain_template in domain_templates - if str(domain_template.name) == name] - else: - return domain_templates - - # validate_NuageVspDomainTemplate - Validates the given pre-configured - # Nuage VSP domain template for the given domain/account user - def validate_NuageVspDomainTemplate(self, name, account=None): - """Validates the pre-configured Nuage VSP domain template""" - if not account: - account = self.account - self.debug("Validating the availability of pre-configured Nuage VSP " - "domain template - %s for domain/account user - %s " - % (name, account)) - domain_templates = self.list_NuageVspDomainTemplates( - name=name, account=account) - self.assertEqual(isinstance(domain_templates, list), True, - "List Nuage VSP Domain Templates should return a " - "valid list" - ) - self.assertEqual(domain_templates[0].name, name, - "Name of the Nuage VSP Domain Template should " - "be in the returned list" - ) - self.debug("Successfully validated the availability of pre-configured " - "Nuage VSP domain template - %s for domain/account user - " - "%s" % (name, account)) - - # associate_NuageVspDomainTemplate - Associates the given pre-configured - # Nuage VSP domain template to the given VPC - def associate_NuageVspDomainTemplate(self, domain_template_name, vpc): - cmd = associateNuageVspDomainTemplate.\ - associateNuageVspDomainTemplateCmd() - cmd.domaintemplate = domain_template_name - cmd.vpcid = vpc.id - cmd.zoneid = self.zone.id - return self.api_client.associateNuageVspDomainTemplate(cmd) - - # update_NuageVspGlobalDomainTemplate - Updates the global setting - # nuagevsp.vpc.domaintemplate.name with the given value - def update_NuageVspGlobalDomainTemplate(self, value): - self.debug("Updating global setting nuagevsp.vpc.domaintemplate.name " - "with value - %s" % value) - self.user_apikey = self.api_client.connection.apiKey - self.user_secretkey = self.api_client.connection.securityKey - self.api_client.connection.apiKey = self.default_apikey - self.api_client.connection.securityKey = self.default_secretkey - Configurations.update(self.api_client, - name="nuagevsp.vpc.domaintemplate.name", - value=value) - self.api_client.connection.apiKey = self.user_apikey - self.api_client.connection.securityKey = self.user_secretkey - self.debug("Successfully updated global setting " - "nuagevsp.vpc.domaintemplate.name with value - %s" % value) - - # list_NuageVspGlobalDomainTemplate - Lists the name of the global/default - # pre-configured Nuage VSP domain template as mentioned in the global - # setting "nuagevsp.vpc.domaintemplate.name" - def list_NuageVspGlobalDomainTemplate(self): - cmd = listNuageVspGlobalDomainTemplate.\ - listNuageVspGlobalDomainTemplateCmd() - return self.api_client.listNuageVspGlobalDomainTemplate(cmd) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_01_nuage_Domain_Template_selection_per_VPC(self): - """Test Nuage VSP Domain Template selection per VPC - """ - - # 1. Associate an invalid/non-existing Nuage VSP domain template to a - # VPC; verify that the association fails. - # 2. Associate a valid/existing pre-configured Nuage VSP domain - # template to a VPC; verify that the association is successful, VPC - # networks (domains) are instantiated from the associated domain - # template in VSD. - # 3. Verify that the state of such VPC networks (domains) in VSD is not - # affected with their restarts in CloudStack with and without - # cleanup. - # 4. Verify that multiple associations (update) of domain templates to - # a VPC goes through till the creation of its first VPC network - # (tier). - # 5. Verify that the VPC networks (domains) creation fails in VSD when - # the associated domain templates to their corresponding VPCs have - # been deleted in VSD. - # 6. Verify that the VPC networks (domains) creation fails in VSD when - # an acl list is associated with them after their corresponding VPCs - # have been associated with a pre-configured Nuage VSP domain - # template. - # 7. Delete all the created objects (cleanup). - - # Creating VPC - vpc_1 = self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - - # Associating pre-configured Nuage VSP Domain Template to VPC - with self.assertRaises(Exception): - self.validate_NuageVspDomainTemplate("invalid_domain_template") - self.debug("There is no domain template with name " - "invalid_domain_template in VSD") - with self.assertRaises(Exception): - self.associate_NuageVspDomainTemplate( - "invalid_domain_template", vpc_1) - self.debug("Association fails as there is no domain template with " - "name invalid_domain_template in VSD") - self.associate_NuageVspDomainTemplate( - self.domain_template_list[0], vpc_1) - - # Creating VPC networks (tiers) - vpc_1_tier_1 = self.create_Network( - self.network_offering, gateway='10.1.3.1', vpc=vpc_1) - vpc_1_tier_2 = self.create_Network( - self.network_offering, gateway='10.1.4.1', vpc=vpc_1) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_1, vpc_1, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_2, vpc_1, - domain_template_name=self.domain_template_list[0]) - - # Restart VPC networks (tiers) without cleanup - Network.restart(vpc_1_tier_1, self.api_client, cleanup=False) - Network.restart(vpc_1_tier_2, self.api_client, cleanup=False) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_1, vpc_1, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_2, vpc_1, - domain_template_name=self.domain_template_list[0]) - - # Restart VPC networks (tiers) with cleanup - Network.restart(vpc_1_tier_1, self.api_client, cleanup=True) - Network.restart(vpc_1_tier_2, self.api_client, cleanup=True) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_1, vpc_1, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_2, vpc_1, - domain_template_name=self.domain_template_list[0]) - - # Restart VPC without cleanup - self.restart_Vpc(vpc_1, cleanup=False) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_1, vpc_1, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_2, vpc_1, - domain_template_name=self.domain_template_list[0]) - - # Restart VPC with cleanup - self.restart_Vpc(vpc_1, cleanup=True) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_1, vpc_1, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_2, vpc_1, - domain_template_name=self.domain_template_list[0]) - - # Creating VPC - vpc_2 = self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - - # Associating pre-configured Nuage VSP Domain Template to VPC - self.validate_NuageVspDomainTemplate(self.domain_template_list[0]) - self.associate_NuageVspDomainTemplate( - self.domain_template_list[0], vpc_2) - self.validate_NuageVspDomainTemplate(self.domain_template_list[1]) - self.associate_NuageVspDomainTemplate( - self.domain_template_list[1], vpc_2) - - # Deleting the associated pre-configured Nuage VSP domain template - enterprise = self._session.user.enterprises.get_first( - filter="externalID BEGINSWITH '%s'" % self.account.domainid) - domain_template = enterprise.domain_templates.get_first( - filter="name is '%s'" % self.domain_template_list[1]) - domain_template.delete() - - # Creating VPC networks (tiers) - with self.assertRaises(Exception): - self.create_Network( - self.network_offering, - gateway='10.1.1.1', - vpc=vpc_2) - self.debug("Corresponding domain creation in VSD fails, but VPC " - "(tier) network gets created on CloudStack as the " - "associated pre-configured Nuage VSP domain template is no " - "longer existing in VSD") - for vpc_2_tier in Network.list(self.api_client, vpcid=vpc_2.id): - Network(vpc_2_tier.__dict__).delete(self.api_client) - - # Re-creating the associated pre-configured Nuage VSP domain template - new_domain_template = self.vsdk.NUDomainTemplate( - name=self.domain_template_list[1], - description=self.domain_template_list[1]) - enterprise = self._session.user.enterprises.get_first( - filter="externalID BEGINSWITH '%s'" % self.account.domainid) - enterprise.create_child(new_domain_template) - self.cleanup_domain_templates.append( - enterprise.domain_templates.get_first( - filter="name is '%s'" % self.domain_template_list[1])) - - vpc_2_tier_1 = self.create_Network( - self.network_offering, gateway='10.1.2.1', vpc=vpc_2) - vpc_2_tier_2 = self.create_Network( - self.network_offering, gateway='10.1.3.1', vpc=vpc_2) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_2_tier_1, vpc_2, - domain_template_name=self.domain_template_list[1]) - self.verify_vsd_network( - self.account.domainid, vpc_2_tier_2, vpc_2, - domain_template_name=self.domain_template_list[1]) - - # Creating VPC - vpc_3 = self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - - # Associating pre-configured Nuage VSP Domain Template to VPC - self.validate_NuageVspDomainTemplate(self.domain_template_list[0]) - self.associate_NuageVspDomainTemplate( - self.domain_template_list[0], vpc_3) - - # Creating an ACL list and an ACL item - acl_list = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc_3) - self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list) - - # Creating VPC networks (tiers) - with self.assertRaises(Exception): - self.create_Network( - self.network_offering, - gateway='10.1.1.1', - vpc=vpc_3, - acl_list=acl_list) - self.debug("Corresponding domain creation in VSD fails, but VPC " - "(tier) network gets created on CloudStack as creation of " - "Network ACLs from CloudStack is not supported when the " - "VPC is associated with a Nuage VSP pre-configured domain " - "template") - for vpc_3_tier in Network.list(self.api_client, vpcid=vpc_3.id): - Network(vpc_3_tier.__dict__).delete(self.api_client) - - vpc_3_tier_1 = self.create_Network( - self.network_offering, gateway='10.1.2.1', vpc=vpc_3) - vpc_3_tier_2 = self.create_Network( - self.network_offering, gateway='10.1.3.1', vpc=vpc_3) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_3_tier_1, vpc_3, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_3_tier_2, vpc_3, - domain_template_name=self.domain_template_list[0]) - - # Creating VPC and VPC network (tier) - vpc = self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - vpc_tier = self.create_Network(self.network_offering, vpc=vpc) - - # VSD verification - self.verify_vsd_network(self.account.domainid, vpc_tier, vpc) - - # Associating pre-configured Nuage VSP Domain Template to VPC - self.validate_NuageVspDomainTemplate(self.domain_template_list[0]) - with self.assertRaises(Exception): - self.associate_NuageVspDomainTemplate( - self.domain_template_list[0], vpc) - self.debug("Association fails as the corresponding domain and domain " - "templates are already created in VSD for the VPC vpc") - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_02_nuage_Domain_Template_selection_per_VPC_as_ROOT_user(self): - """Test Nuage VSP Domain Template selection per VPC as ROOT domain - regular user - """ - - # Repeat the tests in the testcase - # "test_01_nuage_Domain_Template_selection_per_VPC" as ROOT domain - # regular user - - # Setting ROOT domain user account information - self.account = self.account_roota - - # Setting ROOT domain user keys in api_client - self.api_client.connection.apiKey = self.user_roota_apikey - self.api_client.connection.securityKey = self.user_roota_secretkey - - # Calling testcase "test_01_nuage_Domain_Template_selection_per_VPC" - self.test_01_nuage_Domain_Template_selection_per_VPC() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_03_nuage_Domain_Template_selection_per_VPC_as_domain_admin(self): - """Test Nuage VSP Domain Template selection per VPC as domain admin - user - """ - - # Repeat the tests in the testcase - # "test_01_nuage_Domain_Template_selection_per_VPC" as domain admin - # user - - # Setting domain D1 admin account information - self.account = self.account_d1 - - # Setting domain D1 admin keys in api_client - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - - # Calling testcase "test_01_nuage_Domain_Template_selection_per_VPC" - self.test_01_nuage_Domain_Template_selection_per_VPC() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_04_nuage_Domain_Template_selection_per_VPC_as_domain_user(self): - """Test Nuage VSP Domain Template selection per VPC as domain - regular user - """ - - # Repeat the tests in the testcase - # "test_01_nuage_Domain_Template_selection_per_VPC" as domain regular - # user - - # Setting domain D1 user account information - self.account = self.account_d1a - - # Setting domain D1 user keys in api_client - self.api_client.connection.apiKey = self.user_d1a_apikey - self.api_client.connection.securityKey = self.user_d1a_secretkey - - # Calling testcase "test_01_nuage_Domain_Template_selection_per_VPC" - self.test_01_nuage_Domain_Template_selection_per_VPC() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_05_nuage_Domain_Template_selection_per_VPC_as_subdom_admin(self): - """Test Nuage VSP Domain Template selection per VPC as subdomain admin - user - """ - - # Repeat the tests in the testcase - # "test_01_nuage_Domain_Template_selection_per_VPC" as subdomain admin - # user - - # Setting subdomain D11 admin account information - self.account = self.account_d11 - - # Setting subdomain D1 admin keys in api_client - self.api_client.connection.apiKey = self.user_d11_apikey - self.api_client.connection.securityKey = self.user_d11_secretkey - - # Calling testcase "test_01_nuage_Domain_Template_selection_per_VPC" - self.test_01_nuage_Domain_Template_selection_per_VPC() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_06_nuage_Domain_Template_selection_per_VPC_as_subdom_user(self): - """Test Nuage VSP Domain Template selection per VPC as subdomain - regular user - """ - - # Repeat the tests in the testcase - # "test_01_nuage_Domain_Template_selection_per_VPC" as subdomain - # regular user - - # Setting subdomain D11 user account information - self.account = self.account_d11a - - # Setting subdomain D11 user keys in api_client - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - - # Calling testcase "test_01_nuage_Domain_Template_selection_per_VPC" - self.test_01_nuage_Domain_Template_selection_per_VPC() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_07_nuage_Global_Domain_Template(self): - """Test Nuage VSP Global Domain Template - """ - - # 1. Update the global setting "nuagevsp.vpc.domaintemplate.name" with - # an invalid/non-existing Nuage VSP domain template name; verify - # that a new VPC creation fails, and gets cleaned up. - # 2. Update the global setting "nuagevsp.vpc.domaintemplate.name" with - # a valid/existing pre-configured Nuage VSP domain template name; - # verify that all VPC networks (domains) get instantiated from that - # pre-configured Nuage VSP domain template. - # 3. Verify that multiple associations (update) of domain templates to - # such VPCs goes through till the creation of their first VPC - # networks (tiers). - # 4. Delete all the created objects (cleanup). - - # Updating global setting "nuagevsp.vpc.domaintemplate.name" - self.update_NuageVspGlobalDomainTemplate( - value="invalid_domain_template") - domain_template = self.list_NuageVspGlobalDomainTemplate()[0].name - self.assertEqual(domain_template, "invalid_domain_template", - "Global setting nuagevsp.vpc.domaintemplate.name was " - "not updated successfully" - ) - with self.assertRaises(Exception): - self.validate_NuageVspDomainTemplate("invalid_domain_template") - self.debug("There is no domain template with name " - "invalid_domain_template in VSD") - - # Creating VPC - with self.assertRaises(Exception): - self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - self.debug("VPC creation fails as there is no domain template with " - "name invalid_domain_template in VSD as mentioned in " - "global setting nuagevsp.vpc.domaintemplate.name") - - # Updating global setting "nuagevsp.vpc.domaintemplate.name" - self.update_NuageVspGlobalDomainTemplate( - value=self.domain_template_list[0]) - domain_template = self.list_NuageVspGlobalDomainTemplate()[0].name - self.assertEqual(domain_template, self.domain_template_list[0], - "Global setting nuagevsp.vpc.domaintemplate.name was " - "not updated successfully" - ) - self.validate_NuageVspDomainTemplate(self.domain_template_list[0]) - - # Creating VPC and VPC networks (tiers) - vpc_1 = self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - vpc_1_tier_1 = self.create_Network( - self.network_offering, gateway='10.1.1.1', vpc=vpc_1) - vpc_1_tier_2 = self.create_Network( - self.network_offering, gateway='10.1.2.1', vpc=vpc_1) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_1, vpc_1, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_1_tier_2, vpc_1, - domain_template_name=self.domain_template_list[0]) - - # Creating VPC and VPC networks (tiers) - vpc_2 = self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - vpc_2_tier_1 = self.create_Network( - self.network_offering, gateway='10.1.1.1', vpc=vpc_2) - vpc_2_tier_2 = self.create_Network( - self.network_offering, gateway='10.1.2.1', vpc=vpc_2) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_2_tier_1, vpc_2, - domain_template_name=self.domain_template_list[0]) - self.verify_vsd_network( - self.account.domainid, vpc_2_tier_2, vpc_2, - domain_template_name=self.domain_template_list[0]) - - # Creating VPC - vpc_3 = self.create_vpc(self.vpc_offering, cidr='10.1.0.0/16') - - # Associating pre-configured Nuage VSP Domain Template to VPC - self.validate_NuageVspDomainTemplate(self.domain_template_list[1]) - self.associate_NuageVspDomainTemplate( - self.domain_template_list[1], vpc_3) - - # Creating VPC networks (tiers) - vpc_3_tier_1 = self.create_Network( - self.network_offering, gateway='10.1.1.1', vpc=vpc_3) - vpc_3_tier_2 = self.create_Network( - self.network_offering, gateway='10.1.2.1', vpc=vpc_3) - - # VSD verification - self.verify_vsd_network( - self.account.domainid, vpc_3_tier_1, vpc_3, - domain_template_name=self.domain_template_list[1]) - self.verify_vsd_network( - self.account.domainid, vpc_3_tier_2, vpc_3, - domain_template_name=self.domain_template_list[1]) - - # Updating global setting "nuagevsp.vpc.domaintemplate.name" - self.update_NuageVspGlobalDomainTemplate(value="") - domain_template = self.list_NuageVspGlobalDomainTemplate()[0].name - self.assertEqual(domain_template, "", - "Global setting nuagevsp.vpc.domaintemplate.name was " - "not updated successfully" - ) - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_08_nuage_Global_Domain_Template_as_ROOT_user(self): - """Test Nuage VSP Global Domain Template as ROOT domain regular user - """ - - # Repeat the tests in the testcase - # "test_07_nuage_Global_Domain_Template" as ROOT domain regular user - - # Setting ROOT domain user account information - self.account = self.account_roota - - # Setting ROOT domain user keys in api_client - self.api_client.connection.apiKey = self.user_roota_apikey - self.api_client.connection.securityKey = self.user_roota_secretkey - - # Calling testcase "test_07_nuage_Global_Domain_Template" - self.test_07_nuage_Global_Domain_Template() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_09_nuage_Global_Domain_Template_as_domain_admin(self): - """Test Nuage VSP Global Domain Template as domain admin user - """ - - # Repeat the tests in the testcase - # "test_07_nuage_Global_Domain_Template" as domain admin user - - # Setting domain D1 admin account information - self.account = self.account_d1 - - # Setting domain D1 admin keys in api_client - self.api_client.connection.apiKey = self.user_d1_apikey - self.api_client.connection.securityKey = self.user_d1_secretkey - - # Calling testcase "test_07_nuage_Global_Domain_Template" - self.test_07_nuage_Global_Domain_Template() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_10_nuage_Global_Domain_Template_as_domain_user(self): - """Test Nuage VSP Global Domain Template as domain regular user - """ - - # Repeat the tests in the testcase - # "test_07_nuage_Global_Domain_Template" as domain regular user - - # Setting domain D1 user account information - self.account = self.account_d1a - - # Setting domain D1 user keys in api_client - self.api_client.connection.apiKey = self.user_d1a_apikey - self.api_client.connection.securityKey = self.user_d1a_secretkey - - # Calling testcase "test_07_nuage_Global_Domain_Template" - self.test_07_nuage_Global_Domain_Template() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_11_nuage_Global_Domain_Template_as_subdomain_admin(self): - """Test Nuage VSP Global Domain Template as subdomain admin user - """ - - # Repeat the tests in the testcase - # "test_07_nuage_Global_Domain_Template" as subdomain admin user - - # Setting subdomain D11 admin account information - self.account = self.account_d11 - - # Setting subdomain D1 admin keys in api_client - self.api_client.connection.apiKey = self.user_d11_apikey - self.api_client.connection.securityKey = self.user_d11_secretkey - - # Calling testcase "test_07_nuage_Global_Domain_Template" - self.test_07_nuage_Global_Domain_Template() - - @attr(tags=["advanced", "nuagevsp"], required_hardware="false") - def test_12_nuage_Global_Domain_Template_as_subdomain_user(self): - """Test Nuage VSP Global Domain Template as subdomain regular user - """ - - # Repeat the tests in the testcase - # "test_07_nuage_Global_Domain_Template" as subdomain regular user - - # Setting subdomain D11 user account information - self.account = self.account_d11a - - # Setting subdomain D11 user keys in api_client - self.api_client.connection.apiKey = self.user_d11a_apikey - self.api_client.connection.securityKey = self.user_d11a_secretkey - - # Calling testcase "test_07_nuage_Global_Domain_Template" - self.test_07_nuage_Global_Domain_Template() diff --git a/test/integration/plugins/nuagevsp/test_nuage_vsp_mngd_subnets.py b/test/integration/plugins/nuagevsp/test_nuage_vsp_mngd_subnets.py deleted file mode 100644 index 1947f661b61..00000000000 --- a/test/integration/plugins/nuagevsp/test_nuage_vsp_mngd_subnets.py +++ /dev/null @@ -1,777 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -""" Component tests for VSP Managed Subnets functionality - with Nuage VSP SDN plugin -""" -# Import Local Modules -from nuageTestCase import nuageTestCase, needscleanup -from marvin.lib.base import (Account, - Domain, - VirtualMachine) -from marvin.cloudstackAPI import updateZone - -# Import System Modules -from nose.plugins.attrib import attr -import time - - -class TestNuageManagedSubnets(nuageTestCase): - """Test Managed Subnets functionality with Nuage VSP SDN plugin - """ - - @classmethod - def setUpClass(cls): - super(TestNuageManagedSubnets, cls).setUpClass() - - # create a nuage vpc offering - cls.nuage_vpc_offering = \ - cls.create_VpcOffering(cls.test_data["nuagevsp"]["vpc_offering"]) - - # tier network offerings - cls.nuage_vpc_network_offering = \ - cls.create_NetworkOffering(cls.test_data["nuagevsp"] - ["vpc_network_offering"]) - - # create a Nuage isolated network offering with vr - cls.nuage_isolated_network_offering = cls.create_NetworkOffering( - cls.test_data["nuagevsp"]["isolated_network_offering"], True) - - # create a Nuage isolated network offering with vr and persistent - cls.nuage_isolated_network_offering_persistent = \ - cls.create_NetworkOffering( - cls.test_data["nuagevsp"] - ["isolated_network_offering_persistent"], - True) - - # create a Nuage isolated network offering without vr - cls.nuage_isolated_network_offering_without_vr = \ - cls.create_NetworkOffering( - cls.test_data["nuagevsp"] - ["isolated_network_offering_without_vr"], - True) - - # create a Nuage isolated network offering without vr but persistent - cls.nuage_isolated_network_offering_without_vr_persistent = \ - cls.create_NetworkOffering( - cls.test_data["nuagevsp"] - ["isolated_network_offering_without_vr_persistent"], - True) - - # create a Nuage shared network offering - cls.nuage_shared_network_offering = cls.create_NetworkOffering( - cls.test_data["nuagevsp"]["shared_nuage_network_offering"], - False) - - cls._cleanup = [ - cls.nuage_isolated_network_offering, - cls.nuage_isolated_network_offering_persistent, - cls.nuage_isolated_network_offering_without_vr, - cls.nuage_isolated_network_offering_without_vr_persistent, - cls.nuage_vpc_offering, - cls.nuage_vpc_network_offering, - cls.nuage_shared_network_offering - ] - return - - def setUp(self): - # Create an account - self.account = Account.create(self.api_client, - self.test_data["account"], - admin=True, - domainid=self.domain.id - ) - self.cleanup = [self.account] - return - - def verify_ping_to_vm(self, src_vm, dst_vm, public_ip, dst_hostname=None): - if self.isSimulator: - self.debug("Simulator Environment: not verifying pinging") - return - try: - src_vm.ssh_ip = public_ip.ipaddress.ipaddress - src_vm.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - src_vm.username = self.test_data["virtual_machine"]["username"] - src_vm.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (src_vm.ssh_ip, src_vm.password)) - - ssh = self.ssh_into_VM(src_vm, public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, dst_vm.ipaddress) - if dst_hostname: - self.verify_pingtovmipaddress(ssh, dst_hostname) - - def verify_pingtovmipaddress(self, ssh, pingtovmipaddress): - """verify ping to ipaddress of the vm and retry 3 times""" - successfull_ping = False - nbr_retries = 0 - max_retries = 5 - cmd = 'ping -c 2 ' + pingtovmipaddress - - while not successfull_ping and nbr_retries < max_retries: - self.debug("ping vm by ipaddress with command: " + cmd) - outputlist = ssh.execute(cmd) - self.debug("command is executed properly " + cmd) - completeoutput = str(outputlist).strip('[]') - self.debug("complete output is " + completeoutput) - if '2 received' in completeoutput: - self.debug("PASS as vm is pingeable: " + completeoutput) - successfull_ping = True - else: - self.debug("FAIL as vm is not pingeable: " + completeoutput) - time.sleep(3) - nbr_retries = nbr_retries + 1 - - if not successfull_ping: - self.fail("FAILED TEST as excepted value not found in vm") - - # verify_vsd_vm - Verifies the given CloudStack VM deployment and status in - # VSD - def verify_vsdmngd_vm(self, vm, vsdmngd_subnet, stopped=False): - self.debug("Verifying the deployment and state of VSD Managed VM " - "- %s in VSD" % vm.name) - vsd_vm = self.vsd.get_vm(filter=self.get_externalID_filter(vm.id)) - self.assertNotEqual(vsd_vm, None, - "VM data format in VSD should not be of type None" - ) - vm_info = VirtualMachine.list(self.api_client, id=vm.id)[0] - for nic in vm_info.nic: - vsd_subnet = vsdmngd_subnet - vsd_vport = self.vsd.get_vport( - subnet=vsd_subnet, filter=self.get_externalID_filter(nic.id)) - vsd_vm_interface = self.vsd.get_vm_interface( - filter=self.get_externalID_filter(nic.id)) - self.assertEqual(vsd_vport.active, True, - "VSD VM vport should be active" - ) - self.assertEqual(vsd_vm_interface.ip_address, nic.ipaddress, - "VSD VM interface IP address should match VM's " - "NIC IP address in CloudStack" - ) - if not self.isSimulator: - self.verify_vsd_object_status(vm, stopped) - self.debug("Successfully verified the deployment and state of VM - %s " - "in VSD" % vm.name) - - @attr(tags=["advanced", "nuagevsp", "isonw"], required_hardware="false") - def test_01_nuage_mngd_subnets_isonw(self): - """Test Nuage VSP Managed Subnets for isolated networks - """ - - # 1. Create multiple L3DomainTemplate with Zone and Subnet on VSP - # Create Ingress & Egress ACL Top & Bottom Templates - # Add ACL rules to allow intra-subnet traffic - # Instiantiate these L3Domains and store its Subnet VSD ID - # 2. Create a persistent and non persistent isolated network offering - # create offerings with and without VirtualRouter - # 3. Create isolated networks specifying above offerings and - # specifying the stored Subnet ID's of VSP - # 4. Verify ACL rules and connectivity via deploying VM's , - # Enabling staticNAT, applying firewall and egress rules - # 5. Verify negative tests like uniqueness of vsd subnet - - # Create all items on vsd required for this test - enterprise = self.fetch_by_externalID(self._session.user.enterprises, - self.domain) - domain_template = self.create_vsd_domain_template(enterprise) - - self.create_vsd_default_acls(domain_template) - - domain1 = self.create_vsd_domain(domain_template, enterprise, - "L3DomainToBeConsumedByACS") - zone1 = self.create_vsd_zone(domain1, "ZoneToBeConsumedByACS") - subnet1 = self.create_vsd_subnet(zone1, "SubnetToBeConsumedByACS", - "10.0.0.1/24") - - domain2 = self.create_vsd_domain(domain_template, enterprise, - "2ndL3DomainToBeConsumedByACS") - zone2 = self.create_vsd_zone(domain2, "2ndZoneToBeConsumedByACS") - subnet2 = self.create_vsd_subnet(zone2, "2ndSubnetToBeConsumedByACS", - "10.1.0.1/24") - - self.create_vsd_dhcp_option(subnet2, 15, ["nuagenetworks2.net"]) - - domain3 = self.create_vsd_domain(domain_template, enterprise, - "3rdL3DomainToBeConsumedByACS") - zone3 = self.create_vsd_zone(domain3, "3rdZoneToBeConsumedByACS") - subnet3 = self.create_vsd_subnet(zone3, "3rdSubnetToBeConsumedByACS", - "10.2.0.1/24") - for i in range(1, 3): - # On ACS create network using non-persistent nw offering allow - isolated_network = self.create_Network( - self.nuage_isolated_network_offering, - gateway="10.0.0.1", netmask="255.255.255.0", - externalid=subnet1.id, cleanup=False) - - # On ACS create network using persistent nw offering allow - isolated_network2 = self.create_Network( - self.nuage_isolated_network_offering_persistent, - gateway="10.5.0.1", netmask="255.255.255.0", - externalid=subnet2.id, cleanup=False) - - with self.assertRaises(Exception): - self.create_Network( - self.nuage_shared_network_offering, gateway="10.2.0.1", - netmask="255.255.255.0", vlan=1201, externalid=subnet3.id) - - # On ACS create network when VSDSubnet is already in use - with self.assertRaises(Exception): - self.create_Network( - self.nuage_isolated_network_offering_persistent, - gateway="10.3.0.1", netmask="255.255.255.0", - externalid=subnet2.id) - - # On ACS create network when VSDSubnet is non-existing - with self.assertRaises(Exception): - self.create_Network( - self.nuage_isolated_network_offering_persistent, - gateway="10.4.0.1", netmask="255.255.255.0", - externalid=subnet2.id+1) - - # verify floating ip and intra subnet connectivity - vm_1 = self.create_VM(isolated_network, cleanup=False) - - self.test_data["virtual_machine"]["displayname"] = "vm2" - self.test_data["virtual_machine"]["name"] = "vm2" - vm_2 = self.create_VM(isolated_network, cleanup=False) - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - - # VSD verification - self.verify_vsd_network_not_present(isolated_network) - self.verify_vsdmngd_vm(vm_1, subnet1) - self.verify_vsdmngd_vm(vm_2, subnet1) - self.debug("Creating Static NAT rule for the deployed VM in the " - "non persistently created Isolated network...") - public_ip = self.acquire_PublicIPAddress(isolated_network) - self.validate_PublicIPAddress(public_ip, isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - self.validate_PublicIPAddress( - public_ip, isolated_network, static_nat=True, vm=vm_1) - self.create_FirewallRule(public_ip, - self.test_data["ingress_rule"]) - self.verify_ping_to_vm(vm_1, vm_2, public_ip, "vm2") - - vm_3 = self.create_VM(isolated_network2, cleanup=False) - self.test_data["virtual_machine"]["displayname"] = "vm4" - self.test_data["virtual_machine"]["name"] = "vm4" - vm_4 = self.create_VM(isolated_network2, cleanup=False) - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - self.verify_vsd_network_not_present(isolated_network2) - self.verify_vsdmngd_vm(vm_3, subnet2) - self.verify_vsdmngd_vm(vm_4, subnet2) - self.debug("Creating Static NAT rule for the deployed VM in the " - "persistently created Isolated network...") - public_ip2 = self.acquire_PublicIPAddress(isolated_network2) - self.validate_PublicIPAddress(public_ip2, isolated_network2) - self.create_StaticNatRule_For_VM(vm_3, public_ip2, - isolated_network2) - self.validate_PublicIPAddress( - public_ip2, isolated_network2, static_nat=True, vm=vm_3) - self.create_FirewallRule(public_ip2, - self.test_data["ingress_rule"]) - - self.verify_ping_to_vm(vm_3, vm_4, public_ip2) - vm_4.delete(self.api_client, expunge=True) - vm_3.delete(self.api_client, expunge=True) - vm_2.delete(self.api_client, expunge=True) - vm_1.delete(self.api_client, expunge=True) - isolated_network2.delete(self.api_client) - isolated_network.delete(self.api_client) - self.debug("Number of loops %s" % i) - - @attr(tags=["advanced", "nuagevsp", "vpc"], required_hardware="false") - def test_02_nuage_mngd_subnets_vpc(self): - """Test Nuage VSP Managed Subnets for vpc and tier networks - """ - - # 1. Create multiple L3DomainTemplate with Zone and Subnet on VSP - # Create Ingress & Egress ACL Top & Bottom Templates - # Add ACL rules to allow intra-subnet traffic - # Instiantiate these L3Domains and store its Subnet VSD ID - # 2. Create a vpc network offering and create a VPC - # create vpc tier network offerings with and without VirtualRouter - # 3. Create vpc tier networks specifying above offerings and - # specifying the stored Subnet ID's of VSP - # 4. Verify ACL rules and connectivity via deploying VM's , - # Enabling staticNAT, applying firewall and egress rules - # 5. Verify negative tests like uniqueness of vsd subnet - - # Create all items on vsd required for this test - enterprise = self.fetch_by_externalID(self._session.user.enterprises, - self.domain) - domain_template = self.create_vsd_domain_template(enterprise) - - self.create_vsd_default_acls(domain_template) - - domain1 = self.create_vsd_domain(domain_template, enterprise, - "L3DomainToBeConsumedByACS") - zone1 = self.create_vsd_zone(domain1, "ZoneToBeConsumedByACS") - subnet1 = self.create_vsd_subnet(zone1, "SubnetToBeConsumedByACS", - "10.1.0.1/24") - subnet2 = self.create_vsd_subnet(zone1, "2ndSubnetToBeConsumedByACS", - "10.1.128.1/24") - - domain2 = self.create_vsd_domain(domain_template, enterprise, - "2ndL3DomainToBeConsumedByACS") - zone2 = self.create_vsd_zone(domain2, "2ndZoneToBeConsumedByACS") - subnet3 = self.create_vsd_subnet(zone2, "3rdSubnetToBeConsumedByACS", - "10.2.128.1/24") - - cmd = updateZone.updateZoneCmd() - cmd.id = self.zone.id - cmd.domain = "vpc.com" - self.api_client.updateZone(cmd) - self.debug("Creating a VPC with Static NAT service provider as " - "VpcVirtualRouter") - vpc = self.create_vpc(self.nuage_vpc_offering, cidr='10.1.0.0/16') - self.validate_vpc(vpc, state="Enabled") - acl_list = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc) - self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list) - self.create_NetworkAclRule( - self.test_data["icmprule"], acl_list=acl_list) - - self.debug("Creating another VPC with Static NAT service provider " - "as VpcVirtualRouter") - vpc2 = self.create_vpc(self.nuage_vpc_offering, cidr='10.2.0.0/16') - self.validate_vpc(vpc2, state="Enabled") - acl_list2 = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc2) - self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list2) - self.create_NetworkAclRule( - self.test_data["icmprule"], acl_list=acl_list2) - - self.debug("Creating an unmanaged VPC tier network with Static NAT") - vpc2_tier_unmngd = self.create_Network(self.nuage_vpc_network_offering, - gateway='10.2.0.1', - vpc=vpc2, - acl_list=acl_list2) - self.validate_Network(vpc2_tier_unmngd, state="Implemented") - - # VPC Tier Network creation should fail as VPC is unmanaged already - with self.assertRaises(Exception): - self.create_Network(self.nuage_vpc_network_offering, - gateway='10.2.128.1', - vpc=vpc2, - acl_list=acl_list2, - externalid=subnet3.id) - - vpc2_tier_unmngd.delete(self.api_client) - vpc2.delete(self.api_client) - - # VPC tier network creation fails when cidr does not match on VSD - with self.assertRaises(Exception): - self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.1.1', - vpc=vpc, - acl_list=acl_list, - externalid=subnet1.id) - - for i in range(1, 3): - self.debug("Creating a mngd VPC tier with Static NAT service") - vpc_tier = self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.0.1', - vpc=vpc, - acl_list=acl_list, - externalid=subnet1.id, - cleanup=False) - self.validate_Network(vpc_tier, state="Implemented") - self.debug("Creating 2nd VPC tier network with Static NAT service") - - # VPC 2nd tier creation fails when cidr doesn't match on VSD - with self.assertRaises(Exception): - self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.129.1', - vpc=vpc, - acl_list=acl_list, - externalid=subnet2.id) - - vpc_2ndtier = self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.128.1', - vpc=vpc, - acl_list=acl_list, - externalid=subnet2.id, - cleanup=False) - self.validate_Network(vpc_2ndtier, state="Implemented") - vpc_vr = self.get_Router(vpc_tier) - self.check_Router_state(vpc_vr, state="Running") - - # VSD verification - self.verify_vsd_network_not_present(vpc_tier, vpc) - self.verify_vsd_network_not_present(vpc_2ndtier, vpc) - - # On ACS create VPCTier network when VSDSubnet is already in use - with self.assertRaises(Exception): - self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.128.1', - vpc=vpc, - acl_list=acl_list, - externalid=subnet2.id) - - # On ACS create VPCTier network when VSDSubnet does not exist - with self.assertRaises(Exception): - self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.128.1', - vpc=vpc, - acl_list=acl_list, - externalid=subnet2.id+1) - - # On ACS create VPCTier network without VSDSubnet should fail - with self.assertRaises(Exception): - self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.203.1', - vpc=vpc, - acl_list=acl_list) - - self.debug("Creating another VPC with Static NAT service provider " - "as VpcVirtualRouter With same CIDR") - vpc3 = self.create_vpc(self.nuage_vpc_offering, cidr='10.1.0.0/16') - self.validate_vpc(vpc3, state="Enabled") - acl_list3 = self.create_NetworkAclList( - name="acl", description="acl", vpc=vpc3) - self.create_NetworkAclRule( - self.test_data["ingress_rule"], acl_list=acl_list3) - self.create_NetworkAclRule( - self.test_data["icmprule"], acl_list=acl_list3) - - self.debug("Creating a mngd VPC tier with Static NAT service") - vpc3_tier_unmngd = \ - self.create_Network(self.nuage_vpc_network_offering, - gateway='10.1.0.1', - vpc=vpc3, - acl_list=acl_list3) - self.validate_Network(vpc3_tier_unmngd, state="Implemented") - vpc3_tier_unmngd.delete(self.api_client) - vpc3.delete(self.api_client) - - self.debug("Deploying a VM in the created VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm1" - self.test_data["virtual_machine"]["name"] = "vpcvm1" - vpc_vm_1 = self.create_VM(vpc_tier, cleanup=False) - self.check_VM_state(vpc_vm_1, state="Running") - self.debug("Deploying another VM in the created VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm2" - self.test_data["virtual_machine"]["name"] = "vpcvm2" - vpc_vm_2 = self.create_VM(vpc_tier, cleanup=False) - self.check_VM_state(vpc_vm_2, state="Running") - self.debug("Deploying a VM in the 2nd VPC tier network") - self.test_data["virtual_machine"]["displayname"] = "vpcvm12" - self.test_data["virtual_machine"]["name"] = "vpcvm12" - vpc_vm_12 = self.create_VM(vpc_2ndtier, cleanup=False) - self.check_VM_state(vpc_vm_2, state="Running") - self.test_data["virtual_machine"]["displayname"] = None - self.test_data["virtual_machine"]["name"] = None - - # VSD verification - self.verify_vsdmngd_vm(vpc_vm_1, subnet1) - self.verify_vsdmngd_vm(vpc_vm_2, subnet1) - self.verify_vsdmngd_vm(vpc_vm_12, subnet2) - - self.debug("Creating Static NAT rule for the deployed VM " - "in the created VPC network...") - public_ip_1 = self.acquire_PublicIPAddress(vpc_tier, vpc=vpc) - self.validate_PublicIPAddress(public_ip_1, vpc_tier) - self.create_StaticNatRule_For_VM(vpc_vm_1, public_ip_1, vpc_tier) - self.validate_PublicIPAddress( - public_ip_1, vpc_tier, static_nat=True, vm=vpc_vm_1) - - self.verify_ping_to_vm(vpc_vm_1, vpc_vm_2, public_ip_1) - self.verify_ping_to_vm(vpc_vm_1, vpc_vm_12, public_ip_1) - - vpc_vm_1.delete(self.api_client, expunge=True) - vpc_vm_2.delete(self.api_client, expunge=True) - vpc_vm_12.delete(self.api_client, expunge=True) - vpc_tier.delete(self.api_client) - vpc_2ndtier.delete(self.api_client) - self.debug("Number of loops %s" % i) - - @attr(tags=["advanced", "nuagevsp", "domains"], required_hardware="false") - def test_03_nuage_mngd_subnets_domains(self): - """Test Nuage VSP Managed Subnets for ACS domains - """ - vsd_enterprise = self.create_vsd_enterprise() - vsd_domain_template = self.create_vsd_domain_template(vsd_enterprise) - - self.create_vsd_default_acls(vsd_domain_template) - - vsd_domain1 = self.create_vsd_domain(vsd_domain_template, - vsd_enterprise, - "L3DomainToBeConsumedByACS") - vsd_zone1 = self.create_vsd_zone(vsd_domain1, "ZoneToBeConsumedByACS") - vsd_subnet1 = self.create_vsd_subnet(vsd_zone1, - "SubnetToBeConsumedByACS", - "10.0.0.1/24") - acs_domain_1 = Domain.create( - self.api_client, - {}, - name="DomainManagedbyVsd", - domainid=vsd_enterprise.id - ) - # Create an admin and an user account under domain D1 - acs_account_1 = Account.create( - self.api_client, - self.test_data["acl"]["accountD1"], - admin=True, - domainid=acs_domain_1.id - ) - self.cleanup.append(acs_domain_1) - self.cleanup.append(acs_account_1) - - # On ACS create network using non-persistent nw offering allow - isolated_network = self.create_Network( - self.nuage_isolated_network_offering, - gateway="10.0.0.1", netmask="255.255.255.0", - account=acs_account_1, - externalid=vsd_subnet1.id) - - # Creation of a domain with inUse domain UUID is not allowed - with self.assertRaises(Exception): - Domain.create( - self.api_client, - {}, - name="AnotherDomainManagedbyVsd", - domainid=vsd_enterprise.id - ) - - # Creation of a domain with unexisting domain UUID is not allowed - with self.assertRaises(Exception): - Domain.create( - self.api_client, - {}, - name="YetAnotherDomainManagedbyVsd", - domainid=vsd_enterprise.id+1 - ) - vm_1 = self.create_VM(isolated_network, account=acs_account_1) - vm_2 = self.create_VM(isolated_network, account=acs_account_1) - # VSD verification - self.verify_vsd_network_not_present(isolated_network) - self.verify_vsdmngd_vm(vm_1, vsd_subnet1) - self.verify_vsdmngd_vm(vm_2, vsd_subnet1) - self.debug("Creating Static NAT rule for the deployed VM in the " - "non persistently created Isolated network...") - public_ip = self.acquire_PublicIPAddress(isolated_network, - account=acs_account_1) - self.validate_PublicIPAddress(public_ip, isolated_network) - self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) - self.validate_PublicIPAddress( - public_ip, isolated_network, static_nat=True, vm=vm_1) - self.create_FirewallRule(public_ip, - self.test_data["ingress_rule"]) - if not self.isSimulator: - vm_public_ip = public_ip.ipaddress.ipaddress - try: - vm_1.ssh_ip = vm_public_ip - vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"] - vm_1.username = self.test_data["virtual_machine"]["username"] - vm_1.password = self.test_data["virtual_machine"]["password"] - self.debug("SSHing into VM: %s with %s" % - (vm_1.ssh_ip, vm_1.password)) - - ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip) - - except Exception as e: - self.fail("SSH into VM failed with exception %s" % e) - - self.verify_pingtovmipaddress(ssh, vm_2.ipaddress) - - @attr(tags=["advanced", "nuagevsp", "account"], required_hardware="false") - def test_04_nuage_mngd_subnets_noadminaccount(self): - """Test Nuage VSP Managed Subnets for ACS domains without admin account - """ - vsd_enterprise = self.create_vsd_enterprise() - vsd_domain_template = self.create_vsd_domain_template(vsd_enterprise) - - self.create_vsd_default_acls(vsd_domain_template) - - vsd_domain1 = self.create_vsd_domain(vsd_domain_template, - vsd_enterprise, - "L3DomainToBeConsumedByACS") - vsd_zone1 = self.create_vsd_zone(vsd_domain1, "ZoneToBeConsumedByACS") - vsd_subnet1 = self.create_vsd_subnet(vsd_zone1, - "SubnetToBeConsumedByACS", - "10.0.0.1/24") - acs_domain_1 = Domain.create( - self.api_client, - {}, - name="DomainManagedbyVsd", - domainid=vsd_enterprise.id - ) - # Create an no admin and an user account under domain D1 - acs_account_1 = Account.create( - self.api_client, - self.test_data["acl"]["accountD1"], - admin=False, - domainid=acs_domain_1.id - ) - self.cleanup.append(acs_domain_1) - self.cleanup.append(acs_account_1) - - # On ACS create network fails as non admin account - with self.assertRaises(Exception): - self.create_Network( - self.nuage_isolated_network_offering, - gateway="10.0.0.1", netmask="255.255.255.0", - account=acs_account_1, - externalid=vsd_subnet1.id) - - @needscleanup - def create_vsd_enterprise(self): - enterprise = self.vsdk.NUEnterprise() - enterprise.name = "EnterpriseToBeConsumedByACS" - enterprise.description = "EnterpriseToBeConsumedByACS" - (enterprise, connection) = self._session.user.create_child(enterprise) - return enterprise - - def create_vsd_ingress_acl_template(self, domain_template, - priority_type="TOP"): - name = "Ingress ACL " + str(priority_type).capitalize() - acl_template = self.vsdk.NUIngressACLTemplate() - acl_template.name = name - acl_template.description = name - acl_template.priority_type = priority_type - acl_template.active = True - (acl_template, connection) = \ - domain_template.create_child(acl_template) - return acl_template - - def create_vsd_egress_acl_template(self, domain_template, - priority_type='TOP'): - name = "Egress ACL " + str(priority_type).capitalize() - acl_template = self.vsdk.NUEgressACLTemplate() - acl_template.name = name - acl_template.description = name - acl_template.priority_type = priority_type - acl_template.active = True - (acl_template, connection) = \ - domain_template.create_child(acl_template) - return acl_template - - @needscleanup - def create_vsd_domain_template(self, enterprise): - domain_template = self.vsdk.NUDomainTemplate() - domain_template.name = "L3DomainTemplateToBeConsumedByACS" - domain_template.description = "L3DomainTemplateToBeConsumedByACS" - (domain_template, connection) = \ - enterprise.create_child(domain_template) - return domain_template - - def create_vsd_default_acls(self, domain_template): - ingress_vsd_acl_template1 = self.create_vsd_ingress_acl_template( - domain_template, "TOP") - ingress_vsd_acl_template2 = self.create_vsd_ingress_acl_template( - domain_template, "BOTTOM") - ingress_vsd_acl_entry1 = self.vsdk.NUIngressACLEntryTemplate() - ingress_vsd_acl_entry1.name = "Default Intra-Subnet Allow" - ingress_vsd_acl_entry1.description = "Default Intra-Subnet Allow" - ingress_vsd_acl_entry1.priority = '1' - ingress_vsd_acl_entry1.protocol = 'ANY' - ingress_vsd_acl_template1.create_child(ingress_vsd_acl_entry1) - - ingress_vsd_acl_entry2 = self.vsdk.NUIngressACLEntryTemplate() - ingress_vsd_acl_entry2.name = "Default Allow TCP" - ingress_vsd_acl_entry2.description = "Default Allow TCP" - ingress_vsd_acl_entry2.priority = '1' - ingress_vsd_acl_entry2.protocol = '6' - ingress_vsd_acl_entry2.source_port = '*' - ingress_vsd_acl_entry2.destination_port = '*' - ingress_vsd_acl_template2.create_child(ingress_vsd_acl_entry2) - - ingress_vsd_acl_entry3 = self.vsdk.NUIngressACLEntryTemplate() - ingress_vsd_acl_entry3.name = "Default Allow UDP" - ingress_vsd_acl_entry3.description = "Default Allow UDP" - ingress_vsd_acl_entry3.priority = '2' - ingress_vsd_acl_entry3.protocol = '17' - ingress_vsd_acl_entry3.source_port = '*' - ingress_vsd_acl_entry3.destination_port = '*' - ingress_vsd_acl_template2.create_child(ingress_vsd_acl_entry3) - ingress_vsd_acl_entry4 = self.vsdk.NUIngressACLEntryTemplate() - ingress_vsd_acl_entry4.name = "Default Allow ICMP" - ingress_vsd_acl_entry4.description = "Default Allow ICMP" - ingress_vsd_acl_entry4.priority = '3' - ingress_vsd_acl_entry4.protocol = '1' - ingress_vsd_acl_template2.create_child(ingress_vsd_acl_entry4) - - egress_vsd_acl_template1 = self.create_vsd_egress_acl_template( - domain_template, 'TOP') - - egress_vsd_acl_template2 = self.create_vsd_egress_acl_template( - domain_template, 'BOTTOM') - - egress_vsd_acl_entry1 = self.vsdk.NUEgressACLEntryTemplate() - egress_vsd_acl_entry1.name = "Default Intra-Subnet Allow" - egress_vsd_acl_entry1.description = "Default Intra-Subnet Allow" - egress_vsd_acl_entry1.priority = '1' - egress_vsd_acl_entry1.protocol = 'ANY' - egress_vsd_acl_template1.create_child(egress_vsd_acl_entry1) - egress_vsd_acl_entry2 = self.vsdk.NUEgressACLEntryTemplate() - egress_vsd_acl_entry2.name = "Default Allow ICMP" - egress_vsd_acl_entry2.description = "Default Allow ICMP" - egress_vsd_acl_entry2.priority = '3' - egress_vsd_acl_entry2.protocol = '1' - egress_vsd_acl_template2.create_child(egress_vsd_acl_entry2) - - def create_vsd_domain(self, domain_template, enterprise, name): - domain = self.vsdk.NUDomain() - domain.name = name - domain.description = name - (domain, connection) = \ - enterprise.instantiate_child(domain, domain_template) - return domain - - def create_vsd_zone(self, domain, name): - zone = self.vsdk.NUZone() - zone.name = name - zone.description = name - (zone, connection) = domain.create_child(zone) - return zone - - def create_vsd_subnet(self, zone, name, cidr): - subnet = self.vsdk.NUSubnet() - subnet.name = name - subnet.description = name - (subnet.gateway, subnet.netmask, subnet.address) = \ - self._cidr_to_netmask(cidr) - (subnet, connection) = zone.create_child(subnet) - return subnet - - def create_vsd_dhcp_option(self, subnet, type, value): - dhcp_option = self.vsdk.NUDHCPOption() - dhcp_option.actual_type = type - dhcp_option.actual_values = value - (dhcp_option, connection) = subnet.create_child(dhcp_option) - return dhcp_option - - def _cidr_to_netmask(self, cidr): - import socket - import struct - network, net_bits = cidr.split('/') - host_bits = 32 - int(net_bits) - netmask_bits = (1 << 32) - (1 << host_bits) - netmask = socket.inet_ntoa(struct.pack('!I', netmask_bits)) - network_bits = struct.unpack('!I', socket.inet_aton(network))[0] - network_masked = socket.inet_ntoa( - struct.pack('!I', netmask_bits & network_bits) - ) - return network, netmask, network_masked diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py index 0ef3f3c3ea9..1b6365a355d 100644 --- a/tools/marvin/marvin/deployDataCenter.py +++ b/tools/marvin/marvin/deployDataCenter.py @@ -563,7 +563,7 @@ class DeployDataCenters(object): netprov.physicalnetworkid = phynetwrk.id result = self.__apiClient.addNetworkServiceProvider(netprov) self.enableProvider(result.id) - elif provider.name in ['Netscaler', 'JuniperSRX', 'F5BigIp', 'NiciraNvp', 'NuageVsp']: + elif provider.name in ['Netscaler', 'JuniperSRX', 'F5BigIp', 'NiciraNvp']: netprov = addNetworkServiceProvider.\ addNetworkServiceProviderCmd() netprov.name = provider.name @@ -633,21 +633,6 @@ class DeployDataCenters(object): self.__tcRunLogger.\ debug("==== AddNiciraNvp Successful =====") self.__addToCleanUp("NiciraNvp", ret.id) - elif provider.name == 'NuageVsp': - dev = addNuageVspDevice.addNuageVspDeviceCmd() - dev.hostname = device.hostname - dev.port = device.port - dev.username = device.username - dev.password = device.password - dev.retrycount = device.retrycount - dev.retryinterval = device.retryinterval - dev.physicalnetworkid = phynetwrk.id - ret = self.__apiClient.addNuageVspDevice(dev) - if ret.id: - self.__tcRunLogger.\ - debug("==== addNuageVspDevice " - "Successful=====") - self.__addToCleanUp("addNuageVspDevice", ret.id) else: raise InvalidParameterException( "Device %s doesn't match " diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py index 5fe2ea7dbac..e7572e91801 100755 --- a/tools/marvin/marvin/lib/base.py +++ b/tools/marvin/marvin/lib/base.py @@ -4260,61 +4260,6 @@ class NetworkServiceProvider: return (apiclient.listNetworkServiceProviders(cmd)) -class Nuage: - """Manage external nuage VSD device""" - - def __init__(self, items): - self.__dict__.update(items) - - @classmethod - def add(cls, apiclient, services, physicalnetworkid, username=None, password=None): - """Add external nuage VSD device to cloudstack""" - - cmd = addNuageVspDevice.addNuageVspDeviceCmd() - cmd.physicalnetworkid = physicalnetworkid - if username: - cmd.username = username - else: - cmd.username = services["username"] - - if password: - cmd.password = password - else: - cmd.password = services["password"] - - cmd.hostname = services["hostname"] - cmd.port = services["port"] - cmd.retrycount = services["retrycount"] - cmd.retryinterval = services["retryinterval"] - cmd.apiversion = services["apiversion"] - - return Nuage(apiclient.addNuageVspDevice(cmd).__dict__) - - def update(self, apiclient, **kwargs): - """Deletes a nuage VSD device from CloudStack""" - - cmd = updateNuageVspDevice.updateNuageVspDeviceCmd() - cmd.physicalnetworkid = self.physicalnetworkid - [setattr(cmd, k, v) for k, v in kwargs.items()] - return apiclient.updateNuageVspDevice(cmd) - - def delete(self, apiclient): - """Deletes a nuage VSD device from CloudStack""" - - cmd = deleteNuageVspDevice.deleteNuageVspDeviceCmd() - cmd.vspdeviceid = self.vspdeviceid - apiclient.deleteNuageVspDevice(cmd) - return - - @classmethod - def list(cls, apiclient, **kwargs): - """List already registered netscaler devices""" - - cmd = listNuageVspDevices.listNuageVspDevicesCmd() - [setattr(cmd, k, v) for k, v in kwargs.items()] - return (apiclient.listNuageVspDevices(cmd)) - - class Router: """Manage router life cycle""" diff --git a/tools/marvin/setup.py b/tools/marvin/setup.py index c469706fc97..45b0f9a3a36 100644 --- a/tools/marvin/setup.py +++ b/tools/marvin/setup.py @@ -59,9 +59,6 @@ setup(name="Marvin", "retries", "PyCrypt" ], - extras_require={ - "nuagevsp": ["vspk", "PyYAML", "futures", "netaddr", "jpype1"] - }, py_modules=['marvin.marvinPlugin'], zip_safe=False, entry_points={ diff --git a/ui/l10n/en.js b/ui/l10n/en.js index eb7b8225089..0c8db8d68c0 100644 --- a/ui/l10n/en.js +++ b/ui/l10n/en.js @@ -311,7 +311,6 @@ var dictionary = { "label.add.F5.device":"Add F5 device", "label.add.LDAP.account":"Add LDAP Account", "label.add.NiciraNvp.device":"Add Nvp Controller", -"label.add.NuageVsp.device":"Add Nuage Virtualized Services Directory (VSD)", "label.add.OpenDaylight.device":"Add OpenDaylight Controller", "label.add.PA.device":"Add Palo Alto device", "label.add.SRX.device":"Add SRX device", @@ -618,7 +617,6 @@ var dictionary = { "label.delete.F5":"Delete F5", "label.delete.NetScaler":"Delete NetScaler", "label.delete.NiciraNvp":"Remove Nvp Controller", -"label.delete.NuageVsp":"Remove Nuage VSD", "label.delete.OpenDaylight.device":"Delete OpenDaylight Controller", "label.delete.PA":"Delete Palo Alto", "label.delete.SRX":"Delete SRX", @@ -1220,8 +1218,6 @@ var dictionary = { "label.none":"None", "label.not.found":"Not Found", "label.notifications":"Notifications", -"label.nuage.vpc.usedomaintemplate":"Use pre-configured Domain Template", -"label.nuage.vpc.domaintemplatelist":"Domain Template", "label.num.cpu.cores":"# of CPU Cores", "label.number.of.clusters":"Number of Clusters", "label.number.of.cpu.sockets":"The Number of CPU Sockets", @@ -1977,7 +1973,6 @@ var dictionary = { "message.add.system.service.offering":"Please fill in the following data to add a new system service offering.", "message.add.template":"Please enter the following data to create your new template", "message.add.volume":"Please fill in the following data to add a new volume.", -"message.added.new.nuage.vsp.controller":"Added new Nuage Vsp Controller", "message.added.vpc.offering":"Added VPC offering", "message.adding.Netscaler.device":"Adding Netscaler device", "message.adding.Netscaler.provider":"Adding Netscaler provider", @@ -2026,7 +2021,6 @@ var dictionary = { "message.confirm.delete.BrocadeVcs":"Please confirm that you would like to delete Brocade Vcs Switch", "message.confirm.delete.F5":"Please confirm that you would like to delete F5", "message.confirm.delete.NetScaler":"Please confirm that you would like to delete NetScaler", -"message.confirm.delete.NuageVsp":"Please confirm that you would like to delete Nuage Virtualized Services Directory", "message.confirm.delete.PA":"Please confirm that you would like to delete Palo Alto", "message.confirm.delete.SRX":"Please confirm that you would like to delete SRX", "message.confirm.delete.acl.list":"Are you sure you want to delete this ACL list?", diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index bc128d5e084..c81a632bd69 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -2424,7 +2424,7 @@ //p.s. Netscaler is supported in both vpc and non-vpc if ($useVpc.is(':visible') && $useVpcCb.is(':checked')) { //*** vpc *** $optionsOfProviders.each(function(index) { - if ($(this).val() == 'InternalLbVm' || $(this).val() == 'VpcVirtualRouter' || $(this).val() == 'Netscaler' || $(this).val() == 'NuageVsp' || $(this).val() == 'NuageVspVpc' || $(this).val() == 'BigSwitchBcf' || $(this).val() == 'ConfigDrive') { + if ($(this).val() == 'InternalLbVm' || $(this).val() == 'VpcVirtualRouter' || $(this).val() == 'Netscaler' || $(this).val() == 'BigSwitchBcf' || $(this).val() == 'ConfigDrive') { $(this).attr('disabled', false); } else { $(this).attr('disabled', true); @@ -2700,18 +2700,13 @@ } //PublicAccess checkbox should be displayed only when 'Connectivity' service is checked - if (args.$form.find('.form-item[rel=\"service.Connectivity.isEnabled\"]').find('input[type=checkbox]').is(':checked') && $guestTypeField.val() == 'Shared' && - args.$form.find('.form-item[rel=\"service.Connectivity.provider\"]').find('select').val() == 'NuageVsp') { + if (args.$form.find('.form-item[rel=\"service.Connectivity.isEnabled\"]').find('input[type=checkbox]').is(':checked') + && $guestTypeField.val() == 'Shared' + && args.$form.find('.form-item[rel=\"service.Connectivity.provider\"]').find('select').val() == 'NuageVsp') { $supportspublicaccess.css('display', 'inline-block'); } else { $supportspublicaccess.hide(); } - - //Uncheck specifyVlan checkbox when (1)guest type is Shared and (2)NuageVsp is selected as a Connectivity provider - if ($guestTypeField.val() == 'Shared') { - var $specifyVlanCheckbox = args.$form.find('.form-item[rel=specifyVlan]').find('input[type=checkbox]'); - $specifyVlanCheckbox.attr('checked', args.$form.find('.form-item[rel=\"service.Connectivity.provider\"]').find('select').val() != 'NuageVsp') - } }); args.$form.change(); @@ -3350,7 +3345,7 @@ inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilitytype'] = 'StretchedL2Subnet'; inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilityvalue'] = true; serviceCapabilityIndex++; - } else if (k == 'supportspublicaccess' && ("Connectivity" in serviceProviderMap) && serviceProviderMap['Connectivity'] == 'NuageVsp') { + } else if (k == 'supportspublicaccess' && ("Connectivity" in serviceProviderMap)) { inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].service'] = 'Connectivity'; inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilitytype'] = 'PublicAccess'; inputData['servicecapabilitylist[' + serviceCapabilityIndex + '].capabilityvalue'] = true; @@ -3902,8 +3897,8 @@ networkServiceObjs.push({ name: 'Dhcp', provider: [ - {name: 'VpcVirtualRouter'}, - {name: 'NuageVsp'}] + {name: 'VpcVirtualRouter'} + ] }); networkServiceObjs.push({ name: 'Dns', @@ -3925,21 +3920,18 @@ name: 'StaticNat', provider: [ {name: 'VpcVirtualRouter'}, - {name: 'NuageVsp'}, {name: 'BigSwitchBcf'}] }); networkServiceObjs.push({ name: 'SourceNat', provider: [ {name: 'VpcVirtualRouter'}, - {name: 'NuageVsp'}, {name: 'BigSwitchBcf'}] }); networkServiceObjs.push({ name: 'NetworkACL', provider: [ {name: 'VpcVirtualRouter'}, - {name: 'NuageVsp'}, {name: 'BigSwitchBcf'}] }); networkServiceObjs.push({ @@ -3963,8 +3955,7 @@ {name: 'BigSwitchBcf'}, {name: 'NiciraNvp'}, {name: 'Ovs'}, - {name: 'JuniperContrailVpcRouter'}, - {name: 'NuageVsp'} + {name: 'JuniperContrailVpcRouter'} ] }); diff --git a/ui/scripts/docs.js b/ui/scripts/docs.js index bbe8f3e64b4..016d806c3bf 100755 --- a/ui/scripts/docs.js +++ b/ui/scripts/docs.js @@ -1297,35 +1297,6 @@ cloudStack.docs = { desc: 'A short description of the offering that can be displayed to users', externalLink: '' }, - // Add Nuage VSP - helpVspHostname: { - desc: 'The hostname/IP address of Nuage VSD', - externalLink: '' - }, - helpVspUsername: { - desc: 'A name of the CMS user in Nuage VSD.', - externalLink: '' - }, - helpVspPassword: { - desc: 'The password for the CMS user in Nuage VSD.', - externalLink: '' - }, - helpVspPort: { - desc: 'The port to communicate with Nuage VSD. e.g. Unspecified/0 if using HAProxy for load balancing or 8443 if connecting directly to a VSD server.', - externalLink: '' - }, - helpVspApiVersion: { - desc: 'The API version of Nuage VSD', - externalLink: '' - }, - helpVspRetries: { - desc: 'Number of times to attempt a command on Nuage VSD before considering the operation failed. Valid values [1 - 10].', - externalLink: '' - }, - helpVspRetryInterval: { - desc: 'The interval of time in milliseconds to wait on failure before attempting to resend the command to Nuage VSD. Valid values [0 - 10000].', - externalLink: '' - }, helpOvm3pool: { desc: 'Pool the Ovm3 nodes in this cluster, required for vm node migrations', externalLink: '' diff --git a/ui/scripts/network.js b/ui/scripts/network.js index 205d937ddf8..145ac9f1922 100644 --- a/ui/scripts/network.js +++ b/ui/scripts/network.js @@ -5152,7 +5152,6 @@ required: true }, select: function(args) { - var data = {}; $.ajax({ url: createURL('listZones'), @@ -5163,49 +5162,6 @@ return zone.networktype == 'Advanced' && !zone.securitygroupsenabled; }); - //We need to be able to change the visibility of the NuageVspDT checkbox based on the selected zone (if the zone supports nuage) - var nuageDomainTemplateHandler = function(event, zoneid) { - zoneid = zoneid || this.value; - - //check if the zone id is already in the cache or not otherwise do a lookup - var cache = args.context.domainTemplateMap; - if (!(cache && cache[zoneid])) { - $.ajax({ - url: createURL('listNuageVspDomainTemplates'), - data: { zoneid: zoneid }, - success: function(json) { - var domaintemplates = json.listnuagevspdomaintemplatesresponse.domaintemplates ? json.listnuagevspdomaintemplatesresponse.domaintemplates : []; - - if (domaintemplates.length) { - args.$form.find("[rel=nuageusedomaintemplate]").show(); - } else { - args.$form.find("[rel=nuageusedomaintemplate]").hide(); - } - } - }); - args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', false); - } else if (cache[zoneid].length) { - if(args.context.globalDomainTemplateUsed[zoneid]){ - args.$form.find("[rel=nuageusedomaintemplate]").show(); - args.$form.find("[rel=nuagedomaintemplatelist]").show(); - args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', true); - } else { - args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', false); - } - args.$form.find("[rel=nuageusedomaintemplate]").show(); - } else { - args.$form.find("[rel=nuageusedomaintemplate]").hide(); - args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', false); - } - }; - - if (advZones && advZones.length > 0) { - nuageDomainTemplateHandler(null, advZones[0].id); - args.$select.bind('click', nuageDomainTemplateHandler); //bind on both events click, change, change event of dropdown. - args.$select.bind('change', nuageDomainTemplateHandler); - args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', false); - } - args.response.success({ data: $.map(advZones, function(zone) { return { @@ -5214,9 +5170,6 @@ }; }) }); - }, - error: function(errorMsg){ - args.$form.find("[rel=nuageusedomaintemplate]").hide(); } }); } @@ -5239,7 +5192,6 @@ validation: { required: true }, - dependsOn: "zoneid", select: function(args) { var data = {}; $.ajax({ @@ -5261,89 +5213,7 @@ } }); } - }, - nuageusedomaintemplate: { - label: 'label.nuage.vpc.usedomaintemplate', - isBoolean: true, - isChecked: false, - isHidden: function(args){ - var cache=args.context.domainTemplateMap; - return !(cache && cache[args.zoneid] && cache[args.zoneid].length); - } - }, - nuagedomaintemplatelist: { - label: 'label.nuage.vpc.domaintemplatelist', - isHidden: true, - dependsOn: ["nuageusedomaintemplate","zoneid"], - select: function(args) { - if(!args.context.domainTemplateMap){//create array if it does not exist. - args.context.domainTemplateMap = []; - args.context.globalDomainTemplateUsed = []; - } - - $.ajax({ - url: createURL('listNuageVspDomainTemplates'), - dataType: "json", - data: { - zoneid: args.zoneid - }, - async: true, - error: function(XMLHttpRequest, textStatus, errorThrown) { - args.response.success({}); - }, - success: function (json) { - $.ajax({ - url: createURL('listNuageVspGlobalDomainTemplate'), - dataType: "json", - data: { - name: "nuagevsp.vpc.domaintemplate.name" - }, - async: true, - success: function(PDTjson){ - var domaintemplates = json.listnuagevspdomaintemplatesresponse.domaintemplates ? json.listnuagevspdomaintemplatesresponse.domaintemplates : []; - var preConfiguredDomainTemplate = PDTjson.listnuagevspglobaldomaintemplateresponse.count == 1 ? PDTjson.listnuagevspglobaldomaintemplateresponse.domaintemplates[0].name : ""; - - if (!domaintemplates.length) { - args.$form.find("[rel=nuageusedomaintemplate]").hide(); - } - - var index = -1; - $.each(domaintemplates, function(key,value) { - if (preConfiguredDomainTemplate == value.name) { - index = key; - } - }); - - //Set global pre configured DT as the default by placing it to the top of the drop down list. - if (index != -1) { - domaintemplates.unshift(domaintemplates[index]); - domaintemplates.splice(index + 1, 1); - args.$form.find("[rel=nuageusedomaintemplate]").show(); - args.$form.find("[rel=nuagedomaintemplatelist]").show(); - args.$form.find("[rel=nuageusedomaintemplate]").find("input").attr('checked', true); - args.context.globalDomainTemplateUsed[args.zoneid] = true; - } else { - args.context.globalDomainTemplateUsed[args.zoneid] = false; - } - - args.context.domainTemplateMap[args.zoneid] = domaintemplates; - args.response.success({ - data: $.map(domaintemplates, function (dt) { - return { - id: dt.name, - description: dt.description - }; - }) - }); - } - }); - - } - }); - } - } - } }, action: function(args) { @@ -5368,64 +5238,19 @@ async: true, success: function(vpcjson) { var jid = vpcjson.createvpcresponse.jobid; - if(args.data.nuageusedomaintemplate){ - //Nuagepre-configured DT is chosen - var dataObj = { - domaintemplate: args.data.nuagedomaintemplatelist, - vpcid: vpcjson.createvpcresponse.id, - zoneid: args.data.zoneid - }; - $.ajax({ - url: createURL("associateNuageVspDomainTemplate"), - dataType: "json", - data: dataObj, - async: true, - success: function(json) { - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.vpc; - } - } - }); - }, - error: function(errordata) { - $.ajax({ - url: createURL("deleteVPC"), - data: { - id: vpcjson.createvpcresponse.id - }, - success: function(json) { - - }, - error: function(data) { - args.response.error(parseXMLHttpResponse(data)); - } - }); - args.response.error(parseXMLHttpResponse(errordata) + ". Rollback of VPC initiated."); + args.response.success({ + _custom: { + jobId: jid, + getUpdatedItem: function(json) { + return json.queryasyncjobresultresponse.jobresult.vpc; } - }); - } else { - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - return json.queryasyncjobresultresponse.jobresult.vpc; - } - } - }); - } - - + } + }); }, error: function(data) { args.response.error(parseXMLHttpResponse(data)); } }); - - - }, notification: { poll: pollAsyncJobResult diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 9720e48ca4b..d87636d953a 100755 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -486,7 +486,7 @@ vlan = args.data.vlan; } cloudStack.addVlanToCommandUrlParameterArrayIfItIsNotNullAndNotEmpty(array1, vlan); - + array1.push("&gateway=" + args.data.gateway); array1.push("&netmask=" + args.data.netmask); array1.push("&startip=" + args.data.startip); @@ -6989,249 +6989,7 @@ } } }, - // Nuage Vsp provider detail view - nuageVsp: { - type: 'detailView', - id: 'nuageVspProvider', - label: 'label.nuageVsp', - viewAll: { - label: 'label.devices', - path: '_zone.nuageVspDevices' - }, - tabs: { - details: { - title: 'label.details', - fields: [{ - name: { - label: 'label.name' - } - }, { - state: { - label: 'label.state' - } - }], - dataProvider: function(args) { - refreshNspData("NuageVsp"); - var providerObj; - $(nspHardcodingArray).each(function() { - if (this.id == "nuageVsp") { - providerObj = this; - return false; //break each loop - } - }); - args.response.success({ - data: providerObj, - actionFilter: networkProviderActionFilter('nuageVsp') - }); - } - } - }, - actions: { - add: { - label: 'label.add.NuageVsp.device', - createForm: { - title: 'label.add.NuageVsp.device', - preFilter: function(args) {}, - fields: { - hostname: { - label: 'label.host.name', - validation: { - required: true - }, - docID: 'helpVspHostname' - }, - username: { - label: 'label.username', - validation: { - required: true - }, - docID: 'helpVspUsername' - }, - password: { - label: 'label.password', - isPassword: true, - validation: { - required: true - }, - docID: 'helpVspPassword' - }, - port: { - label: 'label.port', - validation: { - required: false, - number: true - }, - docID: 'helpVspPort' - }, - apiversion: { - label: 'label.api.version', - defaultValue: 'v3_2', - validation: { - required: true - }, - docID: 'helpVspApiVersion' - }, - retrycount: { - label: 'label.numretries', - defaultValue: '4', - validation: { - required: true, - number: true - }, - docID: 'helpVspRetries' - }, - retryinterval: { - label: 'label.retry.interval', - defaultValue: '60', - validation: { - required: false, - number: true - }, - docID: 'helpVspRetryInterval' - } - } - }, - action: function(args) { - if (nspMap["nuageVsp"] == null) { - $.ajax({ - url: createURL("addNetworkServiceProvider&name=NuageVsp&physicalnetworkid=" + selectedPhysicalNetworkObj.id), - dataType: "json", - async: true, - success: function(json) { - var jobId = json.addnetworkserviceproviderresponse.jobid; - var addNuageVspProviderIntervalID = setInterval(function() { - $.ajax({ - url: createURL("queryAsyncJobResult&jobId=" + jobId), - dataType: "json", - success: function(json) { - var result = json.queryasyncjobresultresponse; - if (result.jobstatus == 0) { - return; //Job has not completed - } else { - clearInterval(addNuageVspProviderIntervalID); - if (result.jobstatus == 1) { - nspMap["nuageVsp"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider; - addNuageVspDevice(args, selectedPhysicalNetworkObj, "addNuageVspDevice", "addnuagevspdeviceresponse", "nuagevspdevice") - } else if (result.jobstatus == 2) { - alert("addNetworkServiceProvider&name=NuageVsp failed. Error: " + _s(result.jobresult.errortext)); - } - } - }, - error: function(XMLHttpResponse) { - var errorMsg = parseXMLHttpResponse(XMLHttpResponse); - alert("addNetworkServiceProvider&name=NuageVsp failed. Error: " + errorMsg); - } - }); - }, g_queryAsyncJobResultInterval); - } - }); - } else { - addNuageVspDevice(args, selectedPhysicalNetworkObj, "addNuageVspDevice", "addnuagevspdeviceresponse", "nuagevspdevice") - } - }, - messages: { - notification: function(args) { - return 'label.add.NuageVsp.device'; - } - }, - notification: { - poll: pollAsyncJobResult - } - }, - enable: { - label: 'label.enable.provider', - action: function(args) { - $.ajax({ - url: createURL("updateNetworkServiceProvider&id=" + nspMap["nuageVsp"].id + "&state=Enabled"), - dataType: "json", - success: function(json) { - var jid = json.updatenetworkserviceproviderresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - $(window).trigger('cloudStack.fullRefresh'); - } - } - }); - } - }); - }, - messages: { - confirm: function(args) { - return 'message.confirm.enable.provider'; - }, - notification: function() { - return 'label.enable.provider'; - } - }, - notification: { - poll: pollAsyncJobResult - } - }, - disable: { - label: 'label.disable.provider', - action: function(args) { - $.ajax({ - url: createURL("updateNetworkServiceProvider&id=" + nspMap["nuageVsp"].id + "&state=Disabled"), - dataType: "json", - success: function(json) { - var jid = json.updatenetworkserviceproviderresponse.jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - $(window).trigger('cloudStack.fullRefresh'); - } - } - }); - } - }); - }, - messages: { - confirm: function(args) { - return 'message.confirm.disable.provider'; - }, - notification: function() { - return 'label.disable.provider'; - } - }, - notification: { - poll: pollAsyncJobResult - } - }, - destroy: { - label: 'label.shutdown.provider', - action: function(args) { - $.ajax({ - url: createURL("deleteNetworkServiceProvider&id=" + nspMap["nuageVsp"].id), - dataType: "json", - success: function(json) { - var jid = json.deletenetworkserviceproviderresponse.jobid; - args.response.success({ - _custom: { - jobId: jid - } - }); - $(window).trigger('cloudStack.fullRefresh'); - } - }); - }, - messages: { - confirm: function(args) { - return 'message.confirm.shutdown.provider'; - }, - notification: function(args) { - return 'label.shutdown.provider'; - } - }, - notification: { - poll: pollAsyncJobResult - } - } - } - }, Opendaylight: { type: 'detailView', id: 'openDaylightProvider', @@ -13703,202 +13461,6 @@ } } }, - nuageVspDevices: { - id: 'nuageVspDevices', - title: 'label.devices', - listView: { - id: 'nuageVspDevices', - fields: { - hostname: { - label: 'label.host.name' - }, - port: { - label: 'label.port' - }, - apiversion: { - label: 'label.api.version' - }, - retrycount: { - label: 'label.numretries' - }, - retryinterval: { - label: 'label.retry.interval' - } - }, - actions: { - add: { - label: 'label.add.NuageVsp.device', - createForm: { - title: 'label.add.NuageVsp.device', - preFilter: function(args) {}, - fields: { - hostname: { - label: 'label.host.name' - }, - username: { - label: 'label.username' - }, - password: { - label: 'label.password', - isPassword: true - }, - port: { - label: 'label.port' - }, - apiversion: { - label: 'label.api.version', - defaultValue: 'v3_2' - }, - retrycount: { - label: 'label.numretries', - defaultValue: '4' - }, - retryinterval: { - label: 'label.retry.interval', - defaultValue: '60' - } - } - }, - action: function(args) { - if (nspMap["nuageVsp"] == null) { - $.ajax({ - url: createURL("addNetworkServiceProvider&name=NuageVsp&physicalnetworkid=" + selectedPhysicalNetworkObj.id), - dataType: "json", - async: true, - success: function(json) { - var jobId = json.addnetworkserviceproviderresponse.jobid; - var addNuageVspProviderIntervalID = setInterval(function() { - $.ajax({ - url: createURL("queryAsyncJobResult&jobId=" + jobId), - dataType: "json", - success: function(json) { - var result = json.queryasyncjobresultresponse; - if (result.jobstatus == 0) { - return; - } else { - clearInterval(addNuageVspProviderIntervalID); - if (result.jobstatus == 1) { - nspMap["nuageVsp"] = json.queryasyncjobresultresponse.jobresult.networkserviceprovider; - addNuageVspDevice(args, selectedPhysicalNetworkObj, "addNuageVspDevice", "addnuagevspdeviceresponse", "nuagevspdevice") - } else if (result.jobstatus == 2) { - alert("addNetworkServiceProvider&name=NuageVsp failed. Error: " + _s(result.jobresult.errortext)); - } - } - }, - error: function(XMLHttpResponse) { - var errorMsg = parseXMLHttpResponse(XMLHttpResponse); - alert("addNetworkServiceProvider&name=NuageVsp failed. Error: " + errorMsg); - } - }); - }, g_queryAsyncJobResultInterval); - } - }); - } else { - addNuageVspDevice(args, selectedPhysicalNetworkObj, "addNuageVspDevice", "addnuagevspdeviceresponse", "nuagevspdevice") - } - }, - - messages: { - notification: function(args) { - return 'message.added.new.nuage.vsp.controller'; - } - }, - notification: { - poll: pollAsyncJobResult - } - } - }, - dataProvider: function(args) { - $.ajax({ - url: createURL("listNuageVspDevices&physicalnetworkid=" + selectedPhysicalNetworkObj.id), - data: { - page: args.page, - pageSize: pageSize - }, - dataType: "json", - async: false, - success: function(json) { - var items = json.listnuagevspdevicesresponse.nuagevspdevice; - args.response.success({ - data: items - }); - } - }); - }, - detailView: { - name: 'Nuage Vsp details', - actions: { - 'remove': { - label: 'label.delete.NuageVsp', - messages: { - confirm: function(args) { - return 'message.confirm.delete.NuageVsp'; - }, - notification: function(args) { - return 'label.delete.NuageVsp'; - } - }, - action: function(args) { - $.ajax({ - url: createURL("deleteNuageVspDevice&vspdeviceid=" + args.context.nuageVspDevices[0].vspdeviceid), - dataType: "json", - async: true, - success: function(json) { - var jid = json.deletenuagevspdeviceresponse.jobid; - args.response.success({ - _custom: { - jobId: jid - } - }); - } - }); - }, - notification: { - poll: pollAsyncJobResult - } - } - }, - tabs: { - details: { - title: 'label.details', - fields: [{ - vspdeviceid: { - label: 'label.id' - }, - hostname: { - label: 'label.host.name' - }, - port: { - label: 'label.port' - }, - apiversion: { - label: 'label.api.version' - }, - retrycount: { - label: 'label.numretries' - }, - retryinterval: { - label: 'label.retry.interval' - } - }], - dataProvider: function(args) { - $.ajax({ - url: createURL("listNuageVspDevices&vspdeviceid=" + args.context.nuageVspDevices[0].vspdeviceid), - dataType: "json", - async: true, - success: function(json) { - var item = json.listnuagevspdevicesresponse.nuagevspdevice[0]; - args.response.success({ - data: item - }); - } - }); - } - } - } - } - } - }, pods: { title: 'label.pods', listView: { @@ -21675,7 +21237,7 @@ function addExternalFirewall(args, physicalNetworkObj, apiCmd, apiCmdRes, apiCmdObj) { var array1 =[]; array1.push("&physicalnetworkid=" + physicalNetworkObj.id); - cloudStack.addUsernameAndPasswordToCommandUrlParameterArrayIfItIsNotNullAndNotEmpty(array1, args.data.username, args.data.password); + cloudStack.addUsernameAndPasswordToCommandUrlParameterArrayIfItIsNotNullAndNotEmpty(array1, args.data.username, args.data.password); array1.push("&networkdevicetype=" + encodeURIComponent(args.data.networkdevicetype)); //construct URL starts here @@ -21864,7 +21426,7 @@ if (l3GatewayServiceUuid != null && l3GatewayServiceUuid.length > 0) { array1.push("&l3gatewayserviceuuid=" + encodeURIComponent(args.data.l3gatewayserviceuuid)); } - + var l2GatewayServiceUuid = args.data.l2gatewayserviceuuid; if (l2GatewayServiceUuid != null && l2GatewayServiceUuid.length > 0) { array1.push("&l2gatewayserviceuuid=" + encodeURIComponent(args.data.l2gatewayserviceuuid)); @@ -21969,36 +21531,6 @@ }); } - function addNuageVspDevice(args, physicalNetworkObj, apiCmd, apiCmdRes, apiCmdObj) { - var array1 = []; - array1.push("&physicalnetworkid=" + physicalNetworkObj.id); - array1.push("&hostname=" + encodeURIComponent(args.data.hostname)); - cloudStack.addUsernameAndPasswordToCommandUrlParameterArrayIfItIsNotNullAndNotEmpty(array1, args.data.username, args.data.password); - array1.push("&port=" + encodeURIComponent(args.data.port)); - array1.push("&apiversion=" + encodeURIComponent(args.data.apiversion)); - array1.push("&retrycount=" + encodeURIComponent(args.data.retrycount)); - array1.push("&retryinterval=" + encodeURIComponent(args.data.retryinterval)); - - $.ajax({ - url: createURL(apiCmd + array1.join("")), - dataType: "json", - type: "POST", - success: function(json) { - var jid = json[apiCmdRes].jobid; - args.response.success({ - _custom: { - jobId: jid, - getUpdatedItem: function(json) { - var item = json.queryasyncjobresultresponse.jobresult[apiCmdObj]; - - return item; - } - } - }); - } - }); - } - function addGloboDnsHost(args, physicalNetworkObj, apiCmd, apiCmdRes) { var array1 = []; array1.push("&physicalnetworkid=" + physicalNetworkObj.id); @@ -22783,9 +22315,6 @@ case "Opendaylight": nspMap[ "Opendaylight"] = items[i]; break; - case "NuageVsp": - nspMap["nuageVsp"] = items[i]; - break; case "GloboDns": nspMap["GloboDns"] = items[i]; break; @@ -22852,12 +22381,6 @@ state: nspMap.securityGroups ? nspMap.securityGroups.state: 'Disabled' }); } else if (selectedZoneObj.networktype == "Advanced") { - nspHardcodingArray.push({ - id: 'nuageVsp', - name: 'Nuage Vsp', - state: nspMap.nuageVsp ? nspMap.nuageVsp.state : 'Disabled' - }); - nspHardcodingArray.push({ id: 'InternalLbVm', name: 'Internal LB VM', diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java index ecfa8ee2ca4..f003d6a9f0f 100644 --- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@ -506,7 +506,7 @@ public class HypervisorHostHelper { */ BroadcastDomainType[] supportedBroadcastTypes = new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan, - BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan, BroadcastDomainType.Vsp}; + BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan}; if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) { throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType + " it not supported on a VMWare hypervisor at this time."); @@ -584,13 +584,6 @@ public class HypervisorHostHelper { } VMwareDVSPortgroupPolicy portGroupPolicy = null; - if (broadcastDomainType == BroadcastDomainType.Vsp) { - //If the broadcastDomainType is Vsp, then set the VMwareDVSPortgroupPolicy - portGroupPolicy = new VMwareDVSPortgroupPolicy(); - portGroupPolicy.setVlanOverrideAllowed(true); - portGroupPolicy.setBlockOverrideAllowed(true); - portGroupPolicy.setPortConfigResetAtDisconnect(true); - } // Next, create the port group. For this, we need to create a VLAN spec. createPortGroup(physicalNetwork, networkName, vlanId, vid, spvlanid, dataCenterMo, shapingPolicy, secPolicy, portGroupPolicy, dvSwitchMo, numPorts, autoExpandSupported); bWaitPortGroupReady = true; @@ -1199,7 +1192,7 @@ public class HypervisorHostHelper { */ BroadcastDomainType[] supportedBroadcastTypes = new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan, - BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan, BroadcastDomainType.Vsp}; + BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan}; if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) { throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType + " it not supported on a VMWare hypervisor at this time.");