当前位置: 首页>>代码示例>>Python>>正文


Python providers.provider_factory函数代码示例

本文整理汇总了Python中utils.providers.provider_factory函数的典型用法代码示例。如果您正苦于以下问题:Python provider_factory函数的具体用法?Python provider_factory怎么用?Python provider_factory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了provider_factory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_mgmt_system

 def get_mgmt_system(self):
     """ Returns the mgmt_system using the :py:func:`utils.providers.provider_factory` method.
     """
     if self.provider_data is not None:
         return provider_factory(self.provider_data)
     elif self.key is not None:
         return provider_factory(self.key)
     else:
         raise ProviderHasNoKey('Provider %s has no key, so cannot get mgmt system')
开发者ID:seandst,项目名称:cfme_tests,代码行数:9,代码来源:provider.py

示例2: process_provider_vms

def process_provider_vms(provider_key, matchers, delta, vms_to_delete):
    with lock:
        print '%s processing' % provider_key
    try:
        now = datetime.datetime.now()
        provider = provider_factory(provider_key)
        for vm_name in provider.list_vm():
            if not match(matchers, vm_name):
                continue

            try:
                vm_creation_time = provider.vm_creation_time(vm_name)
            except:
                logger.error('Failed to get creation/boot time for %s on %s' % (
                    vm_name, provider_key))
                continue

            if vm_creation_time + delta < now:
                vm_delta = now - vm_creation_time
                with lock:
                    vms_to_delete[provider_key].add((vm_name, vm_delta))
        with lock:
            print '%s finished' % provider_key
    except Exception as ex:
        with lock:
            print '%s failed' % provider_key
        logger.error('failed to process vms from provider %s', provider_key)
        logger.exception(ex)
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:28,代码来源:cleanup_old_vms.py

示例3: get_mgmt_system

 def get_mgmt_system(self):
     """ Returns the mgmt_system using the :py:func:`utils.providers.provider_factory` method.
     """
     if not self.key:
         raise ProviderHasNoKey("Provider %s has no key, so cannot get mgmt system")
     else:
         return provider_factory(self.key)
开发者ID:kbrock,项目名称:cfme_tests,代码行数:7,代码来源:provider.py

示例4: wait_for_provider_or_timeout

    def wait_for_provider_or_timeout(self, provider):
        '''Wait for a provider to become available or timeout trying'''
        ec, tc = wait_for(self.is_quad_icon_available,
                          [provider['name']])
        detail_pg = self.quadicon_region.selected[0].click()

        client = provider_factory(provider['request'])
        host_stats = client.stats('num_datastore',
                                  'num_host',
                                  'num_cluster')
        client.disconnect()
        wait = partial(wait_for,
                       detail_pg.do_stats_match,
                       [host_stats],
                       message="do_stats_match",
                       num_sec=180)
        try:
            ec, tc = wait()
        except TimedOutError:
            # Help him
            assert detail_pg.click_on_refresh_relationships(), "Could not refresh relationships!"
            ec, tc = wait()
        self.header.site_navigation_menu('Infrastructure'). \
            sub_navigation_menu('Providers').click()
        return
开发者ID:jkrocil,项目名称:cfme_tests,代码行数:25,代码来源:providers.py

示例5: provision_appliance

def provision_appliance(version=None, vm_name_prefix='cfme', template=None, provider_name=None):
    """Provisions fresh, unconfigured appliance of a specific version

    Note:
        Version must be mapped to template name under ``appliance_provisioning > versions``
        in ``cfme_data.yaml``.

    Args:
        version: version of appliance to provision
        vm_name_prefix: name prefix to use when deploying the appliance vm

    Returns: Unconfigured appliance; instance of :py:class:`Appliance`

    Usage:
        my_appliance = provision_appliance('5.2.1.8', 'my_tests')
        my_appliance.fix_ntp_clock()
        my_appliance.enable_internal_db()
        my_appliance.wait_for_web_ui()
        or
        my_appliance = provision_appliance('5.2.1.8', 'my_tests')
        my_appliance.configure(patch_ajax_wait=False)
        (identical outcome)
    """

    def _generate_vm_name():
        if version is not None:
            version_digits = ''.join([letter for letter in version if letter.isdigit()])
            return '{}_{}_{}'.format(vm_name_prefix, version_digits, generate_random_string())
        else:
            return '{}_{}'.format(vm_name_prefix, generate_random_string())

    if version is not None:
        templates_by_version = conf.cfme_data['appliance_provisioning']['versions']
        try:
            template_name = templates_by_version[version]
        except KeyError:
            raise ApplianceException('No template found matching version {}'.format(version))

    if template is not None:
        template_name = template

    if provider_name is None:
        provider_name = conf.cfme_data['appliance_provisioning']['provider']
    prov_data = conf.cfme_data['management_systems'][provider_name]

    provider = provider_factory(provider_name)
    vm_name = _generate_vm_name()

    deploy_args = {}
    deploy_args['vm_name'] = vm_name

    if prov_data['type'] == 'rhevm':
        deploy_args['cluster_name'] = prov_data['default_cluster']

    provider.deploy_template(template_name, **deploy_args)

    return Appliance(provider_name, vm_name)
开发者ID:slouderm,项目名称:cfme_tests,代码行数:57,代码来源:appliance.py

示例6: mgmt_sys_api_clients

def mgmt_sys_api_clients(mozwebqa, cfme_data):
    """Returns a list of management system api clients"""
    clients = {}
    for sys_name in cfme_data.data["management_systems"]:
        if sys_name in clients:
            # Overlapping sys_name entry in cfme_data.yaml
            logger.warning("Overriding existing entry for %s." % sys_name)
        clients[sys_name] = provider_factory(sys_name)
    return clients
开发者ID:jwadkins,项目名称:cfme_tests,代码行数:9,代码来源:mgmt_system.py

示例7: power_state_buttons

def power_state_buttons(request, current_provider):
    manager = provider_factory(current_provider)
    vm_name = request.POST["vm_name"]
    power_state = request.POST["power_state"]
    can_power_on = power_state in {Appliance.Power.SUSPENDED, Appliance.Power.OFF}
    can_power_off = power_state in {Appliance.Power.ON}
    can_suspend = power_state in {Appliance.Power.ON} and manager.can_suspend
    can_delete = power_state in {Appliance.Power.OFF}
    return render(request, 'appliances/vms/_buttons.html', locals())
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:9,代码来源:views.py

示例8: __init__

    def __init__(self, provider_name, vm_name):
        """Initializes a deployed appliance VM
        """
        self.name = Appliance._default_name
        self.db_address = None

        self._provider = provider_factory(provider_name)
        self._vm_name = vm_name
        self._address = None
开发者ID:sshveta,项目名称:cfme_tests,代码行数:9,代码来源:appliance.py

示例9: wait_for_provider_or_timeout

    def wait_for_provider_or_timeout(self, provider):
        """Wait for a provider to become available or timeout trying"""
        ec, tc = wait_for(self.is_quad_icon_available, [provider["name"]])
        detail_pg = self.quadicon_region.selected[0].click()

        client = provider_factory(provider["request"])
        host_stats = client.stats("num_template")
        client.disconnect()
        ec, tc = wait_for(detail_pg.do_stats_match, [host_stats], message="do_stats_match", num_sec=300)
        return
开发者ID:jwadkins,项目名称:cfme_tests,代码行数:10,代码来源:__init__.py

示例10: call_provider

def call_provider(provider_name, action, *args):
    # Given a provider class, find the named method and call it with
    # *args. This could possibly be generalized for other CLI tools.
    provider = provider_factory(provider_name)

    try:
        call = getattr(provider, action)
    except AttributeError:
        raise Exception('Action "%s" not found' % action)
    return call(*args)
开发者ID:jwadkins,项目名称:cfme_tests,代码行数:10,代码来源:providers.py

示例11: test_validate_provider_details

    def test_validate_provider_details(self, infra_providers_pg, provider_data):
        prov_pg = infra_providers_pg
        prov_pg.select_provider(provider_data['name'])

        client = provider_factory(provider_data['request'])
        host_stats = client.stats()

        detail_pg = prov_pg.quadicon_region.selected[0].click()
        Assert.true(detail_pg.do_stats_match(host_stats),
            'Host stats should match with mgmt_system stats')
开发者ID:rlandy,项目名称:cfme_tests,代码行数:10,代码来源:test_infrastructure_providers.py

示例12: get_provider_templates

def get_provider_templates(provider_key, templates_providers, thread_lock):
    # functionalized to make it easy to farm this out to threads
    provider_mgmt = provider_factory(provider_key)
    try:
        templates = provider_mgmt.list_template()
        print provider_key, 'returned %d templates' % len(templates)
        with thread_lock:
            for template in templates:
                templates_providers[template].append(provider_key)
    except:
        print provider_key, 'failed'
开发者ID:slouderm,项目名称:cfme_tests,代码行数:11,代码来源:populate_template_tracker.py

示例13: wait_for_provider_or_timeout

    def wait_for_provider_or_timeout(self, provider):
        """Wait for a provider to become available or timeout trying"""
        ec, tc = wait_for(self.is_quad_icon_available, [provider["name"]])
        detail_pg = self.quadicon_region.selected[0].click()

        client = provider_factory(provider["request"])
        host_stats = client.stats("num_datastore", "num_host", "num_cluster")
        client.disconnect()
        ec, tc = wait_for(detail_pg.do_stats_match, [host_stats], message="do_stats_match", num_sec=300)
        self.header.site_navigation_menu("Infrastructure").sub_navigation_menu("Providers").click()
        return
开发者ID:rlandy,项目名称:cfme_tests,代码行数:11,代码来源:providers.py

示例14: vm

def vm(request, setup_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_mgmt = provider_factory(setup_a_provider.key)
    provider = rest_api.collections.providers.find_by(name=setup_a_provider.name)[0]
    vm_name = deploy_template(
        setup_a_provider.key,
        "test_rest_vm_{}".format(fauxfactory.gen_alphanumeric(length=4)))
    request.addfinalizer(lambda: provider_mgmt.delete_vm(vm_name))
    provider.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:seandst,项目名称:cfme_tests,代码行数:14,代码来源:test_rest.py

示例15: vm_action

def vm_action(request, current_provider):
    if not request.user.is_authenticated():
        return HttpResponse("Not authenticated", content_type="text/plain")
    try:
        provider_factory(current_provider)
    except Exception as e:
        return HttpResponse(
            "Troubles with provider {}: {}".format(current_provider, str(e)),
            content_type="text/plain")
    vm_name = request.POST["vm_name"]
    action = request.POST["action"]
    if action == "poweron":
        anyvm_power_on.delay(current_provider, vm_name)
    elif action == "poweroff":
        anyvm_power_off.delay(current_provider, vm_name)
    elif action == "suspend":
        anyvm_suspend.delay(current_provider, vm_name)
    elif action == "delete":
        anyvm_delete.delay(current_provider, vm_name)
    else:
        HttpResponse("No such action {}!".format(action), content_type="text/plain")
    logger().info("User {} initiated {} on {}@{}".format(
        request.user.username, action, vm_name, current_provider))
    return HttpResponse("Action {} was initiated".format(action), content_type="text/plain")
开发者ID:petrblaho,项目名称:cfme_tests,代码行数:24,代码来源:views.py


注:本文中的utils.providers.provider_factory函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。