Beispiel #1
0
    def test_list(self):
        """@Test: Check if Subnet can be listed

        @Feature: Subnet - List

        @Assert: Subnet is listed

        """

        # Fetch current total
        result = Subnet.list()
        total_subnet = len(result.stdout)

        # Make a new subnet
        try:
            make_subnet()
        except CLIFactoryError as err:
            self.fail(err)

        # Fetch total again
        result = Subnet.list()
        self.assertGreater(
            len(result.stdout),
            total_subnet,
            "Total subnets should have increased")
Beispiel #2
0
    def test_negative_create_1(self):
        """@Test: Create subnet with invalid or missing required attributes

        @Feature: Subnet create

        @Assert: Subnet is not created
        """
        for options in invalid_missing_attributes():
            with self.subTest(options):
                with self.assertRaises(CLIFactoryError):
                    make_subnet(options)
Beispiel #3
0
    def test_negative_create_with_attributes(self):
        """Create subnet with invalid or missing required attributes

        @id: de468dd3-7ba8-463e-881a-fd1cb3cfc7b6

        @Assert: Subnet is not created
        """
        for options in invalid_missing_attributes():
            with self.subTest(options):
                with self.assertRaisesRegex(CLIFactoryError, u"Could not create the subnet:"):
                    make_subnet(options)
Beispiel #4
0
    def test_list(self):
        """@Test: Check if Subnet can be listed

        @Feature: Subnet - List

        @Assert: Subnet is listed
        """
        # Fetch current total
        subnets_before = Subnet.list()
        # Make a new subnet
        make_subnet()
        # Fetch total again
        subnets_after = Subnet.list()
        self.assertGreater(len(subnets_after), len(subnets_before))
Beispiel #5
0
    def test_positive_list(self):
        """Check if Subnet can be listed

        @id: 2ee376f7-9dd9-4b46-b414-801197d5455c

        @Assert: Subnet is listed
        """
        # Fetch current total
        subnets_before = Subnet.list()
        # Make a new subnet
        make_subnet()
        # Fetch total again
        subnets_after = Subnet.list()
        self.assertGreater(len(subnets_after), len(subnets_before))
Beispiel #6
0
    def test_negative_create_1(self, options):
        """@Test: Create subnet with invalid or missing required attributes

        @Feature: Subnet create

        @Assert: Subnet is not created

        """
        bug_id = options.pop('bz-bug', None)
        if bug_id is not None and bz_bug_is_open(bug_id):
            self.skipTest('Bugzilla bug {0} is open.'.format(bug_id))

        with self.assertRaises(CLIFactoryError):
            make_subnet(options)
Beispiel #7
0
    def test_positive_update_2(self):
        """@Test: Check if Subnet network and mask can be updated

        @Feature: Subnet - Update

        @Assert: Subnet network and mask are updated

        """

        network = gen_ipaddr()
        mask = '255.255.255.0'
        try:
            subnet = make_subnet({
                u'network': network,
                u'mask': mask,
            })
        except CLIFactoryError as err:
            self.fail(err)
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        result = Subnet.update({
            u'id': subnet['id'],
            u'network': new_network,
            u'mask': new_mask,
        })
        self.assertEqual(result.return_code, 0)

        # check - subnet is updated
        result = Subnet.info({u'id': subnet['id']})
        self.assertEqual(result.stdout['network'], new_network)
        self.assertEqual(result.stdout['mask'], new_mask)
Beispiel #8
0
    def test_positive_update_3(self, pool):
        """@Test: Check if Subnet address pool can be updated

        @Feature: Subnet - Update

        @Assert: Subnet address pool is updated

        """
        pool.sort()
        try:
            subnet = make_subnet({u'mask': '255.255.255.0'})
        except CLIFactoryError as err:
            self.fail(err)
        # generate pool range from network address
        ip_from = re.sub('\d+$', str(pool[0]), subnet['network'])
        ip_to = re.sub('\d+$', str(pool[1]), subnet['network'])
        result = Subnet.update({
            u'id': subnet['id'],
            u'from': ip_from,
            u'to': ip_to,
        })
        self.assertEqual(result.return_code, 0)
        self.assertEqual(len(result.stderr), 0)

        # check - subnet is updated
        result = Subnet.info({u'id': subnet['id']})
        self.assertEqual(result.return_code, 0)
        self.assertEqual(result.stdout['from'], ip_from)
        self.assertEqual(result.stdout['to'], ip_to)
Beispiel #9
0
    def test_negative_update_1(self, options):
        """@Test: Update subnet with invalid or missing required attributes

        @Feature: Subnet - Update

        @Assert: Subnet is not updated

        """

        bug_id = options.pop('bz-bug', None)
        if bug_id is not None and bz_bug_is_open(bug_id):
            self.skipTest('Bugzilla bug {0} is open.'.format(bug_id))

        try:
            subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)
        options['id'] = subnet['id']
        result = Subnet.update(options)
        self.assertNotEqual(result.return_code, 0)
        self.assertNotEqual(len(result.stderr), 0)

        # check - subnet is not updated
        result = Subnet.info({u'id': subnet['id']})
        for key in options.keys():
            self.assertEqual(subnet[key], result.stdout[key])
Beispiel #10
0
    def test_positive_create_2(self, pool):
        """@Test: Create subnet with valid address pool

        @Feature: Subnet positive create

        @Assert: Subnet is created and address pool is set

        """
        pool.sort()
        mask = '255.255.255.0'
        network = orm.IPAddressField().get_value()
        # generate pool range from network address
        from_ip = re.sub('\d+$', str(pool[0]), network)
        to_ip = re.sub('\d+$', str(pool[1]), network)
        try:
            subnet = make_subnet({
                u'mask': mask,
                u'network': network,
                u'from': from_ip,
                u'to': to_ip,
            })
        except CLIFactoryError as err:
            self.fail(err)
        self.assertEqual(subnet['from'], from_ip)
        self.assertEqual(subnet['to'], to_ip)
    def test_negative_update_address_pool(self):
        """Update subnet with invalid address pool

        :id: d0a857b4-be10-4b5d-86d4-43cf99c11619

        :expectedresults: Subnet is not updated

        :CaseImportance: Critical
        """
        subnet = make_subnet()
        for options in invalid_addr_pools():
            with self.subTest(options):
                opts = {u'id': subnet['id']}
                # generate pool range from network address
                for key, val in options.items():
                    opts[key] = re.sub(r'\d+$', str(val), subnet['network'])
                with self.assertRaisesRegex(
                    CLIReturnCodeError,
                    u'Could not update the subnet:'
                ):
                    Subnet.update(opts)
                # check - subnet is not updated
                result = Subnet.info({u'id': subnet['id']})
                for key in options.keys():
                    self.assertEqual(result[key], subnet[key])
Beispiel #12
0
    def test_update_location_with_subnet_by_name(self):
        """@Test: Create new location with assigned subnet to it. Try to update
        that location and change assigned subnet on another one. Use subnet
        name as a parameter

        @Feature: Location

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

        """
        subnet = [make_subnet() for _ in range(2)]
        loc = make_location({'subnets': subnet[0]['name']})
        self.assertIn(subnet[0]['name'], loc['subnets'][0])
        self.assertIn(subnet[0]['network'], loc['subnets'][0])

        result = Location.update({
            'id': loc['id'],
            'subnets': subnet[1]['name'],
        })
        self.assertEqual(result.return_code, 0)

        result = Location.info({'id': loc['id']})
        self.assertEqual(result.return_code, 0)
        self.assertIn(subnet[1]['name'], result.stdout['subnets'][0])
        self.assertIn(subnet[1]['network'], result.stdout['subnets'][0])
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        :id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4

        :expectedresults: Subnet network and mask are updated

        :CaseImportance: Critical
        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network'], new_network)
        self.assertEqual(subnet['mask'], new_mask)
    def test_positive_create_with_address_pool(self):
        """Create subnet with valid address pool

        :id: d74a52a7-df56-44ef-89a3-081c14e81e43

        :expectedresults: Subnet is created and address pool is set

        :CaseImportance: Critical
        """
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                mask = '255.255.255.0'
                # generate pool range from network address
                network = gen_ipaddr()
                from_ip = re.sub(r'\d+$', str(pool[0]), network)
                to_ip = re.sub(r'\d+$', str(pool[1]), network)
                subnet = make_subnet({
                    u'from': from_ip,
                    u'mask': mask,
                    u'network': network,
                    u'to': to_ip,
                })
                self.assertEqual(subnet['from'], from_ip)
                self.assertEqual(subnet['to'], to_ip)
    def test_negative_create_with_attributes(self):
        """Create subnet with invalid or missing required attributes

        :id: de468dd3-7ba8-463e-881a-fd1cb3cfc7b6

        :expectedresults: Subnet is not created

        :CaseImportance: Critical
        """
        for options in invalid_missing_attributes():
            with self.subTest(options):
                with self.assertRaisesRegex(
                    CLIFactoryError,
                    u'Could not create the subnet:'
                ):
                    make_subnet(options)
Beispiel #16
0
    def test_positive_delete_1(self, test_name):
        """
        @Test: Check if Subnet can be deleted
        @Feature: Subnet - Delete
        @Assert: Subnet is deleted
        """

        new_subnet = make_subnet({'name': test_name['name']})

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Delete it
        result = Subnet.delete({'id': result.stdout['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not deleted")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Fetch it again
        result = Subnet.info({'id': new_subnet['id']})
        self.assertGreater(
            result.return_code,
            0,
            "Subnet should not be found")
        self.assertGreater(
            len(result.stderr), 0, "No error was expected")
Beispiel #17
0
    def test_positive_update_2(self):
        """@Test: Check if Subnet network and mask can be updated

        @Feature: Subnet - Update

        @Assert: Subnet network and mask are updated

        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network'], new_network)
        self.assertEqual(subnet['mask'], new_mask)
Beispiel #18
0
 def test_add_subnet(self):
     "Add a subnet to an org"
     org_result = make_org()
     subnet_result = make_subnet()
     return_value = Org().add_subnet(
             {'name': org_result['name'], 'subnet': subnet_result['name']})
     self.assertTrue(return_value.return_code, 0)
     self.assertFalse(return_value.stderr)
Beispiel #19
0
    def test_negative_create_2(self, pool):
        """@Test: Create subnet with invalid address pool range

        @Feature: Create subnet negative

        @Assert: Subnet is not created

        """
        mask = '255.255.255.0'
        network = gen_ipaddr()
        opts = {u'mask': mask, u'network': network}
        # generate pool range from network address
        for key, val in pool.iteritems():
            opts[key] = re.sub('\d+$', str(val), network)

        with self.assertRaises(CLIFactoryError):
            make_subnet(opts)
Beispiel #20
0
    def test_negative_create_with_address_pool(self):
        """Create subnet with invalid address pool range

        @id: c7824327-b5ef-4f95-bd4b-ba4eff73551c

        @Assert: Subnet is not created
        """
        mask = '255.255.255.0'
        network = gen_ipaddr()
        for pool in invalid_addr_pools():
            with self.subTest(pool):
                opts = {u'mask': mask, u'network': network}
                # generate pool range from network address
                for key, val in pool.iteritems():
                    opts[key] = re.sub(r'\d+$', str(val), network)
                with self.assertRaises(CLIFactoryError):
                    make_subnet(opts)
Beispiel #21
0
    def test_negative_create_with_address_pool(self):
        """Create subnet with invalid address pool range

        @id: c7824327-b5ef-4f95-bd4b-ba4eff73551c

        @Assert: Subnet is not created
        """
        mask = "255.255.255.0"
        network = gen_ipaddr()
        for pool in invalid_addr_pools():
            with self.subTest(pool):
                opts = {u"mask": mask, u"network": network}
                # generate pool range from network address
                for key, val in pool.iteritems():
                    opts[key] = re.sub(r"\d+$", str(val), network)
                with self.assertRaises(CLIFactoryError) as raise_ctx:
                    make_subnet(opts)
                self.assert_error_msg(raise_ctx, u"Could not create the subnet:")
Beispiel #22
0
    def test_create_subnet_with_domain(self):
        """@Test: Check if subnet with domain can be created

        @Feature: Subnet - Positive create

        @Assert: Subnet is created and has new domain assigned
        """
        domain = make_domain()
        subnet = make_subnet({'domain-ids': domain['id']})
        self.assertIn(domain['name'], subnet['domains'])
Beispiel #23
0
    def test_positive_create_with_gateway(self):
        """Check if subnet with gateway can be created

        @id: 483c0d1d-c542-4be5-8c56-27b2a09db54a

        @Assert: Subnet is created and has gateway assigned
        """
        gateway = gen_ipaddr(ip3=True)
        subnet = make_subnet({"gateway": gateway})
        self.assertIn(gateway, subnet["gateway"])
Beispiel #24
0
    def test_positive_create_with_domain(self):
        """Check if subnet with domain can be created

        @id: 7ce7b139-d2b7-44f4-9c1a-1bd591f95334

        @Assert: Subnet is created and has new domain assigned
        """
        domain = make_domain()
        subnet = make_subnet({"domain-ids": domain["id"]})
        self.assertIn(domain["name"], subnet["domains"])
Beispiel #25
0
    def test_create_subnet_with_gateway(self):
        """@Test: Check if subnet with gateway can be created

        @Feature: Subnet - Positive create

        @Assert: Subnet is created and has gateway assigned
        """
        gateway = gen_ipaddr(ip3=True)
        subnet = make_subnet({'gateway': gateway})
        self.assertIn(gateway, subnet['gateway'])
Beispiel #26
0
    def test_positive_create_with_name(self):
        """Check if Subnet can be created with random names

        @id: 99cda3eb-3912-461b-83bd-f906b78eeca0

        @Assert: Subnet is created and has random name
        """
        for name in valid_data_list():
            with self.subTest(name):
                subnet = make_subnet({"name": name})
                self.assertEqual(subnet["name"], name)
Beispiel #27
0
    def test_positive_create_with_ipam(self):
        """Check if subnet with different ipam types can be created

        @id: ba4c66fd-50e6-441d-acc2-6ab39d8439d2

        @Assert: Subnet is created and correct ipam type is assigned
        """
        for ipam_type in (SUBNET_IPAM_TYPES["dhcp"], SUBNET_IPAM_TYPES["internal"], SUBNET_IPAM_TYPES["none"]):
            with self.subTest(ipam_type):
                subnet = make_subnet({"ipam": ipam_type})
                self.assertIn(ipam_type, subnet["ipam"])
Beispiel #28
0
    def test_positive_create_1(self):
        """@Test: Check if Subnet can be created with random names

        @Feature: Subnet - Create

        @Assert: Subnet is created and has random name
        """
        for name in valid_data_list():
            with self.subTest(name):
                subnet = make_subnet({'name': name})
                self.assertEqual(subnet['name'], name)
    def test_positive_create_with_gateway(self):
        """Check if subnet with gateway can be created

        :id: 483c0d1d-c542-4be5-8c56-27b2a09db54a

        :expectedresults: Subnet is created and has gateway assigned

        :CaseImportance: Critical
        """
        gateway = gen_ipaddr(ip3=True)
        subnet = make_subnet({'gateway': gateway})
        self.assertIn(gateway, subnet['gateway'])
Beispiel #30
0
    def test_positive_list(self):
        """Check if Subnet can be listed

        @id: 2ee376f7-9dd9-4b46-b414-801197d5455c

        @Assert: Subnet is listed
        """
        # Make a new subnet
        subnet = make_subnet()
        # Fetch ids from subnets list
        subnets_ids = [subnet_["id"] for subnet_ in Subnet.list()]
        self.assertIn(subnet["id"], subnets_ids)
Beispiel #31
0
    def test_positive_update_1(self, test_name):
        """
        @Test: Check if Subnet name can be updated
        @Feature: Subnet - Update
        @Assert: Subnet name is updated
        """

        new_subnet = make_subnet()

        # Fetch it
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Update the name
        result = Subnet.update(
            {'id': new_subnet['id'], 'new-name': test_name['name']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not updated")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")

        # Fetch it again
        result = Subnet.info({'id': new_subnet['id']})
        self.assertEqual(
            result.return_code,
            0,
            "Subnet was not found")
        self.assertEqual(
            len(result.stderr), 0, "No error was expected")
        self.assertEqual(
            result.stdout['name'], test_name['name'], "Names should match")
        self.assertNotEqual(
            result.stdout['name'], new_subnet['name'], "Names should not match"
        )
Beispiel #32
0
    def test_negative_update_address_pool(self):
        """Update subnet with invalid address pool

        @id: d0a857b4-be10-4b5d-86d4-43cf99c11619

        @Assert: Subnet is not updated
        """
        subnet = make_subnet()
        for options in invalid_addr_pools():
            with self.subTest(options):
                opts = {u'id': subnet['id']}
                # generate pool range from network address
                for key, val in options.iteritems():
                    opts[key] = re.sub(r'\d+$', str(val), subnet['network'])
                with self.assertRaisesRegex(CLIReturnCodeError,
                                            u'Could not update the subnet:'):
                    Subnet.update(opts)
                # check - subnet is not updated
                result = Subnet.info({u'id': subnet['id']})
                for key in options.keys():
                    self.assertEqual(result[key], subnet[key])
Beispiel #33
0
    def test_positive_update_address_pool(self):
        """Check if Subnet address pool can be updated

        :id: 18ced88f-d62e-4e15-8b7b-0a08c4ef239b

        :expectedresults: Subnet address pool is updated
        """
        subnet = make_subnet({u'mask': '255.255.255.0'})
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                # generate pool range from network address
                ip_from = re.sub(r'\d+$', str(pool[0]), subnet['network-addr'])
                ip_to = re.sub(r'\d+$', str(pool[1]), subnet['network-addr'])
                Subnet.update({
                    u'from': ip_from,
                    u'id': subnet['id'],
                    u'to': ip_to,
                })
                subnet = Subnet.info({u'id': subnet['id']})
                self.assertEqual(subnet['start-of-ip-range'], ip_from)
                self.assertEqual(subnet['end-of-ip-range'], ip_to)
Beispiel #34
0
    def test_negative_update_attributes(self):
        """Update subnet with invalid or missing required attributes

        :id: ab60372e-cef7-4495-bd66-68e7dbece475

        :expectedresults: Subnet is not updated

        :CaseImportance: Critical
        """
        subnet = make_subnet()
        for options in invalid_missing_attributes():
            with self.subTest(options):
                options['id'] = subnet['id']
                with self.assertRaisesRegex(
                    CLIReturnCodeError,
                    u'Could not update the subnet:'
                ):
                    Subnet.update(options)
                    # check - subnet is not updated
                    result = Subnet.info({u'id': subnet['id']})
                    for key in options.keys():
                        self.assertEqual(subnet[key], result[key])
    def test_positive_update_address_pool(self):
        """Check if Subnet address pool can be updated

        @Feature: Subnet - Update

        @Assert: Subnet address pool is updated
        """
        subnet = make_subnet({u'mask': '255.255.255.0'})
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                # generate pool range from network address
                ip_from = re.sub(r'\d+$', str(pool[0]), subnet['network'])
                ip_to = re.sub(r'\d+$', str(pool[1]), subnet['network'])
                Subnet.update({
                    u'from': ip_from,
                    u'id': subnet['id'],
                    u'to': ip_to,
                })
                subnet = Subnet.info({u'id': subnet['id']})
                self.assertEqual(subnet['from'], ip_from)
                self.assertEqual(subnet['to'], ip_to)
    def test_positive_update_with_subnet_by_name(self):
        """Create new location with assigned subnet to it. Try to update
        that location and change assigned subnet on another one. Use subnet
        name as a parameter

        @Feature: Location

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

        """
        subnet = [make_subnet() for _ in range(2)]
        loc = make_location({'subnets': subnet[0]['name']})
        self.assertIn(subnet[0]['name'], loc['subnets'][0])
        self.assertIn(subnet[0]['network'], loc['subnets'][0])
        Location.update({
            'id': loc['id'],
            'subnets': subnet[1]['name'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertIn(subnet[1]['name'], loc['subnets'][0])
        self.assertIn(subnet[1]['network'], loc['subnets'][0])
Beispiel #37
0
    def test_positive_remove_subnet_by_id(self):
        """Remove a subnet from organization by its ID

        @Feature: Organization

        @Assert: Subnet is removed from the org
        """
        org = make_org()
        subnet = make_subnet()
        Org.add_subnet({
            'name': org['name'],
            'subnet': subnet['name'],
        })
        org = Org.info({'id': org['id']})
        self.assertEqual(len(org['subnets']), 1)
        self.assertIn(subnet['name'], org['subnets'][0])
        Org.remove_subnet({
            'name': org['name'],
            'subnet-id': subnet['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertEqual(len(org['subnets']), 0)
Beispiel #38
0
def test_negative_update_address_pool(options):
    """Update subnet with invalid address pool

    :parametrized: yes

    :id: d0a857b4-be10-4b5d-86d4-43cf99c11619

    :expectedresults: Subnet is not updated

    :CaseImportance: Medium
    """
    subnet = make_subnet()
    opts = {'id': subnet['id']}
    # generate pool range from network address
    for key, val in options.items():
        opts[key] = re.sub(r'\d+$', str(val), subnet['network-addr'])
    with pytest.raises(CLIReturnCodeError, match='Could not update the subnet:'):
        Subnet.update(opts)
    # check - subnet is not updated
    result = Subnet.info({'id': subnet['id']})
    for key in ['start-of-ip-range', 'end-of-ip-range']:
        assert result[key] == subnet[key]
Beispiel #39
0
    def test_negative_update_address_pool(self):
        """Update subnet with invalid address pool

        :id: d0a857b4-be10-4b5d-86d4-43cf99c11619

        :expectedresults: Subnet is not updated

        :CaseImportance: Medium
        """
        subnet = make_subnet()
        for options in invalid_addr_pools():
            with self.subTest(options):
                opts = {'id': subnet['id']}
                # generate pool range from network address
                for key, val in options.items():
                    opts[key] = re.sub(r'\d+$', str(val), subnet['network-addr'])
                with self.assertRaisesRegex(CLIReturnCodeError, 'Could not update the subnet:'):
                    Subnet.update(opts)
                # check - subnet is not updated
                result = Subnet.info({'id': subnet['id']})
                for key in ['start-of-ip-range', 'end-of-ip-range']:
                    self.assertEqual(result[key], subnet[key])
 def setUp(self):
     """Create VM, subscribe it to satellite-tools repo, install katello-ca
         and katello-agent packages, add remote execution key
     """
     super(RemoteExecutionTestCase, self).setUp()
     # Create VM and register content host
     self.client = VirtualMachine(distro=DISTRO_RHEL7)
     self.addCleanup(vm_cleanup, self.client)
     self.client.create()
     self.client.install_katello_ca()
     # Register content host, install katello-agent
     self.client.register_contenthost(
         self.org['label'],
         self.activation_key['name'],
     )
     self.assertTrue(self.client.subscribed)
     self.client.enable_repo(REPOS['rhst7']['id'])
     self.client.install_katello_agent()
     add_remote_execution_ssh_key(self.client.ip_addr)
     # create subnet for current org, default loc and domain
     subnet_options = {
         u'domain-ids': 1,
         u'organization-ids': self.org["id"],
         u'location-ids': 2
        }
     if not bz_bug_is_open(1328322):
         subnet_options[u'remote-execution-proxy-id'] = 1
     new_sub = make_subnet(subnet_options)
     # add rex proxy to subnet, default is internal proxy (id 1)
     if bz_bug_is_open(1328322):
         subnet = entities.Subnet(id=new_sub["id"])
         subnet.remote_execution_proxy_ids = [1]
         subnet.update(["remote_execution_proxy_ids"])
     # add host to subnet
     Host.update({
         'name': self.client.hostname,
         'subnet-id': new_sub['id'],
     })
Beispiel #41
0
    def test_positive_create_with_address_pool(self):
        """Create subnet with valid address pool

        @id: d74a52a7-df56-44ef-89a3-081c14e81e43

        @Assert: Subnet is created and address pool is set
        """
        for pool in valid_addr_pools():
            with self.subTest(pool):
                pool.sort()
                mask = '255.255.255.0'
                # generate pool range from network address
                network = gen_ipaddr()
                from_ip = re.sub(r'\d+$', str(pool[0]), network)
                to_ip = re.sub(r'\d+$', str(pool[1]), network)
                subnet = make_subnet({
                    u'from': from_ip,
                    u'mask': mask,
                    u'network': network,
                    u'to': to_ip,
                })
                self.assertEqual(subnet['from'], from_ip)
                self.assertEqual(subnet['to'], to_ip)
Beispiel #42
0
    def test_positive_update_with_subnet_by_name(self):
        """Create new location with assigned subnet to it. Try to update
        that location and change assigned subnet on another one. Use subnet
        name as a parameter

        :id: 2bb2ec4a-2423-46a8-8772-a263823640df

        :expectedresults: Location is updated successfully and has correct
            subnet with expected network address assigned to it

        :CaseImportance: Critical
        """
        subnet = [make_subnet() for _ in range(2)]
        loc = make_location({'subnets': subnet[0]['name']})
        self.assertIn(subnet[0]['name'], loc['subnets'][0])
        self.assertIn(subnet[0]['network'], loc['subnets'][0])
        Location.update({
            'id': loc['id'],
            'subnets': subnet[1]['name'],
        })
        loc = Location.info({'id': loc['id']})
        self.assertIn(subnet[1]['name'], loc['subnets'][0])
        self.assertIn(subnet[1]['network'], loc['subnets'][0])
Beispiel #43
0
    def test_positive_remove_subnet_by_id(self):
        """Remove a subnet from organization by its ID

        @id: 4868ef18-983a-48b4-940a-e1b55f01f0b6

        @Assert: Subnet is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        subnet = make_subnet()
        Org.add_subnet({
            'name': org['name'],
            'subnet': subnet['name'],
        })
        org = Org.info({'id': org['id']})
        self.assertEqual(len(org['subnets']), 1)
        self.assertIn(subnet['name'], org['subnets'][0])
        Org.remove_subnet({
            'name': org['name'],
            'subnet-id': subnet['id'],
        })
        org = Org.info({'id': org['id']})
        self.assertEqual(len(org['subnets']), 0)
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        @Feature: Subnet - Update

        @Assert: Subnet network and mask are updated
        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network'], new_network)
        self.assertEqual(subnet['mask'], new_mask)
Beispiel #45
0
    def test_positive_update_network_mask(self):
        """Check if Subnet network and mask can be updated

        :id: 6a8d7750-71f1-4cd8-bf90-f2eac457c3b4

        :expectedresults: Subnet network and mask are updated
        """
        network = gen_ipaddr()
        mask = '255.255.255.0'
        subnet = make_subnet({
            u'mask': mask,
            u'network': network,
        })
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        Subnet.update({
            u'id': subnet['id'],
            u'mask': new_mask,
            u'network': new_network,
        })
        # check - subnet is updated
        subnet = Subnet.info({u'id': subnet['id']})
        self.assertEqual(subnet['network-addr'], new_network)
        self.assertEqual(subnet['network-mask'], new_mask)
Beispiel #46
0
    def test_positive_remove_subnet_by_name(self):
        """Remove a subnet from organization by its name

        @id: adb5310b-76c5-4aca-8220-fdf0fe605cb0

        @Assert: Subnet is removed from the org

        @CaseLevel: Integration
        """
        org = make_org()
        subnet = make_subnet()
        Org.add_subnet({
            'name': org['name'],
            'subnet': subnet['name'],
        })
        org = Org.info({'id': org['id']})
        self.assertEqual(len(org['subnets']), 1)
        self.assertIn(subnet['name'], org['subnets'][0])
        Org.remove_subnet({
            'name': org['name'],
            'subnet': subnet['name'],
        })
        org = Org.info({'id': org['id']})
        self.assertEqual(len(org['subnets']), 0)
Beispiel #47
0
def test_positive_add_and_remove_subnets(module_org):
    """add and remove a subnet from organization

    :id: adb5310b-76c5-4aca-8220-fdf0fe605cb0

    :BZ:
        1. Add and remove subnet by name
        2. Add and remove subnet by id

    :expectedresults: Subnets are handled as expected

    :BZ: 1395229

    :CaseLevel: Integration
    """
    subnets = [make_subnet() for _ in range(0, 2)]
    Org.add_subnet({'name': module_org.name, 'subnet': subnets[0]['name']})
    Org.add_subnet({'name': module_org.name, 'subnet-id': subnets[1]['id']})
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['subnets']) == 2, "Failed to add subnets"
    Org.remove_subnet({'name': module_org.name, 'subnet': subnets[0]['name']})
    Org.remove_subnet({'name': module_org.name, 'subnet-id': subnets[1]['id']})
    org_info = Org.info({'id': module_org.id})
    assert len(org_info['subnets']) == 0, "Failed to remove subnets"
Beispiel #48
0
    def test_negative_update_2(self, options):
        """@Test: Update subnet with invalid address pool

        @Feature: Subnet - Update

        @Assert: Subnet is not updated

        """
        try:
            subnet = make_subnet()
        except CLIFactoryError as err:
            self.fail(err)

        opts = {u'id': subnet['id']}
        # generate pool range from network address
        for key, val in options.iteritems():
            opts[key] = re.sub('\d+$', str(val), subnet['network'])
        result = Subnet.update(opts)
        self.assertNotEqual(result.return_code, 0)

        # check - subnet is not updated
        result = Subnet.info({u'id': subnet['id']})
        for key in options.keys():
            self.assertEqual(result.stdout[key], subnet[key])
Beispiel #49
0
    def test_positive_create_2(self, pool):
        """@Test: Create subnet with valid address pool

        @Feature: Subnet positive create

        @Assert: Subnet is created and address pool is set

        """
        pool.sort()
        mask = '255.255.255.0'
        network = gen_ipaddr()  # generate pool range from network address
        from_ip = re.sub('\d+$', str(pool[0]), network)
        to_ip = re.sub('\d+$', str(pool[1]), network)
        try:
            subnet = make_subnet({
                u'mask': mask,
                u'network': network,
                u'from': from_ip,
                u'to': to_ip,
            })
        except CLIFactoryError as err:
            self.fail(err)
        self.assertEqual(subnet['from'], from_ip)
        self.assertEqual(subnet['to'], to_ip)
Beispiel #50
0
def test_positive_create_with_multiple_entities_and_delete(
        module_puppet_org, puppet_content_source, puppet_classes,
        session_puppet_enabled_sat):
    """Check if hostgroup with multiple options can be created and deleted

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

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

    :BZ: 1395254, 1313056

    :CaseLevel: Integration

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

        :id: d74a52a7-df56-44ef-89a3-081c14e81e43

        :expectedresults: Subnet is created, updated and deleted

        :CaseImportance: Critical
        """
        name = valid_data_list()[0]
        pool = sorted(valid_addr_pools()[0])
        mask = '255.255.255.0'
        # generate pool range from network address
        network = gen_ipaddr()
        from_ip = re.sub(r'\d+$', str(pool[0]), network)
        to_ip = re.sub(r'\d+$', str(pool[1]), network)
        domains_amount = random.randint(3, 5)
        domains = [make_domain() for _ in range(domains_amount)]
        gateway = gen_ipaddr(ip3=True)
        ipam_type = SUBNET_IPAM_TYPES['dhcp']
        subnet = make_subnet(
            {
                'name': name,
                'from': from_ip,
                'mask': mask,
                'network': network,
                'to': to_ip,
                'domain-ids': [domain['id'] for domain in domains],
                'gateway': gateway,
                'ipam': ipam_type,
            }
        )
        # Check if Subnet can be listed
        subnets_ids = [subnet_['id'] for subnet_ in Subnet.list()]
        self.assertIn(subnet['id'], subnets_ids)
        self.assertEqual(subnet['name'], name)
        self.assertEqual(subnet['start-of-ip-range'], from_ip)
        self.assertEqual(subnet['end-of-ip-range'], to_ip)
        self.assertEqual(len(subnet['domains']), domains_amount)
        for domain in domains:
            self.assertIn(domain['name'], subnet['domains'])
        self.assertIn(gateway, subnet['gateway-addr'])
        self.assertIn(ipam_type, subnet['ipam'])

        # update subnet
        new_name = valid_data_list()[0]
        pool = sorted(valid_addr_pools()[0])
        # generate pool range from network address
        new_network = gen_ipaddr()
        new_mask = '255.255.192.0'
        ip_from = re.sub(r'\d+$', str(pool[0]), new_network)
        ip_to = re.sub(r'\d+$', str(pool[1]), new_network)
        ipam_type = SUBNET_IPAM_TYPES['internal']
        Subnet.update(
            {
                'new-name': new_name,
                'from': ip_from,
                'id': subnet['id'],
                'to': ip_to,
                'mask': new_mask,
                'network': new_network,
                'ipam': ipam_type,
                'domain-ids': "",  # delete domains needed for subnet delete
            }
        )
        subnet = Subnet.info({'id': subnet['id']})
        self.assertEqual(subnet['name'], new_name)
        self.assertEqual(subnet['start-of-ip-range'], ip_from)
        self.assertEqual(subnet['end-of-ip-range'], ip_to)
        self.assertEqual(subnet['network-addr'], new_network)
        self.assertEqual(subnet['network-mask'], new_mask)
        self.assertIn(ipam_type, subnet['ipam'])

        # delete subnet
        Subnet.delete({'id': subnet['id']})
        with self.assertRaises(CLIReturnCodeError):
            Subnet.info({'id': subnet['id']})
Beispiel #52
0
    def test_positive_create_with_multiple_entities(self):
        """Check if hostgroup with multiple options can be created

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

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

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        puppet_proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })

        make_hostgroup_params = {
            'location-ids': loc['id'],
            'environment-id': env['id'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy-id': puppet_proxy['id'],
            'puppet-ca-proxy-id': puppet_proxy['id'],
            'content-view-id': cv['id'],
            'domain-id': domain['id'],
            'subnet-id': subnet['id'],
            'organization-ids': org['id'],
            'architecture-id': arch['id'],
            'partition-table-id': ptable['id'],
            'medium-id': media['id'],
            'operatingsystem-id': os['id'],
        }
        # If bug is open provide LCE id as parameter
        # because LCE name cause errors
        if bz_bug_is_open(1395254):
            make_hostgroup_params.pop('lifecycle-environment')
            make_hostgroup_params['lifecycle-environment-id'] = lce['id']

        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertIn(org['name'], hostgroup['organizations'])
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['environment'])
        self.assertEqual(puppet_proxy['id'],
                         hostgroup['puppet-master-proxy-id'])
        self.assertEqual(puppet_proxy['id'], hostgroup['puppet-ca-proxy-id'])
        self.assertEqual(domain['name'], hostgroup['domain'])
        self.assertEqual(subnet['name'], hostgroup['subnet'])
        self.assertEqual(arch['name'], hostgroup['architecture'])
        self.assertEqual(ptable['name'], hostgroup['partition-table'])
        self.assertEqual(media['name'], hostgroup['medium'])
        self.assertEqual(
            "{0} {1}.{2}".format(os['name'], os['major-version'],
                                 os['minor-version']),
            hostgroup['operating-system'])
        if not bz_bug_is_open('1313056'):
            self.assertEqual(cv['name'], hostgroup['content-view'])
            self.assertEqual(lce['name'], hostgroup['lifecycle-environment'])
    def test_positive_create_with_multiple_entities_ids(self):
        """Check if hostgroup with multiple options ids can be created

        :id: 6277613b-0ece-4dee-b9d8-504f8299ac38

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

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        make_hostgroup_params = {
            'location-ids': loc['id'],
            'environment-id': env['id'],
            'lifecycle-environment-id': lce['id'],
            'puppet-proxy-id': proxy['id'],
            'puppet-ca-proxy-id': proxy['id'],
            'content-source-id': proxy['id'],
            'content-view-id': cv['id'],
            'domain-id': domain['id'],
            'subnet-id': subnet['id'],
            'organization-ids': org['id'],
            'architecture-id': arch['id'],
            'partition-table-id': ptable['id'],
            'medium-id': media['id'],
            'operatingsystem-id': os['id'],
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertEqual(cv['id'], hostgroup['content-view']['id'])
        self.assertEqual(lce['id'], hostgroup['lifecycle-environment']['id'])
        self.assertEqual(proxy['id'], hostgroup['content-source']['id'])
        # get the json output format
        hostgroup = HostGroup.info({'id': hostgroup['id']},
                                   output_format='json')
        self.assertIn(org['id'], hostgroup['organizations'][0]['id'])
        self.assertIn(loc['id'], hostgroup['locations'][0]['id'])
        self.assertEqual(env['id'], hostgroup['puppet-environment']['id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-master-proxy']['id'])
        self.assertEqual(proxy['id'], hostgroup['puppet-ca-proxy']['id'])
        self.assertEqual(domain['id'], hostgroup['network']['domain']['id'])
        self.assertEqual(subnet['id'],
                         hostgroup['network']['subnet-ipv4']['id'])
        self.assertEqual(arch['id'],
                         hostgroup['operating-system']['architecture']['id'])
        self.assertEqual(
            ptable['id'],
            hostgroup['operating-system']['partition-table']['id'])
        self.assertEqual(media['id'],
                         hostgroup['operating-system']['medium']['id'])
        self.assertEqual(
            os['id'], hostgroup['operating-system']['operating-system']['id'])
    def test_positive_create_with_multiple_entities_name(self):
        """Check if hostgroup with multiple options name can be created

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

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

        :BZ: 1395254, 1313056

        :CaseLevel: Integration
        """
        # Common entities
        loc = make_location()
        org = make_org()
        env = make_environment({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        lce = make_lifecycle_environment({'organization-id': org['id']})
        proxy = Proxy.list({
            'search':
            'url = https://{0}:9090'.format(settings.server.hostname)
        })[0]
        # Content View should be promoted to be used with LC Env
        cv = make_content_view({'organization-id': org['id']})
        ContentView.publish({'id': cv['id']})
        cv = ContentView.info({'id': cv['id']})
        ContentView.version_promote({
            'id': cv['versions'][0]['id'],
            'to-lifecycle-environment-id': lce['id'],
        })
        # Network
        domain = make_domain({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        subnet = make_subnet({
            'domain-ids': domain['id'],
            'organization-ids': org['id'],
        })
        # Operating System
        arch = make_architecture()
        ptable = make_partition_table({
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        os = make_os({
            'architecture-ids': arch['id'],
            'partition-table-ids': ptable['id'],
        })
        os_full_name = "{0} {1}.{2}".format(os['name'], os['major-version'],
                                            os['minor-version'])
        media = make_medium({
            'operatingsystem-ids': os['id'],
            'location-ids': loc['id'],
            'organization-ids': org['id'],
        })
        # Note: in the current hammer version there is no content source name
        # option
        make_hostgroup_params = {
            'organizations': org['name'],
            'locations': loc['name'],
            'environment': env['name'],
            'lifecycle-environment': lce['name'],
            'puppet-proxy': proxy['name'],
            'puppet-ca-proxy': proxy['name'],
            'content-source-id': proxy['id'],
            'content-view': cv['name'],
            'domain': domain['name'],
            'subnet': subnet['name'],
            'architecture': arch['name'],
            'partition-table': ptable['name'],
            'medium': media['name'],
            'operatingsystem': os_full_name,
            'query-organization': org['name']
        }
        hostgroup = make_hostgroup(make_hostgroup_params)
        self.assertIn(org['name'], hostgroup['organizations'])
        self.assertIn(loc['name'], hostgroup['locations'])
        self.assertEqual(env['name'], hostgroup['puppet-environment'])
        self.assertEqual(proxy['name'], hostgroup['puppet-master-proxy'])
        self.assertEqual(proxy['name'], hostgroup['puppet-ca-proxy'])
        self.assertEqual(domain['name'], hostgroup['network']['domain'])
        self.assertEqual(subnet['name'], hostgroup['network']['subnet-ipv4'])
        self.assertEqual(arch['name'],
                         hostgroup['operating-system']['architecture'])
        self.assertEqual(ptable['name'],
                         hostgroup['operating-system']['partition-table'])
        self.assertEqual(media['name'],
                         hostgroup['operating-system']['medium'])
        self.assertEqual(os_full_name,
                         hostgroup['operating-system']['operating-system'])
        self.assertEqual(cv['name'], hostgroup['content-view']['name'])
        self.assertEqual(lce['name'],
                         hostgroup['lifecycle-environment']['name'])
        self.assertEqual(proxy['name'], hostgroup['content-source']['name'])
Beispiel #55
0
    def test_positive_create_with_multiple_entities_and_delete(self):
        """Check if hostgroup with multiple options can be created and deleted

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

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

        :BZ: 1395254, 1313056

        :CaseLevel: Integration

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