def setUp(self): """Create a host to use in tests""" super(HostDeleteTestCase, self).setUp() # Use the default installation smart proxy result = Proxy.list() self.assertGreater(len(result), 0) self.puppet_proxy = result[0] self.host = entities.Host() self.host.create_missing() self.host = Host.create({ u'architecture-id': self.host.architecture.id, u'domain-id': self.host.domain.id, u'environment-id': self.host.environment.id, # pylint:disable=no-member u'location-id': self.host.location.id, u'mac': self.host.mac, u'medium-id': self.host.medium.id, u'name': gen_string('alphanumeric'), u'operatingsystem-id': self.host.operatingsystem.id, # pylint:disable=no-member u'organization-id': self.host.organization.id, u'partition-table-id': self.host.ptable.id, u'puppet-proxy-id': self.puppet_proxy['id'], u'root-pass': self.host.root_pass, })
def setUpClass(cls): super(HostGroupTestCase, cls).setUpClass() cls.org = make_org() # Setup for puppet class related tests puppet_modules = [ { 'author': 'robottelo', 'name': 'generic_1' }, { 'author': 'robottelo', 'name': 'generic_2' }, ] cls.cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO, cls.org['id']) cls.env = Environment.list( {'search': 'content_view="{0}"'.format(cls.cv['name'])})[0] cls.puppet_classes = [ Puppet.info({ 'name': mod['name'], 'puppet-environment': cls.env['name'] }) for mod in puppet_modules ] cls.content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] cls.hostgroup = make_hostgroup({ 'content-source-id': cls.content_source['id'], 'organization-ids': cls.org['id'] })
def setUp(self): """Create a host to reuse later""" super(HostUpdateTestCase, self).setUp() self.proxies = Proxy.list() self.assertGreater(len(self.proxies), 0) self.puppet_proxy = self.proxies[0] # using nailgun to create dependencies self.host_args = entities.Host() self.host_args.create_missing() # using CLI to create host self.host = Host.create({ u'architecture-id': self.host_args.architecture.id, u'domain-id': self.host_args.domain.id, u'environment-id': self.host_args.environment.id, # pylint:disable=no-member u'location-id': self.host_args.location.id, u'mac': self.host_args.mac, u'medium-id': self.host_args.medium.id, u'name': self.host_args.name, u'operatingsystem-id': self.host_args.operatingsystem.id, # pylint:disable=no-member u'organization-id': self.host_args.organization.id, u'partition-table-id': self.host_args.ptable.id, u'puppet-proxy-id': self.puppet_proxy['id'], u'root-pass': self.host_args.root_pass, })
def setUpClass(cls): """Create host to tests parameters for""" super(HostParameterTestCase, cls).setUpClass() cls.proxies = Proxy.list() assert len(cls.proxies) > 0 cls.puppet_proxy = cls.proxies[0] # using nailgun to create dependencies cls.host = entities.Host() cls.host.create_missing() # using CLI to create host cls.host = Host.create({ u'architecture-id': cls.host.architecture.id, u'domain-id': cls.host.domain.id, u'environment-id': cls.host.environment.id, u'location-id': cls.host.location.id, # pylint:disable=no-member u'mac': cls.host.mac, u'medium-id': cls.host.medium.id, u'name': cls.host.name, u'operatingsystem-id': cls.host.operatingsystem.id, # pylint:disable=no-member u'organization-id': cls.host.organization.id, u'partition-table-id': cls.host.ptable.id, u'puppet-proxy-id': cls.puppet_proxy['id'], u'root-pass': cls.host.root_pass, })
def test_negative_update_content_source(self): """Attempt to update hostgroup's content source with invalid value :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26 :BZ: 1260697, 1313056 :expectedresults: Host group was not updated. Content source remains the same as it was before update :CaseImportance: Medium """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) with self.assertRaises(CLIBaseError): HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': gen_integer(10000, 99999), }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual( hostgroup['content-source']['name'], content_source['name'])
def test_positive_update_content_source(self): """Update hostgroup's content source :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source :CaseImportance: High """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) new_content_source = make_proxy() self.addCleanup(capsule_cleanup, new_content_source['id']) self.addCleanup(HostGroup.delete, {'id': hostgroup['id']}) HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual( hostgroup['content-source']['name'], new_content_source['name'])
def setUpClass(cls): """Create host to tests parameters for""" super(HostParameterTestCase, cls).setUpClass() cls.proxies = Proxy.list() assert len(cls.proxies) > 0 cls.puppet_proxy = cls.proxies[0] # using nailgun to create dependencies cls.host = entities.Host() cls.host.create_missing() # using CLI to create host cls.host = Host.create({ u'architecture-id': cls.host.architecture.id, u'domain-id': cls.host.domain.id, u'environment-id': cls.host.environment.id, u'location-id': cls.host.location.id, # pylint:disable=no-member u'mac': cls.host.mac, u'medium-id': cls.host.medium.id, u'name': cls.host.name, u'operatingsystem-id': cls.host.operatingsystem.id, # pylint:disable=no-member u'organization-id': cls.host.organization.id, u'partition-table-id': cls.host.ptable.id, u'puppet-proxy-id': cls.puppet_proxy['id'], u'root-pass': cls.host.root_pass, })
def setUp(self): """Create a host to reuse later""" super(HostUpdateTestCase, self).setUp() self.proxies = Proxy.list() self.assertGreater(len(self.proxies), 0) self.puppet_proxy = self.proxies[0] # using nailgun to create dependencies self.host_args = entities.Host() self.host_args.create_missing() # using CLI to create host self.host = Host.create({ u'architecture-id': self.host_args.architecture.id, u'domain-id': self.host_args.domain.id, u'environment-id': self.host_args.environment.id, # pylint:disable=no-member u'location-id': self.host_args.location.id, u'mac': self.host_args.mac, u'medium-id': self.host_args.medium.id, u'name': self.host_args.name, u'operatingsystem-id': self.host_args.operatingsystem.id, # pylint:disable=no-member u'organization-id': self.host_args.organization.id, u'partition-table-id': self.host_args.ptable.id, u'puppet-proxy-id': self.puppet_proxy['id'], u'root-pass': self.host_args.root_pass, })
def setUp(self): """Create a host to use in tests""" super(HostDeleteTestCase, self).setUp() # Use the default installation smart proxy result = Proxy.list() self.assertGreater(len(result), 0) self.puppet_proxy = result[0] self.host = entities.Host() self.host.create_missing() self.host = Host.create({ u'architecture-id': self.host.architecture.id, u'domain-id': self.host.domain.id, u'environment-id': self.host.environment.id, # pylint:disable=no-member u'location-id': self.host.location.id, u'mac': self.host.mac, u'medium-id': self.host.medium.id, u'name': gen_string('alphanumeric'), u'operatingsystem-id': self.host.operatingsystem.id, # pylint:disable=no-member u'organization-id': self.host.organization.id, u'partition-table-id': self.host.ptable.id, u'puppet-proxy-id': self.puppet_proxy['id'], u'root-pass': self.host.root_pass, })
def test_positive_update_content_source(self): """Update hostgroup's content source :id: c22218a1-4d86-4ac1-ad4b-79b10c9adcde :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: Hostgroup was successfully updated with new content source :CaseImportance: High """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) new_content_source = make_proxy() self.addCleanup(capsule_cleanup, new_content_source['id']) self.addCleanup(HostGroup.delete, {'id': hostgroup['id']}) HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': new_content_source['id'], }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['content-source']['name'], new_content_source['name'])
def test_negative_update_content_source(self): """Attempt to update hostgroup's content source with invalid value :id: 4ffe6d18-3899-4bf1-acb2-d55ea09b7a26 :BZ: 1260697, 1313056 :expectedresults: Host group was not updated. Content source remains the same as it was before update :CaseImportance: Medium """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) with self.assertRaises(CLIReturnCodeError): HostGroup.update({ 'id': hostgroup['id'], 'content-source-id': gen_integer(10000, 99999), }) hostgroup = HostGroup.info({'id': hostgroup['id']}) self.assertEqual(hostgroup['content-source']['name'], content_source['name'])
def default_proxy(): """ Returns default capsule/proxy id""" proxy = Proxy.list({'search': settings.server.hostname})[0] p_features = set(proxy.get('features').split(', ')) if {'Puppet', 'Ansible', 'Openscap'}.issubset(p_features): proxy_id = proxy.get('id') else: raise ProxyError('Some features like Puppet, DHCP, Openscap, Ansible are not present') return proxy_id
def setUp(self): """Find an existing puppet proxy. Record information about this puppet proxy as ``self.puppet_proxy``. """ super(HostCreateTestCase, self).setUp() # Use the default installation smart proxy result = Proxy.list() self.assertGreater(len(result), 0) self.puppet_proxy = result[0]
def setUp(self): """Find an existing puppet proxy. Record information about this puppet proxy as ``self.puppet_proxy``. """ super(HostCreateTestCase, self).setUp() # Use the default installation smart proxy result = Proxy.list() self.assertGreater(len(result), 0) self.puppet_proxy = result[0]
def default_proxy(module_target_sat): """Returns default capsule/proxy id""" proxy = Proxy.list({'search': module_target_sat.hostname})[0] p_features = set(proxy.get('features').split(', ')) if {'Ansible', 'Openscap'}.issubset(p_features): proxy_id = proxy.get('id') else: raise ProxyError( 'Some features like DHCP, Openscap, Ansible are not present') return proxy_id
def test_create_hostgroup_with_puppet_proxy(self): """@Test: Check if hostgroup with puppet proxy server can be created @Feature: Hostgroup - Positive create @Assert: Hostgroup is created and has puppet proxy server assigned """ puppet_proxy = Proxy.list()[0] hostgroup = make_hostgroup({"puppet-proxy": puppet_proxy["name"]}) self.assertEqual(puppet_proxy["id"], hostgroup["puppet-master-proxy-id"])
def test_positive_create_with_puppet_ca_proxy(self): """Check if hostgroup with puppet CA proxy server can be created @id: f7ea1c94-8a0e-4500-98b3-0ecd63b3ce3c @Assert: Hostgroup is created and has puppet CA proxy server assigned """ puppet_proxy = Proxy.list()[0] hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']}) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
def test_positive_create_with_puppet_ca_proxy(self): """Check if hostgroup with puppet CA proxy server can be created @Feature: Hostgroup - Positive create @Assert: Hostgroup is created and has puppet CA proxy server assigned """ puppet_proxy = Proxy.list()[0] hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']}) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
def test_create_hostgroup_with_puppet_ca_proxy(self): """@Test: Check if hostgroup with puppet CA proxy server can be created @Feature: Hostgroup - Positive create @Assert: Hostgroup is created and has puppet CA proxy server assigned """ puppet_proxy = Proxy.list()[0] hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']}) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
def test_positive_create_with_puppet_ca_proxy(self): """Check if hostgroup with puppet CA proxy server can be created @id: f7ea1c94-8a0e-4500-98b3-0ecd63b3ce3c @Assert: Hostgroup is created and has puppet CA proxy server assigned """ puppet_proxy = Proxy.list()[0] hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']}) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
def setUp(self): """Find an existing puppet proxy. Record information about this puppet proxy as ``self.puppet_proxy``. """ # Use the default installation smart proxy result = Proxy.list() self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) self.assertGreater(len(result.stdout), 0) self.puppet_proxy = result.stdout[0]
def test_positive_create_with_puppet_proxy(self): """Check if hostgroup with puppet proxy server can be created @id: 3a922d9f-7466-4565-b279-c1481f63a4ce @Assert: Hostgroup is created and has puppet proxy server assigned """ puppet_proxy = Proxy.list()[0] hostgroup = make_hostgroup({'puppet-proxy': puppet_proxy['name']}) self.assertEqual( puppet_proxy['id'], hostgroup['puppet-master-proxy-id'], )
def test_positive_create_with_puppet_ca_proxy(self): """Check if hostgroup with puppet CA proxy server can be created @id: f7ea1c94-8a0e-4500-98b3-0ecd63b3ce3c @Assert: Hostgroup is created and has puppet CA proxy server assigned """ puppet_proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']}) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
def test_positive_create_with_puppet_proxy(self): """Check if hostgroup with puppet proxy server can be created @id: 3a922d9f-7466-4565-b279-c1481f63a4ce @Assert: Hostgroup is created and has puppet proxy server assigned """ puppet_proxy = Proxy.list()[0] hostgroup = make_hostgroup({'puppet-proxy': puppet_proxy['name']}) self.assertEqual( puppet_proxy['id'], hostgroup['puppet-master-proxy-id'], )
def test_positive_create_1(self): """@test: A host can be created with a random name @feature: Hosts @assert: A host is created and the name matches """ # Use the default installation smart proxy result = Proxy.list() self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) self.assertGreater(len(result.stdout), 0) puppet_proxy = result.stdout[0] host_name = gen_string(str_type='alpha', length=gen_integer(1, 10)) try: # Creating dependent objects architecture = make_architecture() domain = make_domain() environment = make_environment() location = make_location() medium = make_medium() ptable = make_partition_table() organization = make_org(cached=True) os = make_os({ u'architecture-ids': architecture['id'], u'medium-ids': medium['id'], u'ptable-ids': ptable['id'], }) host = make_host({ u'architecture-id': architecture['id'], u'domain-id': domain['id'], u'environment-id': environment['id'], u'location-id': location['id'], u'medium-id': medium['id'], u'name': host_name, u'operatingsystem-id': os['id'], u'organization-id': organization['id'], u'partition-table-id': ptable['id'], u'puppet-proxy-id': puppet_proxy['id'], }) except CLIFactoryError as err: self.fail(err) name = '{0}.{1}'.format(host_name, domain['name']).lower() self.assertEqual(host['name'], name)
def test_positive_create_1(self): """@test: A host can be created with a random name @feature: Hosts @assert: A host is created and the name matches """ # Use the default installation smart proxy result = Proxy.list() self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) self.assertGreater(len(result.stdout), 0) puppet_proxy = result.stdout[0] host_name = gen_string(str_type='alpha', length=gen_integer(1, 10)) try: # Creating dependent objects architecture = make_architecture() domain = make_domain() environment = make_environment() location = make_location() medium = make_medium() ptable = make_partition_table() organization = make_org(cached=True) os = make_os({ u'architecture-ids': architecture['id'], u'medium-ids': medium['id'], u'partition-table-ids': ptable['id'], }) host = make_host({ u'architecture-id': architecture['id'], u'domain-id': domain['id'], u'environment-id': environment['id'], u'location-id': location['id'], u'medium-id': medium['id'], u'name': host_name, u'operatingsystem-id': os['id'], u'organization-id': organization['id'], u'partition-table-id': ptable['id'], u'puppet-proxy-id': puppet_proxy['id'], }) except CLIFactoryError as err: self.fail(err) name = '{0}.{1}'.format(host_name, domain['name']).lower() self.assertEqual(host['name'], name)
def test_positive_create_with_puppet_proxy(self): """Check if hostgroup with puppet proxy server can be created @id: 3a922d9f-7466-4565-b279-c1481f63a4ce @Assert: Hostgroup is created and has puppet proxy server assigned """ puppet_proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({'puppet-proxy': puppet_proxy['name']}) self.assertEqual( puppet_proxy['id'], hostgroup['puppet-master-proxy-id'], )
def test_positive_create_with_puppet_ca_proxy(self): """Check if hostgroup with puppet CA proxy server can be created :id: f7ea1c94-8a0e-4500-98b3-0ecd63b3ce3c :expectedresults: Hostgroup is created and has puppet CA proxy server assigned :CaseLevel: Integration """ puppet_proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({'puppet-ca-proxy': puppet_proxy['name']}) self.assertEqual(puppet_proxy['name'], hostgroup['puppet-ca-proxy'])
def test_positive_validate_inherited_cv_lce(session, module_host_template): """Create a host with hostgroup specified via CLI. Make sure host inherited hostgroup's lifecycle environment, content view and both fields are properly reflected via WebUI. :id: c83f6819-2649-4a8b-bb1d-ce93b2243765 :expectedresults: Host's lifecycle environment and content view match the ones specified in hostgroup. :CaseLevel: Integration :BZ: 1391656 """ lce = make_lifecycle_environment({'organization-id': module_host_template.organization.id}) content_view = make_content_view({'organization-id': module_host_template.organization.id}) ContentView.publish({'id': content_view['id']}) version_id = ContentView.version_list({'content-view-id': content_view['id']})[0]['id'] ContentView.version_promote({ 'id': version_id, 'to-lifecycle-environment-id': lce['id'], 'organization-id': module_host_template.organization.id, }) hostgroup = make_hostgroup({ 'content-view-id': content_view['id'], 'lifecycle-environment-id': lce['id'], 'organization-ids': module_host_template.organization.id, }) puppet_proxy = Proxy.list({'search': 'name = {0}'.format(settings.server.hostname)})[0] host = make_host({ 'architecture-id': module_host_template.architecture.id, 'domain-id': module_host_template.domain.id, 'environment-id': module_host_template.environment.id, 'hostgroup-id': hostgroup['id'], 'location-id': module_host_template.location.id, 'medium-id': module_host_template.medium.id, 'operatingsystem-id': module_host_template.operatingsystem.id, 'organization-id': module_host_template.organization.id, 'partition-table-id': module_host_template.ptable.id, 'puppet-proxy-id': puppet_proxy['id'], }) with session: values = session.host.read(host['name'], ['host.lce', 'host.content_view']) assert values['host']['lce'] == lce['name'] assert values['host']['content_view'] == content_view['name']
def test_positive_create_with_puppet_proxy(self): """Check if hostgroup with puppet proxy server can be created :id: 3a922d9f-7466-4565-b279-c1481f63a4ce :expectedresults: Hostgroup is created and has puppet proxy server assigned :CaseImportance: Critical """ puppet_proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({'puppet-proxy': puppet_proxy['name']}) self.assertEqual( puppet_proxy['id'], hostgroup['puppet-master-proxy-id'], )
def test_positive_create_with_content_source(self): """Create a hostgroup with content source specified :id: 49ba2e4e-7772-4e5f-ac49-33f3a4966110 :BZ: 1260697 :expectedresults: A hostgroup is created with expected content source assigned :CaseImportance: High """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) self.assertEqual(hostgroup['content-source'], content_source['name'])
def test_create_hostgroup_with_puppet_proxy(self): """@Test: Check if hostgroup with puppet proxy server can be created @Feature: Hostgroup - Positive create @Assert: Hostgroup is created and has puppet proxy server assigned """ proxy_list = Proxy.list() self.assertEqual(proxy_list.return_code, 0) puppet_proxy = proxy_list.stdout[0] try: hostgroup = make_hostgroup( {'puppet-proxy': puppet_proxy['name']}) except CLIFactoryError as err: self.fail(err) self.assertEqual( puppet_proxy['id'], hostgroup['puppet-master-proxy-id'], )
def test_positive_create_with_content_source(self): """Create a hostgroup with content source specified :id: 49ba2e4e-7772-4e5f-ac49-33f3a4966110 :customerscenario: true :BZ: 1260697, 1313056 :expectedresults: A hostgroup is created with expected content source assigned :CaseImportance: High """ content_source = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] hostgroup = make_hostgroup({ 'content-source-id': content_source['id'], 'organization-ids': self.org['id'], }) self.assertEqual( hostgroup['content-source']['name'], content_source['name'])
def test_positive_create_with_multiple_entities_name(self): """Check if hostgroup with multiple options name can be created :id: a3ef4f0e-971d-4307-8d0a-35103dff6586 :expectedresults: Hostgroup should be created and has all defined entities assigned :BZ: 1395254, 1313056 :CaseLevel: Integration """ # Common entities loc = make_location() org = make_org() env = make_environment({ 'location-ids': loc['id'], 'organization-ids': org['id'], }) lce = make_lifecycle_environment({'organization-id': org['id']}) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # 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 = { 'organizations': org['name'], 'locations': loc['name'], 'environment': env['name'], 'lifecycle-environment': lce['name'], 'puppet-proxy': proxy['name'], 'puppet-ca-proxy': proxy['name'], 'content-source-id': proxy['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, 'query-organization': org['name'] } hostgroup = make_hostgroup(make_hostgroup_params) self.assertIn(org['name'], hostgroup['organizations']) self.assertIn(loc['name'], hostgroup['locations']) self.assertEqual(env['name'], hostgroup['puppet-environment']) self.assertEqual(proxy['name'], hostgroup['puppet-master-proxy']) self.assertEqual(proxy['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(proxy['name'], hostgroup['content-source']['name'])
def test_positive_create_with_multiple_entities(self): """Check if hostgroup with multiple options can be created :id: a3ef4f0e-971d-4307-8d0a-35103dff6586 :expectedresults: Hostgroup should be created and has all defined entities assigned :CaseLevel: Integration """ # Common entities loc = make_location() org = make_org() env = make_environment({ 'location-ids': loc['id'], 'organization-ids': org['id'], }) lce = make_lifecycle_environment({'organization-id': org['id']}) puppet_proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # 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'], }) media = make_medium({ 'operatingsystem-ids': os['id'], 'location-ids': loc['id'], 'organization-ids': org['id'], }) make_hostgroup_params = { 'location-ids': loc['id'], 'environment-id': env['id'], 'lifecycle-environment': lce['name'], 'puppet-proxy-id': puppet_proxy['id'], 'puppet-ca-proxy-id': puppet_proxy['id'], 'content-view-id': cv['id'], 'domain-id': domain['id'], 'subnet-id': subnet['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'medium-id': media['id'], 'operatingsystem-id': os['id'], } # If bug is open provide LCE id as parameter # because LCE name cause errors if bz_bug_is_open(1395254): make_hostgroup_params.pop('lifecycle-environment') make_hostgroup_params['lifecycle-environment-id'] = lce['id'] hostgroup = make_hostgroup(make_hostgroup_params) self.assertIn(org['name'], hostgroup['organizations']) self.assertIn(loc['name'], hostgroup['locations']) self.assertEqual(env['name'], hostgroup['environment']) self.assertEqual( puppet_proxy['id'], hostgroup['puppet-master-proxy-id'] ) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id']) self.assertEqual(domain['name'], hostgroup['domain']) self.assertEqual(subnet['name'], hostgroup['subnet']) self.assertEqual(arch['name'], hostgroup['architecture']) self.assertEqual(ptable['name'], hostgroup['partition-table']) self.assertEqual(media['name'], hostgroup['medium']) self.assertEqual( "{0} {1}.{2}".format( os['name'], os['major-version'], os['minor-version'] ), hostgroup['operating-system'] ) if not bz_bug_is_open('1313056'): self.assertEqual(cv['name'], hostgroup['content-view']) self.assertEqual( lce['name'], hostgroup['lifecycle-environment'] )
def configure_puppet_test(cls): """Sets up the whole provisioning environment needed for Puppet based end-to-end tests like OSCAP etc :returns: A dict of entities to help with provisioning """ cls.rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content'] cls.rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] cls.rhel8_content = OSCAP_DEFAULT_CONTENT['rhel8_content'] sat6_hostname = settings.server.hostname proxy = Proxy.list({'search': sat6_hostname})[0] p_features = set(proxy.get('features').split(', ')) if {'Puppet', 'Ansible', 'Openscap'}.issubset(p_features): cls.proxy_id = proxy.get('id') else: raise ProxyError( 'Some features like Puppet, DHCP, Openscap, Ansible are not present' ) ak_name_8 = gen_string('alpha') ak_name_7 = gen_string('alpha') ak_name_6 = gen_string('alpha') repo_values = [ { 'repo': settings.sattools_repo['rhel8'], 'akname': ak_name_8 }, { 'repo': settings.sattools_repo['rhel7'], 'akname': ak_name_7 }, { 'repo': settings.sattools_repo['rhel6'], 'akname': ak_name_6 }, ] # Create new organization and environment. org = entities.Organization(name=gen_string('alpha')).create() cls.puppet_env = (entities.Environment().search( query={'search': 'name=production'})[0].read()) cls.puppet_env.organization.append(org) cls.puppet_env = cls.puppet_env.update(['organization']) smart_proxy = (entities.SmartProxy().search( query={'search': f'name={sat6_hostname}'})[0].read()) smart_proxy.import_puppetclasses(environment=cls.puppet_env.name) env = entities.LifecycleEnvironment(organization=org, name=gen_string('alpha')).create() # Create content view content_view = entities.ContentView(organization=org, name=gen_string('alpha')).create() # Create activation keys for rhel6, rhel7 and rhel8. for repo in repo_values: activation_key = entities.ActivationKey(name=repo.get('akname'), environment=env, organization=org).create() # Setup org for a custom repo for RHEL6, RHEL7 and RHEL8. setup_org_for_a_custom_repo({ 'url': repo.get('repo'), 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id, }) for content in cls.rhel8_content, cls.rhel7_content, cls.rhel6_content: content = Scapcontent.info({'title': content}, output_format='json') organization_ids = [ content_org['id'] for content_org in content.get('organizations', []) ] organization_ids.append(org.id) Scapcontent.update({ 'title': content['title'], 'organization-ids': organization_ids }) return { 'org_name': org.name, 'cv_name': content_view.name, 'sat6_hostname': settings.server.hostname, 'ak_name': { 'rhel8': ak_name_8, 'rhel7': ak_name_7, 'rhel6': ak_name_6 }, 'env_name': env.name, }
def test_positive_create_with_synced_content(self): """Check if hostgroup with synced kickstart repository can be created :id: 7c51ac72-359c-488a-8658-88b5a94d7e7a :customerscenario: true :expectedresults: Hostgroup should be created and has proper installation content id present :BZ: 1415707 :CaseLevel: Integration """ # Check whether path to kickstart media is set if settings.rhel6_os is None: raise ValueError( 'Installation media path is not set in properties file') # Common entities org = make_org() lce = make_lifecycle_environment({'organization-id': org['id']}) product = make_product({'organization-id': org['id']}) repo = make_repository({ u'url': settings.rhel6_os, u'product-id': product['id'], u'content-type': u'yum', }) Repository.synchronize({'id': repo['id']}) cv = make_content_view({ 'organization-id': org['id'], 'repository-ids': [repo['id']], }) ContentView.publish({'id': cv['id']}) cv = ContentView.info({'id': cv['id']}) cvv = cv['versions'][0] ContentView.version_promote({ 'id': cvv['id'], 'to-lifecycle-environment-id': lce['id'], }) # Get the Partition table ID ptable = PartitionTable.info({'name': DEFAULT_PTABLE}) # Get the arch ID arch = Architecture.list({ 'search': 'name={0}'.format(DEFAULT_ARCHITECTURE)})[0] # Get the OS ID os = OperatingSys.list({ 'search': 'name="RedHat" AND major="{0}" OR major="{1}"'.format( RHEL_6_MAJOR_VERSION, RHEL_7_MAJOR_VERSION) })[0] # Update the OS with found arch and ptable OperatingSys.update({ 'id': os['id'], 'architectures': arch['name'], 'partition-tables': ptable['name'], }) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # Search for proper installation repository id synced_repo = Repository.list({ 'content-view-version-id': cvv['id'], 'organization-id': org['id'], 'environment-id': lce['id'], })[0] hostgroup = make_hostgroup({ 'lifecycle-environment-id': lce['id'], 'puppet-proxy-id': proxy['id'], 'puppet-ca-proxy-id': proxy['id'], 'content-source-id': proxy['id'], 'content-view-id': cv['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'operatingsystem-id': os['id'], 'kickstart-repository-id': synced_repo['id'], }) hg = HostGroup.info({'id': hostgroup['id']}, output_format='json') self.assertEqual( hg['operating-system']['kickstart_repository_id'], synced_repo['id'] )
def content_source(): """Return the proxy.""" return Proxy.list({'search': f'url = https://{settings.server.hostname}:9090'})[0]
def test_positive_validate_inherited_cv_lce(self): """Create a host with hostgroup specified via CLI. Make sure host inherited hostgroup's lifecycle environment, content view and both fields are properly reflected via WebUI :id: c83f6819-2649-4a8b-bb1d-ce93b2243765 :expectedresults: Host's lifecycle environment and content view match the ones specified in hostgroup :CaseLevel: Integration :BZ: 1391656 """ host = entities.Host() host.create_missing() new_lce = cli_factory.make_lifecycle_environment( {'organization-id': host.organization.id}) new_cv = cli_factory.make_content_view( {'organization-id': host.organization.id}) cli_ContentView.publish({'id': new_cv['id']}) version_id = cli_ContentView.version_list({ 'content-view-id': new_cv['id'], })[0]['id'] cli_ContentView.version_promote({ 'id': version_id, 'to-lifecycle-environment-id': new_lce['id'], 'organization-id': host.organization.id, }) hostgroup = cli_factory.make_hostgroup({ 'content-view-id': new_cv['id'], 'lifecycle-environment-id': new_lce['id'], 'organization-ids': host.organization.id, }) puppet_proxy = cli_Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] cli_factory.make_host({ 'architecture-id': host.architecture.id, 'domain-id': host.domain.id, 'environment-id': host.environment.id, 'hostgroup-id': hostgroup['id'], 'location-id': host.location.id, 'medium-id': host.medium.id, 'name': host.name, 'operatingsystem-id': host.operatingsystem.id, 'organization-id': host.organization.id, 'partition-table-id': host.ptable.id, 'puppet-proxy-id': puppet_proxy['id'], }) with Session(self.browser) as session: set_context(session, host.organization.name, host.location.name) result = self.hosts.fetch_host_parameters( host.name, host.domain.name, [['Host', 'Lifecycle Environment'], ['Host', 'Content View']], ) self.assertEqual(result['Lifecycle Environment'], new_lce['name']) self.assertEqual(result['Content View'], new_cv['name'])
def test_positive_create_with_multiple_entities_ids(self): """Check if hostgroup with multiple options ids can be created :id: 6277613b-0ece-4dee-b9d8-504f8299ac38 :expectedresults: Hostgroup should be created and has all defined entities assigned :BZ: 1395254, 1313056 :CaseLevel: Integration """ # Common entities loc = make_location() org = make_org() env = make_environment({ 'location-ids': loc['id'], 'organization-ids': org['id'], }) lce = make_lifecycle_environment({'organization-id': org['id']}) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # 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'], }) media = make_medium({ 'operatingsystem-ids': os['id'], 'location-ids': loc['id'], 'organization-ids': org['id'], }) make_hostgroup_params = { 'location-ids': loc['id'], 'environment-id': env['id'], 'lifecycle-environment-id': lce['id'], 'puppet-proxy-id': proxy['id'], 'puppet-ca-proxy-id': proxy['id'], 'content-source-id': proxy['id'], 'content-view-id': cv['id'], 'domain-id': domain['id'], 'subnet-id': subnet['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'medium-id': media['id'], 'operatingsystem-id': os['id'], } hostgroup = make_hostgroup(make_hostgroup_params) self.assertEqual(cv['id'], hostgroup['content-view']['id']) self.assertEqual(lce['id'], hostgroup['lifecycle-environment']['id']) self.assertEqual(proxy['id'], hostgroup['content-source']['id']) # get the json output format hostgroup = HostGroup.info( {'id': hostgroup['id']}, output_format='json') self.assertIn(org['id'], hostgroup['organizations'][0]['id']) self.assertIn(loc['id'], hostgroup['locations'][0]['id']) self.assertEqual( env['id'], hostgroup['puppet-environment']['environment_id']) self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy-id']) self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy-id']) self.assertEqual(domain['id'], hostgroup['domain']['domain_id']) self.assertEqual( subnet['id'], hostgroup['network']['subnet-ipv4']['id']) self.assertEqual( arch['id'], hostgroup['architecture']['architecture_id']) self.assertEqual( ptable['id'], hostgroup['partition-table']['ptable_id']) self.assertEqual(media['id'], hostgroup['medium']['medium_id']) self.assertEqual( os['id'], hostgroup['operating-system']['operatingsystem_id'])
def test_positive_validate_inherited_cv_lce(session, module_host_template): """Create a host with hostgroup specified via CLI. Make sure host inherited hostgroup's lifecycle environment, content view and both fields are properly reflected via WebUI. :id: c83f6819-2649-4a8b-bb1d-ce93b2243765 :expectedresults: Host's lifecycle environment and content view match the ones specified in hostgroup. :CaseLevel: Integration :BZ: 1391656 """ lce = make_lifecycle_environment( {'organization-id': module_host_template.organization.id}) content_view = make_content_view( {'organization-id': module_host_template.organization.id}) ContentView.publish({'id': content_view['id']}) version_id = ContentView.version_list( {'content-view-id': content_view['id']})[0]['id'] ContentView.version_promote({ 'id': version_id, 'to-lifecycle-environment-id': lce['id'], 'organization-id': module_host_template.organization.id, }) hostgroup = make_hostgroup({ 'content-view-id': content_view['id'], 'lifecycle-environment-id': lce['id'], 'organization-ids': module_host_template.organization.id, }) puppet_proxy = Proxy.list( {'search': 'name = {0}'.format(settings.server.hostname)})[0] host = make_host({ 'architecture-id': module_host_template.architecture.id, 'domain-id': module_host_template.domain.id, 'environment-id': module_host_template.environment.id, 'hostgroup-id': hostgroup['id'], 'location-id': module_host_template.location.id, 'medium-id': module_host_template.medium.id, 'operatingsystem-id': module_host_template.operatingsystem.id, 'organization-id': module_host_template.organization.id, 'partition-table-id': module_host_template.ptable.id, 'puppet-proxy-id': puppet_proxy['id'], }) with session: values = session.host.read(host['name'], ['host.lce', 'host.content_view']) assert values['host']['lce'] == lce['name'] assert values['host']['content_view'] == content_view['name']
def test_positive_create_with_multiple_entities_ids(self): """Check if hostgroup with multiple options ids can be created :id: 6277613b-0ece-4dee-b9d8-504f8299ac38 :expectedresults: Hostgroup should be created and has all defined entities assigned :BZ: 1395254, 1313056 :CaseLevel: Integration """ # Common entities loc = make_location() org = make_org() env = make_environment({ 'location-ids': loc['id'], 'organization-ids': org['id'], }) lce = make_lifecycle_environment({'organization-id': org['id']}) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # 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'], }) media = make_medium({ 'operatingsystem-ids': os['id'], 'location-ids': loc['id'], 'organization-ids': org['id'], }) make_hostgroup_params = { 'location-ids': loc['id'], 'environment-id': env['id'], 'lifecycle-environment-id': lce['id'], 'puppet-proxy-id': proxy['id'], 'puppet-ca-proxy-id': proxy['id'], 'content-source-id': proxy['id'], 'content-view-id': cv['id'], 'domain-id': domain['id'], 'subnet-id': subnet['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'medium-id': media['id'], 'operatingsystem-id': os['id'], } hostgroup = make_hostgroup(make_hostgroup_params) self.assertEqual(cv['id'], hostgroup['content-view']['id']) self.assertEqual(lce['id'], hostgroup['lifecycle-environment']['id']) self.assertEqual(proxy['id'], hostgroup['content-source']['id']) # get the json output format hostgroup = HostGroup.info({'id': hostgroup['id']}, output_format='json') self.assertIn(org['id'], hostgroup['organizations'][0]['id']) self.assertIn(loc['id'], hostgroup['locations'][0]['id']) self.assertEqual(env['id'], hostgroup['puppet-environment']['id']) self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy']['id']) self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy']['id']) self.assertEqual(domain['id'], hostgroup['network']['domain']['id']) self.assertEqual(subnet['id'], hostgroup['network']['subnet-ipv4']['id']) self.assertEqual(arch['id'], hostgroup['operating-system']['architecture']['id']) self.assertEqual( ptable['id'], hostgroup['operating-system']['partition-table']['id']) self.assertEqual(media['id'], hostgroup['operating-system']['medium']['id']) self.assertEqual( os['id'], hostgroup['operating-system']['operating-system']['id'])
def content_source(default_sat): """Return the proxy.""" return Proxy.list({'search': f'url = {default_sat.url}:9090'})[0]
def content_source(module_target_sat): """Return the proxy.""" return Proxy.list({'search': f'url = {module_target_sat.url}:9090'})[0]
def test_positive_create_with_multiple_entities(self): """Check if hostgroup with multiple options can be created :id: a3ef4f0e-971d-4307-8d0a-35103dff6586 :expectedresults: Hostgroup should be created and has all defined entities assigned :CaseLevel: Integration """ # Common entities loc = make_location() org = make_org() env = make_environment({ 'location-ids': loc['id'], 'organization-ids': org['id'], }) lce = make_lifecycle_environment({'organization-id': org['id']}) puppet_proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # 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'], }) media = make_medium({ 'operatingsystem-ids': os['id'], 'location-ids': loc['id'], 'organization-ids': org['id'], }) make_hostgroup_params = { 'location-ids': loc['id'], 'environment-id': env['id'], 'lifecycle-environment': lce['name'], 'puppet-proxy-id': puppet_proxy['id'], 'puppet-ca-proxy-id': puppet_proxy['id'], 'content-view-id': cv['id'], 'domain-id': domain['id'], 'subnet-id': subnet['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'medium-id': media['id'], 'operatingsystem-id': os['id'], } # If bug is open provide LCE id as parameter # because LCE name cause errors if bz_bug_is_open(1395254): make_hostgroup_params.pop('lifecycle-environment') make_hostgroup_params['lifecycle-environment-id'] = lce['id'] hostgroup = make_hostgroup(make_hostgroup_params) self.assertIn(org['name'], hostgroup['organizations']) self.assertIn(loc['name'], hostgroup['locations']) self.assertEqual(env['name'], hostgroup['environment']) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-master-proxy-id']) self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id']) self.assertEqual(domain['name'], hostgroup['domain']) self.assertEqual(subnet['name'], hostgroup['subnet']) self.assertEqual(arch['name'], hostgroup['architecture']) self.assertEqual(ptable['name'], hostgroup['partition-table']) self.assertEqual(media['name'], hostgroup['medium']) self.assertEqual( "{0} {1}.{2}".format(os['name'], os['major-version'], os['minor-version']), hostgroup['operating-system']) if not bz_bug_is_open('1313056'): self.assertEqual(cv['name'], hostgroup['content-view']) self.assertEqual(lce['name'], hostgroup['lifecycle-environment'])
def test_positive_create_with_synced_content(self): """Check if hostgroup with synced kickstart repository can be created :id: 7c51ac72-359c-488a-8658-88b5a94d7e7a :customerscenario: true :expectedresults: Hostgroup should be created and has proper installation content id present :BZ: 1415707 :CaseLevel: Integration """ # Check whether path to kickstart media is set if settings.rhel6_os is None: raise ValueError( 'Installation media path is not set in properties file') # Common entities org = make_org() lce = make_lifecycle_environment({'organization-id': org['id']}) product = make_product({'organization-id': org['id']}) repo = make_repository({ u'url': settings.rhel6_os, u'product-id': product['id'], u'content-type': u'yum', }) Repository.synchronize({'id': repo['id']}) cv = make_content_view({ 'organization-id': org['id'], 'repository-ids': [repo['id']], }) ContentView.publish({'id': cv['id']}) cv = ContentView.info({'id': cv['id']}) cvv = cv['versions'][0] ContentView.version_promote({ 'id': cvv['id'], 'to-lifecycle-environment-id': lce['id'], }) # Get the Partition table ID ptable = PartitionTable.info({'name': DEFAULT_PTABLE}) # Get the arch ID arch = Architecture.list( {'search': 'name={0}'.format(DEFAULT_ARCHITECTURE)})[0] # Get the OS ID os = OperatingSys.list({ 'search': 'name="RedHat" AND major="{0}" OR major="{1}"'.format( RHEL_6_MAJOR_VERSION, RHEL_7_MAJOR_VERSION) })[0] # Update the OS with found arch and ptable OperatingSys.update({ 'id': os['id'], 'architectures': arch['name'], 'partition-tables': ptable['name'], }) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # Search for proper installation repository id synced_repo = Repository.list({ 'content-view-version-id': cvv['id'], 'organization-id': org['id'], 'environment-id': lce['id'], })[0] hostgroup = make_hostgroup({ 'lifecycle-environment-id': lce['id'], 'puppet-proxy-id': proxy['id'], 'puppet-ca-proxy-id': proxy['id'], 'content-source-id': proxy['id'], 'content-view-id': cv['id'], 'organization-ids': org['id'], 'architecture-id': arch['id'], 'partition-table-id': ptable['id'], 'operatingsystem-id': os['id'], 'kickstart-repository-id': synced_repo['id'], }) hg = HostGroup.info({'id': hostgroup['id']}, output_format='json') self.assertEqual(hg['kickstart-repository']['id'], synced_repo['id'])
def test_positive_create_with_multiple_entities_name(self): """Check if hostgroup with multiple options name can be created :id: a3ef4f0e-971d-4307-8d0a-35103dff6586 :expectedresults: Hostgroup should be created and has all defined entities assigned :BZ: 1395254, 1313056 :CaseLevel: Integration """ # Common entities loc = make_location() org = make_org() env = make_environment({ 'location-ids': loc['id'], 'organization-ids': org['id'], }) lce = make_lifecycle_environment({'organization-id': org['id']}) proxy = Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] # 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 = { 'organizations': org['name'], 'locations': loc['name'], 'environment': env['name'], 'lifecycle-environment': lce['name'], 'puppet-proxy': proxy['name'], 'puppet-ca-proxy': proxy['name'], 'content-source-id': proxy['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, 'query-organization': org['name'] } hostgroup = make_hostgroup(make_hostgroup_params) self.assertIn(org['name'], hostgroup['organizations']) self.assertIn(loc['name'], hostgroup['locations']) self.assertEqual(env['name'], hostgroup['puppet-environment']) self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy-id']) self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy-id']) self.assertEqual(domain['name'], hostgroup['domain']) self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4']) self.assertEqual(arch['name'], hostgroup['architecture']) self.assertEqual(ptable['name'], hostgroup['partition-table']) self.assertEqual(media['name'], hostgroup['medium']) self.assertEqual(os_full_name, hostgroup['operating-system']) self.assertEqual(cv['name'], hostgroup['content-view']['name']) self.assertEqual( lce['name'], hostgroup['lifecycle-environment']['name']) self.assertEqual(proxy['name'], hostgroup['content-source']['name'])
def configure_puppet_test(cls): """Sets up the whole provisioning environment needed for Puppet based end-to-end tests like OSCAP etc :returns: A dict of entities to help with provisioning """ cls.rhel6_content = OSCAP_DEFAULT_CONTENT['rhel6_content'] cls.rhel7_content = OSCAP_DEFAULT_CONTENT['rhel7_content'] sat6_hostname = settings.server.hostname proxy = Proxy.list({'search': sat6_hostname})[0] p_features = set(proxy.get('features').split(', ')) if {'Puppet', 'Ansible', 'Openscap'}.issubset(p_features): cls.proxy_id = proxy.get('id') else: raise ProxyError( 'Some features like Puppet, DHCP, Openscap, Ansible are not present' ) ak_name_7 = gen_string('alpha') ak_name_6 = gen_string('alpha') repo_values = [ { 'repo': settings.sattools_repo['rhel6'], 'akname': ak_name_6 }, { 'repo': settings.sattools_repo['rhel7'], 'akname': ak_name_7 }, ] # Create new organization and environment. org = entities.Organization(name=gen_string('alpha')).create() loc = entities.Location().search( query={'search': "{0}".format(DEFAULT_LOC)})[0].read() cls.puppet_env = entities.Environment().search( query={u'search': u'name=production'})[0].read() cls.puppet_env.location.append(loc) cls.puppet_env.organization.append(org) cls.puppet_env = cls.puppet_env.update(['location', 'organization']) Proxy.import_classes({ u'environment': cls.puppet_env.name, u'name': sat6_hostname, }) Proxy.update({ 'id': cls.proxy_id, 'organizations': org.name, 'locations': DEFAULT_LOC }) env = entities.LifecycleEnvironment(organization=org, name=gen_string('alpha')).create() # Create content view content_view = entities.ContentView(organization=org, name=gen_string('alpha')).create() # Create two activation keys for rhel7 and rhel6 for repo in repo_values: activation_key = entities.ActivationKey( name=repo.get('akname'), environment=env, organization=org, ).create() # Setup org for a custom repo for RHEL6 and RHEL7 setup_org_for_a_custom_repo({ 'url': repo.get('repo'), 'organization-id': org.id, 'content-view-id': content_view.id, 'lifecycle-environment-id': env.id, 'activationkey-id': activation_key.id }) for content in cls.rhel6_content, cls.rhel7_content: Scapcontent.update({ 'title': content, 'organizations': org.name, 'locations': DEFAULT_LOC }) return { 'org_name': org.name, 'cv_name': content_view.name, 'sat6_hostname': settings.server.hostname, 'ak_name': { 'rhel7': ak_name_7, 'rhel6': ak_name_6 }, 'env_name': env.name, }
def test_positive_validate_inherited_cv_lce(self): """Create a host with hostgroup specified via CLI. Make sure host inherited hostgroup's lifecycle environment, content view and both fields are properly reflected via WebUI @id: c83f6819-2649-4a8b-bb1d-ce93b2243765 @Assert: Host's lifecycle environment and content view match the ones specified in hostgroup @CaseLevel: Integration @BZ: 1391656 """ host = entities.Host() host.create_missing() new_lce = cli_factory.make_lifecycle_environment({ 'organization-id': host.organization.id}) new_cv = cli_factory.make_content_view({ 'organization-id': host.organization.id}) cli_ContentView.publish({'id': new_cv['id']}) version_id = cli_ContentView.version_list({ 'content-view-id': new_cv['id'], })[0]['id'] cli_ContentView.version_promote({ 'id': version_id, 'to-lifecycle-environment-id': new_lce['id'], 'organization-id': host.organization.id, }) hostgroup = cli_factory.make_hostgroup({ 'content-view-id': new_cv['id'], 'lifecycle-environment-id': new_lce['id'], 'organization-ids': host.organization.id, }) puppet_proxy = cli_Proxy.list({ 'search': 'url = https://{0}:9090'.format(settings.server.hostname) })[0] cli_factory.make_host({ 'architecture-id': host.architecture.id, 'domain-id': host.domain.id, 'environment-id': host.environment.id, 'hostgroup-id': hostgroup['id'], 'location-id': host.location.id, 'medium-id': host.medium.id, 'name': host.name, 'operatingsystem-id': host.operatingsystem.id, 'organization-id': host.organization.id, 'partition-table-id': host.ptable.id, 'puppet-proxy-id': puppet_proxy['id'], }) with Session(self.browser) as session: set_context(session, host.organization.name, host.location.name) result = self.hosts.fetch_host_parameters( host.name, host.domain.name, [['Host', 'Lifecycle Environment'], ['Host', 'Content View']], ) self.assertEqual(result['Lifecycle Environment'], new_lce['name']) self.assertEqual(result['Content View'], new_cv['name'])