本文整理汇总了Python中marvin.lib.base.NetworkOffering类的典型用法代码示例。如果您正苦于以下问题:Python NetworkOffering类的具体用法?Python NetworkOffering怎么用?Python NetworkOffering使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NetworkOffering类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_04_vpc_private_gateway_with_invalid_lswitch
def test_04_vpc_private_gateway_with_invalid_lswitch(self):
self.logger.debug('Adding NSX device')
self.add_nicira_device(self.nicira_master_controller)
self.logger.debug('Creating VPC offering')
self.vpc_offering = VpcOffering.create(self.api_client, self.vpc_offering_services)
self.vpc_offering.update(self.api_client, state='Enabled')
self.test_cleanup.append(self.vpc_offering)
self.logger.debug('Creating VPC tier offering')
self.vpc_tier_offering = NetworkOffering.create(self.api_client, self.vpc_tier_offering_services, conservemode=False)
self.vpc_tier_offering.update(self.api_client, state='Enabled')
self.test_cleanup.append(self.vpc_tier_offering)
self.logger.debug('Creating private network offering')
self.private_network_offering = NetworkOffering.create(self.api_client, self.private_network_offering_services)
self.private_network_offering.update(self.api_client, state='Enabled')
self.test_cleanup.append(self.private_network_offering)
allow_all_acl_id = 'bd6d44f8-fc11-11e5-8fe8-5254001daa61'
bad_lswitch = 'lswitch:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
vpc = self.create_vpc()
network = self.create_vpc_tier(vpc)
virtual_machine = self.create_virtual_machine(network)
self.logger.debug('Creating private gateway')
with self.assertRaises(CloudstackAPIException) as cm:
self.create_private_gateway(vpc, "10.0.3.99", "10.0.3.100", allow_all_acl_id, bad_lswitch)
the_exception = cm.exception
the_message_matcher = "^.*Refusing to design this network because the specified lswitch (%s) does not exist.*$" % bad_lswitch
self.assertRegexpMatches(str(the_exception), the_message_matcher)
示例2: createEnabledNetworkOffering
def createEnabledNetworkOffering(apiclient, networkServices):
"""Create and enable network offering according to the type
@output: List, containing [ Result,Network Offering,Reason ]
Ist Argument('Result') : FAIL : If exception or assertion error occurs
PASS : If network offering
is created and enabled successfully
IInd Argument(Net Off) : Enabled network offering
In case of exception or
assertion error, it will be None
IIIrd Argument(Reason) : Reason for failure,
default to None
"""
try:
resultSet = [FAIL, None, None]
# Create network offering
network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False)
# Update network offering state from disabled to enabled.
NetworkOffering.update(network_offering, apiclient, id=network_offering.id,
state="enabled")
except Exception as e:
resultSet[2] = e
return resultSet
return [PASS, network_offering, None]
示例3: create_network
def create_network(self, net_offerring, vpc_id, gateway='10.1.1.1'):
try:
self.logger.debug('Create NetworkOffering')
net_offerring["name"] = "NET_OFF-" + str(gateway)
nw_off = NetworkOffering.create(
self.apiclient,
net_offerring,
conservemode=False)
nw_off.update(self.apiclient, state='Enabled')
self.logger.debug('Created and Enabled NetworkOffering')
self.services["network"]["name"] = "NETWORK-" + str(gateway)
self.logger.debug('Adding Network=%s to VPC ID %s' % (self.services["network"], vpc_id))
obj_network = Network.create(
self.apiclient,
self.services["network"],
accountid=self.account.name,
domainid=self.account.domainid,
networkofferingid=nw_off.id,
zoneid=self.zone.id,
gateway=gateway,
vpcid=vpc_id)
self.logger.debug("Created network with ID: %s" % obj_network.id)
except Exception, e:
raise Exception('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
示例4: create_network
def create_network(self, net_offerring, gateway='10.1.1.1',vpc=None):
try:
self.debug('Create NetworkOffering')
net_offerring["name"] = "NET_OFF-" + str(gateway)
nw_off = NetworkOffering.create(self.apiclient,
net_offerring,
conservemode=False
)
# Enable Network offering
nw_off.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off)
self.debug('Created and Enabled NetworkOffering')
self.services["network"]["name"] = "NETWORK-" + str(gateway)
self.debug('Adding Network=%s' % self.services["network"])
obj_network = Network.create(self.apiclient,
self.services["network"],
accountid=self.account.name,
domainid=self.account.domainid,
networkofferingid=nw_off.id,
zoneid=self.zone.id,
gateway=gateway,
vpcid=vpc.id if vpc else self.vpc.id
)
self.debug("Created network with ID: %s" % obj_network.id)
return obj_network
except Exception, e:
self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
示例5: setUpClass
def setUpClass(cls):
cls.testClient = super(TestRedundantIsolateNetworks, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.api_client)
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
# Create an account, network, VM and IP addresses
cls.account = Account.create(cls.api_client, cls.services["account"], admin=True, domainid=cls.domain.id)
cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
cls.services["nw_off_persistent_RVR"]["egress_policy"] = "true"
cls.network_offering = NetworkOffering.create(
cls.api_client, cls.services["nw_off_persistent_RVR"], conservemode=True
)
cls.network_offering.update(cls.api_client, state="Enabled")
cls._cleanup = [cls.service_offering, cls.network_offering]
cls.logger = logging.getLogger("TestRedundantIsolateNetworks")
cls.stream_handler = logging.StreamHandler()
cls.logger.setLevel(logging.DEBUG)
cls.logger.addHandler(cls.stream_handler)
return
示例6: setUpClass
def setUpClass(cls):
cls.testClient = super(TestMaxProjectNetworks, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.services["service_offering"]
)
cls.network_offering = NetworkOffering.create(
cls.api_client,
cls.services["network_offering"],
conservemode=True
)
# Enable Network offering
cls.network_offering.update(cls.api_client, state='Enabled')
cls._cleanup = [
cls.service_offering,
cls.network_offering
]
return
示例7: create_network
def create_network(self, net_offerring, gateway='10.1.1.1', vpc=None, nr_vms=2, mark_net_cleanup=True):
if not nr_vms or nr_vms <= 0:
self.fail("At least 1 VM has to be created. You informed nr_vms < 1")
try:
self.logger.debug('Create NetworkOffering')
net_offerring["name"] = "NET_OFF-" + str(gateway)
nw_off = NetworkOffering.create(
self.apiclient,
net_offerring,
conservemode=False)
nw_off.update(self.apiclient, state='Enabled')
self.logger.debug('Created and Enabled NetworkOffering')
self.services["network"]["name"] = "NETWORK-" + str(gateway)
self.logger.debug('Adding Network=%s' % self.services["network"])
obj_network = Network.create(
self.apiclient,
self.services["network"],
accountid=self.account.name,
domainid=self.account.domainid,
networkofferingid=nw_off.id,
zoneid=self.zone.id,
gateway=gateway,
vpcid=vpc.id if vpc else self.vpc.id
)
self.logger.debug("Created network with ID: %s" % obj_network.id)
except Exception, e:
self.fail('Unable to create a Network with offering=%s because of %s ' % (net_offerring, e))
示例8: setUpClass
def setUpClass(cls):
testClient = super(TestIsolatedNetworkInvalidGw, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create Accounts
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
cls.services["network"]["zoneid"] = cls.zone.id
cls.network_offering = NetworkOffering.create(
cls.apiclient,
cls.services["network_offering"],
)
# Enable Network offering
cls.network_offering.update(cls.apiclient, state='Enabled')
cls.services["network"]["networkoffering"] = cls.network_offering.id
cls._cleanup = [
cls.account,
cls.network_offering
]
return
示例9: setUpClass
def setUpClass(cls):
cls.testClient = super(TestRedundantRouterNetworkCleanups, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
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.network_offering = NetworkOffering.create(
cls.api_client,
cls.services["network_offering"],
conservemode=True
)
# Enable Network offering
cls.network_offering.update(cls.api_client, state='Enabled')
cls._cleanup = [
cls.service_offering,
cls.network_offering,
]
return
示例10: create_NetworkOffering
def create_NetworkOffering(self, net_offering, suffix=None, conserve_mode=False):
self.debug("Creating Network offering")
if suffix:
net_offering["name"] = "NET_OFF-" + str(suffix)
nw_off = NetworkOffering.create(self.api_client,
net_offering,
conservemode=conserve_mode
)
# Enable Network offering
nw_off.update(self.api_client, state="Enabled")
self.cleanup.append(nw_off)
self.debug("Created and Enabled Network offering")
return nw_off
示例11: test_04_network_without_domain_CS19303
def test_04_network_without_domain_CS19303(self):
"""
@Desc: Errors editing a network without a network domain specified
@Steps:
Step1: Create a network offering with SourceNAT,staticNAT and dhcp services
Step2: Verify the network offering creation
Step3: Create an isolated network with the offering created in step1 and without a network domain specified
Step4: Verify the network creation
Step5: Edit the network and verify that updating network should not error out
"""
self.debug(
"Creating n/w offering with SourceNat,StaticNat and DHCP services in VR & conserve mode:off"
)
self.network_offering = NetworkOffering.create(
self.api_client,
self.services["network_offering_withoutDNS"],
conservemode=False
)
self.assertIsNotNone(
self.network_offering,
"Failed to create NO with Sourcenat,staticnat and dhcp only services"
)
self.cleanup.append(self.network_offering)
self.debug("Created n/w offering with ID: %s" % self.network_offering.id)
# Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled')
self.debug("Creating nw without dns service using no id: %s" % self.network_offering.id)
self.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
)
self.assertIsNotNone(
self.network,
"Failed to create network without DNS service and network domain"
)
self.debug("Created network with NO: %s" % self.network_offering.id)
try:
self.network_update = self.network.update(
self.apiclient,
name="NW without nw domain"
)
self.debug("Success:Network update has been successful without network domain")
except Exception as e:
self.fail("Error editing a network without network domain specified: %s" % e)
return
示例12: setUpClass
def setUpClass(cls):
cls.testClient = super(TestDeployVmWithUserDataMultiNic, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.test_data = cls.testClient.getParsedTestDataConfig()
# Get Domain, Zone, Template
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.test_data["ostype"])
if cls.zone.localstorageenabled:
cls.storagetype = "local"
cls.test_data["service_offerings"]["tiny"]["storagetype"] = "local"
else:
cls.storagetype = "shared"
cls.test_data["service_offerings"]["tiny"]["storagetype"] = "shared"
cls.service_offering = ServiceOffering.create(cls.api_client, cls.test_data["service_offerings"]["tiny"])
# Create Network offering without userdata
cls.network_offering_nouserdata = NetworkOffering.create(cls.api_client, cls.test_data["network_offering"])
# Enable Network offering
cls.network_offering_nouserdata.update(cls.api_client, state="Enabled")
# Create Network Offering with all the serices
cls.network_offering_all = NetworkOffering.create(cls.api_client, cls.test_data["isolated_network_offering"])
# Enable Network offering
cls.network_offering_all.update(cls.api_client, state="Enabled")
cls._cleanup = [cls.service_offering, cls.network_offering_nouserdata, cls.network_offering_all]
# Generate userdata of 2500 bytes. This is larger than the 2048 bytes limit.
# CS however allows for upto 4K bytes in the code. So this must succeed.
# Overall, the query length must not exceed 4K, for then the json decoder
# will fail this operation at the marvin client side itcls.
cls.userdata = "".join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500))
示例13: setUpClass
def setUpClass(cls):
cls.apiclient = super(
TestASASetup,
cls
).getClsTestClient().getApiClient()
cls.services = Services().services
cls.network_offering = NetworkOffering.create(
cls.apiclient,
cls.services["network_offering"],
conservemode=True)
# Enable network offering
cls.network_offering.update(cls.apiclient, state='Enabled')
cls._cleanup = [
cls.network_offering,
]
return
示例14: validate_NetworkOffering
def validate_NetworkOffering(self, net_offering, state=None):
"""Validates the Network offering"""
self.debug("Check if the Network offering is created successfully ?")
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 in state - %s" % state
)
self.debug("Network offering creation successfully validated for %s" % net_offering.name)
示例15: setUpClass
def setUpClass(cls):
cls.testClient = super(TestAdapterTypeForNic, cls).getClsTestClient()
cls.api_client = cls.testClient.getApiClient()
cls.testdata = cls.testClient.getParsedTestDataConfig()
cls.hypervisor = get_hypervisor_type(cls.api_client)
# 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.testdata["ostype"])
# Create Accounts & networks
cls.testdata["isolated_network"]["zoneid"] = cls.zone.id
cls._cleanup = []
cls.account = Account.create(
cls.api_client,
cls.testdata["account"],
domainid=cls.domain.id)
cls._cleanup.append(cls.account)
cls.userapiclient = cls.testClient.getUserApiClient(
UserName=cls.account.name,
DomainName=cls.account.domain
)
cls.service_offering = ServiceOffering.create(
cls.api_client,
cls.testdata["service_offering"])
cls._cleanup.append(cls.service_offering)
# Create Shared Network Offering
cls.isolated_network_offering = NetworkOffering.create(
cls.api_client,
cls.testdata["isolated_network_offering"])
cls._cleanup.append(cls.isolated_network_offering)
# Enable Isolated Network offering
cls.isolated_network_offering.update(cls.api_client, state='Enabled')
return