本文整理汇总了Python中marvin.lib.base.VPC.create方法的典型用法代码示例。如果您正苦于以下问题:Python VPC.create方法的具体用法?Python VPC.create怎么用?Python VPC.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.VPC
的用法示例。
在下文中一共展示了VPC.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_02_create_vpc_from_offering_with_regionlevelvpc_service_capability
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def test_02_create_vpc_from_offering_with_regionlevelvpc_service_capability(self):
""" Test create VPC offering
"""
# Steps for validation
# 1. Create VPC Offering by specifying all supported Services
# 2. VPC offering should be created successfully.
if not self.isOvsPluginEnabled:
self.skipTest("OVS plugin should be enabled to run this test case")
self.debug("Creating inter VPC offering")
vpc_off = VpcOffering.create(
self.apiclient,
self.services["vpc_offering"]
)
vpc_off.update(self.apiclient, state='Enabled')
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.assertEqual(vpc.distributedvpcrouter, True, "VPC created should have 'distributedvpcrouter' set to True")
try:
vpc.delete(self.apiclient)
except Exception as e:
self.fail("Failed to delete VPC network - %s" % e)
return
示例2: create_vpc
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def create_vpc(self, name, cidr):
print name, cidr
try:
vpcOffering = VpcOffering.list(self.apiclient, isdefault=True)
self.assert_(vpcOffering is not None and len(
vpcOffering) > 0, "No VPC offerings found")
self.services["vpc"] = {}
self.services["vpc"]["name"] = name
self.services["vpc"]["displaytext"] = name
self.services["vpc"]["cidr"] = cidr
vpc = VPC.create(
apiclient=self.apiclient,
services=self.services["vpc"],
networkDomain="vpc.internallb",
vpcofferingid=vpcOffering[0].id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.domain.id
)
self.assertIsNotNone(vpc, "VPC creation failed")
self.logger.debug("Created VPC %s" % vpc.id)
return vpc
except Exception as e:
self.fail("Failed to create VPC: %s due to %s" % (name, e))
示例3: setUp
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def setUp(self):
self.routers = []
self.networks = []
self.ips = []
self.apiclient = self.testClient.getApiClient()
self.account = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.domain.id)
self.vpc_off = get_default_vpc_offering(self.apiclient)
self.logger.debug("Creating a VPC network in the account: %s" % self.account.name)
self.services["vpc"]["cidr"] = '10.1.1.1/16'
self.vpc = VPC.create(
self.apiclient,
self.services["vpc"],
vpcofferingid=self.vpc_off.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid)
self.cleanup = [self.vpc, self.account]
return
示例4: setUp
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def setUp(self):
self.routers = []
self.networks = []
self.ips = []
self.apiclient = self.testClient.getApiClient()
self.hypervisor = self.testClient.getHypervisorInfo()
self.account = Account.create(
self.apiclient,
self.services["account"],
admin=True,
domainid=self.domain.id)
self.logger.debug("Creating a VPC offering..")
self.vpc_off = VpcOffering.create(
self.apiclient,
self.services["vpc_offering"])
self.logger.debug("Enabling the VPC offering created")
self.vpc_off.update(self.apiclient, state='Enabled')
self.logger.debug("Creating a VPC network in the account: %s" % self.account.name)
self.services["vpc"]["cidr"] = '10.1.1.1/16'
self.vpc = VPC.create(
self.apiclient,
self.services["vpc"],
vpcofferingid=self.vpc_off.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid)
self.cleanup = [self.vpc, self.vpc_off, self.account]
return
示例5: setUpClass
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def setUpClass(cls):
cls.logger = MarvinLog(MarvinLog.LOGGER_TEST).get_logger()
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
cls.testClient = super(TestRouterIpTablesPolicies, cls).getClsTestClient()
cls.apiclient = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.apiclient,
cls.zone.id
)
cls.services["vpc"]["cidr"] = '10.1.1.1/16'
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.vpc_offering = get_default_vpc_offering(cls.apiclient)
cls.logger.debug("VPC Offering '%s' selected", cls.vpc_offering.name)
cls.network_offering = get_default_network_offering(cls.apiclient)
cls.logger.debug("Network Offering '%s' selected", cls.network_offering.name)
cls.default_allow_acl = get_network_acl(cls.apiclient, 'default_allow')
cls.logger.debug("ACL '%s' selected", cls.default_allow_acl.name)
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
admin=True,
domainid=cls.domain.id)
cls.vpc1 = VPC.create(cls.apiclient,
cls.services['vpcs']['vpc1'],
vpcofferingid=cls.vpc_offering.id,
zoneid=cls.zone.id,
domainid=cls.domain.id,
account=cls.account.name)
cls.logger.debug("VPC '%s' created, CIDR: %s", cls.vpc1.name, cls.vpc1.cidr)
cls.network1 = Network.create(cls.apiclient,
cls.services['networks']['network1'],
networkofferingid=cls.network_offering.id,
aclid=cls.default_allow_acl.id,
vpcid=cls.vpc1.id,
zoneid=cls.zone.id,
domainid=cls.domain.id,
accountid=cls.account.name)
cls.logger.debug("Network '%s' created, CIDR: %s, Gateway: %s", cls.network1.name, cls.network1.cidr, cls.network1.gateway)
cls.service_offering = get_default_virtual_machine_offering(cls.apiclient)
cls.entity_manager = EntityManager(cls.apiclient, cls.services, cls.service_offering, cls.account, cls.zone, cls.network1, cls.logger)
cls._cleanup = [cls.account]
return
示例6: setUpClass
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def setUpClass(cls):
cls.testClient = super(TestVPCRoutersBasic, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.vpcSupported = True
cls._cleanup = []
if cls.hypervisor.lower() == 'hyperv':
cls.vpcSupported = False
return
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.vpc_off = VpcOffering.create(
cls.api_client,
cls.services["vpc_offering"]
)
cls.vpc_off.update(cls.api_client, state='Enabled')
cls.account = Account.create(
cls.api_client,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
cls._cleanup = [cls.account]
cls._cleanup.append(cls.vpc_off)
#cls.debug("Enabling the VPC offering created")
cls.vpc_off.update(cls.api_client, state='Enabled')
# cls.debug("creating a VPC network in the account: %s" %
# cls.account.name)
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
)
cls._cleanup.append(cls.service_offering)
return
示例7: test_vpcnetwork_nuage
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC 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))
示例8: setUp
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def setUp(self):
self.vpc_off = get_default_vpc_offering(self.apiclient)
self.vpc = VPC.create(
self.apiclient,
self.services["vpc"],
vpcofferingid=self.vpc_off.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid)
self.cleanup = [self.vpc]
self.entity_manager.set_cleanup(self.cleanup)
return
示例9: create_Vpc
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def create_Vpc(self, vpc_offering, cidr='10.1.1.1/16', cleanup=True):
self.debug("Creating a VPC network in the account: %s" % self.account.name)
self.test_data["vpc"]["cidr"] = cidr
vpc = VPC.create(
self.api_client,
self.test_data["vpc"],
vpcofferingid=vpc_offering.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created VPC with ID: %s" % vpc.id)
if cleanup:
self.cleanup.append(vpc)
return vpc
示例10: create_Vpc
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def create_Vpc(self, vpc_offering, cidr="10.1.1.1/16", cleanup=True):
self.debug("Creating a VPC in the account - %s" % self.account.name)
self.test_data["vpc"]["name"] = "TestVPC"
self.test_data["vpc"]["displaytext"] = "TestVPC"
self.test_data["vpc"]["cidr"] = cidr
vpc = VPC.create(self.api_client,
self.test_data["vpc"],
vpcofferingid=vpc_offering.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid
)
self.debug("Created VPC with ID - %s" % vpc.id)
if cleanup:
self.cleanup.append(vpc)
return vpc
示例11: createVPC
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def createVPC(self, vpc_offering, cidr='10.1.1.1/16'):
try:
self.logger.debug("Creating a VPC in the account: %s" % self.account.name)
self.services["vpc"]["cidr"] = cidr
vpc = VPC.create(
self.apiclient,
self.services["vpc"],
vpcofferingid=vpc_offering.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid)
self.logger.debug("Created VPC with ID: %s" % vpc.id)
except Exception, e:
self.fail('Unable to create VPC due to %s ' % e)
示例12: deploy_vpc
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def deploy_vpc(self, vpc_data, account):
self.logger.debug('>>> VPC => Creating "%s"...', vpc_data['name'])
vpc = VPC.create(
api_client=self.api_client,
data=vpc_data,
zone=self.zone,
account=account,
randomizeID=self.randomizeNames
)
self.dynamic_names['vpcs'][vpc_data['name']] = vpc.name
self.logger.debug('>>> VPC => ID: %s => Name: %s => CIDR: %s => State: %s => Offering: %s '
'=> Account: %s => Domain: %s', vpc.id, vpc.name, vpc.cidr, vpc.state, vpc.vpcofferingid,
vpc.account, vpc.domainid)
self.deploy_acls(vpc_data['acls'], vpc)
self.deploy_networks(vpc_data['networks'], vpc)
示例13: test_02_create_vpc_wait_gc
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def test_02_create_vpc_wait_gc(self):
""" Test VPC when host is in maintenance mode and wait till nw gc
"""
# Validate the following
# 1. Put the host in maintenance mode.
# 2. Attempt to Create a VPC with cidr - 10.1.1.1/16
# 3. Wait for the VPC GC thread to run.
# 3. VPC will be created but will be in "Disabled" state and should
# get deleted
self.debug("creating a VPC network in the account: %s" %
self.account.name)
self.services["vpc"]["cidr"] = '10.1.1.1/16'
vpc = VPC.create(
self.apiclient,
self.services["vpc"],
vpcofferingid=self.vpc_off.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
start=False
)
self.validate_vpc_network(vpc, state='inactive')
interval = list_configurations(
self.apiclient,
name='network.gc.interval'
)
wait = list_configurations(
self.apiclient,
name='network.gc.wait'
)
self.debug("Sleep till network gc thread runs..")
# Sleep to ensure that all resources are deleted
time.sleep(int(interval[0].value) + int(wait[0].value))
vpcs = VPC.list(
self.apiclient,
id=vpc.id,
listall=True
)
self.assertEqual(
vpcs,
None,
"List VPC should not return anything after network gc"
)
return
示例14: setUp
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def setUp(self):
self.logger.debug("Creating a VPC offering.")
self.vpc_off = VpcOffering.create(self.apiclient, self.services["vpc_offering"])
self.logger.debug("Enabling the VPC offering created")
self.vpc_off.update(self.apiclient, state="Enabled")
self.logger.debug("Creating a VPC network in the account: %s" % self.account.name)
self.vpc = VPC.create(
self.apiclient,
self.services["vpc"],
vpcofferingid=self.vpc_off.id,
zoneid=self.zone.id,
account=self.account.name,
domainid=self.account.domainid,
)
return
示例15: create_Vpc
# 需要导入模块: from marvin.lib.base import VPC [as 别名]
# 或者: from marvin.lib.base.VPC import create [as 别名]
def create_Vpc(cls, vpc_offering, cidr='10.1.0.0/16', testdata=None,
account=None, networkDomain=None):
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