vFW DT tutorial improvements 81/96281/1
authorLukasz Rajewski <lukasz.rajewski@orange.com>
Thu, 19 Sep 2019 08:24:20 +0000 (10:24 +0200)
committerLukasz Rajewski <lukasz.rajewski@orange.com>
Thu, 26 Sep 2019 11:55:10 +0000 (11:55 +0000)
- Fixed workflow script for osdf request
- ansible_inventory file generation added
- Licence for upload policy script

Change-Id: Ia46d19750569f649ce12dcdb49571299d87d8fee
Signed-off-by: Lukasz Rajewski <lukasz.rajewski@orange.com>
Issue-ID: INT-751
(cherry picked from commit e659e3afec2f3987d071510efe63e72374ef1a88)

tutorials/vFWDT/policies/rules/uploadPolicies.sh
tutorials/vFWDT/workflow/workflow.py [changed mode: 0644->0755]

index 3200ba9..7d1ccd1 100755 (executable)
@@ -1,5 +1,22 @@
 #!/bin/bash
 
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 Orange
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END=========================================================
+
 `./yq > /dev/null 2>&1`
 
 if [ $? -ne 0 ]; then
old mode 100644 (file)
new mode 100755 (executable)
index 455bd29..ef3700a
@@ -73,6 +73,7 @@ class BaseServer(http.server.BaseHTTPRequestHandler):
         self.end_headers()
 
         data = simplejson.loads(self.data_string)
+        #print(json.dumps(data, indent=4))
         self.osdf_resp["last"]["data"] = data
         self.osdf_resp["last"]["id"] = data["requestId"]
         with open("response.json", "w") as outfile:
@@ -352,9 +353,11 @@ def _osdf_request(rancher_ip, onap_ip, aai_data, exclude, use_oof_cache):
     if exclude:
         template["placementInfo"]["placementDemands"][0]["excludedCandidates"][0]["identifiers"].\
             append(aai_data['vf-module-id'])
+        del template["placementInfo"]["placementDemands"][0]["requiredCandidates"]
     else:
         template["placementInfo"]["placementDemands"][0]["requiredCandidates"][0]["identifiers"].\
             append(aai_data['vf-module-id'])
+        del template["placementInfo"]["placementDemands"][0]["excludedCandidates"]
 
     #print(json.dumps(template, indent=4))
 
@@ -792,10 +795,16 @@ def execute_workflow(vfw_vnf_id, rancher_ip, onap_ip, use_oof_cache, if_close_lo
     print(json.dumps(aai_data, indent=4))
     lcm_requests = build_appc_lcms_requests_body(rancher_ip, onap_ip, aai_data, use_oof_cache, if_close_loop_vfw)
     print("\nAnsible Inventory:")
+    inventory = "[host]\nlocalhost   ansible_connection=local\n"
     for key in ansible_inventory:
-        print("[{}]".format(key))
+        inventory += str("[{}]\n").format(key)
         for host in ansible_inventory[key]:
-            print(ansible_inventory[key][host])
+            inventory += str("{}\n").format(ansible_inventory[key][host])
+
+    print(inventory)
+    f = open("Ansible_inventory", 'w+')
+    f.write(inventory)
+    f.close()
 
     if info_only:
         return