本文整理汇总了Python中marvin.lib.base.Configurations类的典型用法代码示例。如果您正苦于以下问题:Python Configurations类的具体用法?Python Configurations怎么用?Python Configurations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Configurations类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_04_rvpc_network_garbage_collector_nics
def test_04_rvpc_network_garbage_collector_nics(self):
""" Create a redundant VPC with 1 Tier, 1 VM, 1 ACL, 1 PF and test Network GC Nics"""
self.logger.debug("Starting test_04_rvpc_network_garbage_collector_nics")
self.query_routers()
self.networks.append(self.create_network(self.services["network_offering"], "10.1.1.1", nr_vms=1))
self.check_routers_state()
self.add_nat_rules()
self.do_vpc_test(False)
self.stop_vm()
gc_wait = Configurations.list(self.apiclient, name="network.gc.wait")
gc_interval = Configurations.list(self.apiclient, name="network.gc.interval")
self.logger.debug("network.gc.wait is ==> %s" % gc_wait)
self.logger.debug("network.gc.interval is ==> %s" % gc_wait)
total_sleep = 120
if gc_wait and gc_interval:
total_sleep = int(gc_wait[0].value) + int(gc_interval[0].value)
else:
self.logger.debug("Could not retrieve the keys 'network.gc.interval' and 'network.gc.wait'. Sleeping for 2 minutes.")
time.sleep(total_sleep * 3)
self.check_routers_interface(interface_to_check="eth2", expected_exists=False)
self.start_vm()
self.check_routers_state(status_to_check="MASTER")
self.check_routers_interface(interface_to_check="eth2", expected_exists=True)
示例2: test_09_expunge_vm
def test_09_expunge_vm(self):
"""Test destroy(expunge) Virtual Machine
"""
# Validate the following
# 1. listVM command should NOT return this VM any more.
self.debug("Expunge VM-ID: %s" % self.small_virtual_machine.id)
cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
cmd.id = self.small_virtual_machine.id
self.apiclient.destroyVirtualMachine(cmd)
config = Configurations.list(self.apiclient, name="expunge.delay")
expunge_delay = int(config[0].value)
time.sleep(expunge_delay * 2)
# VM should be destroyed unless expunge thread hasn't run
# Wait for two cycles of the expunge thread
config = Configurations.list(self.apiclient, name="expunge.interval")
expunge_cycle = int(config[0].value)
wait_time = expunge_cycle * 2
while wait_time >= 0:
list_vm_response = VirtualMachine.list(self.apiclient, id=self.small_virtual_machine.id)
if list_vm_response:
time.sleep(expunge_cycle)
wait_time = wait_time - expunge_cycle
else:
break
self.debug("listVirtualMachines response: %s" % list_vm_response)
self.assertEqual(list_vm_response, None, "Check Expunged virtual machine is in listVirtualMachines response")
return
示例3: test_03_concurrent_snapshot_global_value_assignment
def test_03_concurrent_snapshot_global_value_assignment(self):
""" Test verifies that exception is raised if string value is assigned to
concurrent.snapshots.threshold.perhost parameter.
"""
with self.assertRaises(Exception):
Configurations.update(
self.apiclient,
"concurrent.snapshots.threshold.perhost",
"String"
)
return
示例4: tearDownClass
def tearDownClass(cls):
try:
# Cleanup resources used
if cls.updateclone:
Configurations.update(cls.api_client,
"vmware.create.full.clone",
value="false",storageid=cls.storageID)
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
示例5: update_NuageVspGlobalDomainTemplate
def update_NuageVspGlobalDomainTemplate(self, value):
self.debug("Updating global setting nuagevsp.vpc.domaintemplate.name "
"with value - %s" % value)
self.user_apikey = self.api_client.connection.apiKey
self.user_secretkey = self.api_client.connection.securityKey
self.api_client.connection.apiKey = self.default_apikey
self.api_client.connection.securityKey = self.default_secretkey
Configurations.update(self.api_client,
name="nuagevsp.vpc.domaintemplate.name",
value=value)
self.api_client.connection.apiKey = self.user_apikey
self.api_client.connection.securityKey = self.user_secretkey
self.debug("Successfully updated global setting "
"nuagevsp.vpc.domaintemplate.name with value - %s" % value)
示例6: test_es_1223_apply_algo_to_pods
def test_es_1223_apply_algo_to_pods(self):
"""
@Desc: Test VM creation while "apply.allocation.algorithm.to.pods" is
set to true
@Reference: https://issues.apache.org/jira/browse/CLOUDSTACK-4947
@Steps:
Step1: Set global configuration "apply.allocation.algorithm.to.pods"
to true
Step2: Restart management server
Step3: Verifying that VM creation is successful
"""
# Step1: set global configuration
# "apply.allocation.algorithm.to.pods" to true
# Configurations.update(self.apiClient,
# "apply.allocation.algorithm.to.pods", "true")
# TODO: restart management server
if not is_config_suitable(apiclient=self.apiClient,
name='apply.allocation.algorithm.to.pods',
value='true'):
self.skipTest('apply.allocation.algorithm.to.pods '
'should be true. skipping')
# TODO:Step2: Restart management server
self.services["virtual_machine"]["zoneid"] = self.zone.id
self.services["virtual_machine"]["template"] = self.template.id
# Step3: Verifying that VM creation is successful
virtual_machine = VirtualMachine.create(
self.apiClient,
self.services["virtual_machine2"],
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
)
self.cleanup.append(virtual_machine)
# Verify VM state
self.assertEqual(
virtual_machine.state,
'Running',
"Check VM state is Running or not"
)
# cleanup: set global configuration
# "apply.allocation.algorithm.to.pods" back to false
Configurations.update(
self.apiClient,
name="apply.allocation.algorithm.to.pods",
value="false"
)
# TODO:cleanup: Restart management server
return
示例7: test_01_cluster_settings
def test_01_cluster_settings(self):
"""change cpu/mem.overprovisioning.factor at cluster level and
verify the change """
listHost = Host.list(self.apiclient,
id=self.deployVmResponse.hostid
)
self.assertEqual(
validateList(listHost)[0],
PASS,
"check list host response for host id %s" %
self.deployVmResponse.hostid)
Configurations.update(self.apiclient,
clusterid=listHost[0].clusterid,
name="mem.overprovisioning.factor",
value=2)
Configurations.update(self.apiclient,
clusterid=listHost[0].clusterid,
name="cpu.overprovisioning.factor",
value=3)
list_cluster = Cluster.list(self.apiclient,
id=listHost[0].clusterid)
self.assertEqual(
validateList(list_cluster)[0],
PASS,
"check list cluster response for cluster id %s" %
listHost[0].clusterid)
self.assertEqual(int(list_cluster[0].cpuovercommitratio),
3,
"check the cpu overcommit value at cluster level ")
self.assertEqual(int(list_cluster[0].memoryovercommitratio),
2,
"check memory overcommit value at cluster level")
Configurations.update(self.apiclient,
clusterid=listHost[0].clusterid,
name="mem.overprovisioning.factor",
value=1)
Configurations.update(self.apiclient,
clusterid=listHost[0].clusterid,
name="cpu.overprovisioning.factor",
value=1)
list_cluster1 = Cluster.list(self.apiclient,
id=listHost[0].clusterid)
self.assertEqual(
validateList(list_cluster1)[0],
PASS,
"check the list cluster response for id %s" %
listHost[0].clusterid)
self.assertEqual(int(list_cluster1[0].cpuovercommitratio),
1,
"check the cpu overcommit value at cluster level ")
self.assertEqual(int(list_cluster1[0].memoryovercommitratio),
1,
"check memory overcommit value at cluster level")
示例8: test_vms_with_same_name
def test_vms_with_same_name(self):
""" Test vm deployment with same name
# 1. Deploy a VM on with perticular name from account_1
# 2. Try to deploy another vm with same name from account_2
# 3. Verify that second VM deployment fails
"""
# Step 1
# Create VM on cluster wide
configs = Configurations.list(
self.apiclient,
name="vm.instancename.flag")
orig_value = configs[0].value
if orig_value == "false":
Configurations.update(self.apiclient,
name="vm.instancename.flag",
value="true"
)
# Restart management server
self.RestartServer()
time.sleep(120)
self.testdata["small"]["displayname"]="TestName"
self.testdata["small"]["name"]="TestName"
VirtualMachine.create(
self.userapiclient_1,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
)
with self.assertRaises(Exception):
VirtualMachine.create(
self.userapiclient_2,
self.testdata["small"],
templateid=self.template.id,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id,
zoneid=self.zone.id,
)
return
示例9: setUpClass
def setUpClass(cls):
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
cls.testClient = super(TestVPCRedundancy, 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.hypervisor = cls.testClient.getHypervisorInfo()
cls.template = get_test_template(cls.api_client, cls.zone.id, cls.hypervisor)
if cls.template == FAILED:
assert False, "get_test_template() failed to return template"
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 = [cls.service_offering]
cls.logger = logging.getLogger('TestVPCRedundancy')
cls.stream_handler = logging.StreamHandler()
cls.logger.setLevel(logging.DEBUG)
cls.logger.addHandler(cls.stream_handler)
cls.advert_int = int(Configurations.list(cls.api_client, name="router.redundant.vrrp.interval")[0].value)
示例10: test_01_VPN_user_limit
def test_01_VPN_user_limit(self):
"""VPN remote access user limit tests"""
# Validate the following
# prerequisite: change management configuration setting of
# remote.access.vpn.user.limit
# 1. provision more users than is set in the limit
# Provisioning of users after the limit should failProvisioning of
# users after the limit should fail
self.debug("Fetching the limit for remote access VPN users")
configs = Configurations.list(
self.apiclient,
name='remote.access.vpn.user.limit',
listall=True)
self.assertEqual(isinstance(configs, list),
True,
"List configs should return a valid response")
limit = int(configs[0].value)
self.debug("Enabling the VPN access for IP: %s" %
self.public_ip.ipaddress)
self.create_VPN(self.public_ip)
self.debug("Creating %s VPN users" % limit)
for x in range(limit):
self.create_VPN_Users()
self.debug("Adding another user exceeding limit for remote VPN users")
with self.assertRaises(Exception):
self.create_VPN_Users()
self.debug("Limit exceeded exception raised!")
return
示例11: setUpClass
def setUpClass(cls):
testClient = super(TestVerifyEventsTable, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.testdata = testClient.getParsedTestDataConfig()
cls.hypervisor = cls.testClient.getHypervisorInfo()
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.template = get_template(
cls.apiclient,
cls.zone.id,
cls.testdata["ostype"])
cls._cleanup = []
try:
cls.unsupportedHypervisor = False
if cls.hypervisor.lower() in ['hyperv', 'lxc', 'kvm']:
if cls.hypervisor.lower() == 'kvm':
configs = Configurations.list(
cls.apiclient,
name='kvm.snapshot.enabled'
)
if configs[0].value == "false":
cls.unsupportedHypervisor = True
else:
cls.unsupportedHypervisor = True
return
# Create an account
cls.account = Account.create(
cls.apiclient,
cls.testdata["account"],
domainid=cls.domain.id
)
# Create user api client of the account
cls.userapiclient = testClient.getUserApiClient(
UserName=cls.account.name,
DomainName=cls.account.domain
)
# Create Service offering
cls.service_offering = ServiceOffering.create(
cls.apiclient,
cls.testdata["service_offering"],
)
cls._cleanup = [
cls.account,
cls.service_offering,
]
except Exception as e:
cls.tearDownClass()
raise e
return
示例12: get_lb_stats_settings
def get_lb_stats_settings(self):
self.logger.debug("Retrieving haproxy stats settings")
settings = {}
try:
settings["stats_port"] = Configurations.list(
self.apiclient, name="network.loadbalancer.haproxy.stats.port")[0].value
settings["stats_uri"] = Configurations.list(
self.apiclient, name="network.loadbalancer.haproxy.stats.uri")[0].value
settings["username"], settings["password"] = Configurations.list(
self.apiclient, name="network.loadbalancer.haproxy.stats.auth")[0].value.split(":")
settings["visibility"] = Configurations.list(
self.apiclient, name="network.loadbalancer.haproxy.stats.visibility")[0].value
self.logger.debug(settings)
except Exception as e:
self.fail("Failed to retrieve stats settings " % e)
return settings
示例13: is_config_suitable
def is_config_suitable(apiclient, name, value):
"""
Ensure if the deployment has the expected `value` for the global setting `name'
@return: true if value is set, else false
"""
configs = Configurations.list(apiclient, name=name)
assert configs is not None and isinstance(configs, list) and len(configs) > 0
return configs[0].value == value
示例14: tearDown
def tearDown(self):
try:
self.debug("Cleaning up the resources")
cleanup_resources(self.apiclient, self.cleanup)
interval = Configurations.list(
self.apiclient,
name='network.gc.interval'
)
wait = Configurations.list(
self.apiclient,
name='network.gc.wait'
)
#time.sleep(int(interval[0].value) + int(wait[0].value))
self.debug("Cleanup complete!")
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
示例15: tearDown
def tearDown(self):
try:
self.debug("Cleaning up the resources")
#Clean up, terminate the created network offerings
#cleanup_resources(self.apiclient, self.cleanup)
interval = Configurations.list(
self.apiclient,
name='network.gc.interval'
)
wait = Configurations.list(
self.apiclient,
name='network.gc.wait'
)
# Sleep to ensure that all resources are deleted
time.sleep(int(interval[0].value) + int(wait[0].value))
self.debug("Cleanup complete!")
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return