Beispiel #1
0
    def setUpClass(cls):
        super().setUpClass()
        bridge = settings.vlan_networking.bridge
        # RHV Settings
        cls.rhev_url = settings.rhev.hostname
        cls.rhev_password = settings.rhev.password
        cls.rhev_username = settings.rhev.username
        cls.rhev_datacenter = settings.rhev.datacenter
        cls.rhev_img_name = settings.rhev.image_name
        cls.rhev_img_arch = settings.rhev.image_arch
        cls.rhev_img_os = settings.rhev.image_os
        cls.rhev_img_user = settings.rhev.image_username
        cls.rhev_img_pass = settings.rhev.image_password
        cls.rhev_vm_name = settings.rhev.vm_name
        cls.rhev_storage_domain = settings.rhev.storage_domain
        cls.rhv_api = RHEVMSystem(
            hostname=cls.rhev_url.split('/')[2],
            username=cls.rhev_username,
            password=cls.rhev_password,
            version='4.0',
            verify=False,
        )
        cls.cluster_id = cls.rhv_api.get_cluster(cls.rhev_datacenter).id
        cls.storage_id = cls.rhv_api.get_storage_domain(cls.rhev_storage_domain).id
        cls.network_id = (
            cls.rhv_api.api.system_service().networks_service().list(search=f'name={bridge}')[0].id
        )
        if is_open('BZ:1685949'):
            dc = cls.rhv_api._data_centers_service.list(search=f'name={cls.rhev_datacenter}')[0]
            dc = cls.rhv_api._data_centers_service.data_center_service(dc.id)
            cls.quota = dc.quotas_service().list()[0].id
        else:
            cls.quota = 'Default'

        # Vmware Settings
        cls.vmware_server = settings.vmware.vcenter
        cls.vmware_password = settings.vmware.password
        cls.vmware_username = settings.vmware.username
        cls.vmware_datacenter = settings.vmware.datacenter
        cls.vmware_img_name = settings.vmware.image_name
        cls.vmware_img_arch = settings.vmware.image_arch
        cls.vmware_img_os = settings.vmware.image_os
        cls.vmware_img_user = settings.vmware.image_username
        cls.vmware_img_pass = settings.vmware.image_password
        cls.vmware_vm_name = settings.vmware.vm_name
        cls.current_interface = VMWARE_CONSTANTS.get('network_interfaces') % bridge
        cls.vmware_api = VMWareSystem(
            hostname=cls.vmware_server, username=cls.vmware_username, password=cls.vmware_password
        )
        cls.vmware_net_id = cls.vmware_api.get_network(cls.current_interface)._moId

        # Provisioning setup
        cls.org = entities.Organization(name=gen_string('alpha')).create()
        cls.org_name = cls.org.name
        cls.loc = entities.Location(name=gen_string('alpha'), organization=[cls.org]).create()
        cls.loc_name = cls.loc.name
        cls.config_env = configure_provisioning(
            compute=True, org=cls.org, loc=cls.loc, os=cls.rhev_img_os
        )
        cls.os_name = cls.config_env['os']
    def setUpClass(cls):
        super(ComputeResourceHostTestCase, cls).setUpClass()
        bridge = settings.vlan_networking.bridge
        # RHV Settings
        cls.rhev_url = settings.rhev.hostname
        cls.rhev_password = settings.rhev.password
        cls.rhev_username = settings.rhev.username
        cls.rhev_datacenter = settings.rhev.datacenter
        cls.rhev_img_name = settings.rhev.image_name
        cls.rhev_img_arch = settings.rhev.image_arch
        cls.rhev_img_os = settings.rhev.image_os
        cls.rhev_img_user = settings.rhev.image_username
        cls.rhev_img_pass = settings.rhev.image_password
        cls.rhev_vm_name = settings.rhev.vm_name
        cls.rhev_storage_domain = settings.rhev.storage_domain
        cls.rhv_api = RHEVMSystem(hostname=cls.rhev_url.split('/')[2],
                                  username=cls.rhev_username,
                                  password=cls.rhev_password,
                                  version='4.0',
                                  verify=False)
        cls.cluster_id = cls.rhv_api.get_cluster(cls.rhev_datacenter).id
        cls.storage_id = cls.rhv_api._get_storage_domain(
            cls.rhev_storage_domain).id
        cls.network_id = (
            cls.rhv_api.api.system_service().networks_service().list(
                search='name={0}'.format(bridge))[0].id)

        # Vmware Settings
        cls.vmware_server = settings.vmware.vcenter
        cls.vmware_password = settings.vmware.password
        cls.vmware_username = settings.vmware.username
        cls.vmware_datacenter = settings.vmware.datacenter
        cls.vmware_img_name = settings.vmware.image_name
        cls.vmware_img_arch = settings.vmware.image_arch
        cls.vmware_img_os = settings.vmware.image_os
        cls.vmware_img_user = settings.vmware.image_username
        cls.vmware_img_pass = settings.vmware.image_password
        cls.vmware_vm_name = settings.vmware.vm_name
        cls.current_interface = (VMWARE_CONSTANTS.get('network_interfaces') %
                                 bridge)
        cls.vmware_api = VMWareSystem(hostname=cls.vmware_server,
                                      username=cls.vmware_username,
                                      password=cls.vmware_password)
        cls.vmware_net_id = cls.vmware_api.get_obj(
            vimtype=vim.Network, name=cls.current_interface)._moId

        # Provisioning setup
        cls.org = entities.Organization(name=gen_string('alpha')).create()
        cls.org_name = cls.org.name
        cls.loc = entities.Location(
            name=gen_string('alpha'),
            organization=[cls.org],
        ).create()
        cls.loc_name = cls.loc.name
        cls.config_env = configure_provisioning(compute=True,
                                                org=cls.org,
                                                loc=cls.loc,
                                                os=cls.rhev_img_os)
        cls.os_name = cls.config_env['os']
Beispiel #3
0
def run(**kwargs):
    thread_queue = []
    providers = list_provider_keys("virtualcenter")
    if kwargs['provider_data']:
        mgmt_sys = providers = kwargs['provider_data']['management_systems']
    else:
        mgmt_sys = cfme_data.management_systems

    # Store thread results, no need to use a lock
    # because threads will not be adding new keys
    results = {provider: None for provider in providers}

    for provider in providers:
        # skip provider if block_upload is set
        if (mgmt_sys[provider].get('template_upload') and
                mgmt_sys[provider]['template_upload'].get('block_upload')):
            logger.info('Skipping upload on %s due to block_upload', provider)
            continue
        if kwargs['provider_data']:
            if mgmt_sys[provider]['type'] != 'virtualcenter':
                continue
            username = mgmt_sys[provider]['username']
            password = mgmt_sys[provider]['password']
        else:
            creds = credentials[mgmt_sys[provider]['credentials']]
            username = creds['username']
            password = creds['password']
        host_ip = mgmt_sys[provider]['ipaddress']
        hostname = mgmt_sys[provider]['hostname']
        client = VMWareSystem(hostname, username, password)

        if not net.is_pingable(host_ip):
            continue
        thread = Thread(target=upload_template,
                        args=(client, hostname, username, password, provider,
                              kwargs.get('image_url'), kwargs.get('template_name'),
                              kwargs['provider_data'], kwargs['stream'], results))
        thread.daemon = True
        thread_queue.append(thread)
        thread.start()

    for thread in thread_queue:
        thread.join()

    failed_providers = [provider for provider, result in results.items() if result is False]
    skipped_providers = [provider for provider, result in results.items() if result is None]
    passed_providers = [provider for provider, result in results.items() if result]

    logger.info("providers skipped: %s", skipped_providers)
    logger.info("providers passed: %s", passed_providers)
    logger.info("providers failed: %s", failed_providers)

    if not passed_providers:
        raise Exception("Template upload failed for all providers")
    else:
        logger.info("Upload passed for at least 1 provider... success!")
def run(**kwargs):

    try:
        thread_queue = []
        providers = list_provider_keys("virtualcenter")
        if kwargs['provider_data']:
            mgmt_sys = providers = kwargs['provider_data'][
                'management_systems']
        else:
            mgmt_sys = cfme_data.management_systems

        for provider in providers:
            # skip provider if block_upload is set
            if (mgmt_sys[provider].get('template_upload') and
                    mgmt_sys[provider]['template_upload'].get('block_upload')):
                logger.info('Skipping upload on {} due to block_upload'.format(
                    provider))
                continue
            if kwargs['provider_data']:
                if mgmt_sys[provider]['type'] != 'virtualcenter':
                    continue
                username = mgmt_sys[provider]['username']
                password = mgmt_sys[provider]['password']
            else:
                creds = credentials[mgmt_sys[provider]['credentials']]
                username = creds['username']
                password = creds['password']
            host_ip = mgmt_sys[provider]['ipaddress']
            hostname = mgmt_sys[provider]['hostname']
            client = VMWareSystem(hostname, username, password)

            if not net.is_pingable(host_ip):
                continue
            thread = Thread(target=upload_template,
                            args=(client, hostname, username, password,
                                  provider, kwargs.get('image_url'),
                                  kwargs.get('template_name'),
                                  kwargs['provider_data'], kwargs['stream']))
            thread.daemon = True
            thread_queue.append(thread)
            thread.start()

        for thread in thread_queue:
            thread.join()
    except Exception:
        logger.exception('Exception during run method')
        return False
Beispiel #5
0
def vmware(bridge):
    vmware = {}
    vmware['vmware_server'] = settings.vmware.vcenter
    vmware['vmware_password'] = settings.vmware.password
    vmware['vmware_username'] = settings.vmware.username
    vmware['vmware_datacenter'] = settings.vmware.datacenter
    vmware['vmware_img_name'] = settings.vmware.image_name
    vmware['vmware_img_arch'] = settings.vmware.image_arch
    vmware['vmware_img_os'] = settings.vmware.image_os
    vmware['vmware_img_user'] = settings.vmware.image_username
    vmware['vmware_img_pass'] = settings.vmware.image_password
    vmware['vmware_vm_name'] = settings.vmware.vm_name
    vmware['current_interface'] = VMWARE_CONSTANTS.get('network_interfaces') % bridge
    vmware['vmware_api'] = VMWareSystem(
        hostname=vmware['vmware_server'],
        username=vmware['vmware_username'],
        password=vmware['vmware_password'],
    )
    vmware['vmware_net_id'] = vmware['vmware_api'].get_network(vmware['current_interface'])._moId
    return vmware
def vmware():
    bridge = settings.vlan_networking.bridge
    vmware = type("", (), {})()
    vmware.vmware_server = settings.vmware.vcenter
    vmware.vmware_password = settings.vmware.password
    vmware.vmware_username = settings.vmware.username
    vmware.vmware_datacenter = settings.vmware.datacenter
    vmware.vmware_img_name = settings.vmware.image_name
    vmware.vmware_img_arch = settings.vmware.image_arch
    vmware.vmware_img_os = settings.vmware.image_os
    vmware.vmware_img_user = settings.vmware.image_username
    vmware.vmware_img_pass = settings.vmware.image_password
    vmware.vmware_vm_name = settings.vmware.vm_name
    vmware.current_interface = VMWARE_CONSTANTS.get('network_interfaces') % bridge
    vmware.vmware_api = VMWareSystem(
        hostname=vmware.vmware_server,
        username=vmware.vmware_username,
        password=vmware.vmware_password,
    )
    vmware.vmware_net_id = vmware.vmware_api.get_network(vmware.current_interface)._moId
    return vmware
Beispiel #7
0
def run(**kwargs):

    try:
        thread_queue = []
        providers = list_provider_keys("virtualcenter")
        if kwargs['provider_data']:
            mgmt_sys = providers = kwargs['provider_data'][
                'management_systems']
        for provider in providers:
            if kwargs['provider_data']:
                if mgmt_sys[provider]['type'] != 'virtualcenter':
                    continue
                username = mgmt_sys[provider]['username']
                password = mgmt_sys[provider]['password']
            else:
                mgmt_sys = cfme_data['management_systems']
                creds = credentials[mgmt_sys[provider]['credentials']]
                username = creds['username']
                password = creds['password']
            host_ip = mgmt_sys[provider]['ipaddress']
            hostname = mgmt_sys[provider]['hostname']
            client = VMWareSystem(hostname, username, password)

            if not net.is_pingable(host_ip):
                continue
            thread = Thread(target=upload_template,
                            args=(client, hostname, username, password,
                                  provider, kwargs.get('image_url'),
                                  kwargs.get('template_name'),
                                  kwargs['provider_data'], kwargs['stream']))
            thread.daemon = True
            thread_queue.append(thread)
            thread.start()

        for thread in thread_queue:
            thread.join()
    except Exception as e:
        print(e)
        return False