Brian Freeman | ee02b31 | 2019-02-04 20:36:08 -0500 | [diff] [blame] | 1 | import json |
| 2 | import os.path |
| 3 | |
| 4 | |
Jerry Flood | d40619e | 2017-08-24 09:38:48 -0400 | [diff] [blame] | 5 | ''' |
| 6 | This metadata identifies the folders to be zipped and uploaded to SDC for model distribution for a given VNF |
| 7 | ''' |
Jerry Flood | 8c63629 | 2017-10-30 13:03:31 -0400 | [diff] [blame] | 8 | GLOBAL_SERVICE_FOLDER_MAPPING = {"vFW" : ['vFW'], \ |
| 9 | "vLB" : ['vLB'], \ |
| 10 | "vVG" : ['vVG'], \ |
Jerry Flood | 3a169a3 | 2017-12-01 12:39:10 -0500 | [diff] [blame] | 11 | "vCPE" : ['vCPE/infra', 'vCPE/vbng', 'vCPE/vbrgemu', 'vCPE/vgmux', 'vCPE/vgw'], |
| 12 | "vFWCL" : ['vFWCL/vFWSNK', 'vFWCL/vPKG'], |
Yang Xu | 2ec8038 | 2018-11-01 12:30:37 -0400 | [diff] [blame] | 13 | "vFWNG" : ['vFW_NextGen/templates'], |
Brian Freeman | eef7c6f | 2018-11-16 18:42:21 -0500 | [diff] [blame] | 14 | "vCPEInfra" : ['vCPE/infra'], |
| 15 | "vCPEvBNG" : ['vCPE/vbng'], |
| 16 | "vCPEvBRGEMU" : ['vCPE/vbrgemu'], |
| 17 | "vCPEvGMUX" : ['vCPE/vgmux'], |
| 18 | "vCPEvGW" : ['vCPE/vgw'], |
bdfreeman1421 | b2a4951 | 2018-11-25 07:32:19 -0500 | [diff] [blame] | 19 | "vCPEResCust" : ['vCPE/vgw'], |
Jerry Flood | 3a169a3 | 2017-12-01 12:39:10 -0500 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | ''' |
| 23 | Map the service to the list of VNFs to be orchestrated |
| 24 | ''' |
| 25 | GLOBAL_SERVICE_VNF_MAPPING = { |
| 26 | "vFW" : ['vFW'], |
| 27 | "vLB" : ['vLB'], |
| 28 | "vVG" : ['vVG'], |
| 29 | "vCPE" : ['vCPE'], |
Brian Freeman | 12ff184 | 2019-02-13 13:54:48 -0500 | [diff] [blame] | 30 | "vFWCL" : ['vFWCLvFWSNK', 'vFWCLvPKG'], |
Yang Xu | 2ec8038 | 2018-11-01 12:30:37 -0400 | [diff] [blame] | 31 | "vFWNG" : ['vFWNG'], |
Brian Freeman | eef7c6f | 2018-11-16 18:42:21 -0500 | [diff] [blame] | 32 | "vCPEInfra" : ['vCPEInfra'], |
| 33 | "vCPEvBNG" : ['vCPEvBNG'], |
| 34 | "vCPEvBRGEMU" : ['vCPEvBRGEMU'], |
| 35 | "vCPEvGMUX" : ['vCPEvGMUX'], |
| 36 | "vCPEvGW" : ['vCPEvGW'], |
bdfreeman1421 | b2a4951 | 2018-11-25 07:32:19 -0500 | [diff] [blame] | 37 | "vCPERestCust" : ['vCPEvGW'], |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 38 | } |
Jerry Flood | d40619e | 2017-08-24 09:38:48 -0400 | [diff] [blame] | 39 | |
| 40 | ''' |
Brian Freeman | eef7c6f | 2018-11-16 18:42:21 -0500 | [diff] [blame] | 41 | |
| 42 | Map the service to the list of Generic Neutron Networks to be orchestrated |
| 43 | |
| 44 | ''' |
| 45 | GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING = { |
| 46 | "vCPEInfra" : ['CPE_SIGNAL','CPE_PUBLIC'], |
| 47 | "vCPEvBNG" : ['BRG_BNG', 'BNG_MUX'], |
| 48 | "vCPEvGMUX" : ['MUX_GW'], |
| 49 | "vCPEvBRGEMU" :[], |
| 50 | "vCPEvGW" :[], |
bdfreeman1421 | b2a4951 | 2018-11-25 07:32:19 -0500 | [diff] [blame] | 51 | "vCPERestCust" :[], |
Brian Freeman | eef7c6f | 2018-11-16 18:42:21 -0500 | [diff] [blame] | 52 | "vFW" :[], |
| 53 | "vLB" :[], |
| 54 | "vVG" :[], |
| 55 | "vFWCL" :[], |
| 56 | "vFWNG" :[], |
| 57 | } |
| 58 | ''' |
| 59 | |
Brian Freeman | 2e1d0ff | 2019-01-23 09:38:13 -0500 | [diff] [blame] | 60 | Map the service to the list of Deployment Artifacts for Closed Loop Control |
| 61 | |
| 62 | ''' |
| 63 | GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING = { |
| 64 | "vCPEInfra" : [], |
| 65 | "vCPEvBNG" : [], |
| 66 | "vCPEvGMUX" : [], |
| 67 | "vCPEvBRGEMU" :[], |
| 68 | "vCPEvGW" :[], |
| 69 | "vCPERestCust" :[], |
| 70 | "vFW" :[], |
| 71 | "vLB" :['tca_docker_k8s_v4.yaml'], |
| 72 | "vVG" :[], |
| 73 | "vFWCL" :[], |
| 74 | "vFWNG" :[], |
| 75 | } |
| 76 | ''' |
| 77 | |
Brian Freeman | eef7c6f | 2018-11-16 18:42:21 -0500 | [diff] [blame] | 78 | |
| 79 | |
Jerry Flood | d40619e | 2017-08-24 09:38:48 -0400 | [diff] [blame] | 80 | This metadata identifes the preloads that need to be done for a VNF as there may be more than one (vLB) |
Jerry Flood | 3a169a3 | 2017-12-01 12:39:10 -0500 | [diff] [blame] | 81 | "template" maps to the parameters in the preload_paramenters.py |
Jerry Flood | 3fc36a3 | 2017-10-11 11:09:19 -0400 | [diff] [blame] | 82 | - GLOBAL_PRELOAD_PARAMETERS[<testcase>][<template>] - |
| 83 | i.e. GLOBAL_PRELOAD_PARAMETERS['Demo'][dnsscaling_preload.template'] |
Jerry Flood | d40619e | 2017-08-24 09:38:48 -0400 | [diff] [blame] | 84 | ''' |
Jerry Flood | 3fc36a3 | 2017-10-11 11:09:19 -0400 | [diff] [blame] | 85 | GLOBAL_SERVICE_TEMPLATE_MAPPING = { |
Brian Freeman | 2e1d0ff | 2019-01-23 09:38:13 -0500 | [diff] [blame] | 86 | "vFW" : [{"isBase" : "true", "template" : "vfw_preload.template", "name_pattern": "base_vfw"}], |
Jerry Flood | 3fc36a3 | 2017-10-11 11:09:19 -0400 | [diff] [blame] | 87 | "vLB" : [{"isBase" : "true", "template" : "vlb_preload.template", "name_pattern": "base_vlb"}, |
| 88 | {"isBase" : "false", "template" : "dnsscaling_preload.template", "name_pattern": "dnsscaling", "prefix" : "vDNS_"}], |
Jerry Flood | 3a169a3 | 2017-12-01 12:39:10 -0500 | [diff] [blame] | 89 | "vVG" : [{"isBase" : "true", "template" : "vvg_preload.template", "name_pattern": "base_vvg"}], |
| 90 | "vCPE" : [{"isBase" : "true", "template" : "vcpe_preload.template", "name_pattern": "base_clearwater"}], |
| 91 | "vFWSNK" : [{"isBase" : "true", "template" : "vfwsnk_preload.template", "name_pattern": "base_vfw"}], |
| 92 | "vPKG" : [{"isBase" : "true", "template" : "vpkg_preload.template", "name_pattern": "base_vpkg"}], |
Bin Yang | 326219a | 2018-05-31 05:35:33 +0000 | [diff] [blame] | 93 | "vFWCL" : [{"isBase" : "true", "template" : "vfwsnk_preload.template", "name_pattern": "base_vfw"}, |
| 94 | {"isBase" : "true", "template" : "vpkg_preload.template", "name_pattern": "base_vpkg"}], |
Brian Freeman | 12ff184 | 2019-02-13 13:54:48 -0500 | [diff] [blame] | 95 | "vFWCLvFWSNK" : [{"isBase" : "true", "template" : "vfwsnk_preload.template", "vnf_index": "0", "name_pattern": "base_vfw"}], |
| 96 | "vFWCLvPKG" : [{"isBase" : "true", "template" : "vpkg_preload.template", "vnf_index": "1" , "name_pattern": "base_vpkg"}], |
Brian Freeman | eef7c6f | 2018-11-16 18:42:21 -0500 | [diff] [blame] | 97 | "vCPEInfra" : [{"isBase" : "true", "template" : "vcpe_infra_preload.template", "name_pattern": "base_infra"}], |
| 98 | "vCPEvBNG" : [{"isBase" : "true", "template" : "vcpe_vbng_preload.template", "name_pattern": "base_vbng"}], |
| 99 | "vCPEvBRGEMU" : [{"isBase" : "true", "template" : "vcpe_vbrgemu_preload.template", "name_pattern": "base_vbrgemu"}], |
| 100 | "vCPEvGMUX" : [{"isBase" : "true", "template" : "vcpe_vgmux_preload.template", "name_pattern": "base_vgmux"}], |
| 101 | "vCPEvGW" : [{"isBase" : "true", "template" : "vcpe_vgw_preload.template", "name_pattern": "base_vgw"}], |
bdfreeman1421 | b2a4951 | 2018-11-25 07:32:19 -0500 | [diff] [blame] | 102 | "vCPEResCust" : [{"isBase" : "true", "template" : "vcpe_vgw_preload.template", "name_pattern": "base_vgw"}], |
Jerry Flood | 3fc36a3 | 2017-10-11 11:09:19 -0400 | [diff] [blame] | 103 | } |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 104 | |
Jerry Flood | d40619e | 2017-08-24 09:38:48 -0400 | [diff] [blame] | 105 | ''' |
| 106 | Used by the Heatbridge Validate Query to A&AI to locate the vserver name |
| 107 | ''' |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 108 | GLOBAL_VALIDATE_NAME_MAPPING = {"vFW" : 'vfw_name_0', |
| 109 | "vLB" : 'vlb_name_0', |
Jerry Flood | 3fc36a3 | 2017-10-11 11:09:19 -0400 | [diff] [blame] | 110 | "vVG" : '', |
Brian Freeman | abf7ac2 | 2018-05-20 19:49:34 -0500 | [diff] [blame] | 111 | "vCPE" : 'vgw_name_0', |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 112 | "vCPEvGW" : 'vgw_name_0', |
bdfreeman1421 | b2a4951 | 2018-11-25 07:32:19 -0500 | [diff] [blame] | 113 | "vCPEResCust" : 'vgw_name_0', |
Brian Freeman | 108048b | 2018-05-22 13:13:05 -0500 | [diff] [blame] | 114 | "vCPEvDNS" : 'vdns_name_0', |
| 115 | "vCPEvAAA" : 'vaaa_name_0', |
| 116 | "vCPEvWEB" : 'vweb_name_0', |
| 117 | "vCPEvDHCP" : 'vdhcp_name_0', |
Yang Xu | 875ab32 | 2018-11-21 22:38:18 -0500 | [diff] [blame] | 118 | "vCPEvGMUX" : 'vgmux_name_0', |
Jerry Flood | 3a169a3 | 2017-12-01 12:39:10 -0500 | [diff] [blame] | 119 | "vFWSNK" : 'vfw_name_0', |
| 120 | "vPKG" : 'vpg_name_0', |
Brian Freeman | 12ff184 | 2019-02-13 13:54:48 -0500 | [diff] [blame] | 121 | "vFWCLvFWSNK" : 'vfw_name_0', |
| 122 | "vFWCLvPKG" : 'vpg_name_0', |
DR695H | ccff30b | 2017-02-17 18:44:24 -0500 | [diff] [blame] | 123 | } |
Brian Freeman | eef7c6f | 2018-11-16 18:42:21 -0500 | [diff] [blame] | 124 | |
Brian Freeman | ee02b31 | 2019-02-04 20:36:08 -0500 | [diff] [blame] | 125 | |
| 126 | |
| 127 | # Create dictionaries for new MAPPING data to join to original MAPPING data |
| 128 | GLOBAL_SERVICE_FOLDER_MAPPING2 = {} |
| 129 | GLOBAL_SERVICE_VNF_MAPPING2 = {} |
| 130 | GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING2 = {} |
| 131 | GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING2 = {} |
| 132 | GLOBAL_SERVICE_TEMPLATE_MAPPING2 = {} |
| 133 | GLOBAL_VALIDATE_NAME_MAPPING2 = {} |
| 134 | |
| 135 | |
| 136 | |
| 137 | folder=os.path.join('./demo/service_mapping') |
| 138 | subfolders = [d for d in os.listdir(folder) if os.path.isdir(os.path.join(folder, d))] |
| 139 | |
| 140 | for service in subfolders: |
| 141 | filepath=os.path.join('./demo/service_mapping', service, 'service_mapping.json') |
| 142 | with open(filepath, 'r') as f: |
| 143 | service_mappings = json.load(f) |
| 144 | for mapping in service_mappings: |
| 145 | if mapping == 'GLOBAL_SERVICE_FOLDER_MAPPING': |
| 146 | GLOBAL_SERVICE_FOLDER_MAPPING2[service]=service_mappings[mapping][service] |
| 147 | if mapping == 'GLOBAL_SERVICE_VNF_MAPPING': |
| 148 | GLOBAL_SERVICE_VNF_MAPPING2[service]=service_mappings[mapping][service] |
| 149 | if mapping == 'GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING': |
| 150 | GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING2[service]=service_mappings[mapping][service] |
| 151 | if mapping == 'GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING': |
Brian Freeman | 12ff184 | 2019-02-13 13:54:48 -0500 | [diff] [blame] | 152 | GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING2[service]=service_mappings[mapping][service] |
Brian Freeman | ee02b31 | 2019-02-04 20:36:08 -0500 | [diff] [blame] | 153 | if mapping == 'GLOBAL_SERVICE_TEMPLATE_MAPPING': |
Brian Freeman | 12ff184 | 2019-02-13 13:54:48 -0500 | [diff] [blame] | 154 | # service changes for complex vnf |
| 155 | #GLOBAL_SERVICE_TEMPLATE_MAPPING2[service]=service_mappings[mapping][service] |
| 156 | for vnftype in service_mappings[mapping]: |
| 157 | GLOBAL_SERVICE_TEMPLATE_MAPPING2[vnftype]=service_mappings[mapping][vnftype] |
Brian Freeman | ee02b31 | 2019-02-04 20:36:08 -0500 | [diff] [blame] | 158 | if mapping == 'GLOBAL_VALIDATE_NAME_MAPPING': |
Brian Freeman | 12ff184 | 2019-02-13 13:54:48 -0500 | [diff] [blame] | 159 | # service changes for complex vnf |
| 160 | #GLOBAL_VALIDATE_NAME_MAPPING2[service]=service_mappings[mapping][service] |
| 161 | for vnftype in service_mappings[mapping]: |
| 162 | GLOBAL_VALIDATE_NAME_MAPPING2[vnftype]=service_mappings[mapping][vnftype] |
Brian Freeman | ee02b31 | 2019-02-04 20:36:08 -0500 | [diff] [blame] | 163 | |
| 164 | # Merge dictionaries |
| 165 | GLOBAL_SERVICE_FOLDER_MAPPING = dict(GLOBAL_SERVICE_FOLDER_MAPPING.items() + GLOBAL_SERVICE_FOLDER_MAPPING2.items()) |
| 166 | GLOBAL_SERVICE_VNF_MAPPING = dict(GLOBAL_SERVICE_VNF_MAPPING.items() + GLOBAL_SERVICE_VNF_MAPPING2.items()) |
| 167 | GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING = dict(GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING.items() + GLOBAL_SERVICE_GEN_NEUTRON_NETWORK_MAPPING2.items()) |
| 168 | GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING = dict(GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING.items() + GLOBAL_SERVICE_DEPLOYMENT_ARTIFACT_MAPPING2.items()) |
| 169 | GLOBAL_SERVICE_TEMPLATE_MAPPING = dict(GLOBAL_SERVICE_TEMPLATE_MAPPING.items() + GLOBAL_SERVICE_TEMPLATE_MAPPING2.items()) |
| 170 | GLOBAL_VALIDATE_NAME_MAPPING = dict(GLOBAL_VALIDATE_NAME_MAPPING.items() + GLOBAL_VALIDATE_NAME_MAPPING2.items()) |