[APACHECNF] Update healthcheck and add scale workflow
[demo.git] / tutorials / ApacheCNF / automation / healthcheck.py
index 9c33375..6fe7239 100644 (file)
@@ -1,5 +1,6 @@
 # ============LICENSE_START=======================================================
 # Copyright (C) 2021 Samsung
+# Modification Copyright (C) 2022 Deutsche Telekom AG
 # ================================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -16,6 +17,7 @@
 # ============LICENSE_END=========================================================
 import logging
 import os
+import sys
 import zipfile
 from io import BytesIO
 
@@ -61,7 +63,7 @@ def resolve_hc_inputs(config: Config):
     vnf_id = vnfs[0].vnf_id
     return service_id, vnf_id
 
-def main():
+def main(status_count):
     mypath = os.path.dirname(os.path.realpath(__file__))
     config = Config(env_dict=VariablesDict.env_variable)
     for vnf in config.service_model["vnfs"]:
@@ -77,7 +79,8 @@ def main():
             cds_input = {"health-check-properties":
                 {
                     "service-instance-id": serv_id,
-                    "vnf-id": vnf_id
+                    "vnf-id": vnf_id,
+                    "status-check-max-count": int(status_count)
                 }
             }
 
@@ -90,4 +93,8 @@ def main():
             logger.info("Please check cds-blueprints-processor logs to see exact status")
 
 if __name__ == "__main__":
-    main()
+    status_count = 1
+    if len(sys.argv) > 1:
+        status_count = sys.argv[1]
+    print(f"Status Check Max Count: %s" % status_count)
+    main(status_count)