3 * ============LICENSE_START=======================================================
4 * Copyright (C) 2019 Orange
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * ============LICENSE_END=========================================================
34 from datetime import datetime
35 from datetime import timedelta
36 from simple_rest_client.api import API
37 from simple_rest_client.resource import Resource
38 from basicauth import encode
39 from urllib3.exceptions import InsecureRequestWarning
42 old_merge_environment_settings = requests.Session.merge_environment_settings
46 ansible_inventory = {}
47 osdf_response = {"last": { "id": "id", "data": None}}
48 print_performance=False
49 stats = open("stats.csv", "w")
50 stats.write("operation;time\n")
53 class BaseServer(http.server.BaseHTTPRequestHandler):
55 def __init__(self, one, two, three):
56 self.osdf_resp = osdf_response
57 super().__init__(one, two, three)
59 def _set_headers(self):
60 self.send_response(200)
61 self.send_header('Content-type', 'application/json')
72 self.data_string = self.rfile.read(int(self.headers['Content-Length']))
73 self.send_response(200)
76 data = simplejson.loads(self.data_string)
77 #print(json.dumps(data, indent=4))
78 self.osdf_resp["last"]["data"] = data
79 self.osdf_resp["last"]["id"] = data["requestId"]
80 with open("response.json", "w") as outfile:
81 simplejson.dump(data, outfile)
86 def __init__(self, description):
87 self.description = description
89 def __call__(self, f):
90 def wrap(*args, **kwargs):
92 if f.__name__ == "appc_lcm_request" or f.__name__ == "confirm_appc_lcm_action":
94 description = self.description
96 description = self.description + ' ' + req['input']['action']
97 if description.find('>') < 0 and print_performance:
98 print (('> {} START').format(description))
101 ret = f(*args, **kwargs)
104 if print_performance:
105 print ('> {} DONE {:0.3f} ms'.format(description, (time2-time1)*1000.0))
106 stats.write("{};{:0.3f}\n".format(description, (time2-time1)*1000.0).replace(".", ","))
111 def _run_osdf_resp_server():
112 server_address = ('', 9000)
113 httpd = http.server.HTTPServer(server_address, BaseServer)
114 print('Starting OSDF Response Server...')
115 httpd.serve_forever()
118 @contextlib.contextmanager
119 def _no_ssl_verification():
120 opened_adapters = set()
121 def merge_environment_settings(self, url, proxies, stream, verify, cert):
122 # Verification happens only once per connection so we need to close
123 # all the opened adapters once we're done. Otherwise, the effects of
124 # verify=False persist beyond the end of this context manager.
125 opened_adapters.add(self.get_adapter(url))
127 settings = old_merge_environment_settings(self, url, proxies, stream, verify, cert)
128 settings['verify'] = False
132 requests.Session.merge_environment_settings = merge_environment_settings
134 with warnings.catch_warnings():
135 warnings.simplefilter('ignore', InsecureRequestWarning)
138 requests.Session.merge_environment_settings = old_merge_environment_settings
140 for adapter in opened_adapters:
147 def _get_aai_rel_link_data(data, related_to, search_key=None, match_dict=None):
148 # some strings that we will encounter frequently
149 rel_lst = "relationship-list"
150 rkey = "relationship-key"
151 rval = "relationship-value"
152 rdata = "relationship-data"
155 m_key = match_dict.get('key')
156 m_value = match_dict.get('value')
160 rel_dict = data.get(rel_lst)
161 if rel_dict: # check if data has relationship lists
162 for key, rel_list in rel_dict.items(): # pylint: disable=W0612
164 if rel.get("related-to") == related_to:
167 link = rel.get("related-link")
168 r_data = rel.get(rdata, [])
171 if rd.get(rkey) == search_key:
173 if not match_dict: # return first match
175 {"link": link, "d_value": dval}
177 break # go to next relation
178 if rd.get(rkey) == m_key \
179 and rd.get(rval) == m_value:
181 if match_dict and matched: # if matching required
183 {"link": link, "d_value": dval}
185 # matched, return search value corresponding
186 # to the matched r_data group
187 else: # no search key; just return the link
189 {"link": link, "d_value": dval}
193 {"link": None, "d_value": None}
198 class AAIApiResource(Resource):
200 'generic_vnf': {'method': 'GET', 'url': 'network/generic-vnfs/generic-vnf/{}'},
201 'vnfc': {'method': 'GET', 'url': 'network/vnfcs/vnfc/{}'},
202 'vnfc_patch': {'method': 'PATCH', 'url': 'network/vnfcs/vnfc/{}'},
203 'link': {'method': 'GET', 'url': '{}'},
204 'service_instance': {'method': 'GET',
205 'url': 'business/customers/customer/{}/service-subscriptions/service-subscription/{}/service-instances/service-instance/{}'}
209 class HASApiResource(Resource):
211 'plans': {'method': 'POST', 'url': 'plans/'},
212 'plan': {'method': 'GET', 'url': 'plans/{}'}
216 class OSDFApiResource(Resource):
218 'placement': {'method': 'POST', 'url': 'placement'}
222 class APPCLcmApiResource(Resource):
224 'distribute_traffic': {'method': 'POST', 'url': 'appc-provider-lcm:distribute-traffic/'},
225 'distribute_traffic_check': {'method': 'POST', 'url': 'appc-provider-lcm:distribute-traffic-check/'},
226 'upgrade_software': {'method': 'POST', 'url': 'appc-provider-lcm:upgrade-software/'},
227 'upgrade_pre_check': {'method': 'POST', 'url': 'appc-provider-lcm:upgrade-pre-check/'},
228 'upgrade_post_check': {'method': 'POST', 'url': 'appc-provider-lcm:upgrade-post-check/'},
229 'action_status': {'method': 'POST', 'url': 'appc-provider-lcm:action-status/'},
230 'check_lock': {'method': 'POST', 'url': 'appc-provider-lcm:check-lock/'},
231 'lock': {'method': 'POST', 'url': 'appc-provider-lcm:lock/'},
232 'unlock': {'method': 'POST', 'url': 'appc-provider-lcm:unlock/'}
236 def _init_python_aai_api(onap_ip, content_type='application/json'):
238 api_root_url="https://{}:30233/aai/v14/".format(onap_ip),
241 'Authorization': encode("AAI", "AAI"),
242 'X-FromAppId': 'SCRIPT',
243 'Accept': 'application/json',
244 'Content-Type': content_type,
245 'X-TransactionId': str(uuid.uuid4()),
249 json_encode_body=True # encode body as json
251 api.add_resource(resource_name='aai', resource_class=AAIApiResource)
255 def _init_python_has_api(onap_ip):
257 api_root_url="https://{}:30275/v1/".format(onap_ip),
260 'Authorization': encode("admin1", "plan.15"),
261 'X-FromAppId': 'SCRIPT',
262 'Accept': 'application/json',
263 'Content-Type': 'application/json',
264 'X-TransactionId': str(uuid.uuid4()),
268 json_encode_body=True # encode body as json
270 api.add_resource(resource_name='has', resource_class=HASApiResource)
274 def _init_python_osdf_api(onap_ip):
276 api_root_url="https://{}:30248/api/oof/v1/".format(onap_ip),
279 'Authorization': encode("test", "testpwd"),
280 'X-FromAppId': 'SCRIPT',
281 'Accept': 'application/json',
282 'Content-Type': 'application/json',
283 'X-TransactionId': str(uuid.uuid4()),
287 json_encode_body=True # encode body as json
289 api.add_resource(resource_name='osdf', resource_class=OSDFApiResource)
293 def _init_python_appc_lcm_api(onap_ip):
295 api_root_url="https://{}:30230/restconf/operations/".format(onap_ip),
298 'Authorization': encode("admin", "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"),
299 'X-FromAppId': 'SCRIPT',
300 'Accept': 'application/json',
301 'Content-Type': 'application/json',
305 json_encode_body=True # encode body as json
307 api.add_resource(resource_name='lcm', resource_class=APPCLcmApiResource)
311 @timing("Load AAI Data")
312 def load_aai_data(vfw_vnf_id, onap_ip):
313 api = _init_python_aai_api(onap_ip)
315 aai_data['service-info'] = {'global-customer-id': '', 'service-instance-id': '', 'service-type': ''}
316 aai_data['vfw-model-info'] = {'model-invariant-id': '', 'model-version-id': '', 'vnf-name': '', 'vnf-type': ''}
317 aai_data['vpgn-model-info'] = {'model-invariant-id': '', 'model-version-id': '', 'vnf-name': '', 'vnf-type': ''}
318 with _no_ssl_verification():
319 response = api.aai.generic_vnf(vfw_vnf_id, body=None, params={'depth': 2}, headers={})
320 aai_data['vfw-model-info']['model-invariant-id'] = response.body.get('model-invariant-id')
321 aai_data['vfw-model-info']['model-version-id'] = response.body.get('model-version-id')
322 aai_data['vfw-model-info']['vnf-name'] = response.body.get('vnf-name')
323 aai_data['vfw-model-info']['vnf-type'] = response.body.get('vnf-type')
324 aai_data['vf-module-id'] = response.body['vf-modules']['vf-module'][0]['vf-module-id']
326 related_to = "service-instance"
327 search_key = "customer.global-customer-id"
328 rl_data_list = _get_aai_rel_link_data(data=response.body, related_to=related_to, search_key=search_key)
329 aai_data['service-info']['global-customer-id'] = rl_data_list[0]['d_value']
331 search_key = "service-subscription.service-type"
332 rl_data_list = _get_aai_rel_link_data(data=response.body, related_to=related_to, search_key=search_key)
333 aai_data['service-info']['service-type'] = rl_data_list[0]['d_value']
335 search_key = "service-instance.service-instance-id"
336 rl_data_list = _get_aai_rel_link_data(data=response.body, related_to=related_to, search_key=search_key)
337 aai_data['service-info']['service-instance-id'] = rl_data_list[0]['d_value']
339 service_link = rl_data_list[0]['link']
340 response = api.aai.link(service_link, body=None, params={}, headers={})
342 related_to = "generic-vnf"
343 search_key = "generic-vnf.vnf-id"
344 rl_data_list = _get_aai_rel_link_data(data=response.body, related_to=related_to, search_key=search_key)
345 for i in range(0, len(rl_data_list)):
346 vnf_id = rl_data_list[i]['d_value']
348 if vnf_id != vfw_vnf_id:
349 vnf_link = rl_data_list[i]['link']
350 response = api.aai.link(vnf_link, body=None, params={}, headers={})
351 if aai_data['vfw-model-info']['model-invariant-id'] != response.body.get('model-invariant-id'):
352 aai_data['vpgn-model-info']['model-invariant-id'] = response.body.get('model-invariant-id')
353 aai_data['vpgn-model-info']['model-version-id'] = response.body.get('model-version-id')
354 aai_data['vpgn-model-info']['vnf-name'] = response.body.get('vnf-name')
355 aai_data['vpgn-model-info']['vnf-type'] = response.body.get('vnf-type')
360 @timing("> OSDF REQ")
361 def _osdf_request(rancher_ip, onap_ip, aai_data, exclude, use_oof_cache):
362 dirname = os.path.join('templates/oof-cache/', aai_data['vf-module-id'])
364 file = os.path.join(dirname, 'sample-osdf-excluded.json')
366 file = os.path.join(dirname, 'sample-osdf-required.json')
367 if use_oof_cache and os.path.exists(file):
368 migrate_from = json.loads(open(file).read())
371 print('Making OSDF request for excluded {}'.format(str(exclude)))
372 api = _init_python_osdf_api(onap_ip)
373 request_id = str(uuid.uuid4())
374 transaction_id = str(uuid.uuid4())
375 callback_url = "http://{}:9000/osdfCallback/".format(str(rancher_ip))
376 template = json.loads(open('templates/osdfRequest.json').read())
377 template["requestInfo"]["transactionId"] = transaction_id
378 template["requestInfo"]["requestId"] = request_id
379 template["requestInfo"]["callbackUrl"] = callback_url
380 template["serviceInfo"]["serviceInstanceId"] = aai_data['service-info']['service-instance-id']
381 template["placementInfo"]["requestParameters"]["chosenCustomerId"] = aai_data['service-info']['global-customer-id']
382 template["placementInfo"]["placementDemands"][0]["resourceModelInfo"]["modelInvariantId"] =\
383 aai_data['vfw-model-info']['model-invariant-id']
384 template["placementInfo"]["placementDemands"][0]["resourceModelInfo"]["modelVersionId"] =\
385 aai_data['vfw-model-info']['model-version-id']
386 template["placementInfo"]["placementDemands"][1]["resourceModelInfo"]["modelInvariantId"] =\
387 aai_data['vpgn-model-info']['model-invariant-id']
388 template["placementInfo"]["placementDemands"][1]["resourceModelInfo"]["modelVersionId"] =\
389 aai_data['vpgn-model-info']['model-version-id']
391 template["placementInfo"]["placementDemands"][0]["excludedCandidates"][0]["identifiers"].\
392 append(aai_data['vf-module-id'])
393 del template["placementInfo"]["placementDemands"][0]["requiredCandidates"]
395 template["placementInfo"]["placementDemands"][0]["requiredCandidates"][0]["identifiers"].\
396 append(aai_data['vf-module-id'])
397 del template["placementInfo"]["placementDemands"][0]["excludedCandidates"]
399 #print(json.dumps(template, indent=4))
401 with _no_ssl_verification():
402 response = api.osdf.placement(body=template, params={}, headers={}) # pylint: disable=W0612
403 #if response.body.get('error_message') is not None:
404 # raise Exception(response.body['error_message']['explanation'])
407 while counter < 600 and osdf_response["last"]["id"] != request_id:
409 if counter % 20 == 0:
413 if osdf_response["last"]["id"] == request_id:
414 status = osdf_response["last"]["data"]["requestStatus"]
415 if status == "completed":
417 "solution": osdf_response["last"]["data"]["solutions"]["placementSolutions"]
419 if not os.path.exists(dirname):
422 f.write(json.dumps(result, indent=4))
426 message = osdf_response["last"]["data"]["statusMessage"]
427 raise Exception("OOF request {}: {}".format(status, message))
429 raise Exception("No response for OOF request")
433 def _has_request(onap_ip, aai_data, exclude, use_oof_cache):
434 dirname = os.path.join('templates/oof-cache/', aai_data['vf-module-id'])
436 file = os.path.join(dirname, 'sample-has-excluded.json')
438 file = os.path.join(dirname, 'sample-has-required.json')
439 if use_oof_cache and os.path.exists(file):
440 migrate_from = json.loads(open(file).read())
443 print('Making HAS request for excluded {}'.format(str(exclude)))
444 api = _init_python_has_api(onap_ip)
445 request_id = str(uuid.uuid4())
446 template = json.loads(open('templates/hasRequest.json').read())
448 template['name'] = request_id
449 node = template['template']['parameters']
450 node['chosen_customer_id'] = aai_data['service-info']['global-customer-id']
451 node['service_id'] = aai_data['service-info']['service-instance-id']
452 node = template['template']['demands']['vFW-SINK'][0]
453 node['filtering_attributes']['model-invariant-id'] = aai_data['vfw-model-info']['model-invariant-id']
454 node['filtering_attributes']['model-version-id'] = aai_data['vfw-model-info']['model-version-id']
456 node['excluded_candidates'][0]['candidate_id'][0] = aai_data['vf-module-id']
457 del node['required_candidates']
459 node['required_candidates'][0]['candidate_id'][0] = aai_data['vf-module-id']
460 del node['excluded_candidates']
461 node = template['template']['demands']['vPGN'][0]
462 node['filtering_attributes']['model-invariant-id'] = aai_data['vpgn-model-info']['model-invariant-id']
463 node['filtering_attributes']['model-version-id'] = aai_data['vpgn-model-info']['model-version-id']
465 #print(json.dumps(template, indent=4))
467 with _no_ssl_verification():
468 response = api.has.plans(body=template, params={}, headers={})
469 if response.body.get('error_message') is not None:
470 raise Exception(response.body['error_message']['explanation'])
472 plan_id = response.body['id']
473 response = api.has.plan(plan_id, body=None, params={}, headers={})
474 status = response.body['plans'][0]['status']
475 while status != 'done' and status != 'error':
477 response = api.has.plan(plan_id, body=None, params={}, headers={})
478 status = response.body['plans'][0]['status']
480 result = response.body['plans'][0]['recommendations'][0]
482 raise Exception(response.body['plans'][0]['message'])
484 if not os.path.exists(dirname):
487 f.write(json.dumps(result, indent=4))
492 def _extract_has_appc_identifiers(has_result, demand, onap_ip):
494 v_server = has_result[demand]['attributes']['vservers'][0]
496 if len(has_result[demand]['attributes']['vservers'][0]['l-interfaces']) == 4:
497 v_server = has_result[demand]['attributes']['vservers'][0]
499 v_server = has_result[demand]['attributes']['vservers'][1]
500 for itf in v_server['l-interfaces']:
501 if itf['ipv4-addresses'][0].startswith("10.0."):
502 ip = itf['ipv4-addresses'][0]
505 if v_server['vserver-name'] in hostname_cache and demand != 'vPGN':
506 v_server['vserver-name'] = v_server['vserver-name'].replace("01", "02")
507 hostname_cache.append(v_server['vserver-name'])
509 api = _init_python_aai_api(onap_ip) # pylint: disable=W0612
510 vnfc_type = demand.lower()
511 # with _no_ssl_verification():
512 # response = api.aai.vnfc(v_server['vserver-name'], body=None, params={}, headers={})
513 # vnfc_type = response.body.get('nfc-naming-code')
516 'vnf-id': has_result[demand]['attributes']['nf-id'],
517 'vf-module-id': has_result[demand]['attributes']['vf-module-id'],
519 'vserver-id': v_server['vserver-id'],
520 'vserver-name': v_server['vserver-name'],
521 'vnfc-type': vnfc_type,
522 'physical-location-id': has_result[demand]['attributes']['physical-location-id']
524 ansible_inventory_entry = "{} ansible_ssh_host={} ansible_ssh_user=ubuntu".format(config['vserver-name'], config['ip'])
525 if demand.lower() not in ansible_inventory:
526 ansible_inventory[demand.lower()] = {}
527 ansible_inventory[demand.lower()][config['vserver-name']] = ansible_inventory_entry
529 _verify_vnfc_data(api, onap_ip, config['vserver-name'], config['ip'])
533 def _verify_vnfc_data(aai_api, onap_ip, vnfc_name, oam_ip):
534 with _no_ssl_verification():
535 response = aai_api.aai.vnfc(vnfc_name, body=None, params=None, headers={})
536 #print(json.dumps(response.body))
537 if "ipaddress-v4-oam-vip" not in response.body:
538 print("VNFC information update for {}".format(vnfc_name))
539 api = _init_python_aai_api(onap_ip, 'application/merge-patch+json')
540 response = api.aai.vnfc_patch(vnfc_name, body={"ipaddress-v4-oam-vip": oam_ip, "vnfc-name": vnfc_name}, params=None, headers={})
543 def _extract_osdf_appc_identifiers(has_result, demand, onap_ip):
545 v_server = has_result[demand]['vservers'][0]
547 if len(has_result[demand]['vservers'][0]['l-interfaces']) == 4:
548 v_server = has_result[demand]['vservers'][0]
550 v_server = has_result[demand]['vservers'][1]
551 for itf in v_server['l-interfaces']:
552 if itf['ipv4-addresses'][0].startswith("10.0."):
553 ip = itf['ipv4-addresses'][0]
556 if v_server['vserver-name'] in hostname_cache and demand != 'vPGN':
557 v_server['vserver-name'] = v_server['vserver-name'].replace("01", "02")
558 hostname_cache.append(v_server['vserver-name'])
560 api = _init_python_aai_api(onap_ip)
561 vnfc_type = demand.lower(),
562 with _no_ssl_verification():
563 response = api.aai.vnfc(v_server['vserver-name'], body=None, params={}, headers={})
564 vnfc_type = response.body.get('nfc-naming-code')
567 'vnf-id': has_result[demand]['nf-id'],
568 'vf-module-id': has_result[demand]['vf-module-id'],
570 'vserver-id': v_server['vserver-id'],
571 'vserver-name': v_server['vserver-name'],
572 'vnfc-type': vnfc_type,
573 'physical-location-id': has_result[demand]['locationId']
575 ansible_inventory_entry = "{} ansible_ssh_host={} ansible_ssh_user=ubuntu".format(config['vserver-name'], config['ip'])
576 if demand.lower() not in ansible_inventory:
577 ansible_inventory[demand.lower()] = {}
578 ansible_inventory[demand.lower()][config['vserver-name']] = ansible_inventory_entry
580 _verify_vnfc_data(api, onap_ip, config['vserver-name'], config['ip'])
585 def _extract_has_appc_dt_config(has_result, demand):
590 "nf-type": has_result[demand]['attributes']['nf-type'],
591 "nf-name": has_result[demand]['attributes']['nf-name'],
592 "vf-module-name": has_result[demand]['attributes']['vf-module-name'],
593 "vnf-type": has_result[demand]['attributes']['vnf-type'],
594 "service_instance_id": "319e60ef-08b1-47aa-ae92-51b97f05e1bc",
595 "cloudClli": has_result[demand]['attributes']['physical-location-id'],
596 "nf-id": has_result[demand]['attributes']['nf-id'],
597 "vf-module-id": has_result[demand]['attributes']['vf-module-id'],
598 "aic_version": has_result[demand]['attributes']['aic_version'],
599 "ipv4-oam-address": has_result[demand]['attributes']['ipv4-oam-address'],
600 "vnfHostName": has_result[demand]['candidate']['host_id'],
601 "cloudOwner": has_result[demand]['candidate']['cloud_owner'],
602 "isRehome": has_result[demand]['candidate']['is_rehome'],
603 "locationId": has_result[demand]['candidate']['location_id'],
604 "locationType": has_result[demand]['candidate']['location_type'],
605 'vservers': has_result[demand]['attributes']['vservers']
610 def _extract_osdf_appc_dt_config(osdf_result, demand):
614 return osdf_result[demand]
617 def _build_config_from_has(has_result, onap_ip):
618 v_pgn_result = _extract_has_appc_identifiers(has_result, 'vPGN', onap_ip)
619 v_fw_result = _extract_has_appc_identifiers(has_result, 'vFW-SINK', onap_ip)
620 dt_config = _extract_has_appc_dt_config(has_result, 'vFW-SINK')
623 'vPGN': v_pgn_result,
624 'vFW-SINK': v_fw_result
626 #print(json.dumps(config, indent=4))
627 config['dt-config'] = {
628 'destinations': [dt_config]
633 def _adapt_osdf_result(osdf_result):
635 demand = _build_osdf_result_demand(osdf_result["solution"][0][0])
636 result[demand["name"]] = demand["value"]
637 demand = _build_osdf_result_demand(osdf_result["solution"][0][1])
638 result[demand["name"]] = demand["value"]
642 def _build_osdf_result_demand(solution):
644 result["name"] = solution["resourceModuleName"]
645 value = {"candidateId": solution["solution"]["identifiers"][0]}
646 for info in solution["assignmentInfo"]:
647 value[info["key"]] = info["value"]
648 result["value"] = value
652 def _build_config_from_osdf(osdf_result, onap_ip):
653 osdf_result = _adapt_osdf_result(osdf_result)
654 v_pgn_result = _extract_osdf_appc_identifiers(osdf_result, 'vPGN', onap_ip)
655 v_fw_result = _extract_osdf_appc_identifiers(osdf_result, 'vFW-SINK', onap_ip)
656 dt_config = _extract_osdf_appc_dt_config(osdf_result, 'vFW-SINK')
659 'vPGN': v_pgn_result,
660 'vFW-SINK': v_fw_result
662 #print(json.dumps(config, indent=4))
663 config['dt-config'] = {
664 'destinations': [dt_config]
669 def _build_appc_lcm_dt_payload(demand, oof_config, action, traffic_presence):
670 is_check = traffic_presence is not None
671 oof_config = copy.deepcopy(oof_config)
673 # node_list = "[ {} ]".format(oof_config['vPGN']['vserver-id'])
675 # node_list = "[ {} ]".format(oof_config['vFW-SINK']['vserver-id'])
676 book_name = "{}/latest/ansible/{}/site.yml".format(demand.lower(), action.lower())
677 config = oof_config[demand]
679 # 'site': config['physical-location-id'],
680 # 'vnfc_type': config['vnfc-type'],
682 # 'ne_id': config['vserver-name'],
683 # 'fixed_ip_address': config['ip']
687 #node_list.append(node)
690 oof_config['dt-config']['trafficpresence'] = traffic_presence
692 file_content = oof_config['dt-config']
695 "configuration-parameters": {
696 "file_parameter_content": json.dumps(file_content)
698 "request-parameters": {
699 "vserver-id": config['vserver-id']
703 config["configuration-parameters"]["book_name"] = book_name
704 payload = json.dumps(config)
708 def _build_appc_lcm_upgrade_payload(demand, oof_config, action, old_version, new_version):
709 oof_config = copy.deepcopy(oof_config)
710 book_name = "{}/latest/ansible/{}/site.yml".format(demand.lower(), action.lower())
711 config = oof_config[demand]
713 file_content = {} #oof_config['dt-config']
716 "configuration-parameters": {
717 "file_parameter_content": json.dumps(file_content),
718 "existing-software-version": old_version,
719 "new-software-version": new_version
721 "request-parameters": {
722 "vserver-id": config['vserver-id']
726 config["configuration-parameters"]["book_name"] = book_name
727 payload = json.dumps(config)
731 def _build_appc_lcm_status_body(req):
733 'request-id': req['input']['common-header']['request-id'],
734 'sub-request-id': req['input']['common-header']['sub-request-id'],
735 'originator-id': req['input']['common-header']['originator-id']
737 payload = json.dumps(payload)
738 template = json.loads(open('templates/appcRestconfLcm.json').read())
739 template['input']['action'] = 'ActionStatus'
740 template['input']['payload'] = payload
741 template['input']['common-header']['request-id'] = req['input']['common-header']['request-id']
742 template['input']['common-header']['sub-request-id'] = str(uuid.uuid4())
743 template['input']['action-identifiers']['vnf-id'] = req['input']['action-identifiers']['vnf-id']
747 @timing("> DT REQ BODY")
748 def _build_appc_lcm_lock_request_body(is_vpkg, config, req_id, action):
753 return _build_appc_lcm_request_body(None, demand, config, req_id, action)
756 @timing("> DT REQ BODY")
757 def _build_appc_lcm_dt_request_body(is_vpkg, config, req_id, action, traffic_presence=None):
762 payload = _build_appc_lcm_dt_payload(demand, config, action, traffic_presence)
763 return _build_appc_lcm_request_body(payload, demand, config, req_id, action)
766 @timing("> UP REQ BODY")
767 def _build_appc_lcm_upgrade_request_body(config, req_id, action, old_version, new_version):
769 payload = _build_appc_lcm_upgrade_payload(demand, config, action, old_version, new_version)
770 return _build_appc_lcm_request_body(payload, demand, config, req_id, action)
773 def _build_appc_lcm_request_body(payload, demand, config, req_id, action):
774 #print(config[demand])
775 template = json.loads(open('templates/appcRestconfLcm.json').read())
776 template['input']['action'] = action
777 if payload is not None:
778 template['input']['payload'] = payload
780 del template['input']['payload']
781 template['input']['common-header']['request-id'] = req_id
782 template['input']['common-header']['sub-request-id'] = str(uuid.uuid4())
783 template['input']['action-identifiers']['vnf-id'] = config[demand]['vnf-id']
787 def _set_appc_lcm_timestamp(body, timestamp=None):
788 if timestamp is None:
789 t = datetime.utcnow() + timedelta(seconds=-10)
790 timestamp = t.strftime('%Y-%m-%dT%H:%M:%S.244Z')
791 body['input']['common-header']['timestamp'] = timestamp
794 @timing("Load OOF Data and Build APPC REQ")
795 def build_appc_lcms_requests_body(rancher_ip, onap_ip, aai_data, use_oof_cache, if_close_loop_vfw, new_version=None):
799 migrate_from = _has_request(onap_ip, aai_data, False, use_oof_cache)
801 if if_close_loop_vfw:
802 migrate_to = migrate_from
804 migrate_to = _has_request(onap_ip, aai_data, True, use_oof_cache)
806 migrate_from = _build_config_from_has(migrate_from, onap_ip)
807 migrate_to = _build_config_from_has(migrate_to, onap_ip)
809 migrate_from = _osdf_request(rancher_ip, onap_ip, aai_data, False, use_oof_cache)
811 if if_close_loop_vfw:
812 migrate_to = migrate_from
814 migrate_to = _osdf_request(rancher_ip, onap_ip, aai_data, True, use_oof_cache)
816 migrate_from = _build_config_from_osdf(migrate_from, onap_ip)
817 migrate_to = _build_config_from_osdf(migrate_to, onap_ip)
819 #print(json.dumps(migrate_from, indent=4))
820 #print(json.dumps(migrate_to, indent=4))
821 req_id = str(uuid.uuid4())
824 if_dt_only = new_version is None
825 if new_version is not None and new_version != "1.0":
832 result.append({"payload": _build_appc_lcm_lock_request_body(True, migrate_from, req_id, 'CheckLock'), "breakOnFailure": True,
833 "description": "Check vPGN Lock Status"})
834 result.append({"payload": _build_appc_lcm_lock_request_body(False, migrate_from, req_id, 'CheckLock'), "breakOnFailure": True,
835 "description": "Check vFW-1 Lock Status"})
836 result.append({"payload": _build_appc_lcm_lock_request_body(False, migrate_to, req_id, 'CheckLock'), "breakOnFailure": True,
837 "description": "Check vFW-2 Lock "})
839 result.append({"payload": _build_appc_lcm_lock_request_body(True, migrate_from, req_id, 'Lock'), "breakOnFailure": True,
840 "description": "Lock vPGN"})
841 result.append({"payload": _build_appc_lcm_lock_request_body(False, migrate_from, req_id, 'Lock'), "breakOnFailure": True,
842 "description": "Lock vFW-1"})
843 result.append({"payload": _build_appc_lcm_lock_request_body(False, migrate_to, req_id, 'Lock'), "breakOnFailure": True,
844 "description": "Lock vFW-2"})
847 payload_dt_check_vpkg = _build_appc_lcm_dt_request_body(True, migrate_from, req_id, 'DistributeTrafficCheck', True)
848 payload_dt_vpkg_to = _build_appc_lcm_dt_request_body(True, migrate_to, req_id, 'DistributeTraffic')
849 payload_dt_check_vfw_from = _build_appc_lcm_dt_request_body(False, migrate_from, req_id, 'DistributeTrafficCheck',
851 payload_dt_check_vfw_to = _build_appc_lcm_dt_request_body(False, migrate_to, req_id, 'DistributeTrafficCheck', True)
853 requests.append({"payload": payload_dt_vpkg_to, "breakOnFailure": True, "description": "Migrating source vFW traffic to destination vFW"})
854 requests.append({"payload": payload_dt_check_vfw_from, "breakOnFailure": True, "description": "Checking traffic has been stopped on the source vFW"})
855 requests.append({"payload": payload_dt_check_vfw_to, "breakOnFailure": True, "description": "Checking traffic has appeared on the destination vFW"})
856 result.append({"payload": payload_dt_check_vpkg, "breakOnFailure": False, "description": "Check current traffic destination on vPGN",
857 "workflow": {"requests": requests, "description": "Migrate Traffic and Verify"}})
859 #_build_appc_lcm_dt_request_body(is_vpkg, config, req_id, action, traffic_presence=None):
860 payload_dt_check_vpkg = _build_appc_lcm_dt_request_body(True, migrate_from, req_id, 'DistributeTrafficCheck', True)
861 payload_dt_vpkg_to = _build_appc_lcm_dt_request_body(True, migrate_to, req_id, 'DistributeTraffic')
862 payload_dt_vpkg_from = _build_appc_lcm_dt_request_body(True, migrate_from, req_id, 'DistributeTraffic')
864 payload_dt_check_vfw_from_absent = _build_appc_lcm_dt_request_body(False, migrate_from, req_id, 'DistributeTrafficCheck', False)
865 payload_dt_check_vfw_to_present = _build_appc_lcm_dt_request_body(False, migrate_to, req_id, 'DistributeTrafficCheck', True)
866 payload_dt_check_vfw_to_absent = _build_appc_lcm_dt_request_body(False, migrate_to, req_id, 'DistributeTrafficCheck', False)
867 payload_dt_check_vfw_from_present = _build_appc_lcm_dt_request_body(False, migrate_from, req_id, 'DistributeTrafficCheck', True)
869 payload_old_version_check_vfw_from = _build_appc_lcm_upgrade_request_body(migrate_from, req_id, 'UpgradePreCheck', old_version, new_version)
870 payload_new_version_check_vfw_from = _build_appc_lcm_upgrade_request_body(migrate_from, req_id, 'UpgradePostCheck', old_version, new_version)
871 payload_upgrade_vfw_from = _build_appc_lcm_upgrade_request_body(migrate_from, req_id, 'UpgradeSoftware', old_version, new_version)
873 migrate_requests = list()
874 migrate_requests.append({"payload": payload_dt_vpkg_to, "breakOnFailure": True, "description": "Migrating source vFW traffic to destination vFW"})
875 migrate_requests.append({"payload": payload_dt_check_vfw_from_absent, "breakOnFailure": True, "description": "Checking traffic has been stopped on the source vFW"})
876 migrate_requests.append({"payload": payload_dt_check_vfw_to_present, "breakOnFailure": True, "description": "Checking traffic has appeared on the destination vFW"})
878 requests.append({"payload": payload_dt_check_vpkg, "breakOnFailure": False, "description": "Check current traffic destination on vPGN",
879 "workflow": {"requests": migrate_requests, "description": "Migrate Traffic and Verify"}})
880 requests.append({"payload": payload_upgrade_vfw_from, "breakOnFailure": True, "description": "Upgrading Software on source vFW"})
881 requests.append({"payload": payload_new_version_check_vfw_from, "breakOnFailure": True, "description": "Check current software version on source vFW"})
882 requests.append({"payload": payload_dt_vpkg_from, "breakOnFailure": True, "description": "Migrating destination vFW traffic to source vFW"})
883 requests.append({"payload": payload_dt_check_vfw_to_absent, "breakOnFailure": True, "description": "Checking traffic has been stopped on the destination vFW"})
884 requests.append({"payload": payload_dt_check_vfw_from_present, "breakOnFailure": True, "description": "Checking traffic has appeared on the source vFW"})
886 result.append({"payload": payload_old_version_check_vfw_from, "breakOnFailure": False, "description": "Check current software version on source vFW",
887 "workflow": {"requests": requests, "description": "Migrate Traffic and Upgrade Software"}})
890 result.append({"payload": _build_appc_lcm_lock_request_body(True, migrate_from, req_id, 'Unlock'), "breakOnFailure": False,
891 "description": "Unlock vPGN"})
892 result.append({"payload": _build_appc_lcm_lock_request_body(False, migrate_from, req_id, 'Unlock'), "breakOnFailure": False,
893 "description": "Unlock vFW-1"})
894 result.append({"payload": _build_appc_lcm_lock_request_body(False, migrate_to, req_id, 'Unlock'), "breakOnFailure": False,
895 "description": "Unlock vFW-2"})
900 @timing("> Execute APPC REQ")
901 def appc_lcm_request(onap_ip, req):
903 api = _init_python_appc_lcm_api(onap_ip)
904 with _no_ssl_verification():
905 #print(json.dumps(req, indent=4))
906 if req['input']['action'] == "DistributeTraffic":
907 result = api.lcm.distribute_traffic(body=req, params={}, headers={})
908 elif req['input']['action'] == "DistributeTrafficCheck":
909 result = api.lcm.distribute_traffic_check(body=req, params={}, headers={})
910 elif req['input']['action'] == "UpgradeSoftware":
911 result = api.lcm.upgrade_software(body=req, params={}, headers={})
912 elif req['input']['action'] == "UpgradePreCheck":
913 result = api.lcm.upgrade_pre_check(body=req, params={}, headers={})
914 elif req['input']['action'] == "UpgradePostCheck":
915 result = api.lcm.upgrade_post_check(body=req, params={}, headers={})
916 elif req['input']['action'] == "CheckLock":
917 result = api.lcm.check_lock(body=req, params={}, headers={})
918 elif req['input']['action'] == "Lock":
919 result = api.lcm.lock(body=req, params={}, headers={})
920 elif req['input']['action'] == "Unlock":
921 result = api.lcm.unlock(body=req, params={}, headers={})
923 raise Exception("{} action not supported".format(req['input']['action']))
925 if result.body['output']['status']['code'] == 400:
926 if req['input']['action'] == "CheckLock":
927 if result.body['output']['locked'] == "FALSE":
931 result.body['output']['status']['code'] = 401
934 elif result.body['output']['status']['code'] == 100:
936 elif result.body['output']['status']['code'] >= 300 and result.body['output']['status']['code'] < 400:
937 print("APPC LCM <<{}>> REJECTED [{} - {}]".format(req['input']['action'], result.body['output']['status']['code'],
938 result.body['output']['status']['message']))
939 elif result.body['output']['status']['code'] > 400 and result.body['output']['status']['code'] < 500:
940 print("APPC LCM <<{}>> FAILED [{} - {}]".format(req['input']['action'], result.body['output']['status']['code'],
941 result.body['output']['status']['message']))
942 # elif result.body['output']['status']['code'] == 311:
943 # timestamp = result.body['output']['common-header']['timestamp']
944 # _set_appc_lcm_timestamp(req, timestamp)
945 # appc_lcm_request(onap_ip, req)
948 raise Exception("{} - {}".format(result.body['output']['status']['code'],
949 result.body['output']['status']['message']))
951 return result.body['output']['status']['code']
954 def appc_lcm_status_request(onap_ip, req):
955 api = _init_python_appc_lcm_api(onap_ip)
956 status_body = _build_appc_lcm_status_body(req)
957 _set_appc_lcm_timestamp(status_body)
958 #print("CHECK STATUS")
959 with _no_ssl_verification():
960 result = api.lcm.action_status(body=status_body, params={}, headers={})
962 if result.body['output']['status']['code'] == 400:
963 status = json.loads(result.body['output']['payload'])
966 raise Exception("{} - {}".format(result.body['output']['status']['code'],
967 result.body['output']['status']['message']))
970 @timing("> Confirm APPC REQ")
971 def confirm_appc_lcm_action(onap_ip, req, check_appc_result):
972 print("APPC LCM << {} >> [Status]".format(req['input']['action']))
976 status = appc_lcm_status_request(onap_ip, req)
977 print(status['status'])
978 if status['status'] == 'SUCCESSFUL':
980 elif status['status'] == 'IN_PROGRESS':
982 elif check_appc_result:
983 print("APPC LCM <<{}>> [{} - {}]".format(req['input']['action'], status['status'], status['status-reason']))
989 @timing("Execute APPC LCM REQs")
990 def _execute_lcm_requests(workflow, onap_ip, check_result):
991 lcm_requests = workflow["requests"]
992 print("WORKFLOW << {} >>".format(workflow["description"]))
993 for i in range(len(lcm_requests)):
994 req = lcm_requests[i]["payload"]
995 #print(json.dumps(req, indent=4))
996 print("APPC LCM << {} >> [{}]".format(req['input']['action'], lcm_requests[i]["description"]))
997 _set_appc_lcm_timestamp(req)
999 result = appc_lcm_request(onap_ip, req)
1000 #print("Result {}".format(result))
1003 conf_result = confirm_appc_lcm_action(onap_ip, req, check_result)
1009 if lcm_requests[i]["breakOnFailure"]:
1010 raise Exception("APPC LCM << {} >> FAILED".format(req['input']['action']))
1011 elif "workflow" in lcm_requests[i]:
1012 print("WORKFLOW << {} >> SKIP".format(lcm_requests[i]["workflow"]["description"]))
1013 elif "workflow" in lcm_requests[i]:
1014 _execute_lcm_requests(lcm_requests[i]["workflow"], onap_ip, check_result)
1017 def _generate_cdt_artifact_request(req_id, artifact, action, vnfc_type):
1021 'request-id': req_id,
1022 'action': "uploadArtifact",
1023 'payload': json.dumps(artifact['payload'])
1028 file = "{}_{}_{}.json".format(artifact['type'], action.lower(), vnfc_type)
1029 dirname = "templates/cdt-requests"
1031 if not os.path.exists(dirname):
1032 os.makedirs(dirname)
1033 f = open("{}/{}".format(dirname, file), 'w')
1034 f.write(json.dumps(req, indent=4))
1040 def _get_name_of_artifact(prefix, action, vnf_type):
1041 return "{}_{}_{}_0.0.1V.json".format(prefix, action, vnf_type)
1044 def _set_artifact_payload(vnf_type, vnfc_type, action, artifact):
1046 if action == "DistributeTraffic" or action == "DistributeTrafficCheck" or action == "AllAction":
1048 elif action == "UpgradeSoftware" or action == "UpgradePreCheck" or action == "UpgradePostCheck":
1051 raise Exception("{} action not supported".format(action))
1053 artifact_contents = ''
1054 if artifact['type'] == 'config_template':
1055 file = 'templates/cdt-templates/templates/action-template.json'
1056 template_file = 'templates/cdt-templates/{}/{}'
1058 template_file = template_file.format(vnfc_type, 'upgrade.json')
1060 template_file = template_file.format(vnfc_type, 'traffic.json')
1061 #print("Template for action {} in {}".format(action, template_file))
1062 #print(json.dumps(json.loads(open(template_file).read()), indent=4))
1063 artifact_contents = json.dumps(json.loads(open(template_file).read()), indent=4).replace("\n", "\r\n")
1064 elif artifact['type'] == 'parameter_definitions':
1065 file = 'templates/cdt-templates/templates/{}'
1067 file = file.format('upgrade-params.json')
1069 file = file.format('traffic-params.json')
1070 elif artifact['type'] == 'param_values':
1071 file = 'templates/cdt-templates/templates/{}'
1073 file = file.format('upgrade-params-list.json')
1075 file = file.format('traffic-params-list.json')
1076 elif artifact['type'] == 'reference_template':
1077 file = 'templates/cdt-templates/templates/reference-all-actions.json'
1079 raise Exception("{} not supported artifact type".format(artifact['type']))
1081 payload = json.loads(open(file).read())
1082 payload['vnf-type'] = vnf_type
1083 payload['artifact-name'] = artifact['name']
1084 payload['action'] = action
1086 if artifact['type'] == 'config_template':
1087 payload['artifact-contents'] = artifact_contents
1088 artifact['payload'] = payload
1091 def _generate_artifacts_for_cdt(vnf_type, vnf_type_formatted, vnfc_type, action):
1094 'name': _get_name_of_artifact("template", action, vnf_type_formatted),
1095 'type': 'config_template',
1096 'payload': {'test': 'test'}
1099 'name': _get_name_of_artifact("pd", action, vnf_type_formatted),
1100 'type': 'parameter_definitions',
1101 'payload': {'test': 'test'}
1104 'name': _get_name_of_artifact("param", action, vnf_type_formatted),
1105 'type': 'param_values',
1106 'payload': {'test': 'test'}
1109 _set_artifact_payload(vnf_type, vnfc_type, action, artifacts[0])
1110 _set_artifact_payload(vnf_type, vnfc_type, action, artifacts[1])
1111 _set_artifact_payload(vnf_type, vnfc_type, action, artifacts[2])
1116 def _generate_cdt_payloads_for_vnf(vnf_info, vnfc_type, actions):
1117 req_id = str(uuid.uuid4()).replace('-','')
1118 vnf_type_formatted = vnf_info['vnf-type'].replace(' ','').replace('/', '_')
1121 'name': _get_name_of_artifact("reference", 'AllAction', vnf_type_formatted),
1122 'type': 'reference_template'
1126 all_action_artifact = artifacts['AllAction'][0]
1128 _set_artifact_payload(vnf_info['vnf-type'], vnfc_type, 'AllAction', all_action_artifact)
1130 for action in actions:
1131 action_artifacts = _generate_artifacts_for_cdt(vnf_info['vnf-type'], vnf_type_formatted, vnfc_type, action)
1132 artifacts[action] = action_artifacts
1134 all_action_artifacts = list()
1136 for action in artifacts:
1137 artifact_list = list()
1140 'action-level': "vnf",
1142 'vnf-type': vnf_info['vnf-type'],
1143 'vnfc-type-list': [],
1146 'artifact-list': artifact_list
1149 if action != 'AllAction':
1150 action_info.update({
1153 'device-protocol': "ANSIBLE",
1154 'user-name': "admin",
1155 'port-number': "8000",
1156 'scopeType': "vnf-type"
1159 for action_artifact in artifacts[action]:
1160 artifact_list.append({'artifact-name': action_artifact['name'], 'artifact-type': action_artifact['type']})
1161 if action != 'AllAction':
1162 req = _generate_cdt_artifact_request(req_id, action_artifact, action, vnfc_type) # pylint: disable=W0612
1163 #print(json.dumps(req, indent=4))
1165 #print(json.dumps(action_info, indent=4))
1166 all_action_artifacts.append(action_info)
1168 all_action_artifact['payload']['artifact-contents'] = json.dumps({'reference_data': all_action_artifacts})
1169 req = _generate_cdt_artifact_request(req_id, all_action_artifact, 'AllAction', vnfc_type)
1170 #print(json.dumps(req, indent=4))
1173 def _generate_cdt_payloads(aai_data):
1174 vfw_actions = ["DistributeTrafficCheck", "UpgradeSoftware", "UpgradePreCheck", "UpgradePostCheck", "UpgradeSoftware"]
1175 vpgn_actions = ["DistributeTraffic", "DistributeTrafficCheck"]
1176 _generate_cdt_payloads_for_vnf(aai_data["vfw-model-info"], "vfw-sink", vfw_actions)
1177 _generate_cdt_payloads_for_vnf(aai_data["vpgn-model-info"], "vpgn", vpgn_actions)
1180 def execute_workflow(vfw_vnf_id, rancher_ip, onap_ip, use_oof_cache, if_close_loop_vfw, info_only, check_result, new_version=None):
1181 print("\nExecuting workflow for VNF ID '{}' on Rancher with IP {} and ONAP with IP {}".format(
1182 vfw_vnf_id, rancher_ip, onap_ip))
1183 print("\nOOF Cache {}, is CL vFW {}, only info {}, check LCM result {}".format(use_oof_cache, if_close_loop_vfw,
1184 info_only, check_result))
1185 if new_version is not None:
1186 print("\nNew vFW software version {}\n".format(new_version))
1188 x = threading.Thread(target=_run_osdf_resp_server, daemon=True)
1190 aai_data = load_aai_data(vfw_vnf_id, onap_ip)
1191 print("\nvFWDT Service Information:")
1192 print(json.dumps(aai_data, indent=4))
1193 lcm_requests = build_appc_lcms_requests_body(rancher_ip, onap_ip, aai_data, use_oof_cache, if_close_loop_vfw, new_version)
1194 print("\nAnsible Inventory:")
1195 inventory = "[host]\nlocalhost ansible_connection=local\n"
1196 for key in ansible_inventory:
1197 inventory += str("[{}]\n").format(key)
1198 for host in ansible_inventory[key]:
1199 inventory += str("{}\n").format(ansible_inventory[key][host])
1202 f = open("Ansible_inventory", 'w+')
1206 _generate_cdt_payloads(aai_data)
1210 print("\nDistribute Traffic Workflow Execution:")
1212 _execute_lcm_requests({"requests": lcm_requests, "description": "Migrate vFW Traffic Conditionally"}, onap_ip, check_result)
1216 help = """\npython3 workflow.py <VNF-ID> <RANCHER-NODE-IP> <K8S-NODE-IP> <IF-CACHE> <IF-VFWCL> <INITIAL-ONLY> <CHECK-STATUS> <VERSION>
1217 \n<VNF-ID> - vnf-id of vFW VNF instance that traffic should be migrated out from
1218 <RANCHER-NODE-IP> - External IP of ONAP Rancher Node i.e. 10.12.5.160 (If Rancher Node is missing this is NFS node)
1219 <K8S-NODE-IP> - External IP of ONAP K8s Worker Node i.e. 10.12.5.212
1220 <IF-CACHE> - If script should use and build OOF response cache (cache it speed-ups further executions of script)
1221 <IF-VFWCL> - If instead of vFWDT service instance vFW or vFWCL one is used (should be False always)
1222 <INITIAL-ONLY> - If only configuration information will be collected (True for initial phase and False for full execution of workflow)
1223 <CHECK-STATUS> - If APPC LCM action status should be verified and FAILURE should stop workflow (when False FAILED status of LCM action does not stop execution of further LCM actions)
1224 <VERSION> - New version of vFW - for tests '1.0' or '2.0'. Ommit when traffic distribution only\n"""
1226 for key in sys.argv:
1227 if key == "-h" or key == "--help":
1232 if len(sys.argv) > 8:
1233 new_version = sys.argv[8]
1236 #vnf_id, Rancher node IP, K8s node IP, use OOF cache, if close loop vfw, if info_only, if check APPC result
1237 execute_workflow(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4].lower() == 'true', sys.argv[5].lower() == 'true',
1238 sys.argv[6].lower() == 'true', sys.argv[7].lower() == 'true', new_version)