def validate_cni_params(config):
    """
    Checks the presence of atleast one plugin in Cni tag
    """
    logger.info("checking multus networks  params")
    net_configs = config_utils.get_networks(config)
    cni_params = []

    for all_keys in net_configs[1]:
        for keys_in_all_keys in net_configs[1][all_keys]:
            cni_params.append(keys_in_all_keys)
            break

    for cni_param in cni_params:
        if consts.WEAVE_TYPE in cni_param.get(consts.MULTUS_CNI_KEY):
            validate_multus_network_weave_params(config)

        if consts.FLANNEL_TYPE in cni_param.get(consts.MULTUS_CNI_KEY):
            validate_multus_network_flannel_params(config)

        if consts.SRIOV_TYPE in cni_param.get(consts.MULTUS_CNI_KEY):
            validate_multus_network_sriov_params(config)

        if consts.MACVLAN_TYPE in cni_param.get(consts.MULTUS_CNI_KEY):
            validate_multus_network_macvlan_params(config)

    validate_dhcpmandatory(config)
Example #2
0
 def test_get_networks(self):
     """
     Ensures network values are properly parsed
     """
     networks_data = config_utils.get_networks(self.config)
     expected = self.config[consts.K8S_KEY][consts.NETWORKS_KEY]
     self.assertEqual(expected, networks_data)
def validate_duplicatein_cni_and_networkplugin(config):
    """
    Checks if there exists the same plugin in both default network
    plugin tag and in Cni parameters
    """
    logger.info("checking duplicate values")
    net_configs = config_utils.get_networks(config)
    networkpluginvalue = net_configs[0].values()[0][consts.NET_PLUGIN_KEY]

    net_elems = config_utils.get_multus_net_elems(config)
    if (consts.WEAVE_TYPE in net_elems
            and consts.WEAVE_TYPE == networkpluginvalue):
        raise ValidationException("duplicate weave")
    if (consts.FLANNEL_TYPE in net_elems
            and consts.FLANNEL_TYPE == networkpluginvalue):
        raise ValidationException("duplicate flannel")
    if (consts.SRIOV_TYPE in net_elems
            and consts.SRIOV_TYPE == networkpluginvalue):
        raise ValidationException("duplicate Sriov")
    if (consts.MACVLAN_TYPE in net_elems
            and consts.MACVLAN_TYPE == networkpluginvalue):
        raise ValidationException("duplicate macvlan")