X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osmclient%2Fcli_commands%2Fvim.py;h=ff1bcc639de0557883b75a7f1d9e2c9f6dcd9679;hb=6be1a7f4c1c6ccced45402e9aadddad813eef2a7;hp=c6424caaf208a941388356a0eaa2afbc36e9ce92;hpb=4c7d798c5bde149f8999370557b848452d950f33;p=osm%2Fosmclient.git 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 @@ -75,6 +75,16 @@ def _check_ca_cert(vim_config: dict) -> None: @click.option( "--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, @@ -97,6 +107,8 @@ def vim_create( wait, vca, creds, + prometheus_url, + prometheus_map, prometheus_config_file, ): """creates a new VIM account""" @@ -106,11 +118,17 @@ def vim_create( 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 @@ -166,6 +184,16 @@ def vim_create( @click.option( "--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, @@ -188,6 +216,8 @@ def vim_update( sdn_port_mapping, wait, creds, + prometheus_url, + prometheus_map, prometheus_config_file, ): """updates a VIM account @@ -218,11 +248,17 @@ def vim_update( 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 )