本文整理汇总了Python中marvin.lib.base.NetworkACL.create方法的典型用法代码示例。如果您正苦于以下问题:Python NetworkACL.create方法的具体用法?Python NetworkACL.create怎么用?Python NetworkACL.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.NetworkACL
的用法示例。
在下文中一共展示了NetworkACL.create方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: define_custom_acl
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
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)
示例2: create_NetworkAclRule
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
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
)
示例3: deploy_network_acl_list
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
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
示例4: create_LB_Rule
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def create_LB_Rule(self, public_ip, network, vmarray, services=None):
self.debug("Creating LB rule for IP address: %s" %
public_ip.ipaddress.ipaddress)
objservices = None
if services:
objservices = services
else:
objservices = self.services["lbrule"]
lb_rule = LoadBalancerRule.create(
self.apiclient,
objservices,
ipaddressid=public_ip.ipaddress.id,
accountid=self.account.name,
networkid=network.id,
vpcid=self.vpc.id,
domainid=self.account.domainid
)
self.debug("Adding virtual machines %s and %s to LB rule" % (vmarray[0], vmarray[1]))
lb_rule.assign(self.apiclient, vmarray)
self.debug("Adding NetworkACl rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create(self.apiclient,
objservices,
networkid=network.id,
traffictype='Ingress'
)
self.debug('nwacl_nat=%s' % nwacl_nat.__dict__)
return lb_rule
示例5: open_egress_to_world
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def open_egress_to_world(self, network):
self.debug("Adding Egress rules to network %s and %s to allow access to internet" % (network.name,self.services["http_rule"]))
nwacl_internet_1 = NetworkACL.create(
self.apiclient,
networkid=network.id,
services=self.services["http_rule"],
traffictype='Ingress'
)
return nwacl_internet_1
示例6: define_custom_acl
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
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)
示例7: create_ingress_rule
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def create_ingress_rule(self, network, services=None):
if not services:
services = self.services["ssh_rule"]
self.debug("Adding NetworkACL rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create(self.apiclient,
services,
networkid=network.id,
traffictype='Ingress'
)
return nwacl_nat
示例8: test_vpcnetwork_nuage
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
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))
示例9: deploy_rule
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def deploy_rule(self, rule_data, acl):
self.logger.debug('>>> ACL RULE => Creating...')
rule = NetworkACL.create(
api_client=self.api_client,
data=rule_data,
acl=acl
)
self.logger.debug('>>> ACL RULE => ID: %s => Number: %s => Action: %s => Traffic Type: %s '
'=> CIDR List: %s => Protocol: %s => Start Port: %s => End Port: %s => ACL: %s',
rule.id, rule.number, rule.action, rule.traffictype, rule.cidrlist, rule.protocol.upper(),
rule.startport, rule.endport, rule.aclid)
示例10: create_NatRule_For_VM
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def create_NatRule_For_VM(self, vm, public_ip, network):
self.debug("Creatinng NAT rule in network for vm with public IP")
nat_rule = NATRule.create(self.apiclient,
vm,
self.services["natrule"],
ipaddressid=public_ip.ipaddress.id,
openfirewall=False,
networkid=network.id,
vpcid=self.vpc.id
)
self.debug("Adding NetwrokACl rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create(self.apiclient,
networkid=network.id,
services=self.services["natrule"],
traffictype='Ingress'
)
self.debug('nwacl_nat=%s' % nwacl_nat.__dict__)
return nat_rule
示例11: create_natrule
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def create_natrule(self, vm, public_ip, network, vpc_id):
self.logger.debug("Creating NAT rule in network for vm with public IP")
nat_rule_services = self.services["natrule"]
nat_rule = NATRule.create(
self.apiclient,
vm,
nat_rule_services,
ipaddressid=public_ip.ipaddress.id,
openfirewall=False,
networkid=network.id,
vpcid=vpc_id,
)
self.logger.debug("Adding NetworkACL rules to make NAT rule accessible")
nwacl_nat = NetworkACL.create(
self.apiclient, networkid=network.id, services=nat_rule_services, traffictype="Ingress"
)
self.logger.debug("nwacl_nat=%s" % nwacl_nat.__dict__)
return nat_rule
示例12: test_01_positive_tests_vm_operations_advanced_zone
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def test_01_positive_tests_vm_operations_advanced_zone(self, value):
""" Positive tests for VMLC test path - Advanced Zone
# 1. List created service offering in setUpClass by name
# 2. List registered template with name
# 3. Create VM in account
# 4. Enable networking for reaching to VM thorugh SSH
# 5. Check VM accessibility through SSH
# 6. Stop vm and verify vm is not accessible
# 7. Start vm and verify vm is not accessible
# 8. Reboot vm and verify vm is not accessible
# 9. Destroy and recover VM
# 10. Change service offering of VM to a different service offering
# 11. Verify that the cpuspeed, cpunumber and memory of VM matches to
# as specified in new service offering
# 12. Start VM and verify VM accessibility
# 13. Find suitable host for VM to migrate and migrate the VM
# 14. Verify VM accessibility on new host
"""
# List created service offering in setUpClass by name
listServiceOfferings = ServiceOffering.list(
self.apiclient,
name=self.service_offering_1.name,
listall=True
)
self.assertEqual(validateList(listServiceOfferings)[0], PASS,
"List validation failed for service offerings list")
self.assertEqual(listServiceOfferings[0].name,
self.service_offering_1.name,
"Names of created service offering\
and listed service offering not matching")
# List registered template with name
listTemplates = Template.list(
self.userapiclient,
templatefilter="self",
name=self.template.name,
listall=True,
zone=self.zone.id)
self.assertEqual(validateList(listTemplates)[0], PASS,
"List validation failed for templates list")
self.assertEqual(listTemplates[0].name, self.template.name,
"Names of created template and listed template\
not matching")
network = CreateNetwork(self, value)
# Create VM in account
self.virtual_machine = VirtualMachine.create(
self.userapiclient,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering_1.id,
networkids=[network.id, ],
zoneid=self.zone.id
)
self.cleanup.append(self.virtual_machine)
publicip = PublicIPAddress.create(
self.userapiclient, accountid=self.account.name,
zoneid=self.zone.id, domainid=self.account.domainid,
networkid=network.id, vpcid=self.vpcid
)
if value == VPC_NETWORK:
lb_rule = LoadBalancerRule.create(
self.apiclient,
self.testdata["vpclbrule"],
ipaddressid=publicip.ipaddress.id,
accountid=self.account.name,
domainid=self.account.domainid,
networkid=network.id,
vpcid=self.vpcid
)
lb_rule.assign(self.apiclient, [self.virtual_machine])
# Opening up the ports in VPC
NetworkACL.create(
self.apiclient,
networkid=network.id,
services=self.testdata["natrule"],
traffictype='Ingress'
)
elif value == ISOLATED_NETWORK:
FireWallRule.create(
self.userapiclient,
ipaddressid=publicip.ipaddress.id,
protocol='TCP',
cidrlist=[self.testdata["fwrule"]["cidr"]],
startport=self.testdata["fwrule"]["startport"],
endport=self.testdata["fwrule"]["endport"]
)
NATRule.create(
self.userapiclient,
self.virtual_machine,
self.testdata["natrule"],
#.........这里部分代码省略.........
示例13: test_03_deploy_vms_in_vpc_with_regionlevelvpc
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self):
"""Test deploy virtual machines in VPC networks"""
# 1. Create VPC Offering by specifying all supported Services
# (Vpn,dhcpdns,UserData, SourceNat,Static NAT and PF,LB,NetworkAcl)
# 2. Create a VPC using the above VPC offering
# 3. Create a network as part of this VPC.
# 4. Deploy few Vms.
# 5. Create a LB rule for this VM.
# 6. Create a PF rule for this VM.
# 7. Create a Static Nat rule for this VM.
# 8. Create Ingress rules on the network to open the above created
# LB PF and Static Nat rule
# 9. Create Egress Network ACL for this network to access google.com.
# 10. Enable VPN services
if not self.isOvsPluginEnabled:
self.skipTest("OVS plugin should be enabled to run this test case")
self.debug("Creating a VPC offering..")
vpc_off = VpcOffering.create(
self.apiclient,
self.services["vpc_offering"]
)
vpc_off.update(self.apiclient, state='Enabled')
self.debug("creating a VPC network in the account: %s" %
self.account.name)
vpc = VPC.create(
self.apiclient,
self.services["vpc"],
vpcofferingid=vpc_off.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
networkDomain=self.account.domainid
)
self.validate_vpc_network(vpc)
self.network_offering = NetworkOffering.create(
self.apiclient,
self.services["network_offering"],
conservemode=False
)
# Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled')
gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway
# for eg. cidr = 10.0.0.1/24
# Gateway = 10.0.0.1
# Creating network using the network offering created
self.debug("Creating network with network offering: %s" %
self.network_offering.id)
network = Network.create(
self.apiclient,
self.services["network"],
accountid=self.account.name,
domainid=self.account.domainid,
networkofferingid=self.network_offering.id,
zoneid=self.zone.id,
gateway=gateway,
vpcid=vpc.id
)
self.debug("Created network with ID: %s" % network.id)
# Spawn an instance in that network
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
networkids=[str(network.id)]
)
self.debug("Deployed VM in network: %s" % network.id)
self.debug("Associating public IP for network: %s" % network.name)
public_ip = PublicIPAddress.create(
self.apiclient,
accountid=self.account.name,
zoneid=self.zone.id,
domainid=self.account.domainid,
networkid=network.id,
vpcid=vpc.id
)
self.debug("Associated %s with network %s" % (
public_ip.ipaddress.ipaddress,
network.id
))
self.debug("Creating LB rule for IP address: %s" %
public_ip.ipaddress.ipaddress)
LoadBalancerRule.create(
self.apiclient,
self.services["lbrule"],
ipaddressid=public_ip.ipaddress.id,
accountid=self.account.name,
#.........这里部分代码省略.........
示例14: setUpClass
# 需要导入模块: from marvin.lib.base import NetworkACL [as 别名]
# 或者: from marvin.lib.base.NetworkACL import create [as 别名]
def setUpClass(cls):
cls._cleanup = []
cls.testClient = super(TestVPCRouterOneNetwork, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.vpcSupported = True
cls._cleanup = []
cls.services = Services().services
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
)
cls._cleanup.append(cls.service_offering)
cls.vpc_off = VpcOffering.create(
cls.api_client,
cls.services["vpc_offering"]
)
cls.vpc_off.update(cls.api_client, state='Enabled')
cls._cleanup.append(cls.vpc_off)
cls.account = Account.create(
cls.api_client,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
cls._cleanup.insert(0, cls.account)
cls.services["vpc"]["cidr"] = '10.1.1.1/16'
cls.vpc = VPC.create(
cls.api_client,
cls.services["vpc"],
vpcofferingid=cls.vpc_off.id,
zoneid=cls.zone.id,
account=cls.account.name,
domainid=cls.account.domainid
)
private_gateway = PrivateGateway.create(
cls.api_client,
gateway='10.1.3.1',
ipaddress='10.1.3.100',
netmask='255.255.255.0',
vlan=678,
vpcid=cls.vpc.id
)
cls.gateways = PrivateGateway.list(
cls.api_client,
id=private_gateway.id,
listall=True
)
static_route = StaticRoute.create(
cls.api_client,
cidr='11.1.1.1/24',
gatewayid=private_gateway.id
)
cls.static_routes = StaticRoute.list(
cls.api_client,
id=static_route.id,
listall=True
)
cls.nw_off = NetworkOffering.create(
cls.api_client,
cls.services["network_offering"],
conservemode=False
)
# Enable Network offering
cls.nw_off.update(cls.api_client, state='Enabled')
cls._cleanup.append(cls.nw_off)
# Creating network using the network offering created
cls.network_1 = Network.create(
cls.api_client,
cls.services["network"],
accountid=cls.account.name,
domainid=cls.account.domainid,
networkofferingid=cls.nw_off.id,
zoneid=cls.zone.id,
gateway='10.1.1.1',
vpcid=cls.vpc.id
)
# Spawn an instance in that network
vm_1 = VirtualMachine.create(
cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
#.........这里部分代码省略.........