"demands": {
"vFW-SINK": [
{
- "attributes": {
+ "filtering_attributes": {
"global-customer-id": {
"get_param": "chosen_customer_id"
},
},
"model-version-id": "202d2fd8-a045-4c9a-b767-2a1639c10291",
"orchestration-status": [
- "active"
+ "Active"
],
"model-invariant-id": "6f3fd439-fd5f-4a2d-95bc-b6bf8787001a",
"service_instance_id": {
"get_param": "service_id"
- },
- "prov-status": "ACTIVE"
+ }
},
"inventory_provider": "aai",
"service_resource_id": "vFW-SINK-XX",
],
"vPGN": [
{
- "attributes": {
+ "filtering_attributes": {
"global-customer-id": {
"get_param": "chosen_customer_id"
},
},
"model-version-id": "6bfe954e-bb00-4111-be3c-33eed9d20a8c",
"orchestration-status": [
- "active"
+ "Active"
],
"model-invariant-id": "3f356335-7b36-41ee-8f74-72d0a2ec3ebf",
"service_instance_id": {
"get_param": "service_id"
- },
- "prov-status": "ACTIVE"
+ }
},
"inventory_provider": "aai",
"service_resource_id": "vPGN-XX",
actions = {
'generic_vnf': {'method': 'GET', 'url': 'network/generic-vnfs/generic-vnf/{}'},
'vnfc': {'method': 'GET', 'url': 'network/vnfcs/vnfc/{}'},
+ 'vnfc_patch': {'method': 'PATCH', 'url': 'network/vnfcs/vnfc/{}'},
'link': {'method': 'GET', 'url': '{}'},
'service_instance': {'method': 'GET',
'url': 'business/customers/customer/{}/service-subscriptions/service-subscription/{}/service-instances/service-instance/{}'}
}
-def _init_python_aai_api(onap_ip):
+def _init_python_aai_api(onap_ip, content_type='application/json'):
api = API(
api_root_url="https://{}:30233/aai/v14/".format(onap_ip),
params={},
'Authorization': encode("AAI", "AAI"),
'X-FromAppId': 'SCRIPT',
'Accept': 'application/json',
- 'Content-Type': 'application/json',
+ 'Content-Type': content_type,
'X-TransactionId': str(uuid.uuid4()),
},
timeout=30,
node['chosen_customer_id'] = aai_data['service-info']['global-customer-id']
node['service_id'] = aai_data['service-info']['service-instance-id']
node = template['template']['demands']['vFW-SINK'][0]
- node['attributes']['model-invariant-id'] = aai_data['vfw-model-info']['model-invariant-id']
- node['attributes']['model-version-id'] = aai_data['vfw-model-info']['model-version-id']
+ node['filtering_attributes']['model-invariant-id'] = aai_data['vfw-model-info']['model-invariant-id']
+ node['filtering_attributes']['model-version-id'] = aai_data['vfw-model-info']['model-version-id']
if exclude:
node['excluded_candidates'][0]['candidate_id'][0] = aai_data['vf-module-id']
del node['required_candidates']
node['required_candidates'][0]['candidate_id'][0] = aai_data['vf-module-id']
del node['excluded_candidates']
node = template['template']['demands']['vPGN'][0]
- node['attributes']['model-invariant-id'] = aai_data['vpgn-model-info']['model-invariant-id']
- node['attributes']['model-version-id'] = aai_data['vpgn-model-info']['model-version-id']
+ node['filtering_attributes']['model-invariant-id'] = aai_data['vpgn-model-info']['model-invariant-id']
+ node['filtering_attributes']['model-version-id'] = aai_data['vpgn-model-info']['model-version-id']
#print(json.dumps(template, indent=4))
if demand.lower() not in ansible_inventory:
ansible_inventory[demand.lower()] = {}
ansible_inventory[demand.lower()][config['vserver-name']] = ansible_inventory_entry
+
+ _verify_vnfc_data(api, onap_ip, config['vserver-name'], config['ip'])
return config
+def _verify_vnfc_data(aai_api, onap_ip, vnfc_name, oam_ip):
+ with _no_ssl_verification():
+ response = aai_api.aai.vnfc(vnfc_name, body=None, params=None, headers={})
+ #print(json.dumps(response.body))
+ if "ipaddress-v4-oam-vip" not in response.body:
+ print("VNFC information update for {}".format(vnfc_name))
+ api = _init_python_aai_api(onap_ip, 'application/merge-patch+json')
+ response = api.aai.vnfc_patch(vnfc_name, body={"ipaddress-v4-oam-vip": oam_ip, "vnfc-name": vnfc_name}, params=None, headers={})
+
+
def _extract_osdf_appc_identifiers(has_result, demand, onap_ip):
if demand == 'vPGN':
v_server = has_result[demand]['vservers'][0]
#print(json.dumps(migrate_to, indent=4))
req_id = str(uuid.uuid4())
result = list()
- old_version = 2.0
+ old_version = "2.0"
if_dt_only = new_version is None
if new_version is not None and new_version != "1.0":
- old_version = 1.0
+ old_version = "1.0"
requests = list()
include_lock = True
@timing("> Execute APPC REQ")
def appc_lcm_request(onap_ip, req):
- print(req)
+ #print(req)
api = _init_python_appc_lcm_api(onap_ip)
with _no_ssl_verification():
#print(json.dumps(req, indent=4))
api = _init_python_appc_lcm_api(onap_ip)
status_body = _build_appc_lcm_status_body(req)
_set_appc_lcm_timestamp(status_body)
- print("CHECK STATUS")
+ #print("CHECK STATUS")
with _no_ssl_verification():
result = api.lcm.action_status(body=status_body, params={}, headers={})
_set_appc_lcm_timestamp(req)
conf_result = False
result = appc_lcm_request(onap_ip, req)
- print("Result {}".format(result))
+ #print("Result {}".format(result))
if result == 100:
conf_result = confirm_appc_lcm_action(onap_ip, req, check_result)
template_file = template_file.format(vnfc_type, 'upgrade.json')
else:
template_file = template_file.format(vnfc_type, 'traffic.json')
-
- artifact_contents = json.dumps(json.loads(open(template_file).read()))
+ #print("Template for action {} in {}".format(action, template_file))
+ #print(json.dumps(json.loads(open(template_file).read()), indent=4))
+ artifact_contents = json.dumps(json.loads(open(template_file).read()), indent=4).replace("\n", "\r\n")
elif artifact['type'] == 'parameter_definitions':
file = 'templates/cdt-templates/templates/{}'
if sw_upgrade:
payload['action'] = action
if artifact['type'] == 'config_template':
- artifact['artifact-contents'] = artifact_contents
+ payload['artifact-contents'] = artifact_contents
artifact['payload'] = payload