Feature 10955: Osmclient changes related to VIM configuration with a Prometheus TSDB system
Change-Id: Ibf9032936c538a7bccbe2b5aab27583ca44f2bfd
Signed-off-by: Luis Vega <lvega@whitestack.com>
diff --git a/osmclient/cli_commands/vim.py b/osmclient/cli_commands/vim.py
index c6424ca..ff1bcc6 100755
--- a/osmclient/cli_commands/vim.py
+++ b/osmclient/cli_commands/vim.py
@@ -76,6 +76,16 @@
"--creds", default=None, help="credentials file (only applicable for GCP VIM type)"
)
@click.option(
+ "--prometheus_url",
+ default=None,
+ help="PrometheusTSBD URL to get VIM data",
+)
+@click.option(
+ "--prometheus_map",
+ default=None,
+ help="PrometheusTSBD metrics mapping for VIM data",
+)
+@click.option(
"--prometheus_config_file",
default=None,
help="Prometheus configuration to get VIM data",
@@ -97,6 +107,8 @@
wait,
vca,
creds,
+ prometheus_url,
+ prometheus_map,
prometheus_config_file,
):
"""creates a new VIM account"""
@@ -106,11 +118,17 @@
if sdn_port_mapping:
utils.check_client_version(ctx.obj, "--sdn_port_mapping")
vim = {}
+ prometheus_config = {}
+ if prometheus_url:
+ prometheus_config["prometheus-url"] = prometheus_url
+ if prometheus_map:
+ prometheus_config["prometheus-map"] = prometheus_map
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
-
+ prometheus_config.update(prometheus_config_dict)
+ if prometheus_config:
+ vim["prometheus-config"] = prometheus_config
vim["vim-username"] = user
vim["vim-password"] = password
vim["vim-url"] = auth_url
@@ -167,6 +185,16 @@
"--creds", default=None, help="credentials file (only applicable for GCP VIM type)"
)
@click.option(
+ "--prometheus_url",
+ default=None,
+ help="PrometheusTSBD URL to get VIM data",
+)
+@click.option(
+ "--prometheus_map",
+ default=None,
+ help="PrometheusTSBD metrics mapping for VIM data",
+)
+@click.option(
"--prometheus_config_file",
default=None,
help="Prometheus configuration to get VIM data",
@@ -188,6 +216,8 @@
sdn_port_mapping,
wait,
creds,
+ prometheus_url,
+ prometheus_map,
prometheus_config_file,
):
"""updates a VIM account
@@ -218,11 +248,17 @@
if creds:
with open(creds, "r") as cf:
vim_config["credentials"] = yaml.safe_load(cf.read())
+ prometheus_config = {}
+ if prometheus_url:
+ prometheus_config["prometheus-url"] = prometheus_url
+ if prometheus_map:
+ prometheus_config["prometheus-map"] = prometheus_map
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}")
+ prometheus_config.update(prometheus_config_dict)
+ if prometheus_config:
+ vim["prometheus-config"] = prometheus_config
ctx.obj.vim.update(
name, vim, vim_config, sdn_controller, sdn_port_mapping, wait=wait
)
diff --git a/osmclient/sol005/http.py b/osmclient/sol005/http.py
index 4234fc8..1b47204 100644
--- a/osmclient/sol005/http.py
+++ b/osmclient/sol005/http.py
@@ -114,7 +114,6 @@
curl_cmd.setopt(pycurl.CUSTOMREQUEST, "PATCH")
curl_cmd.setopt(pycurl.POST, 1)
curl_cmd.setopt(pycurl.WRITEFUNCTION, data.write)
-
if postfields_dict is not None:
jsondata = json.dumps(postfields_dict)
if "password" in postfields_dict:
diff --git a/osmclient/sol005/vim.py b/osmclient/sol005/vim.py
index 72a0822..fa40140 100644
--- a/osmclient/sol005/vim.py
+++ b/osmclient/sol005/vim.py
@@ -108,7 +108,6 @@
if vim_config:
vim_account["config"] = vim_config
# vim_account['config'] = json.dumps(vim_config)
-
http_code, resp = self._http.post_cmd(
endpoint=self._apiBase, postfields_dict=vim_account
)
@@ -197,6 +196,8 @@
vim_account["vim_user"] = vim_access["vim-username"] or "null"
vim_account["vim_password"] = vim_access["vim-password"] or "null"
vim_account["vim_tenant_name"] = vim_access["vim-tenant-name"] or "null"
+ if "prometheus-config" in vim_access:
+ vim_account["prometheus_config"] = vim_access["prometheus-config"]
return vim_account
def get_id(self, name):