Ejemplo n.º 1
0
    def test_invalid_mtu(self, mocker, deckhand_ingester, drydock_state,
                         input_files):

        input_file = input_files.join("invalid_validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = MtuRational()
        message_list = validator.execute(site_design, orchestrator=orch)

        regex = re.compile(r'MTU must be between \d+ and \d+')
        regex_1 = re.compile('MTU must be <= the parent Network Link')

        for msg in message_list:
            msg = msg.to_dict()
            LOG.debug(msg)
            assert msg.get('error')
            assert len(msg.get('documents')) > 0
            assert any([
                regex.search(msg.get('message')),
                regex_1.search(msg.get('message'))
            ])

        assert len(message_list) == 4
Ejemplo n.º 2
0
    def test_invalid_storage_sizing(self, deckhand_ingester, drydock_state,
                                    input_files, mock_get_build_data):

        input_file = input_files.join("invalid_validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = StorageSizing()
        message_list = validator.execute(site_design, orchestrator=orch)

        regex = re.compile(
            '(Storage partition)|(Logical Volume) .+ size is < 0')
        regex_1 = re.compile('greater than 99%')

        assert len(message_list) == 8
        for msg in message_list:
            msg = msg.to_dict()
            LOG.debug(msg)
            assert regex.search(
                msg.get('message')) is not None or regex_1.search(
                    msg.get('message')) is not None
            assert msg.get('error') is True
    def test_invalid_unique_network(self, mocker, deckhand_ingester,
                                    drydock_state, input_files):

        input_file = input_files.join("invalid_unique_network.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = UniqueNetworkCheck()
        message_list = validator.execute(site_design, orchestrator=orch)

        regex = re.compile(
            'Allowed network .+ duplicated on NetworkLink .+ and NetworkLink .+'
        )
        regex_1 = re.compile(
            'Interface \S+ attached to network \S+ not allowed on interface link'
        )

        assert len(message_list) >= 2

        for msg in message_list:
            msg = msg.to_dict()
            LOG.debug(msg)
            assert msg.get('error')
            assert any([
                regex.search(msg.get('message')),
                regex_1.search(msg.get('message'))
            ])
Ejemplo n.º 4
0
    def test_invalid_bootaction_pkg_list(self, deckhand_ingester,
                                         drydock_state, setup, input_files,
                                         mock_get_build_data):
        input_file = input_files.join("invalid_bootaction_pkg.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        ba_doc = objects.DocumentReference(
            doc_type=hd_fields.DocumentType.Deckhand,
            doc_name="invalid_pkg_list",
            doc_schema="drydock/BootAction/v1")

        assert status.status == hd_fields.ValidationResult.Failure

        ba_msg = [msg for msg in status.message_list if ba_doc in msg.docs]

        assert len(ba_msg) > 0

        for msg in ba_msg:
            LOG.debug(msg)
            assert ":) is not a valid format" in msg.message
            assert msg.error
Ejemplo n.º 5
0
    def test_invalid_rational_network_bond(self, mocker, deckhand_ingester,
                                           drydock_state, input_files):
        input_file = input_files.join("invalid_validation.yaml")

        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.rational_network_bond(site_design)

        regex = re.compile(
            'Network Link Bonding Error: Down delay is less than mon rate on BaremetalNode .+'
        )
        regex_1 = re.compile(
            'Network Link Bonding Error: Up delay is less than mon rate on BaremetalNode .+'
        )

        for msg in message_list:
            msg = msg.to_dict()
            assert msg.get('error') is True
            assert regex.match(
                msg.get('message')) is not None or regex_1.match(
                    msg.get('message')) is not None

        assert len(message_list) == 2
    def test_valid_param_reference(self, deckhand_ingester, input_files,
                                   setup):
        input_file = input_files.join("deckhand_fullsite.yaml")

        design_state = DrydockState()
        design_ref = "file://%s" % str(input_file)

        orchestrator = Orchestrator(state_manager=design_state,
                                    ingester=deckhand_ingester)

        design_status, design_data = orchestrator.get_effective_site(
            design_ref)

        assert len(design_data.baremetal_nodes) == 3

        node = design_data.get_baremetal_node("compute01")

        assert node.hardware_profile == 'HPGen9v3'

        isolcpu = node.kernel_params.get('isolcpus', None)

        # '2,4' is defined in the HardwareProfile as cpu_sets.sriov
        assert isolcpu == '2,4'

        hugepagesz = node.kernel_params.get('hugepagesz', None)

        assert hugepagesz == '1G'
Ejemplo n.º 7
0
    def test_invalid_platform(self, mocker, deckhand_ingester, drydock_state,
                              input_files):
        mock_images = mocker.patch(
            "drydock_provisioner.drivers.node.maasdriver.driver."
            "MaasNodeDriver.get_available_images")
        mock_images.return_value = ['xenial']
        mock_kernels = mocker.patch(
            "drydock_provisioner.drivers.node.maasdriver.driver."
            "MaasNodeDriver.get_available_kernels")
        mock_kernels.return_value = ['ga-16.04', 'hwe-16.04']

        input_file = input_files.join("invalid_kernel.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester,
                            enabled_drivers=config.config_mgr.conf.plugins)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = PlatformSelection()
        message_list = validator.execute(site_design, orchestrator=orch)

        for r in message_list:
            LOG.debug(r.to_dict())

        msg = message_list[0].to_dict()
        assert 'invalid kernel lts' in msg.get('message')
        assert msg.get('error')
        assert len(msg.get('documents')) > 0
        assert len(message_list) == 1
Ejemplo n.º 8
0
    def test_design_inheritance(self, input_files, setup):
        input_file = input_files.join("fullsite.yaml")

        design_state = DrydockState()
        design_ref = "file://%s" % str(input_file)

        ingester = Ingester()
        ingester.enable_plugin(
            'drydock_provisioner.ingester.plugins.yaml.YamlIngester')

        orchestrator = Orchestrator(
            state_manager=design_state, ingester=ingester)

        design_status, design_data = orchestrator.get_effective_site(
            design_ref)

        assert len(design_data.baremetal_nodes) == 2

        node = design_data.get_baremetal_node("controller01")

        assert node.hardware_profile == 'HPGen9v3'

        iface = node.get_applied_interface('bond0')

        assert len(iface.get_hw_slaves()) == 2

        iface = node.get_applied_interface('pxe')

        assert len(iface.get_hw_slaves()) == 1
Ejemplo n.º 9
0
    def test_invalid_rational_network_trunking(self, deckhand_ingester,
                                               drydock_state, input_files):
        input_file = input_files.join("invalid_rational_network_trunking.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.network_trunking_rational(site_design)

        regex = re.compile(
            'Rational Network Trunking Error: Trunking mode is disabled, a trunking'
            'default_network must be defined; on NetworkLink .+')

        regex_1 = re.compile(
            'Rational Network Trunking Error: If there is more than 1 allowed network,'
            'trunking mode must be enabled; on NetworkLink .+')

        for msg in message_list:
            msg = msg.to_dict()
            assert msg.get('error')
            assert regex.match(
                msg.get('message')) is not None or regex_1.match(
                    msg.get('message')) is not None

        assert len(message_list) == 2
Ejemplo n.º 10
0
    def test_invalid_ip_locality_invalid_network(self, input_files,
                                                 drydock_state,
                                                 deckhand_ingester):
        input_file = input_files.join("invalid_validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = IpLocalityCheck()
        message_list = validator.execute(site_design, orchestrator=orch)

        regex = re.compile(
            'The gateway IP Address .+ is not within the defined CIDR: .+ of .+'
        )
        regex_1 = re.compile('.+ is not a valid network.')
        regex_2 = re.compile(
            'The IP Address .+ is not within the defined CIDR: .+ of .+ .')

        assert len(message_list) == 3

        for msg in message_list:
            msg = msg.to_dict()
            LOG.debug(msg)
            assert len(msg.get('documents')) > 0
            assert msg.get('error')
            assert any([
                regex.search(msg.get('message')),
                regex_1.search(msg.get('message')),
                regex_2.search(msg.get('message'))
            ])
Ejemplo n.º 11
0
    def test_invalid_rational_network_bond(self, mocker, deckhand_ingester,
                                           drydock_state, input_files):
        input_file = input_files.join("invalid_validation.yaml")

        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(
            state_manager=drydock_state, ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = RationalNetworkBond()
        message_list = validator.execute(site_design, orchestrator=orch)

        regex = re.compile('Down delay \S+ is less than mon rate \S+')
        regex_1 = re.compile('Up delay \S+ is less than mon rate \S+')

        for msg in message_list:
            msg = msg.to_dict()
            LOG.debug(msg)
            assert msg.get('error')
            assert len(msg.get('documents')) > 0
            assert any([
                regex.search(msg.get('message')),
                regex_1.search(msg.get('message'))
            ])

        assert len(message_list) == 2
Ejemplo n.º 12
0
    def test_invalid_storage_sizing(self, deckhand_ingester, drydock_state,
                                    input_files):

        input_file = input_files.join("invalid_validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.storage_sizing(site_design)

        regex = re.compile(
            'Storage Sizing Error: Storage .+ size is < 0 on Baremetal Node .+'
        )
        regex_1 = re.compile(
            'Storage Sizing Error: Storage .+ size is greater than 99 on Baremetal Node .+'
        )

        assert len(message_list) == 6
        for msg in message_list:
            msg = msg.to_dict()
            assert regex.match(
                msg.get('message')) is not None or regex_1.match(
                    msg.get('message')) is not None
            assert msg.get('error') is True
Ejemplo n.º 13
0
    def test_routedomain_omit_source_subnet(self, input_files, setup):
        input_file = input_files.join("deckhand_routedomain.yaml")

        design_state = DrydockState()
        design_ref = "file://%s" % str(input_file)

        ingester = Ingester()
        ingester.enable_plugin(
            'drydock_provisioner.ingester.plugins.deckhand.DeckhandIngester')

        orchestrator = Orchestrator(state_manager=design_state,
                                    ingester=ingester)

        design_status, design_data = orchestrator.get_effective_site(
            design_ref)

        assert design_status.status == hd_fields.ValidationResult.Success

        net_rack3 = design_data.get_network('storage_rack3')

        route_cidrs = list()
        for r in net_rack3.routes:
            if 'subnet' in r and r.get('subnet') is not None:
                route_cidrs.append(r.get('subnet'))

        assert '172.16.3.0/24' not in route_cidrs
Ejemplo n.º 14
0
    def test_invalid_storage_partitioning(self, deckhand_ingester,
                                          drydock_state, input_files,
                                          mock_get_build_data):
        input_file = input_files.join("invalid_validation.yaml")

        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = StoragePartitioning()
        message_list = validator.execute(site_design)

        regex = re.compile('Volume group .+ not assigned any physical volumes')

        for msg in message_list:
            msg = msg.to_dict()
            LOG.debug(msg)
            assert len(msg.get('documents')) > 0
            assert msg.get('error')
            assert regex.search(msg.get('message')) is not None

        assert len(message_list) == 2
Ejemplo n.º 15
0
    def test_invalid_ip_locality_invalid_network(self, input_files,
                                                 drydock_state,
                                                 deckhand_ingester):
        input_file = input_files.join("invalid_validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.ip_locality_check(site_design)

        regex = re.compile(
            'IP Locality Error: The gateway IP Address .+ is not within the defined CIDR: .+ of .+'
        )
        regex_1 = re.compile('IP Locality Error: .+ is not a valid network.')
        regex_2 = re.compile(
            'IP Locality Error: The IP Address .+ is not within the defined CIDR: .+ of .+ .'
        )

        assert len(message_list) == 3
        for msg in message_list:
            msg = msg.to_dict()
            assert msg.get('error')
            assert (regex.match(msg.get('message')) is not None
                    or regex_1.match(msg.get('message')) is not None
                    or regex_2.match(msg.get('message')) is not None)
    def test_invalid_rational_network_trunking(self, deckhand_ingester,
                                               drydock_state, input_files):
        input_file = input_files.join("invalid_rational_network_trunking.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = NetworkTrunkingRational()
        message_list = validator.execute(site_design, orchestrator=orch)

        regex = re.compile(
            'Trunking mode is disabled, a trunking default_network must be defined'
        )

        regex_1 = re.compile(
            'If there is more than 1 allowed network,trunking mode must be enabled'
        )

        regex_2 = re.compile('native network has a defined VLAN tag')

        for msg in message_list:
            msg = msg.to_dict()
            LOG.debug(msg)
            assert msg.get('error')
            assert len(msg.get('documents')) > 0
            assert any([
                regex.search(msg.get('message')),
                regex_1.search(msg.get('message')),
                regex_2.search(msg.get('message'))
            ])

        assert len(message_list) == 3
    def test_invalid_mtu(self, mocker, deckhand_ingester, drydock_state,
                         input_files):

        input_file = input_files.join("invalid_mtu.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.mtu_rational(site_design)

        regex = re.compile(
            'Mtu Error: Mtu must be between 1400 and 64000; on Network .+')
        regex_1 = re.compile(
            'Mtu Error: Mtu must be <= the parent Network Link; for Network .+'
        )

        for msg in message_list:
            msg = msg.to_dict()
            assert msg.get('error')
            assert regex.match(
                msg.get('message')) is not None or regex_1.match(
                    msg.get('message')) is not None

        assert len(message_list) == 4
Ejemplo n.º 18
0
    def test_invalid_ip_locality_address_not_in_network(self, input_files, drydock_state, deckhand_ingester):
        input_file = input_files.join("invalid_ip_locality_address_not_in_network.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.ip_locality_check(site_design)
        msg = message_list[0].to_dict()

        assert 'IP Locality Error: The IP Address' in msg.get('message')
        assert msg.get('error') is True
Ejemplo n.º 19
0
    def test_no_baremetal_node(self, input_files, drydock_state, deckhand_ingester):
        input_file = input_files.join("ip_locality_no_baremetal_node.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.ip_locality_check(site_design)
        msg = message_list[0].to_dict()

        assert msg.get('message') == 'No baremetal_nodes found.'
        assert msg.get('error') is False
Ejemplo n.º 20
0
    def test_ip_locality(self, input_files, drydock_state, deckhand_ingester):
        input_file = input_files.join("validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = IpLocalityCheck()
        message_list = validator.execute(site_design, orchestrator=orch)
        msg = message_list[0].to_dict()

        assert msg.get('error') is False
    def test_rational_network_trunking(self, deckhand_ingester, drydock_state, input_files):

        input_file = input_files.join("rational_network_trunking.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state, ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.network_trunking_rational(site_design)
        msg = message_list[0].to_dict()

        assert msg.get('message') == 'Rational Network Trunking'
        assert msg.get('error') is False
Ejemplo n.º 22
0
    def test_no_duplicate_IPs_no_addressing(self, input_files, drydock_state,
                                            deckhand_ingester):
        input_file = input_files.join("no_duplicate_IPs_no_addressing.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.no_duplicate_IPs_check(site_design)
        msg = message_list[0].to_dict()

        assert msg.get('message') == 'No BaremetalNodes Found.'
        assert msg.get('error') is False
Ejemplo n.º 23
0
    def test_validate_no_nodes(self, deckhand_ingester, drydock_state,
                               input_files, mock_get_build_data):
        """Test that a design with no baremetal nodes validates."""

        input_file = input_files.join("deckhand_fullsite_no_nodes.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        val = Validator(orch)
        response = val.validate_design(site_design)

        assert response.status == hd_fields.ValidationResult.Success
    def test_mtu(self, mocker, deckhand_ingester, drydock_state, input_files):

        input_file = input_files.join("mtu_rational.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.mtu_rational(site_design)
        msg = message_list[0].to_dict()

        assert msg.get('message') == 'Mtu'
        assert msg.get('error') is False
        assert len(message_list) == 1
Ejemplo n.º 25
0
    def test_invalid_no_duplicate_IPs(self, input_files, drydock_state,
                                      deckhand_ingester):
        input_file = input_files.join(
            "invalid_no_duplicate_IPs_addresses_duplicated.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.no_duplicate_IPs_check(site_design)
        msg = message_list[0].to_dict()

        assert msg.get('error') is True
        assert 'Error! Duplicate IP Address Found:' in msg.get('message')
Ejemplo n.º 26
0
    def test_storage_partitioning(self, deckhand_ingester, drydock_state,
                                  input_files):
        input_file = input_files.join("validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = StoragePartitioning()
        message_list = validator.execute(site_design, orchestrator=orch)
        msg = message_list[0].to_dict()

        assert len(message_list) == 1
        assert msg.get('error') is False
    def test_no_duplicate_IPs_no_baremetal_node(self, input_files,
                                                drydock_state,
                                                deckhand_ingester):
        input_file = input_files.join("no_baremetal_node.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = NoDuplicateIpsCheck()
        message_list = validator.execute(site_design, orchestrator=orch)
        msg = message_list[0].to_dict()

        assert 'No BaremetalNodes Found.' in msg.get('message')
        assert msg.get('error') is False
Ejemplo n.º 28
0
    def test_rational_network_bond(self, mocker, deckhand_ingester,
                                   drydock_state, input_files):
        input_file = input_files.join("validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(
            state_manager=drydock_state, ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        validator = RationalNetworkBond()
        message_list = validator.execute(site_design, orchestrator=orch)
        msg = message_list[0].to_dict()

        assert msg.get('error') is False
        assert len(message_list) == 1
        assert len(msg.get('documents')) == 0
Ejemplo n.º 29
0
    def test_absent_bootaction(self, deckhand_ingester, drydock_state, setup,
                               input_files, mock_get_build_data):
        input_file = input_files.join("absent_bootaction.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(state_manager=drydock_state,
                            ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        ba_msg = [
            msg for msg in status.message_list
            if ("DD4001" in msg.name
                and msg.level == hd_fields.MessageLevels.WARN)
        ]

        assert len(ba_msg) > 0
    def test_invalid_no_duplicate_IPs(self, input_files, drydock_state,
                                      deckhand_ingester):
        input_file = input_files.join("invalid_validation.yaml")
        design_ref = "file://%s" % str(input_file)

        orch = Orchestrator(
            state_manager=drydock_state, ingester=deckhand_ingester)

        status, site_design = Orchestrator.get_effective_site(orch, design_ref)

        message_list = Validator.no_duplicate_IPs_check(site_design)

        regex = re.compile(
            'Error! Duplicate IP Address Found: .+ is in use by both .+ and .+.'
        )
        for msg in message_list:
            msg = msg.to_dict()
            assert msg.get('error') is True
            assert regex.match(msg.get('message')) is not None