Feature 10920: Monitoring of NFVI-leve VNF metrics form Prometheus TSDB 53/11953/4
authorvegall <lvega@whitestack.com>
Wed, 27 Apr 2022 15:56:04 +0000 (15:56 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 18 May 2022 08:49:25 +0000 (10:49 +0200)
Change-Id: Id1c9782735de51b5348b8930de9c4cdd5d81f406
Signed-off-by: vegall <lvega@whitestack.com>
osmclient/scripts/osm.py

index 58b34c5..3ce02df 100755 (executable)
@@ -3154,6 +3154,7 @@ def pdu_delete(ctx, name, force):
 )
 @click.option("--vca", default=None, help="VCA to be used in this VIM account")
 @click.option("--creds", default=None, help="credentials file (only applycable for GCP VIM type)")
+@click.option("--prometheus_config_file", default=None, help="Prometheus configuration to get VIM data")
 @click.pass_context
 def vim_create(
     ctx,
@@ -3171,6 +3172,7 @@ def vim_create(
     wait,
     vca,
     creds,
+    prometheus_config_file
 ):
     """creates a new VIM account"""
     logger.debug("")
@@ -3180,6 +3182,11 @@ def vim_create(
     if sdn_port_mapping:
         check_client_version(ctx.obj, "--sdn_port_mapping")
     vim = {}
+    if prometheus_config_file:
+        with open(prometheus_config_file) as prometheus_file:
+            prometheus_config_dict = json.load(prometheus_file)
+        vim["prometheus-config"] = prometheus_config_dict
+
     vim["vim-username"] = user
     vim["vim-password"] = password
     vim["vim-url"] = auth_url
@@ -3229,6 +3236,7 @@ def vim_create(
     "until the operation is completed, or timeout",
 )
 @click.option("--creds", default=None, help="credentials file (only applycable for GCP VIM type)")
+@click.option("--prometheus_config_file", default=None, help="Prometheus configuration to get VIM data")
 @click.pass_context
 def vim_update(
     ctx,
@@ -3246,6 +3254,7 @@ def vim_update(
     sdn_port_mapping,
     wait,
     creds,
+    prometheus_config_file
 ):
     """updates a VIM account
 
@@ -3275,6 +3284,10 @@ def vim_update(
     if creds:
         with open(creds, "r") as cf:
             vim_config["credentials"] = yaml.safe_load(cf.read())
+    if prometheus_config_file:
+        with open(prometheus_config_file) as prometheus_file:
+            prometheus_config_dict = json.load(prometheus_file)
+        vim["prometheus-config"] = prometheus_config_dict
     logger.info(f"VIM: {vim}, VIM config: {vim_config}")
     ctx.obj.vim.update(name, vim, vim_config, sdn_controller, sdn_port_mapping, wait=wait)
     # except ClientException as e: