Support running healthcheck in any mode supported 66/88666/1
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Tue, 28 May 2019 13:59:05 +0000 (15:59 +0200)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Tue, 28 May 2019 14:04:01 +0000 (16:04 +0200)
So far it was only possible to run health checking
script with a default option of 'health'. This patch
allows passing through to healtcheck script any mode
that it supports via --health-mode runtime option.

Change-Id: Ic0145e5b4a1f17d64867287538dd63b850d86feb
Issue-ID: OOM-1806
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
helm_deployment_status.py

index 7f8954f..e92f64b 100755 (executable)
@@ -101,10 +101,10 @@ def get_k8s_controllers(k8s):
 
     return k8s_controllers, list(not_ready_controllers)
 
-def exec_healthcheck(hp_script, namespace):
+def exec_healthcheck(hp_script, namespace, hp_mode):
     try:
         hc = subprocess.check_output(
-                ['sh', hp_script, namespace, 'health'],
+                ['sh', hp_script, namespace, hp_mode],
                 stderr=subprocess.STDOUT)
         return 0, hc
     except subprocess.CalledProcessError as err:
@@ -171,7 +171,8 @@ def print_status(verbosity, resources, not_ready_pods):
     print('\n'.join(status_strings), '\n')
 
 def parse_args():
-    parser = argparse.ArgumentParser(description='Monitor ONAP deployment progress')
+    parser = argparse.ArgumentParser(description='Monitor ONAP deployment progress',
+            formatter_class=argparse.ArgumentDefaultsHelpFormatter)
     parser.add_argument('--namespace', '-n', default='onap',
             help='Kubernetes namespace of ONAP')
     parser.add_argument('--server', '-s', help='address of Kubernetes cluster')
@@ -179,6 +180,9 @@ def parse_args():
             default=expanduser('~') + '/.kube/config',
             help='path to .kube/config file')
     parser.add_argument('--health-path', '-hp', help='path to ONAP robot ete-k8s.sh')
+    parser.add_argument('--health-mode', default='health', help='healthcheck mode',
+            choices=('health','healthdist','distribute','instantiate','instantiateVFWCL',
+                     'instantiateDemoVFWCL','portal'))
     parser.add_argument('--no-helm', action='store_true', help='Do not check Helm')
     parser.add_argument('--check-frequency', '-w', default=300, type=int,
             help='time between readiness checks in seconds')
@@ -294,7 +298,7 @@ def main():
 
     if args.health_path is not None:
         try:
-            hc_rc, hc_output = exec_healthcheck(args.health_path, args.namespace)
+            hc_rc, hc_output = exec_healthcheck(args.health_path, args.namespace, args.health_mode)
         except IOError as err:
             sys.exit(err.strerror)
         print(hc_output.decode('utf-8'))