예제 #1
0
    def test_negative_delete_by_id(self):
        """Create HostGroup then delete it by wrong ID

        @id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3

        @assert: HostGroup is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.delete({'id': entity_id})
예제 #2
0
    def test_negative_delete_by_id(self):
        """Create HostGroup then delete it by wrong ID

        @feature: HostGroup

        @assert: HostGroup is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.delete({'id': entity_id})
예제 #3
0
    def test_negative_delete_by_id(self):
        """Create HostGroup then delete it by wrong ID

        @id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3

        @assert: HostGroup is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.delete({'id': entity_id})
예제 #4
0
    def test_positive_impact_delete_attribute(self):
        """Impact on variable after deleting associated attribute.

        :id: ac6f3a65-ed39-4e97-bdee-349f08bd878e

        :steps:

            1.  Create a variable with matcher for some attribute.
            2.  Delete the attribute.
            3.  Recreate the attribute with same name as earlier.

        :expectedresults:

            1.  The matcher for deleted attribute removed from variable.
            2.  On recreating attribute, the matcher should not reappear in
                variable.

        :CaseLevel: Integration
        """
        hostgroup_name = gen_string('alpha')
        matcher_value = gen_string('alpha')
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet_class['name']})
        hostgroup = make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        SmartVariable.add_override_value({
            'smart-variable-id':
            smart_variable['id'],
            'match':
            'hostgroup={0}'.format(hostgroup_name),
            'value':
            matcher_value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'hostgroup={0}'.format(hostgroup_name))
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'],
            matcher_value,
        )
        HostGroup.delete({'id': hostgroup['id']})
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
        make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
예제 #5
0
    def test_negative_delete_by_id(self):
        """Create HostGroup then delete it by wrong ID

        @feature: HostGroup

        @assert: HostGroup is not deleted
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.delete({'id': entity_id})
예제 #6
0
    def test_negative_delete_by_id(self):
        """Create HostGroup then delete it by wrong ID

        :id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3

        :expectedresults: HostGroup is not deleted

        :CaseLevel: Integration
        """
        entity_id = invalid_id_list()[0]
        with self.assertRaises(CLIReturnCodeError):
            HostGroup.delete({'id': entity_id})
예제 #7
0
    def test_positive_impact_delete_attribute(self):
        """Impact on variable after deleting associated attribute.

        @id: ac6f3a65-ed39-4e97-bdee-349f08bd878e

        @steps:

        1.  Create a variable with matcher for some attribute.
        2.  Delete the attribute.
        3.  Recreate the attribute with same name as earlier.

        @assert:

        1.  The matcher for deleted attribute removed from variable.
        2.  On recreating attribute, the matcher should not reappear in
        variable.

        @CaseLevel: Integration
        """
        hostgroup_name = gen_string('alpha')
        matcher_value = gen_string('alpha')
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet_class['name']})
        hostgroup = make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        SmartVariable.add_override_value({
            'smart-variable-id': smart_variable['id'],
            'match': 'hostgroup={0}'.format(hostgroup_name),
            'value': matcher_value,
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(
            smart_variable['override-values']['values']['1']['match'],
            'hostgroup={0}'.format(hostgroup_name)
        )
        self.assertEqual(
            smart_variable['override-values']['values']['1']['value'],
            matcher_value,
        )
        HostGroup.delete({'id': hostgroup['id']})
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
        make_hostgroup({
            'name': hostgroup_name,
            'environment-id': self.env['id'],
            'puppet-class-ids': self.puppet_class['id']
        })
        smart_variable = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(len(smart_variable['override-values']['values']), 0)
예제 #8
0
    def test_negative_delete_by_id(self):
        """Create HostGroup then delete it by wrong ID

        :id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3

        :expectedresults: HostGroup is not deleted

        :CaseImportance: Critical
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.delete({'id': entity_id})
예제 #9
0
    def test_negative_delete_by_id(self):
        """Create HostGroup then delete it by wrong ID

        :id: 047c9f1a-4dd6-4fdc-b7ed-37cc725c68d3

        :expectedresults: HostGroup is not deleted

        :CaseImportance: Critical
        """
        for entity_id in invalid_id_list():
            with self.subTest(entity_id):
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.delete({'id': entity_id})
예제 #10
0
    def test_positive_delete_by_id(self):
        """Create HostGroup with valid values then delete it
        by ID

        @id: fe7dedd4-d7c3-4c70-b70d-c2deff357b76

        @assert: HostGroup is deleted
        """
        for name in valid_hostgroups_list():
            with self.subTest(name):
                hostgroup = make_hostgroup({'name': name})
                HostGroup.delete({'id': hostgroup['id']})
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.info({'id': hostgroup['id']})
예제 #11
0
    def test_positive_delete_by_id(self):
        """Create HostGroup with valid values then delete it
        by ID

        @feature: HostGroup

        @assert: HostGroup is deleted
        """
        for name in valid_hostgroups_list():
            with self.subTest(name):
                hostgroup = make_hostgroup({'name': name})
                HostGroup.delete({'id': hostgroup['id']})
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.info({'id': hostgroup['id']})
예제 #12
0
    def test_positive_delete(self):
        """@test: Create HostGroup with valid values then delete it
        by ID

        @feature: HostGroup

        @assert: HostGroup is deleted
        """
        for name in valid_data_list():
            with self.subTest(name):
                hostgroup = make_hostgroup({"name": name})
                HostGroup.delete({"id": hostgroup["id"]})
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.info({"id": hostgroup["id"]})
예제 #13
0
    def test_positive_delete_by_id(self):
        """Create HostGroup with valid values then delete it
        by ID

        :id: fe7dedd4-d7c3-4c70-b70d-c2deff357b76

        :expectedresults: HostGroup is deleted

        :CaseImportance: Critical
        """
        for name in valid_hostgroups_list():
            with self.subTest(name):
                hostgroup = make_hostgroup({'name': name})
                HostGroup.delete({'id': hostgroup['id']})
                with self.assertRaises(CLIReturnCodeError):
                    HostGroup.info({'id': hostgroup['id']})
예제 #14
0
 def _cleanup():
     if HostGroup.exists(search=('id', host_group['id'])):
         HostGroup.delete(options={'id': host_group['id']})
예제 #15
0
def test_positive_create_with_multiple_entities_and_delete(
        module_puppet_org, puppet_content_source, puppet_classes,
        session_puppet_enabled_sat):
    """Check if hostgroup with multiple options can be created and deleted

    :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

    :expectedresults: Hostgroup should be created, has all defined
        entities assigned and deleted

    :BZ: 1395254, 1313056

    :CaseLevel: Integration

    :CaseImportance: Critical
    """
    with session_puppet_enabled_sat:
        # Common entities
        name = valid_hostgroups_list()[0]
        loc = make_location()
        org_2 = entities.Organization().create()
        orgs = [module_puppet_org, org_2]
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org_2.id
        })
        lce = make_lifecycle_environment({'organization-id': org_2.id})
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org_2.id})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id']
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org_2.id
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org_2.id
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org_2.id
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id']
        })
        os_full_name = "{} {}.{}".format(os['name'], os['major-version'],
                                         os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org_2.id,
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'name': name,
            'organization-ids': [org.id for org in orgs],
            'locations': loc['name'],
            'puppet-environment': env['name'],
            'lifecycle-environment-id': lce['id'],
            'puppet-proxy': puppet_content_source['name'],
            'puppet-ca-proxy': puppet_content_source['name'],
            'content-source-id': puppet_content_source['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'puppet-classes': puppet_classes[0]['name'],
            'query-organization': org_2.name,
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        assert hostgroup['name'] == name
        assert {org.name for org in orgs} == set(hostgroup['organizations'])
        assert loc['name'] in hostgroup['locations']
        assert env['name'] == hostgroup['puppet-environment']
        assert puppet_content_source['name'] == hostgroup[
            'puppet-master-proxy']
        assert puppet_content_source['name'] == hostgroup['puppet-ca-proxy']
        assert domain['name'] == hostgroup['network']['domain']
        assert subnet['name'] == hostgroup['network']['subnet-ipv4']
        assert arch['name'] == hostgroup['operating-system']['architecture']
        assert ptable['name'] == hostgroup['operating-system'][
            'partition-table']
        assert media['name'] == hostgroup['operating-system']['medium']
        assert os_full_name == hostgroup['operating-system'][
            'operating-system']
        assert cv['name'] == hostgroup['content-view']['name']
        assert lce['name'] == hostgroup['lifecycle-environment']['name']
        assert puppet_content_source['name'] == hostgroup['content-source'][
            'name']
        assert puppet_classes[0]['name'] in hostgroup['puppetclasses']
        # delete hostgroup
        HostGroup.delete({'id': hostgroup['id']})
        with pytest.raises(CLIReturnCodeError):
            HostGroup.info({'id': hostgroup['id']})
예제 #16
0
 def _cleanup():
     with session_puppet_enabled_sat:
         HostGroup.delete({'id': hostgroup['id']})
         capsule_cleanup(new_content_source['id'])
예제 #17
0
 def _cleanup():
     HostGroup.delete({'id': hostgroup['id']})
     capsule_cleanup(new_content_source['id'])
예제 #18
0
    def test_positive_create_with_multiple_entities_and_delete(self):
        """Check if hostgroup with multiple options can be created and deleted

        :id: a3ef4f0e-971d-4307-8d0a-35103dff6586

        :expectedresults: Hostgroup should be created, has all defined
            entities assigned and deleted

        :BZ: 1395254, 1313056

        :CaseLevel: Integration

        :CaseImportance: Critical
        """
        # Common entities
        name = valid_hostgroups_list()[0]
        loc = make_location()
        org = make_org()
        orgs = [org, self.org]
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id']
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id']
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id']
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id']
        })
        os_full_name = "{0} {1}.{2}".format(os['name'], os['major-version'],
                                            os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'name': name,
            'organization-ids': [org['id'] for org in orgs],
            'locations': loc['name'],
            'environment': env['name'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy': self.content_source['name'],
            'puppet-ca-proxy': self.content_source['name'],
            'content-source-id': self.content_source['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'puppet-classes': self.puppet_classes[0]['name'],
            'query-organization': org['name'],
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertEqual(hostgroup['name'], name)
        self.assertEqual(set(org['name'] for org in orgs),
                         set(hostgroup['organizations']))
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['puppet-environment'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['puppet-master-proxy'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['puppet-ca-proxy'])
        self.assertEqual(domain['name'], hostgroup['network']['domain'])
        self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4'])
        self.assertEqual(arch['name'],
                         hostgroup['operating-system']['architecture'])
        self.assertEqual(ptable['name'],
                         hostgroup['operating-system']['partition-table'])
        self.assertEqual(media['name'],
                         hostgroup['operating-system']['medium'])
        self.assertEqual(os_full_name,
                         hostgroup['operating-system']['operating-system'])
        self.assertEqual(cv['name'], hostgroup['content-view']['name'])
        self.assertEqual(lce['name'],
                         hostgroup['lifecycle-environment']['name'])
        self.assertEqual(self.content_source['name'],
                         hostgroup['content-source']['name'])
        self.assertIn(self.puppet_classes[0]['name'],
                      hostgroup['puppetclasses'])
        # delete hostgroup
        HostGroup.delete({'id': hostgroup['id']})
        with self.assertRaises(CLIReturnCodeError):
            HostGroup.info({'id': hostgroup['id']})