def __launch_sriov_network(k8s_conf, sriov_host): master_host, ip = config_utils.get_first_master_host(k8s_conf) for sriov_net in sriov_host[consts.SRIOV_NETWORKS_KEY]: dpdk_enable = config_utils.bool_val(sriov_net.get( consts.SRIOV_DPDK_ENABLE_KEY)) if dpdk_enable: logger.info('SRIOV NETWORK CREATION STARTED USING DPDK DRIVER') host_type = sriov_net.get(consts.TYPE_KEY) sriov_intf = sriov_net.get(consts.SRIOV_INTF_KEY) sriov_nw_name = sriov_net.get(consts.NETWORK_NAME_KEY) pb_vars = { 'intf': sriov_intf, 'network_name': sriov_nw_name, 'dpdk_driver': consts.DPDK_DRIVER, 'dpdk_tool': consts.DPDK_TOOL, 'node_hostname': sriov_host.get(consts.HOSTNAME_KEY), 'PROJ_ARTIFACT_DIR': config_utils.get_project_artifact_dir( k8s_conf), } ansible_utils.apply_playbook( consts.K8_SRIOV_DPDK_CR_NW, [master_host], consts.NODE_USER, variables=pb_vars) if host_type == consts.NET_TYPE_LOCAL_TYPE: logger.info('SRIOV NETWORK CREATION STARTED USING ' 'KERNEL DRIVER WITH IPAM host-local') pb_vars = { 'host_name': master_host, 'intf': sriov_intf, 'network_name': sriov_nw_name, 'rangeStart': sriov_net.get(consts.RANGE_START_KEY), 'rangeEnd': sriov_net.get(consts.RANGE_END_KEY), 'subnet': sriov_net.get(consts.SUBNET_KEY), 'gateway': sriov_net.get(consts.GATEWAY_KEY), 'masterPlugin': sriov_net.get(consts.MASTER_PLUGIN_KEY), 'PROJ_ARTIFACT_DIR': config_utils.get_project_artifact_dir( k8s_conf), } ansible_utils.apply_playbook( consts.K8_SRIOV_CR_NW, consts.NODE_USER, variables=pb_vars) if host_type == consts.DHCP_TYPE: logger.info( 'SRIOV NETWORK CREATION STARTED USING ' 'KERNEL DRIVER WITH IPAM host-dhcp') pb_vars = { 'intf': sriov_intf, 'network_name': sriov_nw_name, 'PROJ_ARTIFACT_DIR': config_utils.get_project_artifact_dir( k8s_conf), } pb_vars.update(config_utils.get_proxy_dict(k8s_conf)) ansible_utils.apply_playbook( consts.K8_SRIOV_DHCP_CR_NW, consts.NODE_USER, variables=pb_vars)
def ismaster_count_for_deployment(config): """ Checks the presence of master f*g must be true atleast once in deployment """ master_count = 0 dflt_net = config_utils.get_default_network(config) if config_utils.bool_val(dflt_net[consts.MASTER_PLUGIN_KEY]): master_count += 1 multus_nets = config_utils.get_multus_cni_cfgs(config) for multus_net in multus_nets: if consts.FLANNEL_NET_TYPE in multus_net: networks = multus_net[consts.FLANNEL_NET_TYPE] for network in networks: validate_dict_data(network, consts.FLANNEL_NET_DTLS_KEY) details = network[consts.FLANNEL_NET_DTLS_KEY] if config_utils.bool_val(details[consts.MASTER_PLUGIN_KEY]): master_count += 1 if consts.WEAVE_NET_TYPE in multus_net: networks = multus_net[consts.WEAVE_NET_TYPE] for network in networks: validate_dict_data(network, consts.WEAVE_NET_DTLS_KEY) details = network[consts.WEAVE_NET_DTLS_KEY] if config_utils.bool_val(details[consts.MASTER_PLUGIN_KEY]): master_count += 1 if consts.MACVLAN_NET_TYPE in multus_net: networks = multus_net[consts.MACVLAN_NET_TYPE] for network in networks: validate_dict_data(network, consts.MACVLAN_NET_DTLS_KEY) details = network[consts.MACVLAN_NET_DTLS_KEY] if config_utils.bool_val(details[consts.MASTER_PLUGIN_KEY]): master_count += 1 if consts.SRIOV_NET_TYPE in multus_net: net_hosts = multus_net[consts.SRIOV_NET_TYPE] for net_host in net_hosts: validate_dict_data(net_host, consts.HOST_KEY) host_conf = net_host[consts.HOST_KEY] validate_dict_data(host_conf, consts.SRIOV_NETWORKS_KEY) networks = host_conf[consts.SRIOV_NETWORKS_KEY] for network in networks: if config_utils.bool_val( network[consts.MASTER_PLUGIN_KEY]): master_count += 1 if master_count > 1: raise ValidationException('isMaster is present more than once')
def launch_sriov_cni_configuration(k8s_conf): """ This function is used to launch sriov cni """ logger.info('EXECUTING SRIOV CNI PLAY') networking_plugin = config_utils.get_networking_plugin(k8s_conf) dpdk_driver = 'vfio-pci' dpdk_enable = False sriov_cfgs = config_utils.get_multus_cni_sriov_cfgs(k8s_conf) for sriov_cfg in sriov_cfgs: sriov_host = sriov_cfg[consts.HOST_KEY] # for sriov_net in sriov_hosts: hostname = sriov_host[consts.HOSTNAME_KEY] for sriov_net in sriov_host[consts.SRIOV_NETWORKS_KEY]: dpdk_enable = config_utils.bool_val( sriov_net.get(consts.SRIOV_DPDK_ENABLE_KEY, None)) pb_vars = { 'host_name': hostname, 'sriov_intf': sriov_net[consts.SRIOV_INTF_KEY], 'networking_plugin': networking_plugin, 'KUBERNETES_PATH': consts.NODE_K8S_PATH, 'PROJ_ARTIFACT_DIR': config_utils.get_project_artifact_dir(k8s_conf), } ansible_utils.apply_playbook(consts.K8_SRIOV_ENABLE, [hostname], config_utils.get_node_user(k8s_conf), variables=pb_vars) pb_vars = config_utils.get_proxy_dict(k8s_conf) pb_vars.update( {'SRC_PACKAGE_PATH': config_utils.get_artifact_dir(k8s_conf)}) ansible_utils.apply_playbook(consts.K8_SRIOV_CNI_BUILD, variables=pb_vars) logger.info('DPDK flag is %s', dpdk_enable) if dpdk_enable is True: pb_vars = config_utils.get_proxy_dict(k8s_conf) pb_vars.update( {'SRC_PACKAGE_PATH': config_utils.get_artifact_dir(k8s_conf)}) ansible_utils.apply_playbook(consts.K8_SRIOV_DPDK_CNI, variables=pb_vars) master_nodes_tuple_3 = config_utils.get_master_nodes_ip_name_type(k8s_conf) for hostname, ip, host_type in master_nodes_tuple_3: logger.info( 'INSTALLING SRIOV BIN ON MASTER. Master Host Name - %s, ' 'Master Host Type - %s', hostname, host_type) ansible_utils.apply_playbook( consts.K8_SRIOV_CNI_BIN_INST, [ip], config_utils.get_node_user(k8s_conf), variables={ 'SRC_PACKAGE_PATH': config_utils.get_artifact_dir(k8s_conf) }) if dpdk_enable is True: logger.info('INSTALLING SRIOV DPDK BIN ON MASTER') ansible_utils.apply_playbook( consts.K8_SRIOV_DPDK_CNI_BIN_INST, [ip], config_utils.get_node_user(k8s_conf), variables={ 'SRC_PACKAGE_PATH': config_utils.get_artifact_dir(k8s_conf) }) minon_ips = config_utils.get_minion_node_ips(k8s_conf) ansible_utils.apply_playbook(consts.K8_SRIOV_DPDK_CNI_BIN_INST, [minon_ips], config_utils.get_node_user(k8s_conf), variables={ 'SRC_PACKAGE_PATH': config_utils.get_artifact_dir(k8s_conf) }) if dpdk_enable is True: logger.info('INSTALLING SRIOV DPDK BIN ON WORKERS') ansible_utils.apply_playbook(consts.K8_SRIOV_DPDK_DRIVER_LOAD, [minon_ips], config_utils.get_node_user(k8s_conf), variables={'dpdk_driver': dpdk_driver}) ansible_utils.apply_playbook( consts.K8_SRIOV_DPDK_CNI_BIN_INST, [minon_ips], config_utils.get_node_user(k8s_conf), variables={ 'SRC_PACKAGE_PATH': config_utils.get_artifact_dir(k8s_conf) })