本文整理汇总了Python中marvin.lib.base.Host.list方法的典型用法代码示例。如果您正苦于以下问题:Python Host.list方法的具体用法?Python Host.list怎么用?Python Host.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Host
的用法示例。
在下文中一共展示了Host.list方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_06_secondary_storage
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_06_secondary_storage(self):
"""Check the status of secondary storage"""
# Validate the following
# 1. List secondary storage
# 2. Check state is "Up" or not
sec_storages = Host.list(
self.apiclient,
zoneid=self.zone.id,
type='SecondaryStorageVM',
listall=True
)
self.assertEqual(
isinstance(sec_storages, list),
True,
"Check if listHosts returns a valid response"
)
for sec_storage in sec_storages:
self.assertEqual(
sec_storage.state,
'Up',
"Secondary storage should be in Up state"
)
return
示例2: setUpClass
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def setUpClass(cls):
testClient = super(TestDeployVmWithVariedPlanners, 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.template = get_template(
cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
if cls.template == FAILED:
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["template"] = cls.template.id
cls.services["zoneid"] = cls.zone.id
cls.account = Account.create(
cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls.hosts = Host.list(cls.apiclient, type='Routing')
cls.clusters = Cluster.list(cls.apiclient)
cls.cleanup = [
cls.account
]
示例3: setUpClass
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def setUpClass(cls):
cls.testClient = super(TestHostsForMigration, 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"])
clusterWithSufficientHosts = None
clusters = Cluster.list(cls.api_client, zoneid=cls.zone.id)
for cluster in clusters:
cls.hosts = Host.list(cls.api_client, clusterid=cluster.id, type="Routing")
if len(cls.hosts) >= 2:
clusterWithSufficientHosts = cluster
break
if clusterWithSufficientHosts is None:
raise unittest.SkipTest("No Cluster with 2 hosts found")
Host.update(cls.api_client, id=cls.hosts[1].id, hosttags="PREMIUM")
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering_with_tag = ServiceOffering.create(
cls.api_client, cls.services["service_offering_with_tag"]
)
cls._cleanup = [cls.service_offering_with_tag]
return
示例4: test_04_hosts
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_04_hosts(self):
"""Check the status of hosts"""
# Validate the following
# 1. List hosts with type=Routing
# 2. Check state is "Up" or not
hosts = Host.list(
self.apiclient,
zoneid=self.zone.id,
type='Routing',
listall=True
)
self.assertEqual(
isinstance(hosts, list),
True,
"Check if listHosts returns a valid response"
)
for host in hosts:
self.assertEqual(
host.state,
'Up',
"Host should be in Up state and running"
)
return
示例5: test_02_migrate_vm
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_02_migrate_vm(self):
"""Test migrate VM in project
# Validate the following
# 1. Create VM with custom disk offering in a project and check
# initial primary storage count
# 2. List the hosts suitable for migrating the VM
# 3. Migrate the VM and verify that primary storage count of project remains same"""
try:
hosts = Host.list(self.apiclient,virtualmachineid=self.vm.id,
listall=True)
self.assertEqual(validateList(hosts)[0], PASS, "hosts list validation failed")
host = hosts[0]
self.vm.migrate(self.apiclient, host.id)
except Exception as e:
self.fail("Exception occured" % e)
expectedCount = self.initialResourceCount
response = matchResourceCount(
self.apiclient, expectedCount,
RESOURCE_PRIMARY_STORAGE,
projectid=self.project.id)
self.assertEqual(response[0], PASS, response[1])
return
示例6: test_06_secondary_storage
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_06_secondary_storage(self):
"""Check the status of secondary storage"""
# Validate the following
# 1. List secondary storage
# 2. Check state is "Up" or not
if self.hypervisor.lower() == 'simulator':
self.skipTest("Hypervisor is simulator skipping")
sec_storages = Host.list(
self.apiclient,
zoneid=self.zone.id,
type='SecondaryStorageVM',
listall=True
)
if sec_storages is None:
self.skipTest("SSVM is not provisioned yet, skipping")
self.assertEqual(
isinstance(sec_storages, list),
True,
"Check if listHosts returns a valid response"
)
for sec_storage in sec_storages:
self.assertEqual(
sec_storage.state,
'Up',
"Secondary storage should be in Up state"
)
return
示例7: test_01_cluster_settings
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
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: migrate_router
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def migrate_router(self, router):
""" Migrate the router """
self.debug("Checking if the host is available for migration?")
hosts = Host.list(self.api_client, zoneid=self.zone.id, type='Routing')
self.assertEqual(
isinstance(hosts, list),
True,
"List hosts should return a valid list"
)
if len(hosts) < 2:
self.skipTest(
"No host available for migration. Test requires atleast 2 hosts")
# Remove the host of current VM from the hosts list
hosts[:] = [host for host in hosts if host.id != router.hostid]
host = hosts[0]
self.debug("Validating if the network rules work properly or not?")
self.debug("Migrating VM-ID: %s from %s to Host: %s" % (
router.id,
router.hostid,
host.id
))
try:
# Migrate the router
cmd = migrateSystemVm.migrateSystemVmCmd()
cmd.isAsync = "false"
cmd.hostid = host.id
cmd.virtualmachineid = router.id
self.api_client.migrateSystemVm(cmd)
except Exception as e:
self.fail("Failed to migrate instance, %s" % e)
self.debug("Waiting for Router mgiration ....")
time.sleep(240)
# List routers to check state of router
router_response = list_routers(
self.api_client,
id=router.id
)
self.assertEqual(
isinstance(router_response, list),
True,
"Check list response returns a valid list"
)
router.hostid = router_response[0].hostid
self.assertEqual(
router.hostid, host.id, "Migration to host %s failed. The router host is"
"still %s" %
(host.id, router.hostid))
return
示例9: test_03_reconnect_host
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_03_reconnect_host(self):
""" Test reconnect Host which has VPC elements
"""
# Steps:
# 1.Reconnect one of the host on which VPC Virtual Router is present.
# Validate the following
# 1. Host should successfully reconnect.
# 2. Network connectivity to all the VMs on the host should not be
# effected due to reconnection.
try:
timeout = self.services["timeout"]
while True:
list_host_response = Host.list(
self.apiclient,
id=self.vpcvr.hostid,
resourcestate="Enabled")
if list_host_response is not None:
break
elif timeout == 0:
raise Exception("Failed to list the Host in Up State")
time.sleep(self.services["sleep"])
timeout = timeout - 1
self.debug("Verified that the Host is in Up State")
except:
self.fail("Failed to find the Host in Up State")
self.debug("Reconnecting the host where VPC VR is running")
try:
Host.reconnect(self.apiclient, id=self.vpcvr.hostid)
except Exception as e:
self.fail("Failed to reconnect to host: %s" % e)
self.debug("Check the status of router after migration")
routers = Router.list(
self.apiclient,
id=self.vpcvr.id,
listall=True
)
self.assertEqual(
isinstance(routers, list),
True,
"List routers shall return the valid response"
)
self.assertEqual(
routers[0].state,
"Running",
"Router state should be running"
)
# TODO: Check for the network connectivity
return
示例10: test_10_list_volumes
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_10_list_volumes(self):
# Validate the following
#
# 1. List Root Volume and waits until it has the newly introduced attributes
#
# 2. Verifies return attributes has values different from none, when instance is running
#
list_vm = VirtualMachine.list(self.apiclient, id=self.virtual_machine.id)[0]
host = Host.list(
self.apiclient,
type='Routing',
id=list_vm.hostid
)[0]
list_pods = get_pod(self.apiclient, self.zone.id, host.podid)
root_volume = self.wait_for_attributes_and_return_root_vol()
self.assertTrue(hasattr(root_volume, "utilization"))
self.assertTrue(root_volume.utilization is not None)
self.assertTrue(hasattr(root_volume, "virtualsize"))
self.assertTrue(root_volume.virtualsize is not None)
self.assertTrue(hasattr(root_volume, "physicalsize"))
self.assertTrue(root_volume.physicalsize is not None)
self.assertTrue(hasattr(root_volume, "vmname"))
self.assertEqual(root_volume.vmname, list_vm.name)
self.assertTrue(hasattr(root_volume, "clustername"))
self.assertTrue(root_volume.clustername is not None)
self.assertTrue(hasattr(root_volume, "clusterid"))
self.assertTrue(root_volume.clusterid is not None)
self.assertTrue(hasattr(root_volume, "storageid"))
self.assertTrue(root_volume.storageid is not None)
self.assertTrue(hasattr(root_volume, "storage"))
self.assertTrue(root_volume.storage is not None)
self.assertTrue(hasattr(root_volume, "zoneid"))
self.assertEqual(root_volume.zoneid, self.zone.id)
self.assertTrue(hasattr(root_volume, "zonename"))
self.assertEqual(root_volume.zonename, self.zone.name)
self.assertTrue(hasattr(root_volume, "podid"))
self.assertEqual(root_volume.podid, list_pods.id)
self.assertTrue(hasattr(root_volume, "podname"))
self.assertEqual(root_volume.podname, list_pods.name)
示例11: setUpClass
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def setUpClass(cls):
cls.testClient = super(TestAttachVolumeISO, 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.pod = get_pod(cls.api_client, cls.zone.id)
cls.services["mode"] = cls.zone.networktype
cls._cleanup = []
cls.unsupportedStorageType = False
cls.hypervisor = cls.testClient.getHypervisorInfo()
if cls.hypervisor.lower() == "lxc":
if not find_storage_pool_type(cls.api_client, storagetype="rbd"):
cls.unsupportedStorageType = True
return
cls.disk_offering = DiskOffering.create(cls.api_client, cls.services["disk_offering"])
cls._cleanup.append(cls.disk_offering)
template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
cls.services["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["iso"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = template.id
# get max data volumes limit based on the hypervisor type and version
listHost = Host.list(cls.api_client, type="Routing", zoneid=cls.zone.id, podid=cls.pod.id)
ver = listHost[0].hypervisorversion
hv = listHost[0].hypervisor
cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
cmd.hypervisor = hv
res = cls.api_client.listHypervisorCapabilities(cmd)
cls.debug("Hypervisor Capabilities: {}".format(res))
for i in range(len(res)):
if res[i].hypervisorversion == ver:
break
cls.max_data_volumes = int(res[i].maxdatavolumeslimit)
cls.debug("max data volumes:{}".format(cls.max_data_volumes))
cls.services["volume"]["max"] = cls.max_data_volumes
# Create VMs, NAT Rules etc
cls.account = Account.create(cls.api_client, cls.services["account"], domainid=cls.domain.id)
cls._cleanup.append(cls.account)
cls.service_offering = ServiceOffering.create(cls.api_client, cls.services["service_offering"])
cls._cleanup.append(cls.service_offering)
cls.virtual_machine = VirtualMachine.create(
cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id,
)
示例12: test_deployVmOnGivenHost
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_deployVmOnGivenHost(self):
"""Test deploy VM on specific host
"""
# Steps for validation
# 1. as admin list available hosts that are Up
# 2. deployVM with hostid=above host
# 3. listVirtualMachines
# 4. destroy VM
# Validate the following
# 1. listHosts returns at least one host in Up state
# 2. VM should be in Running
# 3. VM should be on the host that it was deployed on
hosts = Host.list(self.apiclient, zoneid=self.zone.id, type="Routing", state="Up", listall=True)
self.assertEqual(isinstance(hosts, list), True, "CS should have atleast one host Up and Running")
host = hosts[0]
self.debug("Deploting VM on host: %s" % host.name)
try:
vm = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account.name,
domainid=self.account.domainid,
serviceofferingid=self.service_offering.id,
hostid=host.id,
)
self.debug("Deploy VM succeeded")
except Exception as e:
self.fail("Deploy VM failed with exception: %s" % e)
self.debug("Cheking the state of deployed VM")
vms = VirtualMachine.list(
self.apiclient, id=vm.id, listall=True, account=self.account.name, domainid=self.account.domainid
)
self.assertEqual(isinstance(vms, list), True, "List Vm should return a valid response")
vm_response = vms[0]
self.assertEqual(vm_response.state, "Running", "VM should be in running state after deployment")
self.assertEqual(vm_response.hostid, host.id, "Host id where VM is deployed should match")
return
示例13: tearDownClass
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def tearDownClass(cls):
try:
for hostid in cls.disabledHosts:
hosts = Host.list(cls.apiclient, id=hostid)
assert (
validateList(hosts)[0] == PASS
), "hosts\
list validation failed"
if hosts[0].resourcestate.lower() == DISABLED.lower():
cmd = updateHost.updateHostCmd()
cmd.id = hostid
cmd.resourcestate = ENABLED
cmd.allocationstate = ENABLE
cls.apiclient.updateHost(cmd)
cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
示例14: test_08_resize_volume
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def test_08_resize_volume(self):
"""Test resize a volume"""
# Verify the size is the new size is what we wanted it to be.
self.debug(
"Attaching volume (ID: %s) to VM (ID: %s)" % (
self.volume.id,
self.virtual_machine.id
))
self.virtual_machine.attach_volume(self.apiClient, self.volume)
self.attached = True
hosts = Host.list(self.apiClient, id=self.virtual_machine.hostid)
self.assertTrue(isinstance(hosts, list))
self.assertTrue(len(hosts) > 0)
self.debug("Found %s host" % hosts[0].hypervisor)
if hosts[0].hypervisor == "XenServer":
self.virtual_machine.stop(self.apiClient)
elif hosts[0].hypervisor.lower() == "vmware":
self.skipTest("Resize Volume is unsupported on VmWare")
# resize the data disk
self.debug("Resize Volume ID: %s" % self.volume.id)
cmd = resizeVolume.resizeVolumeCmd()
cmd.id = self.volume.id
cmd.diskofferingid = self.services['resizeddiskofferingid']
self.apiClient.resizeVolume(cmd)
count = 0
success = False
while count < 3:
list_volume_response = Volume.list(
self.apiClient,
id=self.volume.id,
type='DATADISK'
)
for vol in list_volume_response:
if vol.id == self.volume.id and vol.size == 3221225472L and vol.state == 'Ready':
success = True
if success:
break
else:
time.sleep(10)
count += 1
示例15: setUpClass
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import list [as 别名]
def setUpClass(cls):
testClient = super(TestDisableEnableHost, cls).getClsTestClient()
cls.apiclient = testClient.getApiClient()
cls.testdata = testClient.getParsedTestDataConfig()
cls.hypervisor = cls.testClient.getHypervisorInfo()
cls.snapshotSupported = True
# Get Zone, Domain and templates
cls.domain = get_domain(cls.apiclient)
cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.pod = get_pod(cls.apiclient, zone_id=cls.zone.id)
hostList = Host.list(cls.apiclient, zoneid=cls.zone.id, type="routing")
clusterList = Cluster.list(cls.apiclient, id=hostList[0].clusterid)
cls.host = Host(hostList[0].__dict__)
cls.cluster = Cluster(clusterList[0].__dict__)
cls.template = get_template(cls.apiclient, cls.zone.id, cls.testdata["ostype"])
cls._cleanup = []
cls.disabledHosts = []
try:
cls.service_offering = ServiceOffering.create(cls.apiclient, cls.testdata["service_offering"])
cls._cleanup.append(cls.service_offering)
cls.disk_offering = DiskOffering.create(cls.apiclient, cls.testdata["disk_offering"])
cls._cleanup.append(cls.disk_offering)
# Create an account
cls.account = Account.create(cls.apiclient, cls.testdata["account"], domainid=cls.domain.id)
cls._cleanup.append(cls.account)
# Create root admin account
cls.admin_account = Account.create(cls.apiclient, cls.testdata["account2"], admin=True)
cls._cleanup.append(cls.admin_account)
# Create user api client of the account
cls.userapiclient = testClient.getUserApiClient(UserName=cls.account.name, DomainName=cls.account.domain)
except Exception as e:
cls.tearDownClass()
raise e
return