本文整理汇总了Python中utils.providers.setup_provider函数的典型用法代码示例。如果您正苦于以下问题:Python setup_provider函数的具体用法?Python setup_provider怎么用?Python setup_provider使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setup_provider函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_appliance
def configure_appliance(browser_setup, provider, vm_name):
''' Configure the appliance for smart state analysis '''
global appliance_vm_name
# ensure smart proxy role enabled
logger.info('Enabling smart proxy role...')
nav_to_roles().edit_defaults_list("smartproxy")
# add provider
logger.info('Setting up provider...')
setup_provider(provider)
# credential hosts
logger.info('Credentialing hosts')
setup_providers_hosts_credentials(provider)
prov_data = cfme_data['management_systems'][provider]
if prov_data['type'] == 'rhevm':
vm_details = nav_to_vm_details(provider, appliance_vm_name)
vm_details.edit_cfme_relationship_and_save()
#wait for vm smart state to enable
logger.info('Waiting for smartstate option to enable...')
vm_details = nav_to_vm_details(provider, vm_name)
wait_for(vm_details.config_button.is_smart_state_analysis_enabled, delay=30,
num_sec=450, fail_func=pytest.sel.refresh)
return browser_setup
示例2: provider_init
def provider_init(provider_key):
"""cfme/infrastructure/provider.py provider object."""
try:
setup_provider(provider_key)
except Exception as e:
logger.info("Exception detected on provider setup: " + str(e))
pytest.skip("It's not possible to set up this provider, therefore skipping")
示例3: setup_for_alerts
def setup_for_alerts(request, alerts, event, vm_name, provider):
"""This function takes alerts and sets up CFME for testing it
Args:
request: py.test funcarg request
alerts: Alert objects
event: Event to hook on (VM Power On, ...)
vm_name: VM name to use for policy filtering
provider: funcarg provider_data
"""
setup_provider(provider.key)
alert_profile = explorer.VMInstanceAlertProfile("Alert profile for %s" % vm_name, alerts)
alert_profile.create()
request.addfinalizer(alert_profile.delete)
alert_profile.assign_to("The Enterprise")
action = explorer.Action("Evaluate Alerts for %s" % vm_name, "Evaluate Alerts", alerts)
action.create()
request.addfinalizer(action.delete)
policy = explorer.VMControlPolicy(
"Evaluate Alerts policy for %s" % vm_name, scope="fill_field(VM and Instance : Name, INCLUDES, %s)" % vm_name
)
policy.create()
request.addfinalizer(policy.delete)
policy_profile = explorer.PolicyProfile("Policy profile for %s" % vm_name, [policy])
policy_profile.create()
request.addfinalizer(policy_profile.delete)
policy.assign_actions_to_event(event, [action])
prov = Provider(provider.data["name"])
prov.assign_policy_profiles(policy_profile.description)
示例4: _setup_provider
def _setup_provider(provider_key, request=None):
def skip(provider_key, previous_fail=False):
if request:
node = request.node
name, location = get_test_idents(node)
skip_data = {'type': 'provider', 'reason': provider_key}
art_client.fire_hook('skip_test', test_location=location, test_name=name,
skip_data=skip_data)
if previous_fail:
raise pytest.skip('Provider {} failed to set up previously in another test, '
'skipping test'.format(provider_key))
else:
raise pytest.skip('Provider {} failed to set up this time, '
'skipping test'.format(provider_key))
# This function is dynamically "fixturized" to setup up a specific provider,
# optionally skipping the provider setup if that provider has previously failed.
if provider_key in _failed_providers:
skip(provider_key, previous_fail=True)
try:
providers.setup_provider(provider_key)
except Exception as ex:
logger.error('Error setting up provider %s', provider_key)
logger.exception(ex)
_failed_providers.add(provider_key)
skip(provider_key)
示例5: 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)
示例6: handle_provider
def handle_provider(provider):
try:
providers.clear_providers()
providers.setup_provider(provider.key)
except FlashMessageException as e:
e.skip_and_log("Provider failed to set up")
else:
yield
finally:
providers.clear_providers()
示例7: provider_init
def provider_init(provider_key, iso_cust_template, provisioning, iso_datastore):
try:
setup_provider(provider_key)
except Exception:
pytest.skip("It's not possible to set up this provider, therefore skipping")
if not iso_datastore.exists():
iso_datastore.create()
# Fails on upstream, BZ1109256
iso_datastore.set_iso_image_type(provisioning["iso_file"], provisioning["iso_image_type"])
if not iso_cust_template.exists():
iso_cust_template.create()
示例8: testing_vm
def testing_vm(request, provisioning, provider):
setup_provider(provider.key)
vm = VM.factory(
"test_ae_hd_{}".format(fauxfactory.gen_alphanumeric()),
provider,
template_name=provisioning["template"]
)
try:
vm.create_on_provider(find_in_cfme=True, allow_skip="default")
yield vm
finally:
vm.delete_from_provider()
if vm.exists:
vm.delete()
示例9: testing_vm
def testing_vm(request, provisioning, provider_crud, provider_key):
setup_provider(provider_key)
vm = Vm(
name="test_ae_hd_{}".format(generate_random_string()),
provider_crud=provider_crud,
template_name=provisioning["template"]
)
def _finalize():
vm.delete_from_provider()
if vm.does_vm_exist_in_cfme():
vm.remove_from_cfme()
request.addfinalizer(_finalize)
vm.create_on_provider()
return vm
示例10: testing_vm
def testing_vm(request, provisioning, provider_crud, provider_key):
setup_provider(provider_key)
vm = Vm(
name="test_ae_hd_{}".format(fauxfactory.gen_alphanumeric()),
provider_crud=provider_crud,
template_name=provisioning["template"]
)
def _finalize():
vm.delete_from_provider()
if vm.does_vm_exist_in_cfme():
vm.remove_from_cfme()
request.addfinalizer(_finalize)
vm.create_on_provider(find_in_cfme=True, allow_skip="default")
return vm
示例11: provisioner
def provisioner(request, provider):
if not provider.exists:
try:
setup_provider(provider.key)
except FlashMessageException as e:
e.skip_and_log("Provider failed to set up")
def _provisioner(template, provisioning_data, delayed=None):
sel.force_navigate('infrastructure_provision_vms', context={
'provider': provider,
'template_name': template,
})
fill(provisioning_form, provisioning_data, action=provisioning_form.submit_button)
flash.assert_no_errors()
return _provisioner
示例12: provisioner
def provisioner(request, provider):
if not provider.exists:
try:
setup_provider(provider.key)
except FlashMessageException as e:
e.skip_and_log("Provider failed to set up")
def _provisioner(template, provisioning_data, delayed=None):
pytest.sel.force_navigate('infrastructure_provision_vms', context={
'provider': provider,
'template_name': template,
})
vm_name = provisioning_data["vm_name"]
fill(provisioning_form, provisioning_data, action=provisioning_form.submit_button)
flash.assert_no_errors()
request.addfinalizer(lambda: cleanup_vm(vm_name, provider))
if delayed is not None:
total_seconds = (delayed - datetime.utcnow()).total_seconds()
row_description = 'Provision from [%s] to [%s]' % (template, vm_name)
cells = {'Description': row_description}
try:
row, __ = wait_for(requests.wait_for_request, [cells],
fail_func=requests.reload, num_sec=total_seconds, delay=5)
pytest.fail("The provisioning was not postponed")
except TimedOutError:
pass
logger.info('Waiting for vm %s to appear on provider %s', vm_name, provider.key)
wait_for(provider.mgmt.does_vm_exist, [vm_name], handle_exception=True, num_sec=600)
# nav to requests page happens on successful provision
logger.info('Waiting for cfme provision request for vm %s' % vm_name)
row_description = 'Provision from [%s] to [%s]' % (template, vm_name)
cells = {'Description': row_description}
row, __ = wait_for(requests.wait_for_request, [cells],
fail_func=requests.reload, num_sec=900, delay=20)
assert row.last_message.text == version.pick(
{version.LOWEST: 'VM Provisioned Successfully',
"5.3": 'Vm Provisioned Successfully', })
return VM.factory(vm_name, provider)
return _provisioner
示例13: _setup_provider
def _setup_provider(provider_key):
def skip(provider_key, previous_fail=False):
if previous_fail:
raise pytest.skip('Provider {} failed to set up previously in another test, '
'skipping test'.format(provider_key))
else:
raise pytest.skip('Provider {} failed to set up this time, '
'skipping test'.format(provider_key))
# This function is dynamically "fixturized" to setup up a specific provider,
# optionally skipping the provider setup if that provider has previously failed.
if provider_key in _failed_providers:
skip(provider_key, previous_fail=True)
try:
providers.setup_provider(provider_key)
except Exception as ex:
logger.error('Error setting up provider %s', provider_key)
logger.exception(ex)
_failed_providers.add(provider_key)
skip(provider_key)
示例14: configure_appliance
def configure_appliance(browser_setup, provider, vm_to_analyze, listener_info):
''' Configure the appliance for smart state analysis '''
global appliance_vm_name
# ensure smart proxy role enabled
logger.info('Enabling smart proxy role...')
nav_to_roles().edit_defaults_list("smartproxy")
# add provider
logger.info('Setting up provider...')
setup_provider(provider)
# credential hosts
logger.info('Credentialing hosts')
setup_providers_hosts_credentials(provider)
prov_data = cfme_data['management_systems'][provider]
if prov_data['type'] == 'rhevm':
vm_details = nav_to_vm_details(provider, appliance_vm_name)
vm_details.edit_cfme_relationship_and_save()
#wait for vm smart state to enable
logger.info('Waiting for smartstate option to enable...')
vm_details = nav_to_vm_details(provider, vm_to_analyze)
wait_for(vm_details.config_button.is_smart_state_analysis_enabled, delay=30,
num_sec=450, fail_func=pytest.sel.refresh)
# Configure for events
ssh_kwargs = {
'username': conf.credentials['ssh']['username'],
'password': conf.credentials['ssh']['password'],
'hostname': appliance_list[provider]
}
# Init SSH client
client = SSHClient(**ssh_kwargs)
setup_for_event_testing(client, None, listener_info, providers.list_infra_providers())
return browser_setup
示例15: provider_init
def provider_init(provider_key):
"""cfme/infrastructure/provider.py provider object."""
try:
setup_provider(provider_key)
except Exception as e:
pytest.skip("Skipping,because it's not possible to set up this provider({})".format(str(e)))