Пример #1
0
    def test_positive_update_org_loc(self):
        """Create a filter and assign it to another organization and location.

         @id: 9bb59109-9701-4ef3-95c6-81f387d372da

         @Assert: Filter is created and assigned to new org and loc.
         """
        org = make_org()
        loc = make_location()
        filter_ = make_filter({
            'role-id': self.role['id'],
            'permissions': self.perms,
            'organization-ids': org['id'],
            'location-ids': loc['id']
        })
        # Update org and loc
        new_org = make_org()
        new_loc = make_location()
        Filter.update({
            'id': filter_['id'],
            'permissions': self.perms,
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id']
        })
        filter_ = Filter.info({'id': filter_['id']})
        # We expect here only one organization and location
        self.assertEqual(filter_['organizations'][0], new_org['name'])
        self.assertEqual(filter_['locations'][0], new_loc['name'])
Пример #2
0
    def test_update_location(self):
        """@Test: Update environment location with new value

        @Feature: Environment - Update

        @Assert: Environment Update finished and new location is assigned

        """
        try:
            old_loc = make_location()
            new_loc = make_location()
            env_name = gen_string('alphanumeric', 10)
            make_environment({
                'name': env_name,
                'location-ids': old_loc['id'],
            })
        except CLIFactoryError as err:
            self.fail(err)
        result = Environment.info({'name': env_name})
        self.assertIn(old_loc['name'], result.stdout['locations'])

        result = Environment.update({
            'name': env_name,
            'location-ids': new_loc['id']
        })
        self.assertEqual(result.return_code, 0)

        result = Environment.info({'name': env_name})
        self.assertIn(new_loc['name'], result.stdout['locations'])
        self.assertNotIn(old_loc['name'], result.stdout['locations'])
Пример #3
0
    def test_create_location_with_different_names_negative(self, name):
        """@Test: Try to create location using invalid names only

        @Feature: Location

        @Assert: Location is not created

        """
        with self.assertRaises(CLIFactoryError):
            make_location({'name': name})
Пример #4
0
    def test_create_location_with_comp_resource_by_id_negative(self):
        """@Test: Try to create new location with incorrect compute resource
        assigned to it. Use compute resource id as a parameter

        @Feature: Location

        @Assert: Location is not created

        """
        with self.assertRaises(CLIFactoryError):
            make_location({'compute-resource-ids': gen_string('numeric', 6)})
Пример #5
0
    def test_create_location_with_user_by_name_negative(self):
        """@Test: Try to create new location with incorrect user assigned to it
        Use user login as a parameter

        @Feature: Location

        @Assert: Location is not created

        """
        with self.assertRaises(CLIFactoryError):
            make_location({'users': gen_string('utf8', 80)})
Пример #6
0
    def test_negative_create_with_compresource_by_id(self):
        """Try to create new location with incorrect compute resource
        assigned to it. Use compute resource id as a parameter

        @id: 83115ace-9340-44cd-9e47-5585b267d7ed

        @Assert: Location is not created

        """
        with self.assertRaises(CLIFactoryError):
            make_location({'compute-resource-ids': gen_string('numeric', 6)})
Пример #7
0
    def test_negative_create_with_user_by_name(self):
        """Try to create new location with incorrect user assigned to it
        Use user login as a parameter

        @id: fa892edf-8c42-44dc-8f36-bed50798b59b

        @Assert: Location is not created

        """
        with self.assertRaises(CLIFactoryError):
            make_location({'users': gen_string('utf8', 80)})
Пример #8
0
    def test_create_location_with_different_names_negative(self):
        """@Test: Try to create location using invalid names only

        @Feature: Location

        @Assert: Location is not created

        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                with self.assertRaises(CLIFactoryError):
                    make_location({'name': invalid_name})
Пример #9
0
    def test_negative_create_with_name(self):
        """Try to create location using invalid names only

        @id: 2dfe8ff0-e84a-42c0-a480-0f8345ee66d0

        @Assert: Location is not created

        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                with self.assertRaises(CLIFactoryError):
                    make_location({'name': invalid_name})
Пример #10
0
    def test_create_location_with_same_names_negative(self):
        """@Test: Try to create location using same name twice

        @Feature: Location

        @Assert: Second location is not created

        """
        name = gen_string('utf8')
        loc = make_location({'name': name})
        self.assertEqual(loc['name'], name)
        with self.assertRaises(CLIFactoryError):
            make_location({'name': name})
Пример #11
0
    def test_negative_create_with_same_name(self):
        """Try to create location using same name twice

        @id: 4fbaea41-9775-40a2-85a5-4dc05cc95134

        @Assert: Second location is not created

        """
        name = gen_string('utf8')
        loc = make_location({'name': name})
        self.assertEqual(loc['name'], name)
        with self.assertRaises(CLIFactoryError):
            make_location({'name': name})
Пример #12
0
    def test_negative_create_with_name(self):
        """Try to create location using invalid names only

        :id: 2dfe8ff0-e84a-42c0-a480-0f8345ee66d0

        :expectedresults: Location is not created


        :CaseImportance: Critical
        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                with self.assertRaises(CLIFactoryError):
                    make_location({'name': invalid_name})
Пример #13
0
    def test_positive_create_with_parent(self):
        """Create new location with parent location specified

        :id: 49b34733-103a-4fee-818b-6a3386253af1

        :BZ: 1299802

        :expectedresults: Location created successfully and has correct and
            expected parent location set

        :CaseImportance: High
        """
        parent_loc = make_location()
        loc = make_location({'parent-id': parent_loc['id']})
        self.assertEqual(loc['parent'], parent_loc['name'])
Пример #14
0
    def test_negative_create_with_same_name(self):
        """Try to create location using same name twice

        :id: 4fbaea41-9775-40a2-85a5-4dc05cc95134

        :expectedresults: Second location is not created


        :CaseImportance: Critical
        """
        name = gen_string('utf8')
        loc = make_location({'name': name})
        self.assertEqual(loc['name'], name)
        with self.assertRaises(CLIFactoryError):
            make_location({'name': name})
Пример #15
0
    def test_positive_list_with_org_and_loc_by_name(self):
        """Test Environment List filtering.

        :id: 962c6750-f203-4478-8827-651db208ff92

        :expectedresults: Results that match both organization and location are
            returned

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create 2 envs with the same organization but different locations
        org = make_org()
        locs = [make_location() for _ in range(2)]
        envs = [make_environment({
            'organizations': org['name'],
            'locations': loc['name'],
        }) for loc in locs]
        results = Environment.list({'organization': org['name']})
        # List environments for the whole organization
        self.assertEqual(len(results), 2)
        self.assertEqual(
            {env['name'] for env in envs},
            {result['name'] for result in results}
        )
        # List environments with additional location filtering
        results = Environment.list({
            'organization': org['name'],
            'location': locs[0]['name'],
        })
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['name'], envs[0]['name'])
Пример #16
0
    def test_positive_remove_capsule_by_id(self):
        """Remove a capsule from organization by its id

        :id: 98681f4f-a5e2-44f6-8879-d23ad90b4c59

        :expectedresults: Capsule is removed from the org

        :CaseLevel: Integration
        """
        loc = make_location()
        proxy = make_proxy()
        # Add capsule and location to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(location_cleanup, loc['id'])

        Location.add_smart_proxy({
            'id': loc['id'],
            'smart-proxy-id': proxy['id'],
        })
        Location.remove_smart_proxy({
            'id': loc['id'],
            'smart-proxy-id': proxy['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertNotIn(proxy['name'], loc['smart-proxies'])
Пример #17
0
    def test_positive_remove_capsule_by_name(self):
        """Remove a capsule from organization by its name

        :id: 91dcafbe-5f52-48af-b5c7-9319b2929f5a

        :expectedresults: Capsule is removed from the org

        :CaseLevel: Integration
        """
        loc = make_location()
        proxy = make_proxy()
        # Add capsule and location to cleanup list
        self.addCleanup(capsule_cleanup, proxy['id'])
        self.addCleanup(location_cleanup, loc['id'])

        Location.add_smart_proxy({
            'name': loc['name'],
            'smart-proxy': proxy['name'],
        })
        Location.remove_smart_proxy({
            'name': loc['name'],
            'smart-proxy': proxy['name'],
        })
        loc = Location.info({'name': loc['name']})
        self.assertNotIn(proxy['name'], loc['smart-proxies'])
Пример #18
0
    def test_positive_update_parameter(self):
        """Update a parameter associated with location

        :id: 7b61fa71-0203-4709-9abd-9bb51ce6c19f

        :expectedresults: Parameter is updated

        :CaseImportance: Critical
        """
        param_name = gen_string('alpha')
        param_new_value = gen_string('alpha')
        location = make_location()
        # Create parameter
        Location.set_parameter({
            'name': param_name,
            'value': gen_string('alpha'),
            'location': location['name'],
        })
        location = Location.info({'id': location['id']})
        self.assertEqual(len(location['parameters']), 1)
        Location.set_parameter({
            'name': param_name,
            'value': param_new_value,
            'location': location['name'],
        })
        location = Location.info({'id': location['id']})
        self.assertEqual(len(location['parameters']), 1)
        self.assertEqual(
            param_new_value, location['parameters'][param_name.lower()])
Пример #19
0
    def test_negative_list_with_org_and_loc_by_id(self):
        """Test Environment List filtering.

        :id: b1659c48-302b-4fe3-a38b-cd34c0fd4878

        :expectedresults: Server returns empty result as there is no
            environment associated with location or organization

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        locs = [make_location() for _ in range(2)]
        make_environment({
            'organization-ids': org['id'],
            'location-ids': locs[0]['id'],
        })
        # But filter by another location
        results = Environment.list({
            'organization-id': org['id'],
            'location-id': locs[1]['id'],
        })
        self.assertEqual(len(results), 0)
Пример #20
0
    def test_negative_list_with_non_existing_org_and_loc_by_id(self):
        """Test Environment List filtering parameters validation.

        :id: 97872953-e1aa-44bd-9ce0-a04bccbc9e94

        :expectedresults: Server returns empty result as there is no
            environment associated with location

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        loc = make_location()
        make_environment({
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })
        # Filter by non-existing location and existing organization
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': org['id'],
                'location-id': gen_string('numeric')
            })
        # Filter by non-existing organization and existing location
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization-id': gen_string('numeric'),
                'location-id': loc['id']
            })
Пример #21
0
    def test_positive_update_org_loc(self):
        """Update org and location of selected discovery rule

        :id: 26da79aa-30e5-4052-98ae-141de071a68a

        :expectedresults: Rule was updated and with given org & location.

        :BZ: 1377990

        :CaseLevel: Integration
        """
        new_org = make_org()
        new_loc = make_location()
        new_hostgroup = make_hostgroup({
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id'],
        })
        rule = self._make_discoveryrule()
        DiscoveryRule.update({
            'id': rule['id'],
            'organization-ids': new_org['id'],
            'location-ids': new_loc['id'],
            'hostgroup-id': new_hostgroup['id'],
        })
        rule = DiscoveryRule.info({'id': rule['id']})
        self.assertIn(new_org['name'], rule['organizations'])
        self.assertIn(new_loc['name'], rule['locations'])
Пример #22
0
    def test_negative_list_with_org_and_loc_by_name(self):
        """Test Environment List filtering.

        :id: b8382ebb-ffa3-4637-b3b4-444af6c2fe9b

        :expectedresults: Server returns empty result as there is no
            environment associated with location or organization

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        locs = [make_location() for _ in range(2)]
        make_environment({
            'organizations': org['name'],
            'locations': locs[0]['name'],
        })
        # But filter by another location
        results = Environment.list({
            'organization': org['name'],
            'location': locs[1]['name'],
        })
        self.assertEqual(len(results), 0)
Пример #23
0
 def setUpClass(cls):
     """Tests for discovery rules via Hammer CLI"""
     super(DiscoveryRuleRoleTestCase, cls).setUpClass()
     cls.org = make_org()
     cls.loc = make_location()
     cls.hostgroup = make_hostgroup({
         u'organization-ids': cls.org['id'],
         u'location-ids': cls.loc['id'],
     })
     cls.password = gen_alphanumeric()
     cls.user = make_user({
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
         'password': cls.password,
     })
     cls.user['password'] = cls.password
     User.add_role({
         'login': cls.user['login'],
         'role': 'Discovery Manager',
     })
     cls.user_reader = make_user({
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
         'password': cls.password,
     })
     cls.user_reader['password'] = cls.password
     User.add_role({
         'login': cls.user_reader['login'],
         'role': 'Discovery Reader',
     })
Пример #24
0
    def test_positive_remove_parameter_by_loc_name(self):
        """Remove a parameter from location

        :id: 97fda466-1894-431e-bc76-3b1c7643522f

        :expectedresults: Parameter is removed from the location

        :CaseImportance: Critical
        """
        param_name = gen_string('alpha')
        location = make_location()
        Location.set_parameter({
            'name': param_name,
            'value': gen_string('alpha'),
            'location': location['name'],
        })
        location = Location.info({'id': location['id']})
        self.assertEqual(len(location['parameters']), 1)
        Location.delete_parameter({
            'name': param_name,
            'location': location['name'],
        })
        location = Location.info({'id': location['id']})
        self.assertEqual(len(location['parameters']), 0)
        self.assertNotIn(param_name.lower(), location['parameters'])
Пример #25
0
    def test_negative_list_with_non_existing_org_and_loc_by_name(self):
        """Test Environment List filtering parameters validation.

        :id: 38cb48e3-a836-47d0-b8a8-9acd33a30546

        :expectedresults: Server returns empty result as there is no
            environment associated with location

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create env with specified organization and location
        org = make_org()
        loc = make_location()
        make_environment({
            'organizations': org['name'],
            'locations': loc['name'],
        })
        # Filter by non-existing location and existing organization
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization': org['name'],
                'location': gen_string('alpha')
            })
        # Filter by non-existing organization and existing location
        with self.assertRaises(CLIReturnCodeError):
            Environment.list({
                'organization': gen_string('alpha'),
                'location': loc['name']
            })
Пример #26
0
    def test_positive_list_with_org_and_loc_by_id(self):
        """Test Environment List filtering.

        :id: 643f7cb5-0817-4b0a-ba5e-434df2033a40

        :expectedresults: Results that match both organization and location are
            returned

        :CaseLevel: Integration

        :BZ: 1337947
        """
        # Create 2 envs with the same organization but different locations
        org = make_org()
        locs = [make_location() for _ in range(2)]
        envs = [make_environment({
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        }) for loc in locs]
        results = Environment.list({'organization-id': org['id']})
        # List environments for the whole organization
        self.assertEqual(len(results), 2)
        self.assertEqual(
            {env['id'] for env in envs},
            {result['id'] for result in results}
        )
        # List environments with additional location filtering
        results = Environment.list({
            'organization-id': org['id'],
            'location-id': locs[0]['id'],
        })
        self.assertEqual(len(results), 1)
        self.assertEqual(results[0]['id'], envs[0]['id'])
Пример #27
0
    def test_positive_update_from_compresources_to_compresource(self):
        """Create location with multiple (not less than three) compute
        resources assigned to it. Try to update location and overwrite all
        compute resources with a new single compute resource. Use compute
        resource id as a parameter

        :id: 3a547413-53dc-4305-84e9-8db7a6bed3b2

        :expectedresults: Location updated successfully and has correct compute
            resource assigned to it

        :CaseImportance: Critical
        """
        resources_amount = randint(3, 5)
        resources = [make_compute_resource() for _ in range(resources_amount)]
        loc = make_location({
            'compute-resource-ids': [resource['id'] for resource in resources],
        })
        self.assertEqual(len(loc['compute-resources']), resources_amount)
        for resource in resources:
            self.assertIn(resource['name'], loc['compute-resources'])

        new_resource = make_compute_resource()
        Location.update({
            'compute-resource-ids': new_resource['id'],
            'id': loc['id'],
        })

        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['compute-resources']), 1)
        self.assertEqual(loc['compute-resources'][0], new_resource['name'])
Пример #28
0
    def test_positive_update_with_manager_role(self):
        """Create template providing the initial name, then update its name
        with manager user role.

        :id: 28c4357a-93cb-4b01-a445-5db50435bcc0

        :expectedresults: Provisioning Template is created, and its name can
            be updated.

        :CaseImportance: Critical

        :BZ: 1277308
        """
        new_name = gen_string('alpha')
        username = gen_string('alpha')
        password = gen_string('alpha')
        org = make_org()
        loc = make_location()
        template = make_template({
            'organization-ids': org['id'], 'location-ids': loc['id']})
        # Create user with Manager role
        user = make_user({
            'login': username,
            'password': password,
            'admin': False,
            'organization-ids': org['id'],
            'location-ids': loc['id'],
        })
        User.add_role({'id': user['id'], 'role': "Manager"})
        # Update template name with that user
        Template.with_user(username=username, password=password).update({
            'id': template['id'], 'name': new_name})
        template = Template.info({'id': template['id']})
        self.assertEqual(new_name, template['name'])
Пример #29
0
    def test_positive_remove_parameter_by_loc_id(self):
        """Remove a parameter from location

        :id: 13836073-3e39-4d3e-b4b4-e87619c28bae

        :expectedresults: Parameter is removed from the location

        :CaseImportance: Critical
        """
        param_name = gen_string('alpha')
        location = make_location()
        Location.set_parameter({
            'name': param_name,
            'value': gen_string('alpha'),
            'location-id': location['id'],
        })
        location = Location.info({'id': location['id']})
        self.assertEqual(len(location['parameters']), 1)
        Location.delete_parameter({
            'name': param_name,
            'location-id': location['id'],
        })
        location = Location.info({'id': location['id']})
        self.assertEqual(len(location['parameters']), 0)
        self.assertNotIn(param_name.lower(), location['parameters'])
Пример #30
0
    def test_positive_update_from_hostgroups_to_hostgroups(self):
        """Create location with multiple (three) host groups assigned to
        it. Try to update location and overwrite all host groups by new
        multiple (two) host groups. Use host groups name as a parameter

        :id: e53504d0-8328-485c-bc8c-36ea9a2ad3e1

        :expectedresults: Location updated successfully and has correct and
            expected host groups assigned to it

        :CaseImportance: Critical
        """
        host_groups = [make_hostgroup() for _ in range(3)]
        loc = make_location({
            'hostgroups': [hg['name'] for hg in host_groups],
        })
        self.assertEqual(len(loc['hostgroups']), 3)
        for host_group in host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
        new_host_groups = [make_hostgroup() for _ in range(2)]
        Location.update({
            'hostgroups': [hg['name'] for hg in new_host_groups],
            'id': loc['id'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertEqual(len(loc['hostgroups']), 2)
        for host_group in new_host_groups:
            self.assertIn(host_group['name'], loc['hostgroups'])
Пример #31
0
    def test_positive_create_with_default_loc(self):
        """Check if user with default location can be created

        @id: efe7256d-8c8f-444c-8d59-43500e1319c3

        @Assert: User is created and has new default location assigned
        """
        location = make_location()
        user = make_user({
            'default-location-id': location['id'],
            'location-ids': location['id'],
        })
        self.assertIn(location['name'], user['locations'])
        self.assertEqual(location['name'], user['default-location'])
Пример #32
0
    def test_positive_create_with_loc(self):
        """Create Compute Resource with location

        :id: 224c7cbc-6bac-4a94-8141-d6249896f5a2

        :expectedresults: Compute resource is created and has location assigned


        :CaseImportance: Critical
        """
        location = make_location()
        comp_resource = make_compute_resource({'location-ids': location['id']})
        self.assertEqual(1, len(comp_resource['locations']))
        self.assertEqual(comp_resource['locations'][0], location['name'])
Пример #33
0
    def test_positive_create_with_subnet_by_id(self):
        """Create new location with assigned subnet to it. Use subnet id
        as a parameter

        @id: cef956bd-7c78-49f8-917a-f344fadf217a

        @Assert: Location created successfully and has correct subnet with
        expected network address assigned to it

        """
        subnet = make_subnet()
        loc = make_location({'subnet-ids': subnet['id']})
        self.assertIn(subnet['name'], loc['subnets'][0])
        self.assertIn(subnet['network'], loc['subnets'][0])
Пример #34
0
    def test_positive_create_with_medium(self):
        """Create new location with assigned media to it.

        :id: 72d71056-6bf7-4af0-95d4-828709e1efba

        :expectedresults: Location created successfully and has correct and
            expected media assigned to it

        :CaseImportance: Critical
        """
        medium = make_medium()
        loc = make_location({'medium-ids': medium['id']})
        self.assertGreater(len(loc['installation-media']), 0)
        self.assertEqual(loc['installation-media'][0], medium['name'])
Пример #35
0
    def test_positive_create_with_environment_by_name(self):
        """Create new location with assigned environment to it. Use
        environment name as a parameter

        :id: 3c9a47b5-798b-4f41-a9dc-219ad43b6fdf

        :expectedresults: Location created successfully and has correct and
            expected environment assigned to it

        :CaseImportance: Critical
        """
        env = make_environment()
        loc = make_location({'environments': env['name']})
        self.assertEqual(loc['environments'][0], env['name'])
Пример #36
0
    def test_positive_create_with_hostgroup_by_id(self):
        """Create new location with assigned host group to it. Use host
        group id as a parameter

        :id: d4421f79-72ea-4d68-8ae7-aedd2b32dfe9

        :expectedresults: Location created successfully and has correct and
            expected host group assigned to it

        :CaseImportance: Critical
        """
        host_group = make_hostgroup()
        loc = make_location({'hostgroup-ids': host_group['id']})
        self.assertEqual(loc['hostgroups'][0], host_group['name'])
Пример #37
0
    def test_positive_create_with_hostgroup_by_name(self):
        """Create new location with assigned host group to it. Use host
        group name as a parameter

        :id: 7b465d98-efcc-4c49-b45b-b51c26d5010d

        :expectedresults: Location created successfully and has correct and
            expected host group assigned to it

        :CaseImportance: Critical
        """
        host_group = make_hostgroup()
        loc = make_location({'hostgroups': host_group['name']})
        self.assertEqual(loc['hostgroups'][0], host_group['name'])
Пример #38
0
    def test_positive_create_with_user_by_id(self):
        """Create new location with assigned user to it. Use user id as
        a parameter

        :id: 96dd25bf-8535-41a5-ba63-60a2b52487b8

        :expectedresults: Location created successfully and has correct user
            assigned to it with expected login name

        :CaseImportance: Critical
        """
        user = make_user()
        loc = make_location({'user-ids': user['id']})
        self.assertEqual(loc['users'][0], user['login'])
Пример #39
0
    def test_positive_create_with_name(self):
        """Try to create location using different value types as a name

        :id: 76a90b92-296c-4b5a-9c81-183ff71937e2

        :expectedresults: Location is created successfully and has proper name


        :CaseImportance: Critical
        """
        for name in valid_loc_data_list():
            with self.subTest(name):
                loc = make_location({'name': name})
                self.assertEqual(loc['name'], name)
Пример #40
0
    def test_positive_create_with_loc(self):
        """Check if Environment with Location can be created

        @id: d2187971-86b2-40c9-a93c-66f37691ae2b

        @Assert: Environment is created and has new Location assigned

        """
        new_loc = make_location()
        new_environment = make_environment({
            'location-ids': new_loc['id'],
            'name': gen_string('alpha'),
        })
        self.assertIn(new_loc['name'], new_environment['locations'])
Пример #41
0
    def test_positive_create_with_subnet_by_name(self):
        """Create new location with assigned subnet to it. Use subnet
        name as a parameter

        @id: efe2fce4-ecd9-4765-8d77-dff776a1ba13

        @Assert: Location created successfully and has correct subnet with
        expected network address assigned to it

        """
        subnet = make_subnet()
        loc = make_location({'subnets': subnet['name']})
        self.assertIn(subnet['name'], loc['subnets'][0])
        self.assertIn(subnet['network'], loc['subnets'][0])
Пример #42
0
    def test_positive_create_with_compresource_by_name(self):
        """Create new location with compute resource assigned to it. Use
        compute resource name as a parameter

        :id: a849c847-bc18-4d87-a47b-43975090f509

        :expectedresults: Location created successfully and has correct compute
            resource assigned to it

        :CaseImportance: Critical
        """
        comp_resource = make_compute_resource()
        loc = make_location({'compute-resources': comp_resource['name']})
        self.assertEqual(loc['compute-resources'][0], comp_resource['name'])
Пример #43
0
    def test_positive_create_with_user_by_name(self):
        """Create new location with assigned user to it. Use user login
        as a parameter

        :id: ed65dfd2-00b6-4ec9-9da0-1956d8a5cf5d

        :expectedresults: Location created successfully and has correct user
            assigned to it with expected login name

        :CaseImportance: Critical
        """
        user = make_user()
        loc = make_location({'users': user['login']})
        self.assertEqual(loc['users'][0], user['login'])
Пример #44
0
    def test_positive_create_with_compresource_by_id(self):
        """Create new location with compute resource assigned to it. Use
        compute resource id as a parameter

        :id: 49c72f7d-08b7-4dd3-af7f-5b97889a4583

        :expectedresults: Location created successfully and has correct compute
            resource assigned to it

        :CaseImportance: Critical
        """
        comp_resource = make_compute_resource()
        loc = make_location({'compute-resource-ids': comp_resource['id']})
        self.assertEqual(loc['compute-resources'][0], comp_resource['name'])
Пример #45
0
    def test_positive_create_with_domain_by_id(self):
        """Create new location with assigned domain to it. Use domain id
        as a parameter

        :id: 54507b72-93ea-471e-bfd5-857c44b6abed

        :expectedresults: Location created successfully and has correct and
            expected domain assigned to it

        :CaseImportance: Critical
        """
        domain = make_domain()
        loc = make_location({'domain-ids': domain['id']})
        self.assertEqual(loc['domains'][0], domain['name'])
Пример #46
0
    def test_positive_create_with_domain_by_name(self):
        """Create new location with assigned domain to it. Use domain
        name as a parameter

        :id: 06426c06-744d-44cf-bbba-449ef1f62659

        :expectedresults: Location created successfully and has correct and
            expected domain assigned to it

        :CaseImportance: Critical
        """
        domain = make_domain()
        loc = make_location({'domains': domain['name']})
        self.assertEqual(loc['domains'][0], domain['name'])
Пример #47
0
    def test_positive_create_with_environment_by_id(self):
        """Create new location with assigned environment to it. Use
        environment id as a parameter

        :id: cd38b895-57f7-4d07-aa4b-7299a69ec203

        :expectedresults: Location created successfully and has correct and
            expected environment assigned to it

        :CaseImportance: Critical
        """
        env = make_environment()
        loc = make_location({'environment-ids': env['id']})
        self.assertEqual(loc['environments'][0], env['name'])
Пример #48
0
    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)
Пример #49
0
def foreman_discovery(target_sat):
    """Steps to Configure foreman discovery

    1. Build PXE default template
    2. Create Organization/Location
    3. Update Global parameters to set default org and location for
        discovered hosts.
    4. Enable auto_provision flag to perform discovery via discovery
        rules.
    """
    # Build PXE default template to get default PXE file
    Template.build_pxe_default()
    # let's just modify the timeouts to speed things up
    target_sat.execute(
        "sed -ie 's/TIMEOUT [[:digit:]]\\+/TIMEOUT 1/g' /var/lib/tftpboot/pxelinux.cfg/default"
    )
    target_sat.execute(
        "sed -ie '/APPEND initrd/s/$/ fdi.countdown=1/' /var/lib/tftpboot/pxelinux.cfg/default"
    )

    # Create Org and location
    org = make_org()
    loc = make_location()

    # Get default settings values
    default_discovery_loc = Settings.list({'search': 'name=discovery_location'})[0]
    default_discovery_org = Settings.list({'search': 'name=discovery_organization'})[0]
    default_discovery_auto = Settings.list({'search': 'name=discovery_auto'})[0]

    # Update default org and location params to place discovered host
    Settings.set({'name': 'discovery_location', 'value': loc['name']})
    Settings.set({'name': 'discovery_organization', 'value': org['name']})

    # Enable flag to auto provision discovered hosts via discovery rules
    Settings.set({'name': 'discovery_auto', 'value': 'true'})

    # Flag which shows whether environment is fully configured for
    # discovered host provisioning.
    configured_env = configure_env_for_provision(org=org, loc=loc)
    yield {
        'default_discovery_auto': default_discovery_auto,
        'default_discovery_loc': default_discovery_loc,
        'default_discovery_org': default_discovery_org,
        'configured_env': configured_env,
    }
    # Restore default global setting's values
    Settings.set({'name': 'discovery_location', 'value': default_discovery_loc['value']})
    Settings.set({'name': 'discovery_organization', 'value': default_discovery_org['value']})
    Settings.set({'name': 'discovery_auto', 'value': default_discovery_auto['value']})
Пример #50
0
    def test_negative_update_with_domain_by_id(self):
        """Try to update existing location with incorrect domain. Use
        domain id as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'domain-ids': gen_string('numeric', 6),
                'id': loc['id'],
            })
Пример #51
0
    def test_positive_delete_by_id(self):
        """Try to delete location using id of that location as a
        parameter

        :id: 71e394e3-85e6-456d-b03d-6787db9059aa

        :expectedresults: Location is deleted successfully


        :CaseImportance: Critical
        """
        loc = make_location()
        Location.delete({'id': loc['id']})
        with self.assertRaises(CLIReturnCodeError):
            Location.info({'id': loc['id']})
Пример #52
0
    def test_positive_create_with_template_by_name(self):
        """Create new location with config template assigned to it. Use
        config template name as a parameter

        @Feature: Location

        @Assert: Location created successfully and list of config templates
        assigned to that location should contain expected one

        """
        template = make_template()
        loc = make_location({'config-templates': template['name']})
        self.assertGreaterEqual(len(loc['templates']), 1)
        self.assertIn(u'{0} ({1})'.format(template['name'], template['type']),
                      loc['templates'])
Пример #53
0
    def test_negative_update_with_template_by_name(self):
        """Try to update existing location with incorrect config
        template. Use template name as a parameter

        @Feature: Location

        @Assert: Location is not updated

        """
        loc = make_location()
        with self.assertRaises(CLIReturnCodeError):
            Location.update({
                'config-templates': gen_string('utf8', 80),
                'id': loc['id'],
            })
Пример #54
0
def test_positive_create_with_loc(libvirt_url):
    """Create Compute Resource with location

    :id: 224c7cbc-6bac-4a94-8141-d6249896f5a2

    :expectedresults: Compute resource is created and has location assigned

    :CaseImportance: High

    :CaseLevel: Integration
    """
    location = make_location()
    comp_resource = make_compute_resource({'location-ids': location['id']})
    assert len(comp_resource['locations']) == 1
    assert comp_resource['locations'][0] == location['name']
Пример #55
0
    def test_positive_add_capsule_by_id(self):
        """Add a capsule to organization by its ID

        @feature: Organization

        @assert: Capsule is added to the org
        """
        loc = make_location()
        proxy = make_proxy()
        Location.add_smart_proxy({
            'name': loc['name'],
            'smart-proxy-id': proxy['id'],
        })
        loc = Location.info({'name': loc['name']})
        self.assertIn(proxy['name'], loc['smart-proxies'])
Пример #56
0
    def test_positive_create_with_template_by_id(self):
        """Create new location with config template assigned to it. Use
        config template id as a parameter

        @id: 1ae669e3-479a-427a-ac97-0878667c3dce

        @Assert: Location created successfully and list of config templates
        assigned to that location should contain expected one

        """
        template = make_template()
        loc = make_location({'config-template-ids': template['id']})
        self.assertGreaterEqual(len(loc['templates']), 1)
        self.assertIn(u'{0} ({1})'.format(template['name'], template['type']),
                      loc['templates'])
Пример #57
0
    def test_positive_create_with_default_loc(self):
        """Check if user with default location can be created

        :id: efe7256d-8c8f-444c-8d59-43500e1319c3

        :expectedresults: User is created and has new default location assigned

        :CaseImportance: Critical
        """
        location = make_location()
        user = make_user({
            'default-location-id': location['id'],
            'location-ids': location['id']
        })
        assert location['name'] in user['locations']
        assert location['name'] == user['default-location']
Пример #58
0
    def test_negative_update_with_name(self):
        """Try to update location using invalid names only

        @Feature: Location

        @Assert: Location is not updated

        """
        for invalid_name in invalid_values_list():
            with self.subTest(invalid_name):
                loc = make_location()
                with self.assertRaises(CLIReturnCodeError):
                    Location.update({
                        'id': loc['id'],
                        'new-name': invalid_name,
                    })
Пример #59
0
    def test_positive_create_with_template_by_name(self):
        """Create new location with config template assigned to it. Use
        config template name as a parameter

        :id: a523bf4e-dc90-4f15-ae79-5246d0568fa5

        :expectedresults: Location created successfully and list of config
            templates assigned to that location should contain expected one

        :CaseImportance: Critical
        """
        template = make_template()
        loc = make_location({'config-templates': template['name']})
        self.assertGreaterEqual(len(loc['templates']), 1)
        self.assertIn(u'{0} ({1})'.format(template['name'], template['type']),
                      loc['templates'])
Пример #60
0
    def test_positive_delete_by_name(self):
        """Try to delete location using name of that location as a
        parameter. Use different value types for testing.

        @Feature: Location

        @Assert: Location is deleted successfully

        """
        for name in valid_loc_data_list():
            with self.subTest(name):
                loc = make_location({'name': name})
                self.assertEqual(loc['name'], name)
                Location.delete({'name': loc['name']})
                with self.assertRaises(CLIReturnCodeError):
                    Location.info({'id': loc['id']})