def setUpClass(cls): """Create an organization, product and ostree repo.""" super(OstreeBranchTestCase, cls).setUpClass() password = '******' cls.user = make_user({'admin': 'true', 'password': password}) cls.user['password'] = password credentials = cls.get_user_credentials() cls.org = make_org_with_credentials(credentials=credentials) cls.product = make_product_with_credentials( {u'organization-id': cls.org['id']}, credentials) # Create new custom ostree repo cls.ostree_repo = make_repository_with_credentials( { u'product-id': cls.product['id'], u'content-type': u'ostree', u'publish-via-http': u'false', u'url': FEDORA27_OSTREE_REPO, }, credentials) Repository.with_user(*credentials).synchronize( {'id': cls.ostree_repo['id']}) cls.cv = make_content_view( { u'organization-id': cls.org['id'], u'repository-ids': [cls.ostree_repo['id']], }, credentials) ContentView.with_user(*credentials).publish({u'id': cls.cv['id']}) cls.cv = ContentView.with_user(*credentials).info( {u'id': cls.cv['id']})
def ostree_repo_with_user(ostree_user_credentials): """Create an user, organization, product and ostree repo, sync ostree repo for particular user, create content view and publish it for particular user """ org = make_org_with_credentials(credentials=ostree_user_credentials) product = make_product_with_credentials( {'organization-id': org['id']}, ostree_user_credentials ) # Create new custom ostree repo ostree_repo = make_repository_with_credentials( { 'product-id': product['id'], 'content-type': 'ostree', 'publish-via-http': 'false', 'url': OSTREE_REPO, }, ostree_user_credentials, ) Repository.with_user(*ostree_user_credentials).synchronize({'id': ostree_repo['id']}) cv = make_content_view( {'organization-id': org['id'], 'repository-ids': [ostree_repo['id']]}, ostree_user_credentials, ) ContentView.with_user(*ostree_user_credentials).publish({'id': cv['id']}) cv = ContentView.with_user(*ostree_user_credentials).info({'id': cv['id']}) return {'cv': cv, 'org': org, 'ostree_repo': ostree_repo, 'product': product}
def setUpClass(cls): """Create an organization, product and ostree repo.""" super(OstreeBranchTestCase, cls).setUpClass() password = '******' cls.user = make_user({'admin': 'true', 'password': password}) cls.user['password'] = password credentials = cls.get_user_credentials() cls.org = make_org_with_credentials( credentials=credentials) cls.product = make_product_with_credentials( { u'organization-id': cls.org['id'] }, credentials ) # Create new custom ostree repo cls.ostree_repo = make_repository_with_credentials( { u'product-id': cls.product['id'], u'content-type': u'ostree', u'publish-via-http': u'false', u'url': FEDORA27_OSTREE_REPO, }, credentials ) Repository.with_user(*credentials).synchronize( {'id': cls.ostree_repo['id']}) cls.cv = make_content_view( { u'organization-id': cls.org['id'], u'repository-ids': [cls.ostree_repo['id']], }, credentials ) ContentView.with_user(*credentials).publish({u'id': cls.cv['id']}) cls.cv = ContentView.with_user(*credentials).info( {u'id': cls.cv['id']})
def test_positive_end_to_end(self): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions 2. Using the new user from above 1. Create a new organization 2. Clone and upload manifest 3. Create a new lifecycle environment 4. Create a custom product 5. Create a custom YUM repository 6. Create a custom PUPPET repository 7. Enable a Red Hat repository 8. Synchronize the three repositories 9. Create a new content view 10. Associate the YUM and Red Hat repositories to new content view 11. Add a PUPPET module to new content view 12. Publish content view 13. Promote content view to the lifecycle environment 14. Create a new activation key 15. Add the products to the activation key 16. Create a new libvirt compute resource 17. Create a new subnet 18. Create a new domain 19. Create a new hostgroup and associate previous entities to it 20. Provision a client @id: 8c8b3ffa-0d54-436b-8eeb-1a3542e100a8 @Assert: All tests should succeed and Content should be successfully fetched by client. """ # step 1: Create a new user with admin permissions password = gen_alphanumeric() user = make_user({u'admin': u'true', u'password': password}) user['password'] = password # step 2.1: Create a new organization org = self._create(user, Org, {u'name': gen_alphanumeric()}) # step 2.2: Clone and upload manifest if self.fake_manifest_is_set: with manifests.clone() as manifest: ssh.upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) # step 2.3: Create a new lifecycle environment lifecycle_environment = self._create( user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': org['id'], u'prior': u'Library', }) # step 2.4: Create a custom product product = self._create(user, Product, { u'name': gen_alphanumeric(), u'organization-id': org['id'], }) repositories = [] # step 2.5: Create custom YUM repository yum_repo = self._create( user, Repository, { u'content-type': u'yum', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': GOOGLE_CHROME_REPO, }) repositories.append(yum_repo) # step 2.6: Create custom PUPPET repository puppet_repo = self._create( user, Repository, { u'content-type': u'puppet', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': FAKE_0_PUPPET_REPO, }) repositories.append(puppet_repo) # step 2.7: Enable a Red Hat repository if self.fake_manifest_is_set: RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product': PRDS['rhel'], u'releasever': '6Server', }) rhel_repo = Repository.info({ u'name': REPOS['rhva6']['name'], u'organization-id': org['id'], u'product': PRDS['rhel'], }) repositories.append(rhel_repo) # step 2.8: Synchronize the three repositories for repo in repositories: Repository.with_user(user['login'], user['password']).synchronize( {u'id': repo['id']}) # step 2.9: Create content view content_view = self._create(user, ContentView, { u'name': gen_alphanumeric(), u'organization-id': org['id'], }) # step 2.10: Associate the YUM and Red Hat repositories to new content # view repositories.remove(puppet_repo) for repo in repositories: ContentView.add_repository({ u'id': content_view['id'], u'organization-id': org['id'], u'repository-id': repo['id'], }) # step 2.11: Add a PUPPET module to new content view result = PuppetModule.with_user(user['login'], user['password']).list({ u'repository-id': puppet_repo['id'], u'per-page': False, }) ContentView.with_user(user['login'], user['password']).puppet_module_add({ u'content-view-id': content_view['id'], u'id': random.choice(result)['id'], }) # step 2.12: Publish content view ContentView.with_user(user['login'], user['password']).publish( {u'id': content_view['id']}) # step 2.13: Promote content view to the lifecycle environment content_view = ContentView.with_user( user['login'], user['password']).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 1) ContentView.with_user(user['login'], user['password']).version_promote({ u'id': cv_version['id'], u'to-lifecycle-environment-id': lifecycle_environment['id'], }) # check that content view exists in lifecycle content_view = ContentView.with_user( user['login'], user['password']).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 2) self.assertEqual(cv_version['lifecycle-environments'][-1]['id'], lifecycle_environment['id']) # step 2.14: Create a new activation key activation_key = self._create( user, ActivationKey, { u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': gen_alphanumeric(), u'organization-id': org['id'], }) # step 2.15: Add the products to the activation key subscription_list = Subscription.with_user( user['login'], user['password']).list({u'organization-id': org['id']}, per_page=False) for subscription in subscription_list: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: ActivationKey.with_user(user['login'], user['password']).add_subscription({ u'id': activation_key['id'], u'quantity': 1, u'subscription-id': subscription['id'], }) # step 2.15.1: Enable product content if self.fake_manifest_is_set: ActivationKey.with_user(user['login'], user['password']).content_override({ u'content-label': AK_CONTENT_LABEL, u'id': activation_key['id'], u'organization-id': org['id'], u'value': '1', }) # BONUS: Create a content host and associate it with promoted # content view and last lifecycle where it exists content_host_name = gen_alphanumeric() content_host = Host.with_user(user['login'], user['password']).subscription_register({ u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': content_host_name, u'organization-id': org['id'], }) if bz_bug_is_open(1328202): results = ContentHost.with_user(user['login'], user['password']).list( {'organization-id': org['id']}) # Content host registration converts the name to lowercase, make # sure to use the same format while matching against the result content_host_name = content_host_name.lower() for result in results: if result['name'] == content_host_name: content_host = result content_host = ContentHost.with_user( user['login'], user['password']).info({'id': content_host['id']}) # check that content view matches what we passed self.assertEqual(content_host['content-view'], content_view['name']) # check that lifecycle environment matches self.assertEqual(content_host['lifecycle-environment'], lifecycle_environment['name']) # step 2.16: Create a new libvirt compute resource self._create( user, ComputeResource, { u'name': gen_alphanumeric(), u'provider': u'Libvirt', u'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname), }) # step 2.17: Create a new subnet subnet = self._create( user, Subnet, { u'name': gen_alphanumeric(), u'network': gen_ipaddr(ip3=True), u'mask': u'255.255.255.0', }) # step 2.18: Create a new domain domain = self._create(user, Domain, {u'name': gen_alphanumeric()}) # step 2.19: Create a new hostgroup and associate previous entities to # it host_group = self._create( user, HostGroup, { u'domain-id': domain['id'], u'name': gen_alphanumeric(), u'subnet-id': subnet['id'], }) if not bz_bug_is_open('1326101'): Org.with_user(user['login'], user['password']).add_hostgroup({ u'hostgroup-id': host_group['id'], u'id': org['id'], }) # step 2.20: Provision a client self.client_provisioning(activation_key['name'], org['label'])
def test_positive_end_to_end(self): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions 2. Using the new user from above 1. Create a new organization 2. Clone and upload manifest 3. Create a new lifecycle environment 4. Create a custom product 5. Create a custom YUM repository 6. Create a custom PUPPET repository 7. Enable a Red Hat repository 8. Synchronize the three repositories 9. Create a new content view 10. Associate the YUM and Red Hat repositories to new content view 11. Add a PUPPET module to new content view 12. Publish content view 13. Promote content view to the lifecycle environment 14. Create a new activation key 15. Add the products to the activation key 16. Create a new libvirt compute resource 17. Create a new subnet 18. Create a new domain 19. Create a new hostgroup and associate previous entities to it 20. Provision a client @id: 8c8b3ffa-0d54-436b-8eeb-1a3542e100a8 @Assert: All tests should succeed and Content should be successfully fetched by client. """ # step 1: Create a new user with admin permissions password = gen_alphanumeric() user = make_user({u'admin': u'true', u'password': password}) user['password'] = password # step 2.1: Create a new organization org = self._create(user, Org, {u'name': gen_alphanumeric()}) # step 2.2: Clone and upload manifest if self.fake_manifest_is_set: with manifests.clone() as manifest: ssh.upload_file(manifest.content, manifest.filename) Subscription.upload({ u'file': manifest.filename, u'organization-id': org['id'], }) # step 2.3: Create a new lifecycle environment lifecycle_environment = self._create( user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': org['id'], u'prior': u'Library', } ) # step 2.4: Create a custom product product = self._create( user, Product, { u'name': gen_alphanumeric(), u'organization-id': org['id'], } ) repositories = [] # step 2.5: Create custom YUM repository yum_repo = self._create( user, Repository, { u'content-type': u'yum', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': GOOGLE_CHROME_REPO, } ) repositories.append(yum_repo) # step 2.6: Create custom PUPPET repository puppet_repo = self._create( user, Repository, { u'content-type': u'puppet', u'name': gen_alphanumeric(), u'product-id': product['id'], u'publish-via-http': u'true', u'url': FAKE_0_PUPPET_REPO, } ) repositories.append(puppet_repo) # step 2.7: Enable a Red Hat repository if self.fake_manifest_is_set: RepositorySet.enable({ u'basearch': 'x86_64', u'name': REPOSET['rhva6'], u'organization-id': org['id'], u'product': PRDS['rhel'], u'releasever': '6Server', }) rhel_repo = Repository.info({ u'name': REPOS['rhva6']['name'], u'organization-id': org['id'], u'product': PRDS['rhel'], }) repositories.append(rhel_repo) # step 2.8: Synchronize the three repositories for repo in repositories: Repository.with_user( user['login'], user['password'] ).synchronize({u'id': repo['id']}) # step 2.9: Create content view content_view = self._create( user, ContentView, { u'name': gen_alphanumeric(), u'organization-id': org['id'], } ) # step 2.10: Associate the YUM and Red Hat repositories to new content # view repositories.remove(puppet_repo) for repo in repositories: ContentView.add_repository({ u'id': content_view['id'], u'organization-id': org['id'], u'repository-id': repo['id'], }) # step 2.11: Add a PUPPET module to new content view result = PuppetModule.with_user( user['login'], user['password'] ).list({ u'repository-id': puppet_repo['id'], u'per-page': False, }) ContentView.with_user( user['login'], user['password'] ).puppet_module_add({ u'content-view-id': content_view['id'], u'id': random.choice(result)['id'], }) # step 2.12: Publish content view ContentView.with_user( user['login'], user['password'] ).publish({u'id': content_view['id']}) # step 2.13: Promote content view to the lifecycle environment content_view = ContentView.with_user( user['login'], user['password'] ).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password'] ).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 1) ContentView.with_user( user['login'], user['password'] ).version_promote({ u'id': cv_version['id'], u'to-lifecycle-environment-id': lifecycle_environment['id'], }) # check that content view exists in lifecycle content_view = ContentView.with_user( user['login'], user['password'] ).info({u'id': content_view['id']}) self.assertEqual(len(content_view['versions']), 1) cv_version = ContentView.with_user( user['login'], user['password'] ).version_info({ 'id': content_view['versions'][0]['id'], }) self.assertEqual(len(cv_version['lifecycle-environments']), 2) self.assertEqual( cv_version['lifecycle-environments'][-1]['id'], lifecycle_environment['id'] ) # step 2.14: Create a new activation key activation_key = self._create( user, ActivationKey, { u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': gen_alphanumeric(), u'organization-id': org['id'], } ) # step 2.15: Add the products to the activation key subscription_list = Subscription.with_user( user['login'], user['password'] ).list( {u'organization-id': org['id']}, per_page=False ) for subscription in subscription_list: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: ActivationKey.with_user( user['login'], user['password'] ).add_subscription({ u'id': activation_key['id'], u'quantity': 1, u'subscription-id': subscription['id'], }) # step 2.15.1: Enable product content if self.fake_manifest_is_set: ActivationKey.with_user( user['login'], user['password'] ).content_override({ u'content-label': AK_CONTENT_LABEL, u'id': activation_key['id'], u'organization-id': org['id'], u'value': '1', }) # BONUS: Create a content host and associate it with promoted # content view and last lifecycle where it exists content_host_name = gen_alphanumeric() content_host = Host.with_user( user['login'], user['password'] ).subscription_register({ u'content-view-id': content_view['id'], u'lifecycle-environment-id': lifecycle_environment['id'], u'name': content_host_name, u'organization-id': org['id'], }) if bz_bug_is_open(1328202): results = ContentHost.with_user( user['login'], user['password'] ).list({ 'organization-id': org['id'] }) # Content host registration converts the name to lowercase, make # sure to use the same format while matching against the result content_host_name = content_host_name.lower() for result in results: if result['name'] == content_host_name: content_host = result content_host = ContentHost.with_user( user['login'], user['password'] ).info({'id': content_host['id']}) # check that content view matches what we passed self.assertEqual( content_host['content-view'], content_view['name'] ) # check that lifecycle environment matches self.assertEqual( content_host['lifecycle-environment'], lifecycle_environment['name'] ) # step 2.16: Create a new libvirt compute resource self._create( user, ComputeResource, { u'name': gen_alphanumeric(), u'provider': u'Libvirt', u'url': u'qemu+ssh://root@{0}/system'.format( settings.compute_resources.libvirt_hostname ), } ) # step 2.17: Create a new subnet subnet = self._create( user, Subnet, { u'name': gen_alphanumeric(), u'network': gen_ipaddr(ip3=True), u'mask': u'255.255.255.0', } ) # step 2.18: Create a new domain domain = self._create(user, Domain, {u'name': gen_alphanumeric()}) # step 2.19: Create a new hostgroup and associate previous entities to # it host_group = self._create( user, HostGroup, { u'domain-id': domain['id'], u'name': gen_alphanumeric(), u'subnet-id': subnet['id'], } ) if not bz_bug_is_open('1326101'): Org.with_user( user['login'], user['password'] ).add_hostgroup({ u'hostgroup-id': host_group['id'], u'id': org['id'], }) # step 2.20: Provision a client self.client_provisioning(activation_key['name'], org['label'])
def test_positive_cli_end_to_end(fake_manifest_is_set, rhel6_contenthost, default_sat): """Perform end to end smoke tests using RH and custom repos. 1. Create a new user with admin permissions 2. Using the new user from above 1. Create a new organization 2. Clone and upload manifest 3. Create a new lifecycle environment 4. Create a custom product 5. Create a custom YUM repository 6. Enable a Red Hat repository 7. Synchronize the three repositories 8. Create a new content view 9. Associate the YUM and Red Hat repositories to new content view 10. Publish content view 11. Promote content view to the lifecycle environment 12. Create a new activation key 13. Add the products to the activation key 14. Create a new libvirt compute resource 15. Create a new subnet 16. Create a new domain 17. Create a new hostgroup and associate previous entities to it 18. Provision a client ** NOT CURRENTLY PROVISIONING :id: 8c8b3ffa-0d54-436b-8eeb-1a3542e100a8 :expectedresults: All tests should succeed and Content should be successfully fetched by client. """ # step 1: Create a new user with admin permissions password = gen_alphanumeric() user = make_user({'admin': 'true', 'password': password}) user['password'] = password # step 2.1: Create a new organization org = _create(user, Org, {'name': gen_alphanumeric()}) # step 2.2: Clone and upload manifest if fake_manifest_is_set: with manifests.clone() as manifest: default_sat.put(manifest, manifest.filename) Subscription.upload({ 'file': manifest.filename, 'organization-id': org['id'] }) # step 2.3: Create a new lifecycle environment lifecycle_environment = _create( user, LifecycleEnvironment, { 'name': gen_alphanumeric(), 'organization-id': org['id'], 'prior': 'Library' }, ) # step 2.4: Create a custom product product = _create(user, Product, { 'name': gen_alphanumeric(), 'organization-id': org['id'] }) repositories = [] # step 2.5: Create custom YUM repository yum_repo = _create( user, Repository, { 'content-type': 'yum', 'name': gen_alphanumeric(), 'product-id': product['id'], 'publish-via-http': 'true', 'url': CUSTOM_RPM_REPO, }, ) repositories.append(yum_repo) # step 2.6: Enable a Red Hat repository if fake_manifest_is_set: RepositorySet.enable({ 'basearch': 'x86_64', 'name': REPOSET['rhva6'], 'organization-id': org['id'], 'product': PRDS['rhel'], 'releasever': '6Server', }) rhel_repo = Repository.info({ 'name': REPOS['rhva6']['name'], 'organization-id': org['id'], 'product': PRDS['rhel'], }) repositories.append(rhel_repo) # step 2.7: Synchronize the three repositories for repo in repositories: Repository.with_user(user['login'], user['password']).synchronize({'id': repo['id']}) # step 2.8: Create content view content_view = _create(user, ContentView, { 'name': gen_alphanumeric(), 'organization-id': org['id'] }) # step 2.9: Associate the YUM and Red Hat repositories to new content view for repo in repositories: ContentView.add_repository({ 'id': content_view['id'], 'organization-id': org['id'], 'repository-id': repo['id'], }) # step 2.10: Publish content view ContentView.with_user(user['login'], user['password']).publish({'id': content_view['id']}) # step 2.11: Promote content view to the lifecycle environment content_view = ContentView.with_user(user['login'], user['password']).info( {'id': content_view['id']}) assert len(content_view['versions']) == 1 cv_version = ContentView.with_user(user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'] }) assert len(cv_version['lifecycle-environments']) == 1 ContentView.with_user(user['login'], user['password']).version_promote({ 'id': cv_version['id'], 'to-lifecycle-environment-id': lifecycle_environment['id'] }) # check that content view exists in lifecycle content_view = ContentView.with_user(user['login'], user['password']).info( {'id': content_view['id']}) assert len(content_view['versions']) == 1 cv_version = ContentView.with_user(user['login'], user['password']).version_info({ 'id': content_view['versions'][0]['id'] }) assert len(cv_version['lifecycle-environments']) == 2 assert cv_version['lifecycle-environments'][-1][ 'id'] == lifecycle_environment['id'] # step 2.12: Create a new activation key activation_key = _create( user, ActivationKey, { 'content-view-id': content_view['id'], 'lifecycle-environment-id': lifecycle_environment['id'], 'name': gen_alphanumeric(), 'organization-id': org['id'], }, ) # step 2.13: Add the products to the activation key subscription_list = Subscription.with_user( user['login'], user['password']).list({'organization-id': org['id']}, per_page=False) for subscription in subscription_list: if subscription['name'] == DEFAULT_SUBSCRIPTION_NAME: ActivationKey.with_user(user['login'], user['password']).add_subscription({ 'id': activation_key['id'], 'quantity': 1, 'subscription-id': subscription['id'], }) # step 2.13.1: Enable product content if fake_manifest_is_set: ActivationKey.with_user(user['login'], user['password']).content_override({ 'content-label': AK_CONTENT_LABEL, 'id': activation_key['id'], 'organization-id': org['id'], 'value': '1', }) # BONUS: Create a content host and associate it with promoted # content view and last lifecycle where it exists content_host_name = gen_alphanumeric() content_host = Host.with_user(user['login'], user['password']).subscription_register({ 'content-view-id': content_view['id'], 'lifecycle-environment-id': lifecycle_environment['id'], 'name': content_host_name, 'organization-id': org['id'], }) content_host = Host.with_user(user['login'], user['password']).info( {'id': content_host['id']}) # check that content view matches what we passed assert content_host['content-information']['content-view'][ 'name'] == content_view['name'] # check that lifecycle environment matches assert (content_host['content-information']['lifecycle-environment'] ['name'] == lifecycle_environment['name']) # step 2.14: Create a new libvirt compute resource _create( user, ComputeResource, { 'name': gen_alphanumeric(), 'provider': 'Libvirt', 'url': f'qemu+ssh://root@{settings.libvirt.libvirt_hostname}/system', }, ) # step 2.15: Create a new subnet subnet = _create( user, Subnet, { 'name': gen_alphanumeric(), 'network': gen_ipaddr(ip3=True), 'mask': '255.255.255.0', }, ) # step 2.16: Create a new domain domain = _create(user, Domain, {'name': gen_alphanumeric()}) # step 2.17: Create a new hostgroup and associate previous entities to it host_group = _create( user, HostGroup, { 'domain-id': domain['id'], 'name': gen_alphanumeric(), 'subnet-id': subnet['id'] }, ) HostGroup.with_user(user['login'], user['password']).update({ 'id': host_group['id'], 'organization-ids': org['id'], 'content-view-id': content_view['id'], 'lifecycle-environment-id': lifecycle_environment['id'], }) # step 2.18: Provision a client # TODO this isn't provisioning through satellite as intended # Note it wasn't well before the change that added this todo rhel6_contenthost.install_katello_ca(default_sat) # Register client with foreman server using act keys rhel6_contenthost.register_contenthost(org['label'], activation_key['name']) assert rhel6_contenthost.subscribed # Install rpm on client package_name = 'python-kitchen' result = rhel6_contenthost.execute(f'yum install -y {package_name}') assert result.status == 0 # Verify that the package is installed by querying it result = rhel6_contenthost.run(f'rpm -q {package_name}') assert result.status == 0
def test_smoke(self): """ @Test: Check that basic content can be created * Create a new user with admin permissions * Using the new user from above: * Create a new organization * Create two new lifecycle environments * Create a custom product * Create a custom YUM repository * Create a custom PUPPET repository * Synchronize both custom repositories * Create a new content view * Associate both repositories to new content view * Publish content view * Promote content view to both lifecycles * Create a new libvirt compute resource * Create a new subnet * Create a new domain * Create a new capsule * Create a new hostgroup and associate previous entities to it @Feature: Smoke Test @Assert: All entities are created and associated. """ # Create new user new_user = make_user({'admin': 'true'}) # Create new org as new user new_org = self._create( new_user, Org, {u'name': self._generate_name()} ) # Create new lifecycle environment 1 lifecycle1 = self._create( new_user, LifecycleEnvironment, {u'organization-id': new_org['id'], u'name': self._generate_name(), u'prior': u'Library'} ) # Create new lifecycle environment 2 lifecycle2 = self._create( new_user, LifecycleEnvironment, {u'organization-id': new_org['id'], u'name': self._generate_name(), u'prior': lifecycle1['name']} ) # Create a new product new_product = self._create( new_user, Product, {u'organization-id': new_org['id'], u'name': self._generate_name()} ) # Create a YUM repository new_repo1 = self._create( new_user, Repository, {u'product-id': new_product['id'], u'name': self._generate_name(), u'content-type': u'yum', u'publish-via-http': u'true', u'url': GOOGLE_CHROME_REPO} ) # Create a Puppet repository new_repo2 = self._create( new_user, Repository, {u'product-id': new_product['id'], u'name': self._generate_name(), u'content-type': u'puppet', u'publish-via-http': u'true', u'url': FAKE_PUPPET_REPO} ) # Synchronize YUM repository result = Repository.with_user( new_user['login'], new_user['password'] ).synchronize({'id': new_repo1['id']}) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to synchronize YUM repo: {0}".format(result.stderr)) # Synchronize puppet repository result = Repository.with_user( new_user['login'], new_user['password'] ).synchronize({'id': new_repo2['id']}) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to synchronize Puppet repo: {0}".format(result.stderr)) # Create a Content View new_cv = self._create( new_user, ContentView, {u'organization-id': new_org['id'], u'name': self._generate_name()} ) # Associate yum repository to content view result = ContentView.with_user( new_user['login'], new_user['password'] ).add_repository( {u'id': new_cv['id'], u'repository-id': new_repo1['id']}) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to add YUM repo to content view: {0}".format( result.stderr)) # Fetch puppet module puppet_result = PuppetModule.with_user( new_user['login'], new_user['password'] ).list( {u'repository-id': new_repo2['id'], u'per-page': False}) self.assertEqual( puppet_result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(puppet_result.stderr), 0, u"Puppet modules list was not generated: {0}".format( result.stderr)) # Associate puppet repository to content view result = ContentView.with_user( new_user['login'], new_user['password'] ).puppet_module_add( { u'content-view-id': new_cv['id'], u'name': puppet_result.stdout[0]['name'] } ) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to add YUM repo to content view: {0}".format( result.stderr)) # Publish content view result = ContentView.with_user( new_user['login'], new_user['password'] ).publish({u'id': new_cv['id']}) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to publish content view: {0}".format(result.stderr)) # Only after we publish version1 the info is populated. result = ContentView.with_user( new_user['login'], new_user['password'] ).info({u'id': new_cv['id']}) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Could not fetch content view info: {0}".format(result.stderr)) # Let us now store the version1 id version1_id = result.stdout['versions'][0]['id'] # Promote content view to first lifecycle result = ContentView.with_user( new_user['login'], new_user['password'] ).version_promote( {u'id': result.stdout['versions'][0]['id'], u'lifecycle-environment-id': lifecycle1['id']}) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to promote content view to lifecycle '{0}': {1}".format( lifecycle1['name'], result.stderr)) # Promote content view to second lifecycle result = ContentView.with_user( new_user['login'], new_user['password'] ).version_promote( {u'id': version1_id, u'lifecycle-environment-id': lifecycle2['id']}) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to promote content view to lifecycle '{0}': {1}".format( lifecycle2['name'], result.stderr)) # Create a new libvirt compute resource result = self._create( new_user, ComputeResource, { u'name': self._generate_name(), u'provider': u'Libvirt', u'url': u'qemu+tcp://{0}:16509/system'.format( conf.properties['main.server.hostname']) }) # Create a new subnet new_subnet = self._create( new_user, Subnet, { u'name': self._generate_name(), u'network': FauxFactory.generate_ipaddr(ip3=True), u'mask': u'255.255.255.0' } ) # Create a domain new_domain = self._create( new_user, Domain, { u'name': self._generate_name(), } ) # Fetch Puppet environment for second lifecycle # (unfortunately it is not straight forward to extract this) # The puppet environment we want has a name like this... env_name = u'KT_{0}_{1}_'.format( # Hyphens are replaced by underscores new_org['label'].replace('-', '_',), lifecycle2['label'].replace('-', '_') ) # We fetch all the puppet environments for our organization... result = Environment.with_user( new_user['login'], new_user['password'] ).list( { u'search': u'organization=\"{0}\"'.format( new_org['name']) }) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to fetch puppet environments: {0}".format( result.stderr)) # Now look for the puppet environment that matches lifecycle2 puppet_env = [ env for env in result.stdout if env['name'].startswith( env_name)] self.assertEqual( len(puppet_env), 1, u'Could not find the puppet environment: {0}'.format(env_name)) # Create new Capsule... new_capsule = self._create( new_user, Proxy, { u'name': self._generate_name(), u'url': u'https://{0}:9090/'.format( conf.properties['main.server.hostname']) } ) # ...and add it to the organization result = Org.with_user( new_user['login'], new_user['password'] ).add_smart_proxy( { u'id': new_org['id'], u'smart-proxy-id': new_capsule['id'] } ) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to add capsule '{0}' to org '{1}': {2}".format( new_capsule['name'], new_org['name'], result.stderr)) # Create a hostgroup... new_hg = self._create( new_user, HostGroup, { u'name': self._generate_name(), u'domain-id': new_domain['id'], u'subnet-id': new_subnet['id'], u'environment-id': puppet_env[0]['id'], u'puppet-ca-proxy-id': new_capsule['id'], u'puppet-proxy-id': new_capsule['id'], } ) # ...and add it to the organization result = Org.with_user( new_user['login'], new_user['password'] ).add_hostgroup( { u'id': new_org['id'], u'hostgroup-id': new_hg['id'] } ) self.assertEqual( result.return_code, 0, u"Return code is non-zero: {0}".format(result.return_code)) self.assertEqual( len(result.stderr), 0, u"Failed to add hostgroup '{0}' to org '{1}': {2}".format( new_hg['name'], new_org['name'], result.stderr))
def test_positive_smoke(self): """Check that basic content can be created * Create a new user with admin permissions * Using the new user from above. * Create a new organization * Create two new lifecycle environments * Create a custom product * Create a custom YUM repository * Create a custom PUPPET repository * Synchronize both custom repositories * Create a new content view * Associate both repositories to new content view * Publish content view * Promote content view to both lifecycles * Create a new libvirt compute resource * Create a new subnet * Create a new domain * Create a new hostgroup and associate previous entities to it @Feature: Smoke Test @Assert: All entities are created and associated. """ # Create new user password = gen_alphanumeric() new_user = make_user({u'admin': u'true', u'password': password}) # Append the password as the info command does not return it new_user[u'password'] = password # Create new org as new user new_org = self._create(new_user, Org, {u'name': gen_alphanumeric()}) # Create new lifecycle environment 1 lifecycle1 = self._create( new_user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], u'prior': u'Library', }) # Create new lifecycle environment 2 lifecycle2 = self._create( new_user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], u'prior': lifecycle1['name'], }) # Create a new product new_product = self._create(new_user, Product, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], }) # Create a YUM repository new_repo1 = self._create( new_user, Repository, { u'content-type': u'yum', u'name': gen_alphanumeric(), u'product-id': new_product['id'], u'publish-via-http': u'true', u'url': GOOGLE_CHROME_REPO, }) # Create a Puppet repository new_repo2 = self._create( new_user, Repository, { u'content-type': u'puppet', u'name': gen_alphanumeric(), u'product-id': new_product['id'], u'publish-via-http': u'true', u'url': FAKE_0_PUPPET_REPO, }) # Synchronize YUM repository Repository.with_user(new_user['login'], new_user['password']).synchronize( {u'id': new_repo1['id']}) # Synchronize puppet repository Repository.with_user(new_user['login'], new_user['password']).synchronize( {u'id': new_repo2['id']}) # Create a Content View new_cv = self._create(new_user, ContentView, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], }) # Associate yum repository to content view ContentView.with_user(new_user['login'], new_user['password']).add_repository({ u'id': new_cv['id'], u'repository-id': new_repo1['id'], }) # Fetch puppet module puppet_result = PuppetModule.with_user(new_user['login'], new_user['password']).list({ u'repository-id': new_repo2['id'], u'per-page': False, }) # Associate puppet repository to content view ContentView.with_user(new_user['login'], new_user['password']).puppet_module_add({ u'content-view-id': new_cv['id'], u'id': puppet_result[0]['id'], }) # Publish content view ContentView.with_user(new_user['login'], new_user['password']).publish( {u'id': new_cv['id']}) # Only after we publish version1 the info is populated. result = ContentView.with_user(new_user['login'], new_user['password']).info( {u'id': new_cv['id']}) # Let us now store the version1 id version1_id = result['versions'][0]['id'] # Promote content view to first lifecycle ContentView.with_user(new_user['login'], new_user['password']).version_promote({ u'id': version1_id, u'to-lifecycle-environment-id': lifecycle1['id'], }) # Promote content view to second lifecycle ContentView.with_user(new_user['login'], new_user['password']).version_promote({ u'id': version1_id, u'to-lifecycle-environment-id': lifecycle2['id'], }) # Create a new libvirt compute resource self._create( new_user, ComputeResource, { u'name': gen_alphanumeric(), u'provider': u'Libvirt', u'url': u'qemu+tcp://{0}:16509/system'.format( settings.server.hostname), }) # Create a new subnet new_subnet = self._create( new_user, Subnet, { u'name': gen_alphanumeric(), u'network': gen_ipaddr(ip3=True), u'mask': u'255.255.255.0', }) # Create a domain new_domain = self._create(new_user, Domain, { u'name': gen_alphanumeric(), }) # Fetch Puppet environment for second lifecycle # (unfortunately it is not straight forward to extract this) # The puppet environment we want has a name like this... env_name = u'KT_{0}_{1}_'.format( # Hyphens are replaced by underscores new_org['label'].replace( '-', '_', ), lifecycle2['label'].replace('-', '_')) # We fetch all the puppet environments for our organization... result = Environment.with_user( new_user['login'], new_user['password']).list({ u'search': u'organization="{0}"'.format(new_org['name']), }) # Now look for the puppet environment that matches lifecycle2 puppet_env = [ env for env in result if env['name'].startswith(env_name) ] self.assertEqual(len(puppet_env), 1) # Create a hostgroup... new_hg = self._create( new_user, HostGroup, { u'domain-id': new_domain['id'], u'environment-id': puppet_env[0]['id'], u'name': gen_alphanumeric(), u'subnet-id': new_subnet['id'], }) # ...and add it to the organization Org.with_user(new_user['login'], new_user['password']).add_hostgroup({ u'hostgroup-id': new_hg['id'], u'id': new_org['id'], })
def test_smoke(self): """@Test: Check that basic content can be created * Create a new user with admin permissions * Using the new user from above: * Create a new organization * Create two new lifecycle environments * Create a custom product * Create a custom YUM repository * Create a custom PUPPET repository * Synchronize both custom repositories * Create a new content view * Associate both repositories to new content view * Publish content view * Promote content view to both lifecycles * Create a new libvirt compute resource * Create a new subnet * Create a new domain * Create a new hostgroup and associate previous entities to it @Feature: Smoke Test @Assert: All entities are created and associated. """ # Create new user password = gen_alphanumeric() new_user = make_user({u'admin': u'true', u'password': password}) # Append the password as the info command does not return it new_user[u'password'] = password # Create new org as new user new_org = self._create( new_user, Org, {u'name': gen_alphanumeric()} ) # Create new lifecycle environment 1 lifecycle1 = self._create( new_user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], u'prior': u'Library', } ) # Create new lifecycle environment 2 lifecycle2 = self._create( new_user, LifecycleEnvironment, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], u'prior': lifecycle1['name'], } ) # Create a new product new_product = self._create( new_user, Product, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], } ) # Create a YUM repository new_repo1 = self._create( new_user, Repository, { u'content-type': u'yum', u'name': gen_alphanumeric(), u'product-id': new_product['id'], u'publish-via-http': u'true', u'url': GOOGLE_CHROME_REPO, } ) # Create a Puppet repository new_repo2 = self._create( new_user, Repository, { u'content-type': u'puppet', u'name': gen_alphanumeric(), u'product-id': new_product['id'], u'publish-via-http': u'true', u'url': FAKE_0_PUPPET_REPO, } ) # Synchronize YUM repository Repository.with_user( new_user['login'], new_user['password'] ).synchronize({u'id': new_repo1['id']}) # Synchronize puppet repository Repository.with_user( new_user['login'], new_user['password'] ).synchronize({u'id': new_repo2['id']}) # Create a Content View new_cv = self._create( new_user, ContentView, { u'name': gen_alphanumeric(), u'organization-id': new_org['id'], } ) # Associate yum repository to content view ContentView.with_user( new_user['login'], new_user['password'] ).add_repository({ u'id': new_cv['id'], u'repository-id': new_repo1['id'], }) # Fetch puppet module puppet_result = PuppetModule.with_user( new_user['login'], new_user['password'] ).list({ u'repository-id': new_repo2['id'], u'per-page': False, }) # Associate puppet repository to content view ContentView.with_user( new_user['login'], new_user['password'] ).puppet_module_add({ u'content-view-id': new_cv['id'], u'id': puppet_result[0]['id'], }) # Publish content view ContentView.with_user( new_user['login'], new_user['password'] ).publish({u'id': new_cv['id']}) # Only after we publish version1 the info is populated. result = ContentView.with_user( new_user['login'], new_user['password'] ).info({u'id': new_cv['id']}) # Let us now store the version1 id version1_id = result['versions'][0]['id'] # Promote content view to first lifecycle ContentView.with_user( new_user['login'], new_user['password'] ).version_promote({ u'id': version1_id, u'to-lifecycle-environment-id': lifecycle1['id'], }) # Promote content view to second lifecycle ContentView.with_user( new_user['login'], new_user['password'] ).version_promote({ u'id': version1_id, u'to-lifecycle-environment-id': lifecycle2['id'], }) # Create a new libvirt compute resource self._create( new_user, ComputeResource, { u'name': gen_alphanumeric(), u'provider': u'Libvirt', u'url': u'qemu+tcp://{0}:16509/system'.format( conf.properties['main.server.hostname']), } ) # Create a new subnet new_subnet = self._create( new_user, Subnet, { u'name': gen_alphanumeric(), u'network': gen_ipaddr(ip3=True), u'mask': u'255.255.255.0', } ) # Create a domain new_domain = self._create( new_user, Domain, { u'name': gen_alphanumeric(), } ) # Fetch Puppet environment for second lifecycle # (unfortunately it is not straight forward to extract this) # The puppet environment we want has a name like this... env_name = u'KT_{0}_{1}_'.format( # Hyphens are replaced by underscores new_org['label'].replace('-', '_',), lifecycle2['label'].replace('-', '_') ) # We fetch all the puppet environments for our organization... result = Environment.with_user( new_user['login'], new_user['password'] ).list({ u'search': u'organization="{0}"'.format(new_org['name']), }) # Now look for the puppet environment that matches lifecycle2 puppet_env = [ env for env in result if env['name'].startswith(env_name) ] self.assertEqual(len(puppet_env), 1) # Create a hostgroup... new_hg = self._create( new_user, HostGroup, { u'domain-id': new_domain['id'], u'environment-id': puppet_env[0]['id'], u'name': gen_alphanumeric(), u'subnet-id': new_subnet['id'], } ) # ...and add it to the organization Org.with_user( new_user['login'], new_user['password'] ).add_hostgroup({ u'hostgroup-id': new_hg['id'], u'id': new_org['id'], })
def test_smoke(self): """@Test: Check that basic content can be created * Create a new user with admin permissions * Using the new user from above: * Create a new organization * Create two new lifecycle environments * Create a custom product * Create a custom YUM repository * Create a custom PUPPET repository * Synchronize both custom repositories * Create a new content view * Associate both repositories to new content view * Publish content view * Promote content view to both lifecycles * Create a new libvirt compute resource * Create a new subnet * Create a new domain * Create a new hostgroup and associate previous entities to it @Feature: Smoke Test @Assert: All entities are created and associated. """ # Create new user password = gen_alphanumeric() new_user = make_user({u"admin": u"true", u"password": password}) # Append the password as the info command does not return it new_user[u"password"] = password # Create new org as new user new_org = self._create(new_user, Org, {u"name": gen_alphanumeric()}) # Create new lifecycle environment 1 lifecycle1 = self._create( new_user, LifecycleEnvironment, {u"organization-id": new_org["id"], u"name": gen_alphanumeric(), u"prior": u"Library"}, ) # Create new lifecycle environment 2 lifecycle2 = self._create( new_user, LifecycleEnvironment, {u"organization-id": new_org["id"], u"name": gen_alphanumeric(), u"prior": lifecycle1["name"]}, ) # Create a new product new_product = self._create(new_user, Product, {u"organization-id": new_org["id"], u"name": gen_alphanumeric()}) # Create a YUM repository new_repo1 = self._create( new_user, Repository, { u"product-id": new_product["id"], u"name": gen_alphanumeric(), u"content-type": u"yum", u"publish-via-http": u"true", u"url": GOOGLE_CHROME_REPO, }, ) # Create a Puppet repository new_repo2 = self._create( new_user, Repository, { u"product-id": new_product["id"], u"name": gen_alphanumeric(), u"content-type": u"puppet", u"publish-via-http": u"true", u"url": FAKE_0_PUPPET_REPO, }, ) # Synchronize YUM repository result = Repository.with_user(new_user["login"], new_user["password"]).synchronize({u"id": new_repo1["id"]}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Synchronize puppet repository result = Repository.with_user(new_user["login"], new_user["password"]).synchronize({u"id": new_repo2["id"]}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Create a Content View new_cv = self._create(new_user, ContentView, {u"organization-id": new_org["id"], u"name": gen_alphanumeric()}) # Associate yum repository to content view result = ContentView.with_user(new_user["login"], new_user["password"]).add_repository( {u"id": new_cv["id"], u"repository-id": new_repo1["id"]} ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Fetch puppet module puppet_result = PuppetModule.with_user(new_user["login"], new_user["password"]).list( {u"repository-id": new_repo2["id"], u"per-page": False} ) self.assertEqual(puppet_result.return_code, 0) self.assertEqual(len(puppet_result.stderr), 0) # Associate puppet repository to content view result = ContentView.with_user(new_user["login"], new_user["password"]).puppet_module_add( {u"content-view-id": new_cv["id"], u"id": puppet_result.stdout[0]["id"]} ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Publish content view result = ContentView.with_user(new_user["login"], new_user["password"]).publish({u"id": new_cv["id"]}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Only after we publish version1 the info is populated. result = ContentView.with_user(new_user["login"], new_user["password"]).info({u"id": new_cv["id"]}) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Let us now store the version1 id version1_id = result.stdout["versions"][0]["id"] # Promote content view to first lifecycle result = ContentView.with_user(new_user["login"], new_user["password"]).version_promote( {u"id": result.stdout["versions"][0]["id"], u"to-lifecycle-environment-id": lifecycle1["id"]} ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Promote content view to second lifecycle result = ContentView.with_user(new_user["login"], new_user["password"]).version_promote( {u"id": version1_id, u"to-lifecycle-environment-id": lifecycle2["id"]} ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Create a new libvirt compute resource result = self._create( new_user, ComputeResource, { u"name": gen_alphanumeric(), u"provider": u"Libvirt", u"url": u"qemu+tcp://{0}:16509/system".format(conf.properties["main.server.hostname"]), }, ) # Create a new subnet new_subnet = self._create( new_user, Subnet, {u"name": gen_alphanumeric(), u"network": gen_ipaddr(ip3=True), u"mask": u"255.255.255.0"} ) # Create a domain new_domain = self._create(new_user, Domain, {u"name": gen_alphanumeric()}) # Fetch Puppet environment for second lifecycle # (unfortunately it is not straight forward to extract this) # The puppet environment we want has a name like this... env_name = u"KT_{0}_{1}_".format( # Hyphens are replaced by underscores new_org["label"].replace("-", "_"), lifecycle2["label"].replace("-", "_"), ) # We fetch all the puppet environments for our organization... result = Environment.with_user(new_user["login"], new_user["password"]).list( {u"search": u'organization="{0}"'.format(new_org["name"])} ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0) # Now look for the puppet environment that matches lifecycle2 puppet_env = [env for env in result.stdout if env["name"].startswith(env_name)] self.assertEqual(len(puppet_env), 1) # Create a hostgroup... new_hg = self._create( new_user, HostGroup, { u"name": gen_alphanumeric(), u"domain-id": new_domain["id"], u"subnet-id": new_subnet["id"], u"environment-id": puppet_env[0]["id"], }, ) # ...and add it to the organization result = Org.with_user(new_user["login"], new_user["password"]).add_hostgroup( {u"id": new_org["id"], u"hostgroup-id": new_hg["id"]} ) self.assertEqual(result.return_code, 0) self.assertEqual(len(result.stderr), 0)