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


Python instance.Instance类代码示例

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


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

示例1: testing_instance

def testing_instance(setup_provider, provider):
    """ Fixture to provision instance on the provider
    """
    instance = Instance.factory(random_vm_name('pwr-c'), provider)
    if not provider.mgmt.does_vm_exist(instance.name):
        instance.create_on_provider(allow_skip="default")
    elif instance.provider.type == "ec2" and \
            provider.mgmt.is_vm_state(instance.name, provider.mgmt.states['deleted']):
        provider.mgmt.set_name(
            instance.name, 'test_terminated_{}'.format(fauxfactory.gen_alphanumeric(8)))
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
    provider.refresh_provider_relationships()

    # Make sure the instance shows up
    try:
        wait_for(lambda: instance.exists,
                 fail_condition=False,
                 num_sec=600,
                 delay=15,
                 fail_func=provider.refresh_provider_relationships)
    except TimedOutError:
        pytest.fail('Failed to find instance in CFME after creating on provider: {}'
                    .format(instance.name))

    yield instance

    logger.info('Fixture cleanup, deleting test instance: %s', instance.name)
    try:
        provider.mgmt.delete_vm(instance.name)
    except Exception:
        logger.exception('Exception when deleting testing_instance: %s', instance.name)
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:31,代码来源:test_instance_power_control.py

示例2: testing_instance

def testing_instance(request, setup_provider, provider, provisioning, vm_name):
    """ Fixture to prepare instance parameters for provisioning
    """
    image = provisioning["image"]["name"]
    note = "Testing provisioning from image {} to vm {} on provider {}".format(image, vm_name, provider.key)

    instance = Instance.factory(vm_name, provider, image)

    request.addfinalizer(instance.delete_from_provider)

    inst_args = {
        "email": "[email protected]",
        "first_name": "Image",
        "last_name": "Provisioner",
        "notes": note,
        "instance_type": provisioning["instance_type"] if provider.type != "azure" else provisioning["vm_size"],
        "availability_zone": provisioning["availability_zone"] if provider.type != "azure" else None,
        "security_groups": [provisioning["security_group"]]
        if provider.type != "azure"
        else provisioning["network_nsg"],
        "guest_keypair": provisioning["guest_keypair"] if provider.type != "azure" else None,
    }

    if isinstance(provider, OpenStackProvider):
        inst_args["cloud_network"] = provisioning["cloud_network"]

    if isinstance(provider, AzureProvider):
        inst_args["cloud_network"] = provisioning["virtual_net"]
        inst_args["cloud_subnet"] = provisioning["subnet_range"]
        inst_args["security_groups"] = provisioning["network_nsg"]
        inst_args["resource_groups"] = provisioning["resource_group"]
        inst_args["instance_type"] = provisioning["vm_size"]
        inst_args["admin_username"] = provisioning["vm_user"]
        inst_args["admin_password"] = provisioning["vm_password"]
    return instance, inst_args
开发者ID:anewmanRH,项目名称:cfme_tests,代码行数:35,代码来源:test_provisioning.py

示例3: test_provision_from_template

def test_provision_from_template(request, setup_provider, provider, vm_name, provisioning):
    """ Tests instance provision from template

    Metadata:
        test_flag: provision
    """
    image = provisioning['image']['name']
    note = ('Testing provisioning from image {} to vm {} on provider {}'.format(
        image, vm_name, provider.key))

    instance = Instance.factory(vm_name, provider, image)

    request.addfinalizer(instance.delete_from_provider)

    inst_args = {
        'email': '[email protected]',
        'first_name': 'Image',
        'last_name': 'Provisioner',
        'notes': note,
        'instance_type': provisioning['instance_type'],
        'availability_zone': provisioning['availability_zone'],
        'security_groups': [provisioning['security_group']],
        'guest_keypair': provisioning['guest_keypair']
    }

    if isinstance(provider, OpenStackProvider):
        inst_args['cloud_network'] = provisioning['cloud_network']

    sel.force_navigate("clouds_instances_by_provider")
    instance.create(**inst_args)
开发者ID:MattLombana,项目名称:cfme_tests,代码行数:30,代码来源:test_provisioning.py

示例4: test_instance

def test_instance(setup_provider_modscope, request, delete_instances_fin, provider, vm_name):
    """ Fixture to provision instance on the provider
    """
    instance = Instance.factory(vm_name, provider)
    if not provider.mgmt.does_vm_exist(vm_name):
        delete_instances_fin[provider.key] = instance
        instance.create_on_provider(allow_skip="default")
    return instance
开发者ID:FilipB,项目名称:cfme_tests,代码行数:8,代码来源:test_cloud_timelines.py

示例5: new_vm

def new_vm(provider, request):
    if provider.one_of(CloudProvider):
        vm = Instance.factory(random_vm_name(context='cockpit'), provider)
    else:
        vm = InfraVm.factory(random_vm_name(context='cockpit'), provider)
    if not provider.mgmt.does_vm_exist(vm.name):
        vm.create_on_provider(find_in_cfme=True, allow_skip="default")
        request.addfinalizer(vm.cleanup_on_provider)
    return vm
开发者ID:LandoCalrizzian,项目名称:cfme_tests,代码行数:9,代码来源:test_cockpit_server.py

示例6: new_instance

def new_instance(provider):
    inst = Instance.factory(random_vm_name('cloud-timeline', max_length=20), provider)
    logger.debug('Fixture new_instance set up! Name: %r Provider: %r', inst.name,
                 inst.provider.name)
    inst.create_on_provider(allow_skip="default", find_in_cfme=True)
    yield inst
    logger.debug('Fixture new_vm teardown! Name: %r Provider: %r', inst.name, inst.provider.name)
    if inst.provider.mgmt.does_vm_exist(inst.name):
        inst.provider.mgmt.delete_vm(inst.name)
开发者ID:LandoCalrizzian,项目名称:cfme_tests,代码行数:9,代码来源:test_cloud_timelines.py

示例7: create_instance

def create_instance(provider):
    instance = Instance.factory(random_vm_name('pwr-c'), provider)
    if not provider.mgmt.does_vm_exist(instance.name):
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
    elif instance.provider.type == "ec2" and \
            provider.mgmt.is_vm_state(instance.name, provider.mgmt.states['deleted']):
        provider.mgmt.set_name(
            instance.name, 'test_terminated_{}'.format(fauxfactory.gen_alphanumeric(8)))
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
    return instance
开发者ID:LandoCalrizzian,项目名称:cfme_tests,代码行数:10,代码来源:test_instance_power_control.py

示例8: new_instance

def new_instance(request, provider):
    instance = Instance.factory(random_vm_name("timelines", max_length=16), provider)

    request.addfinalizer(instance.delete_from_provider)

    if not provider.mgmt.does_vm_exist(instance.name):
        logger.info("deploying %s on provider %s", instance.name, provider.key)
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
        if instance.provider.one_of(EC2Provider):
            ec2_sleep()
    return instance
开发者ID:dajohnso,项目名称:cfme_tests,代码行数:11,代码来源:test_cloud_timelines.py

示例9: test_provision_cloud_init

def test_provision_cloud_init(request, setup_provider, provider, provisioning,
                              setup_ci_template, vm_name):
    """ Tests provisioning from a template with cloud_init

    Metadata:
        test_flag: cloud_init, provision
    """
    image = provisioning.get('ci-image') or provisioning['image']['name']
    note = ('Testing provisioning from image {} to vm {} on provider {}'.format(
        image, vm_name, provider.key))
    logger.info(note)

    mgmt_system = provider.mgmt

    instance = Instance.factory(vm_name, provider, image)

    request.addfinalizer(instance.cleanup_on_provider)
    # TODO: extend inst_args for other providers except EC2 if needed
    inst_args = {
        'request': {'email': '[email protected]',
                    'first_name': 'Image',
                    'last_name': 'Provisioner',
                    'notes': note},
        'catalog': {'vm_name': vm_name},
        'properties': {'instance_type': provisioning['instance_type'],
                       'guest_keypair': provisioning['guest_keypair']},
        'environment': {'availability_zone': provisioning['availability_zone'],
                        'cloud_network': provisioning['cloud_network'],
                        'security_groups': [provisioning['security_group']]},
        'customize': {'custom_template': {'name': provisioning['ci-template']}}
    }

    if provider.one_of(OpenStackProvider):
        floating_ip = mgmt_system.get_first_floating_ip()
        inst_args['environment']['public_ip_address'] = floating_ip

    logger.info('Instance args: {}'.format(inst_args))

    instance.create(**inst_args)
    provision_request = provider.appliance.collections.requests.instantiate(vm_name,
                                                                   partial_check=True)
    provision_request.wait_for_request()
    connect_ip = mgmt_system.get_ip_address(vm_name)

    # Check that we can at least get the uptime via ssh this should only be possible
    # if the username and password have been set via the cloud-init script so
    # is a valid check
    with ssh.SSHClient(hostname=connect_ip, username=provisioning['ci-username'],
                       password=provisioning['ci-pass']) as ssh_client:
        wait_for(ssh_client.uptime, num_sec=200, handle_exception=True)
开发者ID:LandoCalrizzian,项目名称:cfme_tests,代码行数:50,代码来源:test_cloud_init_provisioning.py

示例10: testing_instance

def testing_instance(request, setup_provider, provider):
    """ Fixture to provision instance on the provider
    """
    instance = Instance.factory("test_inst_pwrctl_{}".format(fauxfactory.gen_alpha(8)), provider)
    if not provider.mgmt.does_vm_exist(instance.name):
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
        request.addfinalizer(instance.delete_from_provider)
    elif instance.provider.type == "ec2" and \
            provider.mgmt.is_vm_state(instance.name, provider.mgmt.states['deleted']):
        provider.mgmt.set_name(
            instance.name, 'test_terminated_{}'.format(fauxfactory.gen_alphanumeric(8)))
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
        request.addfinalizer(instance.delete_from_provider)
    return instance
开发者ID:akrzos,项目名称:cfme_tests,代码行数:14,代码来源:test_instance_power_control.py

示例11: test_provision_cloud_init

def test_provision_cloud_init(request, setup_provider, provider, provisioning,
                              setup_ci_template, vm_name):
    """ Tests provisioning from a template with cloud_init

    Metadata:
        test_flag: cloud_init, provision
    """
    image = provisioning.get('ci-image', None) or provisioning['image']['name']
    note = ('Testing provisioning from image {} to vm {} on provider {}'.format(
        image, vm_name, provider.key))
    logger.info(note)

    mgmt_system = provider.mgmt

    instance = Instance.factory(vm_name, provider, image)

    request.addfinalizer(instance.delete_from_provider)

    inst_args = {
        'email': '[email protected]',
        'first_name': 'Image',
        'last_name': 'Provisioner',
        'notes': note,
        'instance_type': provisioning['instance_type'],
        'availability_zone': provisioning['availability_zone'],
        'security_groups': [provisioning['security_group']],
        'guest_keypair': provisioning['guest_keypair'],
        'custom_template': {'name': [provisioning['ci-template']]},
    }

    if provider.type == "openstack":
        floating_ip = mgmt_system.get_first_floating_ip()
        inst_args['cloud_network'] = provisioning['cloud_network']
        inst_args['public_ip_address'] = floating_ip

    logger.info('Instance args: {}'.format(inst_args))

    instance.create(**inst_args)

    connect_ip, tc = wait_for(mgmt_system.get_ip_address, [vm_name], num_sec=300,
                              handle_exception=True)

    # Check that we can at least get the uptime via ssh this should only be possible
    # if the username and password have been set via the cloud-init script so
    # is a valid check
    sshclient = ssh.SSHClient(hostname=connect_ip, username=provisioning['ci-username'],
                              password=provisioning['ci-pass'])
    wait_for(sshclient.uptime, num_sec=200, handle_exception=True)
开发者ID:ManageIQ,项目名称:integration_tests,代码行数:48,代码来源:test_cloud_init_provisioning.py

示例12: testing_instance

def testing_instance(request, setup_provider, provider):
    """ Fixture to provision instance on the provider
    """
    instance = Instance.factory(random_vm_name('pwr-c'), provider)
    if not provider.mgmt.does_vm_exist(instance.name):
        instance.create_on_provider(timeout=1000, allow_skip="default", find_in_cfme=True)
        request.addfinalizer(instance.delete_from_provider)
        provider.refresh_provider_relationships()
    elif instance.provider.type == "ec2" and \
            provider.mgmt.is_vm_state(instance.name, provider.mgmt.states['deleted']):
        provider.mgmt.set_name(
            instance.name, 'test_terminated_{}'.format(fauxfactory.gen_alphanumeric(8)))
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
        request.addfinalizer(instance.delete_from_provider)
        provider.refresh_provider_relationships()
    instance.wait_to_appear()
    return instance
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:17,代码来源:test_instance_power_control.py

示例13: testing_instance

def testing_instance(setup_provider, provider):
    """ Fixture to provision instance on the provider
    """
    instance = Instance.factory(random_vm_name('pwr-c'), provider)
    if not provider.mgmt.does_vm_exist(instance.name):
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)
    elif instance.provider.type == "ec2" and \
            provider.mgmt.is_vm_state(instance.name, provider.mgmt.states['deleted']):
        provider.mgmt.set_name(
            instance.name, 'test_terminated_{}'.format(fauxfactory.gen_alphanumeric(8)))
        instance.create_on_provider(allow_skip="default", find_in_cfme=True)

    yield instance

    logger.info('Fixture cleanup, deleting test instance: %s', instance.name)
    try:
        provider.mgmt.delete_vm(instance.name)
    except Exception:
        logger.exception('Exception when deleting testing_instance: %s', instance.name)
开发者ID:akarol,项目名称:cfme_tests,代码行数:19,代码来源:test_instance_power_control.py

示例14: test_tenant_quota_enforce_via_lifecycle_cloud

def test_tenant_quota_enforce_via_lifecycle_cloud(request, appliance, provider, setup_provider,
                                            set_roottenant_quota, extra_msg, custom_prov_data,
                                            approve, prov_data, vm_name, template_name):
    """Test Tenant Quota in UI"""
    prov_data.update(custom_prov_data)
    prov_data['catalog']['vm_name'] = vm_name
    prov_data.update({
        'request': {'email': 'test_{}@example.com'.format(fauxfactory.gen_alphanumeric())}})
    instance = Instance.factory(vm_name, provider, template_name)
    instance.create(**prov_data)

    # nav to requests page to check quota validation
    request_description = 'Provision from [{}] to [{}{}]'.format(template_name, vm_name, extra_msg)
    provision_request = appliance.collections.requests.instantiate(request_description)
    if approve:
        provision_request.approve_request(method='ui', reason="Approved")
    provision_request.wait_for_request(method='ui')
    assert provision_request.row.reason.text == "Quota Exceeded"

    request.addfinalizer(provision_request.remove_request)
开发者ID:LandoCalrizzian,项目名称:cfme_tests,代码行数:20,代码来源:test_tenant_quota.py

示例15: testing_instance

def testing_instance(request, setup_provider, provider, provisioning, vm_name):
    """ Fixture to prepare instance parameters for provisioning
    """
    image = provisioning['image']['name']
    note = ('Testing provisioning from image {} to vm {} on provider {}'.format(
        image, vm_name, provider.key))

    instance = Instance.factory(vm_name, provider, image)

    request.addfinalizer(instance.delete_from_provider)

    inst_args = {
        'email': '[email protected]',
        'first_name': 'Image',
        'last_name': 'Provisioner',
        'notes': note,
    }
    if not isinstance(provider, AzureProvider):
        inst_args['instance_type'] = provisioning['instance_type']
        inst_args['availability_zone'] = provisioning['availability_zone']
        inst_args['security_groups'] = [provisioning['security_group']]
        inst_args['guest_keypair'] = provisioning['guest_keypair']

    if isinstance(provider, OpenStackProvider):
        inst_args['cloud_network'] = provisioning['cloud_network']

    if isinstance(provider, GCEProvider):
        inst_args['cloud_network'] = provisioning['cloud_network']
        inst_args['boot_disk_size'] = provisioning['boot_disk_size']
        inst_args['is_preemtible'] = True if current_version() >= "5.7" else None

    if isinstance(provider, AzureProvider):
        inst_args['cloud_network'] = provisioning['virtual_net']
        inst_args['cloud_subnet'] = provisioning['subnet_range']
        inst_args['security_groups'] = provisioning['network_nsg']
        inst_args['resource_groups'] = provisioning['resource_group']
        inst_args['instance_type'] = provisioning['vm_size'].lower() \
            if current_version() >= "5.7" else provisioning['vm_size']
        inst_args['admin_username'] = provisioning['vm_user']
        inst_args['admin_password'] = provisioning['vm_password']
    return instance, inst_args
开发者ID:RonnyPfannschmidt,项目名称:cfme_tests,代码行数:41,代码来源:test_provisioning.py


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