本文整理汇总了Python中utils.virtual_machines.deploy_template函数的典型用法代码示例。如果您正苦于以下问题:Python deploy_template函数的具体用法?Python deploy_template怎么用?Python deploy_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deploy_template函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: cu_vm
def cu_vm(provider, vm_name, template):
"""
Deploys CU VM
"""
provider_dict = cfme_data["management_systems"][provider]
datastore = provider_dict["cap_and_util"]["allowed_datastores"]
resource_pool = provider_dict["cap_and_util"]["resource_pool"]
deploy_template(provider, vm_name, template, resourcepool=resource_pool, allowed_datastores=datastore)
prov_mgmt = get_mgmt(provider)
vm_running(prov_mgmt, vm_name)
ip = prov_mgmt.get_ip_address(vm_name)
vm_ssh_creds = provider_dict["capandu_vm_creds"]
sshname = credentials[vm_ssh_creds]["username"]
sshpass = credentials[vm_ssh_creds]["password"]
# Create cron jobs to generate disk and network activity on the CU VM.
ssh_client = make_ssh_client(ip, sshname, sshpass)
try:
config_cu_vm(ssh_client)
except CUCommandException:
_vm_cleanup(prov_mgmt, vm_name)
raise
vm_running(prov_mgmt, vm_name)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:26,代码来源:create_cu_vm.py
示例2: test_cloud_instance_discovery
def test_cloud_instance_discovery(request, provider_crud, provider_init, provider_mgmt,
instance_name):
"""
Tests whether cfme will successfully discover a cloud instance change
(add/delete).
As there is currently no way to listen to AWS events,
CFME must be refreshed manually to see the changes.
Metadata:
test_flag: discovery
"""
if not provider_mgmt.does_vm_exist(instance_name):
deploy_template(provider_crud.key, instance_name, allow_skip="default")
test_instance = instance.instance_factory(instance_name, provider_crud)
request.addfinalizer(test_instance.delete_from_provider)
try:
wait_for(_does_instance_exist_in_CFME, [test_instance], num_sec=800, delay=30,
fail_func=test_instance.provider_crud.refresh_provider_relationships,
handle_exception=True)
except TimedOutError:
pytest.fail("Instance was not found in CFME")
test_instance.delete_from_provider()
try:
wait_for(_is_instance_archived, [test_instance], num_sec=800, delay=30,
fail_func=test_instance.provider_crud.refresh_provider_relationships,
handle_exception=True)
except TimedOutError:
pytest.fail("instance was not found in Archives")
开发者ID:seandst,项目名称:cfme_tests,代码行数:28,代码来源:test_cloud_instance_discovery.py
示例3: cu_vm
def cu_vm(provider, vm_name, template):
"""
Deploys CU VM
"""
provider_dict = cfme_data['management_systems'][provider]
# TODO this key isn't in cfme qe yamls
datastore = provider_dict['cap_and_util']['allowed_datastores']
resource_pool = provider_dict['cap_and_util']['resource_pool']
# TODO methods deploy_template calls don't accept resourcepool and allowed_datastores as kwargs
deploy_template(provider, vm_name, template,
resourcepool=resource_pool, allowed_datastores=datastore)
prov_mgmt = get_mgmt(provider)
vm_running(prov_mgmt, vm_name)
ip = prov_mgmt.get_ip_address(vm_name)
# TODO this key isn't in cfme qe yamls
vm_ssh_creds = provider_dict['capandu_vm_creds']
sshname = credentials[vm_ssh_creds]['username']
sshpass = credentials[vm_ssh_creds]['password']
# Create cron jobs to generate disk and network activity on the CU VM.
with make_ssh_client(ip, sshname, sshpass) as ssh_client:
try:
config_cu_vm(ssh_client)
except CUCommandException:
_vm_cleanup(prov_mgmt, vm_name)
raise
vm_running(prov_mgmt, vm_name)
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:31,代码来源:create_cu_vm.py
示例4: vm
def vm(request, provider_mgmt, provider_crud, provider_key, provider_data, small_template):
setup_provider(provider_key)
vm_name = "test_actions-{}-{}".format(provider_key, generate_random_string())
if isinstance(provider_mgmt, mgmt_system.RHEVMSystem):
kwargs = {"cluster": provider_data["default_cluster"]}
elif isinstance(provider_mgmt, mgmt_system.VMWareSystem):
kwargs = {}
elif isinstance(provider_mgmt, mgmt_system.SCVMMSystem):
kwargs = {"host_group": provider_data.get("host_group", "All Hosts")}
else:
raise TypeError("Cannot handle provider {}".format(type(provider_mgmt).__name__))
try:
deploy_template(
provider_key,
vm_name,
template_name=small_template,
**kwargs
)
except TimedOutError:
try:
provider_mgmt.delete_vm(vm_name)
except TimedOutError:
logger.warning("Could not delete VM {}!".format(vm_name))
finally:
# If this happened, we should skip all tests from this provider in this module
pytest.skip("{} is quite likely overloaded! Check its status!".format(provider_key))
def finalize():
"""if getting SOAP object failed, we would not get the VM deleted! So explicit teardown."""
logger.info("Shutting down VM with name %s" % vm_name)
if provider_mgmt.is_vm_suspended(vm_name):
logger.info("Powering up VM %s to shut it down correctly." % vm_name)
provider_mgmt.start_vm(vm_name)
if provider_mgmt.is_vm_running(vm_name):
logger.info("Powering off VM %s" % vm_name)
provider_mgmt.stop_vm(vm_name)
if provider_mgmt.does_vm_exist(vm_name):
logger.info("Deleting VM %s in %s" % (vm_name, provider_mgmt.__class__.__name__))
provider_mgmt.delete_vm(vm_name)
request.addfinalizer(finalize)
# Make it appear in the provider
provider_crud.refresh_provider_relationships()
# Get the SOAP object
soap = wait_for(
lambda: get_vm_object(vm_name),
message="VM object %s appears in CFME" % vm_name,
fail_condition=None,
num_sec=600,
delay=15,
)[0]
return VMWrapper(provider_mgmt, vm_name, soap)
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:56,代码来源:test_actions.py
示例5: create_on_provider
def create_on_provider(self, timeout=900, find_in_cfme=False, **kwargs):
"""Create the VM on the provider
Args:
timeout: Number of seconds to wait for the VM to appear in CFME
Will not wait at all, if set to 0 (Defaults to ``900``)
"""
deploy_template(self.provider.key, self.name, self.template_name, **kwargs)
if find_in_cfme:
self.provider.refresh_provider_relationships()
self.wait_to_appear(timeout=timeout, load_details=False)
开发者ID:akrzos,项目名称:cfme_tests,代码行数:11,代码来源:vm.py
示例6: create_on_provider
def create_on_provider(self, timeout=900):
"""Create the instance on the provider
Args:
timeout: Number of seconds to wait for the instance to appear in CFME
Will not wait at all, if set to 0 (Defaults to ``900``)
"""
deploy_template(self.provider_crud.key, self.name, self.template_name)
if timeout:
self.provider_crud.refresh_provider_relationships()
self.wait_for_vm_to_appear(timeout=timeout, load_details=False)
开发者ID:slouderm,项目名称:cfme_tests,代码行数:11,代码来源:instance.py
示例7: depot_machine_ip
def depot_machine_ip():
""" Deploy vm for depot test
This fixture uses for deploy vm on provider from yaml and then receive it's ip
After test run vm deletes from provider
"""
depot_machine_name = "test_long_log_depot_{}".format(fauxfactory.gen_alphanumeric())
data = conf.cfme_data.get("log_db_operations", {})
depot_provider_key = data["log_db_depot_template"]["provider"]
depot_template_name = data["log_db_depot_template"]["template_name"]
prov = get_mgmt(depot_provider_key)
deploy_template(depot_provider_key,
depot_machine_name,
template_name=depot_template_name)
yield prov.get_ip_address(depot_machine_name)
prov.delete_vm(depot_machine_name)
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:16,代码来源:test_log_depot_operation.py
示例8: vm
def vm(request, a_provider, rest_api):
# Don't use cfme.rest.vm because we don't need finalizer and delete vm after test
provider_rest = rest_api.collections.providers.get(name=a_provider.name)
vm_name = deploy_template(
a_provider.key,
"test_rest_vm_{}".format(fauxfactory.gen_alphanumeric(length=6)))
provider_rest.action.refresh()
wait_for(
lambda: len(rest_api.collections.vms.find_by(name=vm_name)) > 0,
num_sec=600, delay=5)
return vm_name
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:11,代码来源:test_vm_retirement_rest.py
示例9: vm
def vm(request, a_provider, rest_api):
provider_rest = rest_api.collections.providers.get(name=a_provider.name)
vm_name = deploy_template(
a_provider.key,
"test_rest_vm_{}".format(fauxfactory.gen_alphanumeric(length=4)))
request.addfinalizer(lambda: a_provider.mgmt.delete_vm(vm_name))
provider_rest.action.refresh()
wait_for(
lambda: len(rest_api.collections.vms.find_by(name=vm_name)) > 0,
num_sec=600, delay=5)
return vm_name
开发者ID:anewmanRH,项目名称:cfme_tests,代码行数:11,代码来源:__init__.py
示例10: vm_name
def vm_name(provider, small_template):
name = "test_alerts_{}".format(fauxfactory.gen_alpha())
try:
name = deploy_template(provider.key, name, template_name=small_template, allow_skip="default")
yield name
finally:
try:
if provider.mgmt.does_vm_exist(name):
provider.mgmt.delete_vm(name)
except Exception as e:
logger.exception(e)
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:11,代码来源:test_alerts.py
示例11: vm
def vm(request, a_provider, rest_api):
if "refresh" not in rest_api.collections.providers.action.all:
pytest.skip("Refresh action is not implemented in this version")
provider_rest = rest_api.collections.providers.find_by(name=a_provider.name)[0]
vm_name = deploy_template(
a_provider.key,
"test_rest_vm_{}".format(fauxfactory.gen_alphanumeric(length=4)))
request.addfinalizer(lambda: a_provider.mgmt.delete_vm(vm_name))
provider_rest.action.refresh()
wait_for(
lambda: len(rest_api.collections.vms.find_by(name=vm_name)) > 0,
num_sec=600, delay=5)
return vm_name
开发者ID:pombredanne,项目名称:cfme_tests,代码行数:13,代码来源:test_rest.py
示例12: test_provider_refresh
def test_provider_refresh(request, setup_a_provider, rest_api):
"""Test checking that refresh invoked from the REST API works.
It provisions a VM when the Provider inventory functionality is disabled, then the functionality
is enabled and we wait for refresh to finish by checking the field in provider and then we check
whether the VM appeared in the provider.
Prerequisities:
* A provider that is set up, with templates suitable for provisioning.
Steps:
* Disable the ``ems_inventory`` and ``ems_operations`` roles
* Provision a VM
* Store old refresh date from the provider
* Initiate refresh
* Wait until the refresh date updates
* The VM should appear soon.
Metadata:
test_flag: rest
"""
if "refresh" not in rest_api.collections.providers.action.all:
pytest.skip("Refresh action is not implemented in this version")
provider_mgmt = get_mgmt(setup_a_provider.key)
provider = rest_api.collections.providers.find_by(name=setup_a_provider.name)[0]
with server_roles_disabled("ems_inventory", "ems_operations"):
vm_name = deploy_template(
setup_a_provider.key,
"test_rest_prov_refresh_{}".format(fauxfactory.gen_alphanumeric(length=4)))
request.addfinalizer(lambda: provider_mgmt.delete_vm(vm_name))
provider.reload()
old_refresh_dt = provider.last_refresh_date
assert provider.action.refresh()["success"], "Refresh was unsuccessful"
wait_for(
lambda: provider.last_refresh_date,
fail_func=provider.reload,
fail_condition=lambda refresh_date: refresh_date == old_refresh_dt,
num_sec=720,
delay=5,
)
# We suppose that thanks to the random string, there will be only one such VM
wait_for(
lambda: len(rest_api.collections.vms.find_by(name=vm_name)),
fail_condition=lambda l: l == 0,
num_sec=180,
delay=10,
)
vms = rest_api.collections.vms.find_by(name=vm_name)
if "delete" in vms[0].action.all:
vms[0].action.delete()
开发者ID:richardfontana,项目名称:cfme_tests,代码行数:50,代码来源:test_rest.py
示例13: vm
def vm(request, a_provider, rest_api):
provider_rest = rest_api.collections.providers.get(name=a_provider.name)
vm_name = deploy_template(
a_provider.key,
'test_rest_vm_{}'.format(fauxfactory.gen_alphanumeric(length=4)))
@request.addfinalizer
def _finished():
try:
a_provider.mgmt.delete_vm(vm_name)
except Exception:
# vm can be deleted/retired by test
logger.warning("Failed to delete vm '{}'.".format(vm_name))
provider_rest.action.refresh()
wait_for(
lambda: rest_api.collections.vms.find_by(name=vm_name) or False,
num_sec=600, delay=5)
return vm_name
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:19,代码来源:gen_data.py
示例14: vm
def vm(request, provider_mgmt, provider_crud, provider_key, provider_data, small_template, vm_name):
try:
setup_provider(provider_key)
except FlashMessageException as e:
e.skip_and_log("Provider failed to set up")
if isinstance(provider_mgmt, mgmt_system.RHEVMSystem):
kwargs = {"cluster": provider_data["default_cluster"]}
elif isinstance(provider_mgmt, mgmt_system.VMWareSystem):
kwargs = {}
elif isinstance(provider_mgmt, mgmt_system.SCVMMSystem):
kwargs = {
"host_group": provider_data.get("provisioning", {}).get("host_group", "All Hosts")}
else:
kwargs = {}
try:
deploy_template(
provider_key,
vm_name,
template_name=small_template,
allow_skip="default",
power_on=True,
**kwargs
)
except TimedOutError as e:
logger.exception(e)
try:
provider_mgmt.delete_vm(vm_name)
except TimedOutError:
logger.warning("Could not delete VM {}!".format(vm_name))
finally:
# If this happened, we should skip all tests from this provider in this module
pytest.skip("{} is quite likely overloaded! Check its status!\n{}: {}".format(
provider_key, type(e).__name__, str(e)))
def finalize():
"""if getting SOAP object failed, we would not get the VM deleted! So explicit teardown."""
logger.info("Shutting down VM with name {}".format(vm_name))
if provider_mgmt.is_vm_suspended(vm_name):
logger.info("Powering up VM {} to shut it down correctly.".format(vm_name))
provider_mgmt.start_vm(vm_name)
if provider_mgmt.is_vm_running(vm_name):
logger.info("Powering off VM {}".format(vm_name))
provider_mgmt.stop_vm(vm_name)
if provider_mgmt.does_vm_exist(vm_name):
logger.info("Deleting VM {} in {}".format(vm_name, provider_mgmt.__class__.__name__))
provider_mgmt.delete_vm(vm_name)
request.addfinalizer(finalize)
# Make it appear in the provider
provider_crud.refresh_provider_relationships()
# Get the SOAP object
soap = wait_for(
lambda: get_vm_object(vm_name),
message="VM object {} appears in CFME".format(vm_name),
fail_condition=None,
num_sec=600,
delay=15,
)[0]
return VMWrapper(provider_mgmt, vm_name, soap)
开发者ID:seandst,项目名称:cfme_tests,代码行数:63,代码来源:test_actions.py
示例15: vm
def vm(request, provider, local_setup_provider, small_template_modscope, vm_name):
if provider.type == "rhevm":
kwargs = {"cluster": provider.data["default_cluster"]}
elif provider.type == "virtualcenter":
kwargs = {}
elif provider.type == "openstack":
kwargs = {}
if 'small_template_flavour' in provider.data:
kwargs = {"flavour_name": provider.data.get('small_template_flavour')}
elif provider.type == "scvmm":
kwargs = {
"host_group": provider.data.get("provisioning", {}).get("host_group", "All Hosts")}
else:
kwargs = {}
try:
deploy_template(
provider.key,
vm_name,
template_name=small_template_modscope,
allow_skip="default",
power_on=True,
**kwargs
)
except TimedOutError as e:
logger.exception(e)
try:
provider.mgmt.delete_vm(vm_name)
except TimedOutError:
logger.warning("Could not delete VM %s!", vm_name)
finally:
# If this happened, we should skip all tests from this provider in this module
pytest.skip("{} is quite likely overloaded! Check its status!\n{}: {}".format(
provider.key, type(e).__name__, str(e)))
@request.addfinalizer
def _finalize():
"""if getting REST object failed, we would not get the VM deleted! So explicit teardown."""
logger.info("Shutting down VM with name %s", vm_name)
if provider.mgmt.is_vm_suspended(vm_name):
logger.info("Powering up VM %s to shut it down correctly.", vm_name)
provider.mgmt.start_vm(vm_name)
if provider.mgmt.is_vm_running(vm_name):
logger.info("Powering off VM %s", vm_name)
provider.mgmt.stop_vm(vm_name)
if provider.mgmt.does_vm_exist(vm_name):
logger.info("Deleting VM %s in %s", vm_name, provider.mgmt.__class__.__name__)
provider.mgmt.delete_vm(vm_name)
# Make it appear in the provider
provider.refresh_provider_relationships()
# Get the REST API object
api = wait_for(
lambda: get_vm_object(vm_name),
message="VM object {} appears in CFME".format(vm_name),
fail_condition=None,
num_sec=600,
delay=15,
)[0]
return VMWrapper(provider, vm_name, api)
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:62,代码来源:test_actions.py
示例16: create_on_provider
def create_on_provider(self):
"""Create the VM on the provider"""
deploy_template(self.provider_crud, self.name, self.template_name)
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:3,代码来源:virtual_machines.py
注:本文中的utils.virtual_machines.deploy_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论