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'))
            ])
    def test_unique_network(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 = UniqueNetworkCheck()
        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
Exemplo n.º 3
0
            result_status.set_status(hd_fields.ValidationResult.Failure)
            result_status.message = "Site design failed validation."
            result_status.reason = "See detail messages."
        else:
            result_status.set_status(hd_fields.ValidationResult.Success)
            result_status.message = "Site design passed validation"

        return result_status


rule_set = [
    BootStorageRational(),
    CidrValidity(),
    HugepagesValidity(),
    IpLocalityCheck(),
    MtuRational(),
    NetworkTrunkingRational(),
    NoDuplicateIpsCheck(),
    PlatformSelection(),
    RationalNetworkBond(),
    StoragePartitioning(),
    StorageSizing(),
    StorageMountpoints(),
    UniqueNetworkCheck(),
    HostnameValidity(),
    IpmiValidity(),
    LibvirtValidity(),
    BootactionDefined(),
    BootactionPackageListValid(),
]