Exemplo n.º 1
0
def test_negative_add_image_rhev_with_invalid_uuid(rhev, module_os):
    """Attempt to add invalid image to the RHEV compute resource

    :id: e8a653f9-9749-4c76-95ed-2411a7c0a117

    :setup: Images/templates should be present in RHEV-M itself,
        so that satellite can use them.

    :steps:

        1. Create a compute resource of type rhev.
        2. Create a image for the compute resource with invalid value for
           uuid parameter, compute-resource image create.

    :expectedresults: The image should not be added to the CR

    :BZ: 1829239
    """
    comp_res = make_compute_resource({
        'provider': 'Ovirt',
        'user': rhev.username,
        'password': rhev.password,
        'datacenter': rhev.datacenter,
        'url': rhev.hostname,
    })
    assert comp_res['name']
    with pytest.raises(CLIReturnCodeError):
        ComputeResource.image_create({
            'compute-resource': comp_res['name'],
            'name': f'img {gen_string(str_type="alpha")}',
            'uuid': f'invalidimguuid {gen_string(str_type="alpha")}',
            'operatingsystem': module_os.title,
            'architecture': rhev.image_arch,
            'username': "******",
        })
Exemplo n.º 2
0
    def test_negative_add_image_rhev_with_invalid_name(self):
        """Attempt to add invalid image name to the RHEV compute resource

        :id: 873a7d79-1e89-4e4f-81ca-b6db1e0246da

        :setup: Images/templates should be present in RHEV-M itself,
            so that satellite can use them.

        :steps:

            1. Create a compute resource of type rhev.
            2. Create a image for the compute resource with invalid value for
               name parameter, compute-resource image create.

        :expectedresults: The image should not be added to the CR

        """
        if self.image_uuid is None:
            self.skipTest('Missing configuration for rhev.image_uuid')

        comp_res = make_compute_resource({
            'provider': 'Ovirt',
            'user': self.username,
            'password': self.password,
            'datacenter': self.datacenter,
            'url': self.current_rhev_url,
        })

        self.assertTrue(comp_res['name'])
        with self.assertRaises(CLIReturnCodeError):
            ComputeResource.image_create({
                'compute-resource':
                comp_res['name'],
                # too long string (>255 chars)
                'name':
                'img {}'.format(gen_string(str_type='alphanumeric',
                                           length=256)),
                'uuid':
                self.image_uuid,
                'operatingsystem':
                self.os['title'],
                'architecture':
                self.image_arch,
                'username':
                "******",
            })
Exemplo n.º 3
0
    def test_positive_add_image_rhev_with_name(self):
        """Add images to the RHEV compute resource

        :id: 2da84165-a56f-4282-9343-94828fa69c13

        :setup: Images/templates should be present in RHEV-M itself,
            so that satellite can use them.

        :steps:

            1. Create a compute resource of type rhev.
            2. Create a image for the compute resource with valid parameter,
               compute-resource image create

        :expectedresults: The image is added to the CR successfully
        """
        if self.image_uuid is None:
            self.skipTest('Missing configuration for rhev.image_uuid')

        comp_res = make_compute_resource({
            'provider': 'Ovirt',
            'user': self.username,
            'password': self.password,
            'datacenter': self.datacenter,
            'url': self.current_rhev_url,
        })
        self.assertTrue(comp_res['name'])
        ComputeResource.image_create({
            'compute-resource':
            comp_res['name'],
            'name':
            'img {}'.format(gen_string(str_type='alpha')),
            'uuid':
            self.image_uuid,
            'operatingsystem':
            self.os['title'],
            'architecture':
            self.image_arch,
            'username':
            "******",
        })
        result = ComputeResource.image_list(
            {'compute-resource': comp_res['name']})
        self.assertEqual(result[0]['uuid'], self.image_uuid)
Exemplo n.º 4
0
def test_negative_add_image_rhev_with_invalid_name(rhev, module_os):
    """Attempt to add invalid image name to the RHEV compute resource

    :id: 873a7d79-1e89-4e4f-81ca-b6db1e0246da

    :setup: Images/templates should be present in RHEV-M itself,
        so that satellite can use them.

    :steps:

        1. Create a compute resource of type rhev.
        2. Create a image for the compute resource with invalid value for
           name parameter, compute-resource image create.

    :expectedresults: The image should not be added to the CR

    """
    if rhev.image_uuid is None:
        pytest.skip('Missing configuration for rhev.image_uuid')

    comp_res = make_compute_resource(
        {
            'provider': 'Ovirt',
            'user': rhev.username,
            'password': rhev.password,
            'datacenter': rhev.datacenter,
            'url': rhev.hostname,
        }
    )

    assert comp_res['name']
    with pytest.raises(CLIReturnCodeError):
        ComputeResource.image_create(
            {
                'compute-resource': comp_res['name'],
                # too long string (>255 chars)
                'name': f'img {gen_string(str_type="alphanumeric", length=256)}',
                'uuid': rhev.image_uuid,
                'operatingsystem': module_os.title,
                'architecture': rhev.image_arch,
                'username': "******",
            }
        )
Exemplo n.º 5
0
    def test_negative_add_image_rhev_with_invalid_uuid(self):
        """Attempt to add invalid image to the RHEV compute resource

        :id: e8a653f9-9749-4c76-95ed-2411a7c0a117

        :setup: Images/templates should be present in RHEV-M itself,
            so that satellite can use them.

        :steps:

            1. Create a compute resource of type rhev.
            2. Create a image for the compute resource with invalid value for
               uuid parameter, compute-resource image create.

        :expectedresults: The image should not be added to the CR

        :BZ: 1829239
        """
        comp_res = make_compute_resource({
            'provider': 'Ovirt',
            'user': self.username,
            'password': self.password,
            'datacenter': self.datacenter,
            'url': self.current_rhev_url,
        })
        self.assertTrue(comp_res['name'])
        with self.assertRaises(CLIReturnCodeError):
            ComputeResource.image_create({
                'compute-resource':
                comp_res['name'],
                'name':
                'img {}'.format(gen_string(str_type='alpha')),
                'uuid':
                'invalidimguuid {}'.format(gen_string(str_type='alpha')),
                'operatingsystem':
                self.os['title'],
                'architecture':
                self.image_arch,
                'username':
                "******",
            })
Exemplo n.º 6
0
def test_positive_add_image_rhev_with_name(rhev, module_os):
    """Add images to the RHEV compute resource

    :id: 2da84165-a56f-4282-9343-94828fa69c13

    :setup: Images/templates should be present in RHEV-M itself,
        so that satellite can use them.

    :steps:

        1. Create a compute resource of type rhev.
        2. Create a image for the compute resource with valid parameter,
           compute-resource image create

    :expectedresults: The image is added to the CR successfully
    """
    if rhev.image_uuid is None:
        pytest.skip('Missing configuration for rhev.image_uuid')

    comp_res = make_compute_resource(
        {
            'provider': 'Ovirt',
            'user': rhev.username,
            'password': rhev.password,
            'datacenter': rhev.datacenter,
            'url': rhev.hostname,
        }
    )
    assert comp_res['name']
    ComputeResource.image_create(
        {
            'compute-resource': comp_res['name'],
            'name': f'img {gen_string(str_type="alpha")}',
            'uuid': rhev.image_uuid,
            'operatingsystem': module_os.title,
            'architecture': rhev.image_arch,
            'username': "******",
        }
    )
    result = ComputeResource.image_list({'compute-resource': comp_res['name']})
    assert result[0]['uuid'] == rhev.image_uuid
Exemplo n.º 7
0
    def test_positive_image_crud(self, default_architecture, module_azurerm_cr, default_os, image):
        """ Finish template/Cloud_init image along with username is being Create, Read, Update and
        Delete in AzureRm compute resources

        :id: e4f40640-46dd-4ef8-8be5-99c625056aff

        :parametrized: yes

        :steps:
            1. Create an AzureRm Compute Resource.
            2. Create a finish template/Cloud_init based image in it.
            3. List/info the created image
            4. Update image name and username
            5. Delete created image

        :expectedresults: Finish template/Cloud_init image should be created, list, updated and
                          deleted in AzureRm CR along with username

        :CaseImportance: Critical

        :CaseLevel: Integration
        """

        # Create
        img_name = gen_string('alpha')
        username = gen_string('alpha')
        img_ft = ComputeResource.image_create(
            {
                'name': img_name,
                'operatingsystem-id': default_os.id,
                'architecture-id': default_architecture.id,
                'uuid': image,
                'compute-resource': module_azurerm_cr.name,
                'username': username,
                'user-data': 'no',
            }
        )[0]
        assert img_ft['message'] == 'Image created.'
        assert img_ft['name'] == img_name

        # Info Image
        img_info = ComputeResource.image_info(
            {'name': img_name, 'compute-resource': module_azurerm_cr.name}
        )[0]
        assert img_info['operating-system'] == default_os.title
        assert img_info['username'] == username
        assert img_info['uuid'] == image
        assert img_info['user-data'] == 'false'
        assert img_info['architecture'] == default_architecture.name

        # List image
        list_img = ComputeResource.image_list({'compute-resource': module_azurerm_cr.name})
        assert len(list_img) == 1
        assert list_img[0]['name'] == img_name

        # Update image
        new_img_name = gen_string('alpha')
        new_username = gen_string('alpha')
        result = ComputeResource.image_update(
            {
                'name': img_name,
                'compute-resource': module_azurerm_cr.name,
                'new-name': new_img_name,
                'username': new_username,
            }
        )[0]
        assert result['message'] == 'Image updated.'
        assert result['name'] == new_img_name

        img_info = ComputeResource.image_info(
            {'name': new_img_name, 'compute-resource': module_azurerm_cr.name}
        )[0]
        assert img_info['username'] == new_username

        # Delete Image
        result = ComputeResource.image_delete(
            {'name': new_img_name, 'compute-resource': module_azurerm_cr.name}
        )[0]
        assert result['message'] == 'Image deleted.'
        assert result['name'] == new_img_name
Exemplo n.º 8
0
def test_positive_provision_rhev_image_based_and_disassociate(
        provisioning, rhev, tear_down, setting_update):
    """Provision a host on RHEV compute resource using image-based provisioning

    :Requirement: Computeresource RHV

    :CaseComponent: ComputeResources-RHEV

    :Assignee: lhellebr

    :id: ba78858f-5cff-462e-a35d-f5aa4d11db52

    :parametrized: yes

    :customerscenario: true

    :BZ: 1356126

    :setup: RHEV with a template on it

    :steps:

        1. Create a RHEV CR
        1. Create an image on that CR
        2. Create a new host using that CR and image
        3. Disassociate the host from the CR

    :expectedresults: Host should be provisioned with image, associated to CR, then disassociated

    :CaseAutomation: Automated
    """
    try:
        name = gen_string('alpha')
        rhv_cr = ComputeResource.create({
            'name': name,
            'provider': 'Ovirt',
            'user': rhev.username,
            'password': rhev.password,
            'datacenter': rhev.datacenter,
            'url': rhev.hostname,
            'ovirt-quota': rhev.quota,
            'organizations': provisioning.org_name,
            'locations': provisioning.loc_name,
        })
        assert rhv_cr['name'] == name
        host_name = gen_string('alpha').lower()
        # use some RHEL (usually latest)
        os = (entities.OperatingSystem().search(
            query={
                'search':
                f'name="RedHat" AND (major="{RHEL_6_MAJOR_VERSION}" OR '
                f'major="{RHEL_7_MAJOR_VERSION}")'
            })[0].read())
        image = ComputeResource.image_create({
            'compute-resource': rhv_cr['name'],
            'name': f'img {gen_string(str_type="alpha")}',
            'uuid': rhev.image_uuid,
            'operatingsystem-id': os.id,
            'architecture': rhev.image_arch,
            'username': '******',
            'password': rhev.image_password,
            'user-data': 'yes',  # so finish template won't be used
        })
        host = make_host({
            'name':
            f'{host_name}',
            'organization':
            provisioning.org_name,
            'domain':
            provisioning.config_env['domain'],
            'subnet':
            provisioning.config_env['subnet'],
            'location':
            provisioning.loc_name,
            'compute-resource-id':
            rhv_cr.get('id'),
            'compute-attributes':
            f"cluster={rhev.cluster_id},"
            "cores=1,"
            "memory=1073741824,"
            "start=0",
            'ip':
            None,
            'mac':
            None,
            'interface':
            f"compute_name=nic1, compute_network={rhev.network_id}",
            'provision-method':
            'image',
            'operatingsystem-id':
            os.id,
            'architecture':
            rhev.image_arch,
            'image-id':
            f'{image[0]["id"]}',
        })
        hostname = f'{host_name}.{provisioning.config_env["domain"]}'
        assert hostname == host['name']
        host_info = Host.info({'name': hostname})
        # Check on RHV, if VM exists
        assert rhev.rhv_api.does_vm_exist(hostname)
        # Get the information of created VM
        rhv_vm = rhev.rhv_api.get_vm(hostname)
        # Assert of Satellite mac address for VM and Mac of VM created is same
        assert host_info.get('network').get(
            'mac') == rhv_vm.get_nics()[0].mac.address
        # Check the host is associated to the CR
        assert 'compute-resource' in host_info
        assert host_info['compute-resource'] == name
        # Done. Do not try to SSH, this image-based test should work even without
        # being in the same network as RHEV. We checked the VM exists and
        # that's enough.

        # Disassociate the host from the CR, check it's disassociated
        Host.disassociate({'name': hostname})
        host_info = Host.info({'name': hostname})
        assert 'compute-resource' not in host_info

    finally:

        # Now, let's just remove the host
        Host.delete({'id': host['id']})
        # Delete the VM since the disassociated VM won't get deleted
        rhv_vm.delete()