本文整理汇总了Python中marvin.lib.base.Host.create方法的典型用法代码示例。如果您正苦于以下问题:Python Host.create方法的具体用法?Python Host.create怎么用?Python Host.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marvin.lib.base.Host
的用法示例。
在下文中一共展示了Host.create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _perform_add_remove_xenserver_host
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import create [as 别名]
def _perform_add_remove_xenserver_host(self, primary_storage_id, sr_name):
xen_sr = self.xen_session.xenapi.SR.get_by_name_label(sr_name)[0]
pbds = self.xen_session.xenapi.SR.get_PBDs(xen_sr)
self._verify_all_pbds_attached(pbds)
num_pbds = len(pbds)
sf_vag_id = self._get_sf_vag_id(self.cluster.id, primary_storage_id)
host_iscsi_iqns = self._get_xenserver_host_iscsi_iqns()
sf_vag = self._get_sf_vag(sf_vag_id)
sf_vag_initiators = self._get_sf_vag_initiators(sf_vag)
self._verifyVag(host_iscsi_iqns, sf_vag_initiators)
sf_vag_initiators_len_orig = len(sf_vag_initiators)
xen_session = XenAPI.Session("https://" + TestData.ip_address_of_new_xenserver_host)
xenserver = self.testdata[TestData.xenServer]
xen_session.xenapi.login_with_password(xenserver[TestData.username], xenserver[TestData.password])
xen_session.xenapi.pool.join(self.xs_pool_master_ip, xenserver[TestData.username], xenserver[TestData.password])
time.sleep(60)
pbds = self.xen_session.xenapi.SR.get_PBDs(xen_sr)
self.assertEqual(
len(pbds),
num_pbds + 1,
"'len(pbds)' is not equal to 'num_pbds + 1'."
)
num_pbds = num_pbds + 1
num_pbds_not_attached = 0
for pbd in pbds:
pbd_record = self.xen_session.xenapi.PBD.get_record(pbd)
if pbd_record["currently_attached"] == False:
num_pbds_not_attached = num_pbds_not_attached + 1
self.assertEqual(
num_pbds_not_attached,
1,
"'num_pbds_not_attached' is not equal to 1."
)
host = Host.create(
self.apiClient,
self.cluster,
self.testdata[TestData.newXenServerHost],
hypervisor="XenServer"
)
self.assertTrue(
isinstance(host, Host),
"'host' is not a 'Host'."
)
pbds = self.xen_session.xenapi.SR.get_PBDs(xen_sr)
self.assertEqual(
len(pbds),
num_pbds,
"'len(pbds)' is not equal to 'num_pbds'."
)
self._verify_all_pbds_attached(pbds)
host_iscsi_iqns = self._get_xenserver_host_iscsi_iqns()
sf_vag = self._get_sf_vag(sf_vag_id)
sf_vag_initiators = self._get_sf_vag_initiators(sf_vag)
self._verifyVag(host_iscsi_iqns, sf_vag_initiators)
sf_vag_initiators_len_new = len(sf_vag_initiators)
self.assertEqual(
sf_vag_initiators_len_new,
sf_vag_initiators_len_orig + 1,
"sf_vag_initiators_len_new' != sf_vag_initiators_len_orig + 1"
)
host.delete(self.apiClient)
pbds = self.xen_session.xenapi.SR.get_PBDs(xen_sr)
self.assertEqual(
len(pbds),
num_pbds,
#.........这里部分代码省略.........
示例2: _perform_add_remove_kvm_host
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import create [as 别名]
def _perform_add_remove_kvm_host(self, primary_storage_id):
sf_vag_id = self._get_sf_vag_id(self.cluster.id, primary_storage_id)
kvm_login = self.testdata[TestData.kvm]
kvm_hosts = []
kvm_hosts.append(TestData.kvm_1_ip_address)
host_iscsi_iqns = self._get_kvm_host_iscsi_iqns(kvm_hosts, kvm_login[TestData.username], kvm_login[TestData.password])
sf_vag = self._get_sf_vag(sf_vag_id)
sf_vag_initiators = self._get_sf_vag_initiators(sf_vag)
self._verifyVag(host_iscsi_iqns, sf_vag_initiators)
sf_vag_initiators_len_orig = len(sf_vag_initiators)
host = Host.create(
self.apiClient,
self.cluster,
self.testdata[TestData.newKvmHost],
hypervisor="KVM"
)
self.assertTrue(
isinstance(host, Host),
"'host' is not a 'Host'."
)
kvm_hosts = []
kvm_hosts.append(TestData.kvm_1_ip_address)
kvm_hosts.append(TestData.ip_address_of_new_kvm_host)
host_iscsi_iqns = self._get_kvm_host_iscsi_iqns(kvm_hosts, kvm_login[TestData.username], kvm_login[TestData.password])
sf_vag = self._get_sf_vag(sf_vag_id)
sf_vag_initiators = self._get_sf_vag_initiators(sf_vag)
self._verifyVag(host_iscsi_iqns, sf_vag_initiators)
sf_vag_initiators_len_new = len(sf_vag_initiators)
self.assertEqual(
sf_vag_initiators_len_new,
sf_vag_initiators_len_orig + 1,
"sf_vag_initiators_len_new' != sf_vag_initiators_len_orig + 1"
)
host.delete(self.apiClient)
kvm_hosts = []
kvm_hosts.append(TestData.kvm_1_ip_address)
host_iscsi_iqns = self._get_kvm_host_iscsi_iqns(kvm_hosts, kvm_login[TestData.username], kvm_login[TestData.password])
sf_vag = self._get_sf_vag(sf_vag_id)
sf_vag_initiators = self._get_sf_vag_initiators(sf_vag)
self._verifyVag(host_iscsi_iqns, sf_vag_initiators)
sf_vag_initiators_len_new = len(sf_vag_initiators)
self.assertEqual(
sf_vag_initiators_len_new,
sf_vag_initiators_len_orig,
"sf_vag_initiators_len_new' != sf_vag_initiators_len_orig"
)
示例3: test_vag_per_host_5
# 需要导入模块: from marvin.lib.base import Host [as 别名]
# 或者: from marvin.lib.base.Host import create [as 别名]
def test_vag_per_host_5(self):
hosts = list_hosts(self.apiClient, clusterid=self.cluster.id)
self.assertTrue(
len(hosts) >= 2,
"There needs to be at least two hosts."
)
unique_vag_ids = self._get_unique_vag_ids(hosts)
self.assertTrue(len(hosts) == len(unique_vag_ids), "To run this test, each host should be in its own VAG.")
primarystorage = self.testdata[TestData.primaryStorage]
primary_storage = StoragePool.create(
self.apiClient,
primarystorage,
scope=primarystorage[TestData.scope],
zoneid=self.zone.id,
provider=primarystorage[TestData.provider],
tags=primarystorage[TestData.tags],
capacityiops=primarystorage[TestData.capacityIops],
capacitybytes=primarystorage[TestData.capacityBytes],
hypervisor=primarystorage[TestData.hypervisor]
)
self.cleanup.append(primary_storage)
self.virtual_machine = VirtualMachine.create(
self.apiClient,
self.testdata[TestData.virtualMachine],
accountid=self.account.name,
zoneid=self.zone.id,
serviceofferingid=self.compute_offering.id,
templateid=self.template.id,
domainid=self.domain.id,
startvm=True
)
root_volume = self._get_root_volume(self.virtual_machine)
sf_account_id = sf_util.get_sf_account_id(self.cs_api, self.account.id, primary_storage.id, self, TestAddRemoveHosts._sf_account_id_should_be_non_zero_int_err_msg)
sf_volumes = sf_util.get_active_sf_volumes(self.sfe, sf_account_id)
sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, root_volume.name, self)
sf_vag_ids = sf_util.get_vag_ids(self.cs_api, self.cluster.id, primary_storage.id, self)
sf_util.check_vags(sf_volume, sf_vag_ids, self)
host = Host(hosts[0].__dict__)
host_iqn = self._get_host_iqn(host)
all_vags = sf_util.get_all_vags(self.sfe)
host_vag = self._get_host_vag(host_iqn, all_vags)
self.assertTrue(host_vag != None, "The host should be in a VAG.")
host.delete(self.apiClient)
sf_volumes = sf_util.get_active_sf_volumes(self.sfe, sf_account_id)
sf_volume = sf_util.check_and_get_sf_volume(sf_volumes, root_volume.name, self)
sf_util.check_vags(sf_volume, sf_vag_ids, self)
all_vags = sf_util.get_all_vags(self.sfe)
host_vag = self._get_host_vag(host_iqn, all_vags)
self.assertTrue(host_vag == None, "The host should not be in a VAG.")
details = {
TestData.username: "root",
TestData.password: "solidfire",
TestData.url: "http://" + host.ipaddress,
TestData.podId : host.podid,
TestData.zoneId: host.zoneid
}
host = Host.create(
self.apiClient,
self.cluster,
details,
hypervisor=host.hypervisor
)
self.assertTrue(
isinstance(host, Host),
"'host' is not a 'Host'."
)
hosts = list_hosts(self.apiClient, clusterid=self.cluster.id)
unique_vag_ids = self._get_unique_vag_ids(hosts)
self.assertTrue(len(hosts) == len(unique_vag_ids) + 1, "There should be one more host than unique VAG.")