Merge release branch 4.11 to master

* 4.11:
  CLOUDSTACK-10306: Upgrade to VMware 6.5 vim jar dependency (#2467)
  CLOUDSTACK-10298: fix for recreation of an earlier deleted Nuage managed network (#2460)
This commit is contained in:
Daan Hoogland 2018-02-27 12:42:41 +01:00
commit cdddecb41e
7 changed files with 538 additions and 196 deletions

View File

@ -38,3 +38,6 @@ mvn install:install-file -Dfile=vim25_55.jar -DgroupId=com.cloud.com.vmwa
# From https://my.vmware.com VMware-vSphere-SDK-6.0.0-3634981.zip # From https://my.vmware.com VMware-vSphere-SDK-6.0.0-3634981.zip
mvn install:install-file -Dfile=vim25_60.jar -DgroupId=com.cloud.com.vmware -DartifactId=vmware-vim25 -Dversion=6.0 -Dpackaging=jar mvn install:install-file -Dfile=vim25_60.jar -DgroupId=com.cloud.com.vmware -DartifactId=vmware-vim25 -Dversion=6.0 -Dpackaging=jar
# From https://my.vmware.com/group/vmware/get-download?downloadGroup=VS-MGMT-SDK65
mvn install:install-file -Dfile=vim25_65.jar -DgroupId=com.cloud.com.vmware -DartifactId=vmware-vim25 -Dversion=6.5 -Dpackaging=jar

View File

@ -35,7 +35,7 @@
</repository> </repository>
</repositories> </repositories>
<properties> <properties>
<nuage.vsp.client.version>1.0.7</nuage.vsp.client.version> <nuage.vsp.client.version>1.0.8</nuage.vsp.client.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>

View File

@ -763,17 +763,17 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru implements Networ
s_logger.debug("Handling trash() call back to delete the network " + network.getName() + " with uuid " + network.getUuid() + " from VSP"); 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(); boolean networkMigrationCopy = network.getRelated() != network.getId();
cleanUpNetworkCaching(network.getId());
if (networkMigrationCopy) { if (networkMigrationCopy) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Network " + network.getName() + " is a copy of a migrated network. Cleaning up network details of related network."); 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.getRelated());
} }
cleanUpNetworkCaching(network.getId());
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
//Clean up VSD managed subnet caching //Clean up VSD managed subnet caching
if (vspNetwork.getNetworkRelatedVsdIds().isVsdManaged()) { if (vspNetwork.getNetworkRelatedVsdIds().isVsdManaged()) {
@ -803,6 +803,7 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru implements Networ
_networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_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_ZONE_ID);
_networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID); _networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID);
_networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_MANAGED);
} }
private boolean networkHasDns(Network network) { private boolean networkHasDns(Network network) {

View File

@ -87,7 +87,7 @@
<cs.jstl.version>1.2</cs.jstl.version> <cs.jstl.version>1.2</cs.jstl.version>
<cs.jstl-api.version>1.2.1</cs.jstl-api.version> <cs.jstl-api.version>1.2.1</cs.jstl-api.version>
<cs.selenium.server.version>1.0-20081010.060147</cs.selenium.server.version> <cs.selenium.server.version>1.0-20081010.060147</cs.selenium.server.version>
<cs.vmware.api.version>6.0</cs.vmware.api.version> <cs.vmware.api.version>6.5</cs.vmware.api.version>
<org.springframework.version>5.0.2.RELEASE</org.springframework.version> <org.springframework.version>5.0.2.RELEASE</org.springframework.version>
<cs.mockito.version>1.10.19</cs.mockito.version> <cs.mockito.version>1.10.19</cs.mockito.version>
<cs.powermock.version>1.6.4</cs.powermock.version> <cs.powermock.version>1.6.4</cs.powermock.version>

View File

@ -18,6 +18,7 @@
""" Custom base class for Nuage VSP SDN plugin specific Marvin tests """ Custom base class for Nuage VSP SDN plugin specific Marvin tests
""" """
# Import Local Modules # Import Local Modules
from bambou.nurest_object import NURESTObject
from marvin.cloudstackTestCase import cloudstackTestCase, unittest from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.lib.base import (Domain, from marvin.lib.base import (Domain,
EgressFireWallRule, EgressFireWallRule,
@ -313,6 +314,8 @@ class nuageTestCase(cloudstackTestCase):
try: try:
if isinstance(obj, VirtualMachine): if isinstance(obj, VirtualMachine):
obj.delete(self.api_client, expunge=True) obj.delete(self.api_client, expunge=True)
elif isinstance(obj, NURESTObject):
obj.delete()
else: else:
obj.delete(self.api_client) obj.delete(self.api_client)
except Exception as e: except Exception as e:

View File

@ -19,8 +19,9 @@
with Nuage VSP SDN plugin with Nuage VSP SDN plugin
""" """
# Import Local Modules # Import Local Modules
from nuageTestCase import nuageTestCase from nuageTestCase import nuageTestCase, needscleanup
from marvin.lib.base import (Account, from marvin.lib.base import (Account,
Domain,
VirtualMachine) VirtualMachine)
from marvin.cloudstackAPI import updateZone from marvin.cloudstackAPI import updateZone
@ -125,27 +126,57 @@ class TestNuageManagedSubnets(nuageTestCase):
if not successfull_ping: if not successfull_ping:
self.fail("FAILED TEST as excepted value not found in vm") self.fail("FAILED TEST as excepted value not found in vm")
def tearDown(self): def verify_pingtovmhostname(self, ssh, pingtovmhostname):
super(TestNuageManagedSubnets, self).tearDown() """verify ping to hostname of the vm and retry 3 times"""
# Cleanup resources used successfull_ping = False
self.debug("Cleaning up the resources") nbr_retries = 0
for obj in reversed(self.cleanup): max_retries = 5
try: cmd = 'ping -c 2 ' + pingtovmhostname
if isinstance(obj, VirtualMachine):
obj.delete(self.api_client, expunge=True) while not successfull_ping and nbr_retries < max_retries:
else: self.debug("ping vm by hostname with command: " + cmd)
obj.delete(self.api_client) outputlist = ssh.execute(cmd)
except Exception as e: self.debug("command is executed properly " + cmd)
self.error("Failed to cleanup %s, got %s" % (obj, e)) completeoutput = str(outputlist).strip('[]')
# cleanup_resources(self.api_client, self.cleanup) self.debug("complete output is " + completeoutput)
self.cleanup = [] if '2 received' in completeoutput:
self.debug("Cloudstack Cleanup complete!") self.debug("PASS as vm is pingeable: " + completeoutput)
enterprise = self.fetch_by_externalID(self._session.user.enterprises, successfull_ping = True
self.domain) else:
domain_template = enterprise.domain_templates.get_first() self.debug("FAIL as vm is not pingeable: " + completeoutput)
domain_template.delete() time.sleep(3)
self.debug("VSD Cleanup complete!") nbr_retries = nbr_retries + 1
return
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") @attr(tags=["advanced", "nuagevsp", "isonw"], required_hardware="false")
def test_01_nuage_mngd_subnets_isonw(self): def test_01_nuage_mngd_subnets_isonw(self):
@ -162,6 +193,7 @@ class TestNuageManagedSubnets(nuageTestCase):
# specifying the stored Subnet ID's of VSP # specifying the stored Subnet ID's of VSP
# 4. Verify ACL rules and connectivity via deploying VM's , # 4. Verify ACL rules and connectivity via deploying VM's ,
# Enabling staticNAT, applying firewall and egress rules # 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 # Create all items on vsd required for this test
enterprise = self.fetch_by_externalID(self._session.user.enterprises, enterprise = self.fetch_by_externalID(self._session.user.enterprises,
@ -175,6 +207,7 @@ class TestNuageManagedSubnets(nuageTestCase):
zone1 = self.create_vsd_zone(domain1, "ZoneToBeConsumedByACS") zone1 = self.create_vsd_zone(domain1, "ZoneToBeConsumedByACS")
subnet1 = self.create_vsd_subnet(zone1, "SubnetToBeConsumedByACS", subnet1 = self.create_vsd_subnet(zone1, "SubnetToBeConsumedByACS",
"10.0.0.1/24") "10.0.0.1/24")
self.create_vsd_dhcp_option(subnet1, 15, ["nuagenetworks1.net"])
domain2 = self.create_vsd_domain(domain_template, enterprise, domain2 = self.create_vsd_domain(domain_template, enterprise,
"2ndL3DomainToBeConsumedByACS") "2ndL3DomainToBeConsumedByACS")
@ -182,43 +215,433 @@ class TestNuageManagedSubnets(nuageTestCase):
subnet2 = self.create_vsd_subnet(zone2, "2ndSubnetToBeConsumedByACS", subnet2 = self.create_vsd_subnet(zone2, "2ndSubnetToBeConsumedByACS",
"10.1.0.1/24") "10.1.0.1/24")
self.create_vsd_dhcp_option(subnet2, 15, ["nuagenetworks2.net"])
domain3 = self.create_vsd_domain(domain_template, enterprise, domain3 = self.create_vsd_domain(domain_template, enterprise,
"3rdL3DomainToBeConsumedByACS") "3rdL3DomainToBeConsumedByACS")
zone3 = self.create_vsd_zone(domain3, "3rdZoneToBeConsumedByACS") zone3 = self.create_vsd_zone(domain3, "3rdZoneToBeConsumedByACS")
subnet3 = self.create_vsd_subnet(zone3, "3rdSubnetToBeConsumedByACS", subnet3 = self.create_vsd_subnet(zone3, "3rdSubnetToBeConsumedByACS",
"10.2.0.1/24") "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)
# 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)
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)
self.test_data["virtual_machine"]["displayname"] = "vm2"
self.test_data["virtual_machine"]["name"] = "vm2"
vm_2 = self.create_VM(isolated_network)
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"])
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)
self.verify_pingtovmhostname(ssh, "vm2")
vm_3 = self.create_VM(isolated_network2)
self.test_data["virtual_machine"]["displayname"] = "vm4"
self.test_data["virtual_machine"]["name"] = "vm4"
vm_4 = self.create_VM(isolated_network2)
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"])
if not self.isSimulator:
vm_public_ip2 = public_ip2.ipaddress.ipaddress
try:
vm_3.ssh_ip = vm_public_ip2
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_ip2)
except Exception as e:
self.fail("SSH into VM failed with exception %s" % e)
self.verify_pingtovmipaddress(ssh2, vm_4.ipaddress)
self.verify_pingtovmhostname(ssh2, "vm4")
vm_1.delete(self.api_client, expunge=True)
vm_2.delete(self.api_client, expunge=True)
isolated_network.delete(self.api_client)
vm_3.delete(self.api_client, expunge=True)
vm_4.delete(self.api_client, expunge=True)
isolated_network2.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)
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)
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)
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
# 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)
if not self.isSimulator:
vm_public_ip_1 = public_ip_1.ipaddress.ipaddress
try:
vpc_vm_1.ssh_ip = vm_public_ip_1
vpc_vm_1.ssh_port = \
self.test_data["virtual_machine"]["ssh_port"]
vpc_vm_1.username = \
self.test_data["virtual_machine"]["username"]
vpc_vm_1.password = \
self.test_data["virtual_machine"]["password"]
self.debug("SSHing into VM: %s with %s" %
(vpc_vm_1.ssh_ip, vpc_vm_1.password))
ssh = vpc_vm_1.get_ssh_client(ipaddress=vm_public_ip_1)
except Exception as e:
self.fail("SSH into VM failed with exception %s" % e)
self.verify_pingtovmipaddress(ssh, vpc_vm_2.ipaddress)
self.verify_pingtovmipaddress(ssh, vpc_vm_12.ipaddress)
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 # On ACS create network using non-persistent nw offering allow
isolated_network = self.create_Network( isolated_network = self.create_Network(
self.nuage_isolated_network_offering, self.nuage_isolated_network_offering,
gateway="10.0.0.1", netmask="255.255.255.0", gateway="10.0.0.1", netmask="255.255.255.0",
externalid=subnet1.id) account=acs_account_1,
externalid=vsd_subnet1.id)
# On ACS create network using persistent nw offering allow # Creation of a domain with inUse domain UUID is not allowed
isolated_network2 = self.create_Network( with self.assertRaises(Exception):
self.nuage_isolated_network_offering_persistent, Domain.create(
gateway="10.1.0.1", netmask="255.255.255.0", self.api_client,
externalid=subnet2.id) {},
name="AnotherDomainManagedbyVsd",
domainid=vsd_enterprise.id
)
try: # Creation of a domain with unexisting domain UUID is not allowed
self.create_Network( with self.assertRaises(Exception):
self.nuage_shared_network_offering, gateway="10.2.0.1", Domain.create(
netmask="255.255.255.0", vlan=1201, externalid=subnet3.id) self.api_client,
except Exception as e: {},
self.debug("Shared Network Creation fails with %s" % e) name="YetAnotherDomainManagedbyVsd",
domainid=vsd_enterprise.id+1
# verify floating ip and intra subnet connectivity )
vm_1 = self.create_VM(isolated_network) vm_1 = self.create_VM(isolated_network, account=acs_account_1)
vm_2 = self.create_VM(isolated_network) 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 " self.debug("Creating Static NAT rule for the deployed VM in the "
"non persistently created Isolated network...") "non persistently created Isolated network...")
public_ip = self.acquire_PublicIPAddress(isolated_network) public_ip = self.acquire_PublicIPAddress(isolated_network,
account=acs_account_1)
self.validate_PublicIPAddress(public_ip, isolated_network) self.validate_PublicIPAddress(public_ip, isolated_network)
self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network) self.create_StaticNatRule_For_VM(vm_1, public_ip, isolated_network)
self.validate_PublicIPAddress( self.validate_PublicIPAddress(
public_ip, isolated_network, static_nat=True, vm=vm_1) public_ip, isolated_network, static_nat=True, vm=vm_1)
self.create_FirewallRule(public_ip, self.test_data["ingress_rule"]) self.create_FirewallRule(public_ip,
self.test_data["ingress_rule"])
if not self.isSimulator: if not self.isSimulator:
vm_public_ip = public_ip.ipaddress.ipaddress vm_public_ip = public_ip.ipaddress.ipaddress
try: try:
@ -236,143 +659,58 @@ class TestNuageManagedSubnets(nuageTestCase):
self.verify_pingtovmipaddress(ssh, vm_2.ipaddress) self.verify_pingtovmipaddress(ssh, vm_2.ipaddress)
vm_3 = self.create_VM(isolated_network2) @attr(tags=["advanced", "nuagevsp", "account"], required_hardware="false")
vm_4 = self.create_VM(isolated_network2) def test_04_nuage_mngd_subnets_noadminaccount(self):
self.debug("Creating Static NAT rule for the deployed VM in the " """Test Nuage VSP Managed Subnets for ACS domains without admin account
"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"])
if not self.isSimulator:
vm_public_ip2 = public_ip2.ipaddress.ipaddress
try:
vm_3.ssh_ip = vm_public_ip2
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_ip2)
except Exception as e:
self.fail("SSH into VM failed with exception %s" % e)
self.verify_pingtovmipaddress(ssh2, vm_4.ipaddress)
@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
""" """
vsd_enterprise = self.create_vsd_enterprise()
vsd_domain_template = self.create_vsd_domain_template(vsd_enterprise)
# 1. Create multiple L3DomainTemplate with Zone and Subnet on VSP self.create_vsd_default_acls(vsd_domain_template)
# 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
# Create all items on vsd required for this test vsd_domain1 = self.create_vsd_domain(vsd_domain_template,
enterprise = self.fetch_by_externalID(self._session.user.enterprises, vsd_enterprise,
self.domain) "L3DomainToBeConsumedByACS")
domain_template = self.create_vsd_domain_template(enterprise) 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)
self.create_vsd_default_acls(domain_template) # 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)
domain1 = self.create_vsd_domain(domain_template, enterprise, @needscleanup
"L3DomainToBeConsumedByACS") def create_vsd_enterprise(self):
zone1 = self.create_vsd_zone(domain1, "ZoneToBeConsumedByACS") enterprise = self.vsdk.NUEnterprise()
subnet1 = self.create_vsd_subnet(zone1, "SubnetToBeConsumedByACS", enterprise.name = "EnterpriseToBeConsumedByACS"
"10.1.0.1/24") enterprise.description = "EnterpriseToBeConsumedByACS"
subnet2 = self.create_vsd_subnet(zone1, "2ndSubnetToBeConsumedByACS", # enterprise.external_id = "ToBeConsumedByACS@" \
"10.1.128.1/24") # + str(self.cms_id)
(enterprise, connection) = self._session.user.create_child(enterprise)
return enterprise
cmd = updateZone.updateZoneCmd() def create_vsd_ingress_acl_template(self, domain_template,
cmd.id = self.zone.id priority_type="TOP"):
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 a VPC tier network 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)
self.validate_Network(vpc_tier, state="Implemented")
self.debug("Creating 2nd VPC tier network with Static NAT service")
vpc_2ndtier = self.create_Network(self.nuage_vpc_network_offering,
gateway='10.1.128.1',
vpc=vpc,
acl_list=acl_list,
externalid=subnet2.id)
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
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)
if not self.isSimulator:
vm_public_ip_1 = public_ip_1.ipaddress.ipaddress
try:
vpc_vm_1.ssh_ip = vm_public_ip_1
vpc_vm_1.ssh_port = \
self.test_data["virtual_machine"]["ssh_port"]
vpc_vm_1.username = \
self.test_data["virtual_machine"]["username"]
vpc_vm_1.password = \
self.test_data["virtual_machine"]["password"]
self.debug("SSHing into VM: %s with %s" %
(vpc_vm_1.ssh_ip, vpc_vm_1.password))
ssh = vpc_vm_1.get_ssh_client(ipaddress=vm_public_ip_1)
except Exception as e:
self.fail("SSH into VM failed with exception %s" % e)
self.verify_pingtovmipaddress(ssh, vpc_vm_2.ipaddress)
self.verify_pingtovmipaddress(ssh, vpc_vm_12.ipaddress)
def create_vsd_ingress_acl_template(self, domain_template, priority_type="TOP"):
name = "Ingress ACL " + str(priority_type).capitalize() name = "Ingress ACL " + str(priority_type).capitalize()
acl_template = self.vsdk.NUIngressACLTemplate() acl_template = self.vsdk.NUIngressACLTemplate()
acl_template.name = name acl_template.name = name
@ -383,7 +721,8 @@ class TestNuageManagedSubnets(nuageTestCase):
domain_template.create_child(acl_template) domain_template.create_child(acl_template)
return acl_template return acl_template
def create_vsd_egress_acl_template(self, domain_template, priority_type='TOP'): def create_vsd_egress_acl_template(self, domain_template,
priority_type='TOP'):
name = "Egress ACL " + str(priority_type).capitalize() name = "Egress ACL " + str(priority_type).capitalize()
acl_template = self.vsdk.NUEgressACLTemplate() acl_template = self.vsdk.NUEgressACLTemplate()
acl_template.name = name acl_template.name = name
@ -394,12 +733,13 @@ class TestNuageManagedSubnets(nuageTestCase):
domain_template.create_child(acl_template) domain_template.create_child(acl_template)
return acl_template return acl_template
@needscleanup
def create_vsd_domain_template(self, enterprise): def create_vsd_domain_template(self, enterprise):
domain_template = self.vsdk.NUDomainTemplate() domain_template = self.vsdk.NUDomainTemplate()
domain_template.name = "L3DomainTemplateToBeConsumedByACS" domain_template.name = "L3DomainTemplateToBeConsumedByACS"
domain_template.description = "L3DomainTemplateToBeConsumedByACS" domain_template.description = "L3DomainTemplateToBeConsumedByACS"
domain_template.external_id = "L3DomainTemplateToBeConsumedByACS@" \ # domain_template.external_id = "L3DomainTemplateToBeConsumedByACS@" \
+ str(self.cms_id) # + str(self.cms_id)
(domain_template, connection) = \ (domain_template, connection) = \
enterprise.create_child(domain_template) enterprise.create_child(domain_template)
return domain_template return domain_template
@ -412,8 +752,6 @@ class TestNuageManagedSubnets(nuageTestCase):
ingress_vsd_acl_entry1 = self.vsdk.NUIngressACLEntryTemplate() ingress_vsd_acl_entry1 = self.vsdk.NUIngressACLEntryTemplate()
ingress_vsd_acl_entry1.name = "Default Intra-Subnet Allow" ingress_vsd_acl_entry1.name = "Default Intra-Subnet Allow"
ingress_vsd_acl_entry1.description = "Default Intra-Subnet Allow" ingress_vsd_acl_entry1.description = "Default Intra-Subnet Allow"
ingress_vsd_acl_entry1.external_id = "ToBeConsumedByACS@" \
+ str(self.cms_id)
ingress_vsd_acl_entry1.priority = '1' ingress_vsd_acl_entry1.priority = '1'
ingress_vsd_acl_entry1.protocol = 'ANY' ingress_vsd_acl_entry1.protocol = 'ANY'
ingress_vsd_acl_template1.create_child(ingress_vsd_acl_entry1) ingress_vsd_acl_template1.create_child(ingress_vsd_acl_entry1)
@ -421,8 +759,6 @@ class TestNuageManagedSubnets(nuageTestCase):
ingress_vsd_acl_entry2 = self.vsdk.NUIngressACLEntryTemplate() ingress_vsd_acl_entry2 = self.vsdk.NUIngressACLEntryTemplate()
ingress_vsd_acl_entry2.name = "Default Allow TCP" ingress_vsd_acl_entry2.name = "Default Allow TCP"
ingress_vsd_acl_entry2.description = "Default Allow TCP" ingress_vsd_acl_entry2.description = "Default Allow TCP"
ingress_vsd_acl_entry2.external_id = "ToBeConsumedByACS@" \
+ str(self.cms_id)
ingress_vsd_acl_entry2.priority = '1' ingress_vsd_acl_entry2.priority = '1'
ingress_vsd_acl_entry2.protocol = '6' ingress_vsd_acl_entry2.protocol = '6'
ingress_vsd_acl_entry2.source_port = '*' ingress_vsd_acl_entry2.source_port = '*'
@ -432,8 +768,6 @@ class TestNuageManagedSubnets(nuageTestCase):
ingress_vsd_acl_entry3 = self.vsdk.NUIngressACLEntryTemplate() ingress_vsd_acl_entry3 = self.vsdk.NUIngressACLEntryTemplate()
ingress_vsd_acl_entry3.name = "Default Allow UDP" ingress_vsd_acl_entry3.name = "Default Allow UDP"
ingress_vsd_acl_entry3.description = "Default Allow UDP" ingress_vsd_acl_entry3.description = "Default Allow UDP"
ingress_vsd_acl_entry3.external_id = "ToBeConsumedByACS@" \
+ str(self.cms_id)
ingress_vsd_acl_entry3.priority = '2' ingress_vsd_acl_entry3.priority = '2'
ingress_vsd_acl_entry3.protocol = '17' ingress_vsd_acl_entry3.protocol = '17'
ingress_vsd_acl_entry3.source_port = '*' ingress_vsd_acl_entry3.source_port = '*'
@ -442,8 +776,6 @@ class TestNuageManagedSubnets(nuageTestCase):
ingress_vsd_acl_entry4 = self.vsdk.NUIngressACLEntryTemplate() ingress_vsd_acl_entry4 = self.vsdk.NUIngressACLEntryTemplate()
ingress_vsd_acl_entry4.name = "Default Allow ICMP" ingress_vsd_acl_entry4.name = "Default Allow ICMP"
ingress_vsd_acl_entry4.description = "Default Allow ICMP" ingress_vsd_acl_entry4.description = "Default Allow ICMP"
ingress_vsd_acl_entry4.external_id = "ToBeConsumedByACS@" \
+ str(self.cms_id)
ingress_vsd_acl_entry4.priority = '3' ingress_vsd_acl_entry4.priority = '3'
ingress_vsd_acl_entry4.protocol = '1' ingress_vsd_acl_entry4.protocol = '1'
ingress_vsd_acl_template2.create_child(ingress_vsd_acl_entry4) ingress_vsd_acl_template2.create_child(ingress_vsd_acl_entry4)
@ -457,16 +789,12 @@ class TestNuageManagedSubnets(nuageTestCase):
egress_vsd_acl_entry1 = self.vsdk.NUEgressACLEntryTemplate() egress_vsd_acl_entry1 = self.vsdk.NUEgressACLEntryTemplate()
egress_vsd_acl_entry1.name = "Default Intra-Subnet Allow" egress_vsd_acl_entry1.name = "Default Intra-Subnet Allow"
egress_vsd_acl_entry1.description = "Default Intra-Subnet Allow" egress_vsd_acl_entry1.description = "Default Intra-Subnet Allow"
egress_vsd_acl_entry1.external_id = "ToBeConsumedByACS@" \
+ str(self.cms_id)
egress_vsd_acl_entry1.priority = '1' egress_vsd_acl_entry1.priority = '1'
egress_vsd_acl_entry1.protocol = 'ANY' egress_vsd_acl_entry1.protocol = 'ANY'
egress_vsd_acl_template1.create_child(egress_vsd_acl_entry1) egress_vsd_acl_template1.create_child(egress_vsd_acl_entry1)
egress_vsd_acl_entry2 = self.vsdk.NUEgressACLEntryTemplate() egress_vsd_acl_entry2 = self.vsdk.NUEgressACLEntryTemplate()
egress_vsd_acl_entry2.name = "Default Allow ICMP" egress_vsd_acl_entry2.name = "Default Allow ICMP"
egress_vsd_acl_entry2.description = "Default Allow ICMP" egress_vsd_acl_entry2.description = "Default Allow ICMP"
egress_vsd_acl_entry2.external_id = "ToBeConsumedByACS@" \
+ str(self.cms_id)
egress_vsd_acl_entry2.priority = '3' egress_vsd_acl_entry2.priority = '3'
egress_vsd_acl_entry2.protocol = '1' egress_vsd_acl_entry2.protocol = '1'
egress_vsd_acl_template2.create_child(egress_vsd_acl_entry2) egress_vsd_acl_template2.create_child(egress_vsd_acl_entry2)
@ -475,7 +803,6 @@ class TestNuageManagedSubnets(nuageTestCase):
domain = self.vsdk.NUDomain() domain = self.vsdk.NUDomain()
domain.name = name domain.name = name
domain.description = name domain.description = name
domain.external_id = name + "@" + str(self.cms_id)
(domain, connection) = \ (domain, connection) = \
enterprise.instantiate_child(domain, domain_template) enterprise.instantiate_child(domain, domain_template)
return domain return domain
@ -484,7 +811,6 @@ class TestNuageManagedSubnets(nuageTestCase):
zone = self.vsdk.NUZone() zone = self.vsdk.NUZone()
zone.name = name zone.name = name
zone.description = name zone.description = name
zone.external_id = name + "@" + str(self.cms_id)
(zone, connection) = domain.create_child(zone) (zone, connection) = domain.create_child(zone)
return zone return zone
@ -492,12 +818,18 @@ class TestNuageManagedSubnets(nuageTestCase):
subnet = self.vsdk.NUSubnet() subnet = self.vsdk.NUSubnet()
subnet.name = name subnet.name = name
subnet.description = name subnet.description = name
subnet.external_id = name + "@" + str(self.cms_id)
(subnet.gateway, subnet.netmask, subnet.address) = \ (subnet.gateway, subnet.netmask, subnet.address) = \
self._cidr_to_netmask(cidr) self._cidr_to_netmask(cidr)
(subnet, connection) = zone.create_child(subnet) (subnet, connection) = zone.create_child(subnet)
return 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): def _cidr_to_netmask(self, cidr):
import socket import socket
import struct import struct

View File

@ -39,7 +39,7 @@ class Domain:
@classmethod @classmethod
def create(cls, apiclient, services, name=None, networkdomain=None, def create(cls, apiclient, services, name=None, networkdomain=None,
parentdomainid=None): parentdomainid=None, domainid=None):
"""Creates an domain""" """Creates an domain"""
cmd = createDomain.createDomainCmd() cmd = createDomain.createDomainCmd()
@ -61,6 +61,9 @@ class Domain:
cmd.parentdomainid = parentdomainid cmd.parentdomainid = parentdomainid
elif "parentdomainid" in services: elif "parentdomainid" in services:
cmd.parentdomainid = services["parentdomainid"] cmd.parentdomainid = services["parentdomainid"]
if domainid:
cmd.domainid = domainid
try: try:
domain = apiclient.createDomain(cmd) domain = apiclient.createDomain(cmd)
if domain is not None: if domain is not None: