def create_network_acl_list(self, name, description, vpc): self.debug("Adding NetworkACL list in VPC: %s" % vpc.id) return NetworkACLList.create(self.api_client, services={}, name=name, description=description, vpcid=vpc.id)
def test_vpcnetwork_nuage(self): """Test network VPC for Nuage""" # 1) Create VPC with Nuage VPC offering vpcOffering = VpcOffering.list(self.apiclient, name="Nuage VSP VPC offering") self.assert_(vpcOffering is not None and len(vpcOffering) > 0, "Nuage VPC offering not found") vpc = VPC.create(apiclient=self.apiclient, services=self.services["vpc"], networkDomain="vpc.networkacl", vpcofferingid=vpcOffering[0].id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid) self.assert_(vpc is not None, "VPC creation failed") # 2) Create ACL aclgroup = NetworkACLList.create(apiclient=self.apiclient, services={}, name="acl", description="acl", vpcid=vpc.id) self.assertIsNotNone(aclgroup, "Failed to create NetworkACL list") self.debug("Created a network ACL list %s" % aclgroup.name) # 3) Create ACL Item aclitem = NetworkACL.create(apiclient=self.apiclient, services={}, protocol="TCP", number="10", action="Deny", aclid=aclgroup.id, cidrlist=["0.0.0.0/0"]) self.assertIsNotNone(aclitem, "Network failed to aclItem") self.debug("Added a network ACL %s to ACL list %s" % (aclitem.id, aclgroup.name)) # 4) Create network with ACL nwNuage = Network.create(self.apiclient, self.services["vpcnetwork"], accountid=self.account.name, domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, vpcid=vpc.id, aclid=aclgroup.id, gateway='10.1.0.1') self.debug("Network %s created in VPC %s" % (nwNuage.id, vpc.id)) # 5) Deploy a vm vm = VirtualMachine.create(self.apiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(nwNuage.id)]) self.assert_(vm is not None, "VM failed to deploy") self.assert_(vm.state == 'Running', "VM is not running") self.debug("VM %s deployed in VPC %s" % (vm.id, vpc.id))
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 )
def define_custom_acl(self): acl1 = NetworkACLList.create(self.api_client, self.attributes['acls']['acl1'], vpcid=self.vpc1.id) NetworkACL.create(self.api_client, self.attributes['acls']['acl1']['entries']['entry1'], networkid=self.network1.id, aclid=acl1.id) try: command = replaceNetworkACLList.replaceNetworkACLListCmd() command.aclid = acl1.id command.gatewayid = self.private_gateway1.id response = self.api_client.replaceNetworkACLList(command) except Exception as e: raise Exception("Exception: %s" % e) self.assertTrue(response.success) self.logger.debug("Private Gateway '%s' ACL replaced", self.private_gateway1.ipaddress) acl2 = NetworkACLList.create(self.api_client, self.attributes['acls']['acl2'], vpcid=self.vpc2.id) NetworkACL.create(self.api_client, self.attributes['acls']['acl2']['entries']['entry2'], networkid=self.network2.id, aclid=acl2.id) try: command2 = replaceNetworkACLList.replaceNetworkACLListCmd() command2.aclid = acl2.id command2.gatewayid = self.private_gateway2.id response2 = self.api_client.replaceNetworkACLList(command2) except Exception as e: raise Exception("Exception: %s" % e) self.assertTrue(response2.success) self.logger.debug("Private Gateway '%s' ACL replaced", self.private_gateway2.ipaddress)
def define_custom_acl(self): acl1 = NetworkACLList.create(self.api_client, self.attributes['acls']['acl1'], vpcid=self.vpc1.id) NetworkACL.create(self.api_client, self.attributes['acls']['acl1']['entries']['entry1'], networkid=self.network1.id, aclid=acl1.id) try: command = replaceNetworkACLList.replaceNetworkACLListCmd() command.aclid = acl1.id command.gatewayid = self.private_gateway1.id response = self.api_client.replaceNetworkACLList(command) except Exception as e: raise Exception("Exception: %s" % e) self.assertTrue(response.success) self.logger.debug("Private Gateway '%s' ACL replaced", self.private_gateway1.ipaddress) acl2 = NetworkACLList.create(self.api_client, self.attributes['acls']['acl2'], vpcid=self.vpc2.id) NetworkACL.create(self.api_client, self.attributes['acls']['acl2']['entries']['entry2'], networkid=self.network2.id, aclid=acl2.id) try: command2 = replaceNetworkACLList.replaceNetworkACLListCmd() command2.aclid = acl2.id command2.gatewayid = self.private_gateway2.id response2 = self.api_client.replaceNetworkACLList(command2) except Exception as e: raise Exception("Exception: %s" % e) self.assertTrue(response2.success) self.logger.debug("Private Gateway '%s' ACL replaced", self.private_gateway2.ipaddress)
def deploy_acl(self, acl_data, vpc): self.logger.debug('>>> ACL => Creating "%s"...', acl_data['name']) acl = NetworkACLList.create(api_client=self.api_client, data=acl_data, vpc=vpc) self.logger.debug('>>> ACL => ID: %s => Name: %s => VPC: %s', acl.id, acl.name, acl.vpcid) self.deploy_rules(acl_data['rules'], acl)
def test_vpcnetwork_nuage(self): """Test network VPC for Nuage""" # 1) Create VPC with Nuage VPC offering vpcOffering = VpcOffering.list(self.apiclient,name="Nuage VSP VPC offering") self.assert_(vpcOffering is not None and len(vpcOffering)>0, "Nuage VPC offering not found") vpc = VPC.create( apiclient=self.apiclient, services=self.services["vpc"], networkDomain="vpc.networkacl", vpcofferingid=vpcOffering[0].id, zoneid=self.zone.id, account=self.account.name, domainid=self.account.domainid ) self.assert_(vpc is not None, "VPC creation failed") # 2) Create ACL aclgroup = NetworkACLList.create(apiclient=self.apiclient, services={}, name="acl", description="acl", vpcid=vpc.id) self.assertIsNotNone(aclgroup, "Failed to create NetworkACL list") self.debug("Created a network ACL list %s" % aclgroup.name) # 3) Create ACL Item aclitem = NetworkACL.create(apiclient=self.apiclient, services={}, protocol="TCP", number="10", action="Deny", aclid=aclgroup.id, cidrlist=["0.0.0.0/0"]) self.assertIsNotNone(aclitem, "Network failed to aclItem") self.debug("Added a network ACL %s to ACL list %s" % (aclitem.id, aclgroup.name)) # 4) Create network with ACL nwNuage = Network.create( self.apiclient, self.services["vpcnetwork"], accountid=self.account.name, domainid=self.account.domainid, networkofferingid=self.network_offering.id, zoneid=self.zone.id, vpcid=vpc.id, aclid=aclgroup.id, gateway='10.1.0.1' ) self.debug("Network %s created in VPC %s" %(nwNuage.id, vpc.id)) # 5) Deploy a vm vm = VirtualMachine.create( self.apiclient, self.services["virtual_machine"], accountid=self.account.name, domainid=self.account.domainid, serviceofferingid=self.service_offering.id, networkids=[str(nwNuage.id)] ) self.assert_(vm is not None, "VM failed to deploy") self.assert_(vm.state == 'Running', "VM is not running") self.debug("VM %s deployed in VPC %s" %(vm.id, vpc.id))
def deploy_acl(self, acl_data, vpc): self.logger.debug('>>> ACL => Creating "%s"...', acl_data['name']) acl = NetworkACLList.create( api_client=self.api_client, data=acl_data, vpc=vpc ) self.logger.debug('>>> ACL => ID: %s => Name: %s => VPC: %s', acl.id, acl.name, acl.vpcid) self.deploy_rules(acl_data['rules'], acl)
def define_custom_acl(self, acl_config, acl_entry_config): acl = NetworkACLList.create(self.api_client, self.attributes['acls'][acl_config], vpcid=self.vpc1.id) NetworkACL.create(self.api_client, self.attributes['acls'][acl_config]['entries'][acl_entry_config], networkid=self.network1.id, aclid=acl.id) self.define_acl(acl)
def define_custom_acl(self, acl_config, acl_entry_config): acl = NetworkACLList.create(self.api_client, self.attributes['acls'][acl_config], vpcid=self.vpc1.id) NetworkACL.create(self.api_client, self.attributes['acls'][acl_config]['entries'][acl_entry_config], networkid=self.network1.id, aclid=acl.id) self.define_acl(acl)
def deploy_network_acl_list(self, acl_list_name, acl_config, network=None, vpc=None): if network: networkid=network.id if network.vpcid: vpcid=network.vpcid acl_list = NetworkACLList.create(self.api_client, name=acl_list_name, services=[], vpcid=vpcid, vpc=vpc) NetworkACL.create(self.api_client, acl_config, networkid=networkid, aclid=acl_list.id) return acl_list
def deploy_network_acl_list(self, acl_list_name, acl_config, network=None, vpc=None): if network: networkid = network.id if network.vpcid: vpcid = network.vpcid acl_list = NetworkACLList.create(self.api_client, name=acl_list_name, services=[], vpcid=vpcid, vpc=vpc) NetworkACL.create(self.api_client, acl_config, networkid=networkid, aclid=acl_list.id) return acl_list