Esempio n. 1
0
    def class_host_custom_ft(
        self,
        azurermclient,
        module_azurerm_custom_finishimg,
        module_azurerm_cr,
        default_architecture,
        module_domain,
        module_location,
        module_org,
        default_os,
        default_smart_proxy,
        module_puppet_environment,
    ):
        """
        Provisions the host on AzureRM using Finish template
        Later in tests this host will be used to perform assertions
        """

        skip_yum_update_during_provisioning(
            template='Kickstart default finish')
        host = entities.Host(
            architecture=default_architecture,
            build=True,
            compute_resource=module_azurerm_cr,
            compute_attributes=self.compute_attrs,
            interfaces_attributes=self.interfaces_attributes,
            domain=module_domain,
            organization=module_org,
            operatingsystem=default_os,
            location=module_location,
            name=self.hostname,
            provision_method='image',
            image=module_azurerm_custom_finishimg,
            root_pass=gen_string('alphanumeric'),
            environment=module_puppet_environment,
            puppet_proxy=default_smart_proxy,
            puppet_ca_proxy=default_smart_proxy,
        ).create()
        yield host
        skip_yum_update_during_provisioning(
            template='Kickstart default finish', reverse=True)
        host.delete()
Esempio n. 2
0
 def class_byos_ft_host(
     self,
     azurermclient,
     module_azurerm_byos_finishimg,
     module_azurerm_cr,
     default_architecture,
     module_domain,
     module_location,
     module_org,
     default_os,
     default_smart_proxy,
     module_puppet_environment,
 ):
     """
     Provisions the host on AzureRM with BYOS Image
     Later in tests this host will be used to perform assertions
     """
     set_hammer_api_timeout()
     skip_yum_update_during_provisioning(
         template='Kickstart default finish')
     host = Host.create(
         {
             'name': self.hostname,
             'compute-resource': module_azurerm_cr.name,
             'compute-attributes': self.compute_attrs,
             'interface': self.interfaces_attributes,
             'location-id': module_location.id,
             'organization-id': module_org.id,
             'domain-id': module_domain.id,
             'architecture-id': default_architecture.id,
             'operatingsystem-id': default_os.id,
             'root-password': gen_string('alpha'),
             'image': module_azurerm_byos_finishimg.name,
             'volume': "disk_size_gb=5",
         },
         timeout=1800,
     )
     yield host
     skip_yum_update_during_provisioning(
         template='Kickstart default finish', reverse=True)
     Host.delete({'name': self.fullhostname}, timeout=1800)
     set_hammer_api_timeout(reverse=True)
Esempio n. 3
0
 def class_host_ud(
     self,
     azurermclient,
     module_azurerm_cloudimg,
     module_azurerm_cr,
     default_architecture,
     module_domain,
     module_location,
     module_org,
     default_os,
     default_smart_proxy,
     module_puppet_environment,
     azurerm_hostgroup,
 ):
     """
     Provisions the host on AzureRM using UserData template
     Later in tests this host will be used to perform assertions
     """
     set_hammer_api_timeout()
     skip_yum_update_during_provisioning(
         template='Kickstart default user data')
     host = Host.create(
         {
             'name': self.hostname,
             'compute-attributes': self.compute_attrs,
             'interface': self.interfaces_attributes,
             'image': module_azurerm_cloudimg.name,
             'hostgroup': azurerm_hostgroup.name,
             'location': module_location.name,
             'organization': module_org.name,
             'operatingsystem-id': default_os.id,
         },
         timeout=1800,
     )
     yield host
     skip_yum_update_during_provisioning(
         template='Kickstart default user data', reverse=True)
     Host.delete({'name': self.fullhostname}, timeout=1800)
     set_hammer_api_timeout(reverse=True)
Esempio n. 4
0
 def test_post_create_gce_cr_and_host(self, arch_os_domain, delete_host):
     """"""
     arch, os, domain_name = arch_os_domain
     hostname = gen_string('alpha')
     self.__class__.fullhost = f'{hostname}.{domain_name}'.lower()
     preentities = get_entity_data(self.__class__.__name__)
     gce_cr = entities.GCEComputeResource().search(
         query={'search': f'name={preentities["cr_name"]}'})[0]
     org = entities.Organization().search(
         query={'search': f'name={preentities["org"]}'})[0]
     loc = entities.Location().search(
         query={'search': f'name={preentities["loc"]}'})[0]
     compute_attrs = {
         'machine_type': 'g1-small',
         'network': 'default',
         'associate_external_ip': True,
         'volumes_attributes': {
             '0': {
                 'size_gb': '10'
             }
         },
         'image_id': LATEST_RHEL7_GCE_IMG_UUID,
     }
     # Host Provisioning Tests
     try:
         skip_yum_update_during_provisioning(
             template='Kickstart default finish')
         gce_hst = entities.Host(
             name=hostname,
             organization=org,
             location=loc,
             root_pass=gen_string('alphanumeric'),
             architecture=arch,
             compute_resource=gce_cr,
             domain=entities.Domain().search(
                 query={'search': f'name={domain_name}'})[0],
             compute_attributes=compute_attrs,
             operatingsystem=os,
             provision_method='image',
         ).create()
     finally:
         skip_yum_update_during_provisioning(
             template='Kickstart default finish', reverse=True)
     wait_for(
         lambda: entities.Host().search(query={
             'search': f'name={self.fullhost}'
         })[0].build_status_label == 'Installed',
         timeout=400,
         delay=15,
         silent_failure=True,
         handle_exception=True,
     )
     assert gce_hst.name == self.fullhost
     gce_hst = entities.Host(id=gce_hst.id).read()
     assert gce_hst.build_status_label == 'Installed'
     # CR Manipulation Tests
     newgce_name = gen_string('alpha')
     newgce_zone = random.choice(VALID_GCE_ZONES)
     gce_cr.name = newgce_name
     gce_cr.zone = newgce_zone
     gce_cr.update(['name', 'zone'])
     gce_cr = entities.GCEComputeResource(id=gce_cr.id).read()
     assert gce_cr.name == newgce_name
     assert gce_cr.zone == newgce_zone
Esempio n. 5
0
def test_positive_end_to_end_azurerm_ft_host_provision(
    session,
    azurermclient,
    module_azurerm_finishimg,
    module_azurerm_cr,
    module_domain,
    module_org,
    module_location,
    module_azure_hg,
):

    """Provision Host with hostgroup and Compute-profile using
    finish template on AzureRm compute resource

    :id: d64d249d-70a2-4329-bff4-3b50b8596c44

    :expectedresults:
            1. Host is provisioned.
            2. Host is deleted Successfully.

    :CaseLevel: System
    """

    hostname = gen_string('alpha')
    fqdn = '{}.{}'.format(hostname, module_domain.name).lower()

    with session:
        session.organization.select(org_name=module_org.name)
        session.location.select(loc_name=module_location.name)

        # Provision Host
        try:
            skip_yum_update_during_provisioning(template='Kickstart default finish')
            session.host.create(
                {
                    'host.name': hostname,
                    'host.hostgroup': module_azure_hg.name,
                    'provider_content.operating_system.root_password': gen_string('alpha'),
                    'provider_content.operating_system.image': module_azurerm_finishimg.name,
                }
            )

            host_info = session.host.get_details(fqdn)
            assert host_info['properties']['properties_table']['Build'] == 'Installed'
            assert (
                host_info['properties']['properties_table']['Host group'] == module_azure_hg.name
            )

            # AzureRm Cloud assertion
            azurecloud_vm = azurermclient.get_vm(name=hostname.lower())
            assert azurecloud_vm
            assert azurecloud_vm.is_running
            assert azurecloud_vm.name == hostname.lower()
            assert azurecloud_vm.ip == host_info['properties']['properties_table']['IP Address']
            assert azurecloud_vm.type == AZURERM_VM_SIZE_DEFAULT

            # Host Delete
            session.host.delete(fqdn)
            assert not session.host.search(fqdn)

            # AzureRm Cloud assertion
            assert not azurecloud_vm.exists

        except Exception as error:
            azure_vm = entities.Host().search(query={'search': 'name={}'.format(fqdn)})
            if azure_vm:
                azure_vm[0].delete(synchronous=False)
            raise error

        finally:
            skip_yum_update_during_provisioning(template='Kickstart default finish', reverse=True)
Esempio n. 6
0
def test_positive_azurerm_host_provision_ud(
    session,
    azurermclient,
    module_azurerm_cloudimg,
    module_azurerm_cr,
    module_domain,
    default_os,
    module_org,
    module_location,
    module_azure_hg,
):

    """Provision a Host with hostgroup and Compute-profile using
    cloud-init image on AzureRm compute resource

    :id: 2dc6c494-0e80-4845-af8f-43d37f69a093

    :expectedresults: Host is provisioned successfully.

    :CaseImportance: Critical

    :CaseLevel: System
    """

    hostname = gen_string('alpha')
    fqdn = '{}.{}'.format(hostname, module_domain.name).lower()

    with session:
        session.organization.select(org_name=module_org.name)
        session.location.select(loc_name=module_location.name)

        # Provision Host
        try:
            skip_yum_update_during_provisioning(template='Kickstart default user data')
            session.host.create(
                {
                    'host.name': hostname,
                    'host.hostgroup': module_azure_hg.name,
                    'provider_content.operating_system.root_password': gen_string('alpha'),
                    'provider_content.operating_system.image': module_azurerm_cloudimg.name,
                }
            )

            host_info = session.host.get_details(fqdn)
            assert host_info['properties']['properties_table']['Build'] == 'Pending installation'
            assert (
                host_info['properties']['properties_table']['Host group'] == module_azure_hg.name
            )

            # AzureRm Cloud assertion
            azurecloud_vm = azurermclient.get_vm(name=hostname.lower())
            assert azurecloud_vm
            assert azurecloud_vm.is_running
            assert azurecloud_vm.name == hostname.lower()
            assert azurecloud_vm.ip == host_info['properties']['properties_table']['IP Address']
            assert azurecloud_vm.type == AZURERM_VM_SIZE_DEFAULT

        finally:
            skip_yum_update_during_provisioning(
                template='Kickstart default user data', reverse=True
            )
            azure_vm = entities.Host().search(query={'search': 'name={}'.format(fqdn)})
            if azure_vm:
                azure_vm[0].delete(synchronous=False)