예제 #1
0
    def test_positive_crud_gce_cr(self, module_org, module_location):
        """Create, Read, Update and Delete GCE compute resources

        :id: b324f8cd-d509-4d7a-b738-08aefafdc2b5

        :expectedresults: GCE Compute resource should be created, read, updated and deleted

        :CaseImportance: Critical

        :CaseLevel: Component
        """
        cr_name = gen_string('alpha')
        # Testing Create
        compresource = entities.GCEComputeResource(
            name=cr_name,
            provider='GCE',
            email=GCE_SETTINGS['client_email'],
            key_path=GCE_SETTINGS['cert_path'],
            project=GCE_SETTINGS['project_id'],
            zone=GCE_SETTINGS['zone'],
            organization=[module_org],
            location=[module_location],
        ).create()
        assert compresource.name == cr_name
        # Testing Update
        new_name = gen_string('alpha')
        description = gen_string('utf8')
        new_zone = random.choice(VALID_GCE_ZONES)
        compresource.name = new_name
        compresource.description = description
        compresource.zone = new_zone
        compresource.update(['name', 'description', 'zone'])
        # Testing Read
        updated = entities.GCEComputeResource(id=compresource.id).read()
        assert updated.name == new_name
        assert updated.description == description
        assert updated.zone == new_zone
        # Testing Delete
        updated.delete()
        assert not entities.GCEComputeResource().search(
            query={'search': 'name={}'.format(new_name)}
        )
예제 #2
0
def module_gce_compute(module_org, module_location, gce_cert):
    gce_cr = entities.GCEComputeResource(
        name=gen_string('alphanumeric'),
        provider='GCE',
        email=gce_cert['client_email'],
        key_path=settings.gce.cert_path,
        project=gce_cert['project_id'],
        zone=settings.gce.zone,
        organization=[module_org],
        location=[module_location],
    ).create()
    return gce_cr
예제 #3
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