# License for the specific language governing permissions and limitations
# under the License.
+import base64
import click
from osmclient.common import print_output
+from osmclient.common.exceptions import ClientException
from osmclient.cli_commands import utils
from prettytable import PrettyTable
import yaml
default=None,
help="VIM specific config parameters in YAML or JSON file",
)
-@click.option("--account_type", default="openstack", help="VIM type")
+@click.option(
+ "--account_type",
+ default="openstack",
+ help="VIM type (openstack, aws, azure, gcp, vmware)",
+)
@click.option("--description", default=None, help="human readable description")
@click.option(
"--sdn_controller",
vim_config = utils.create_config(config_file, config)
_check_ca_cert(vim_config)
if creds:
- with open(creds, "r") as cf:
- vim_config["credentials"] = yaml.safe_load(cf.read())
+ with open(creds, "rb") as cf:
+ creds_content = cf.read()
+ vim_config["credentials_base64"] = base64.b64encode(creds_content).decode(
+ "utf-8"
+ )
+ if account_type != "aws":
+ try:
+ # Convert binary content to text before loading as YAML
+ creds_text = creds_content.decode("utf-8")
+ vim_config["credentials"] = yaml.safe_load(creds_text)
+ except (UnicodeDecodeError, yaml.YAMLError) as e:
+ raise ClientException(f"Error decoding credentials file: {e}")
ctx.obj.vim.create(
name, vim, vim_config, sdn_controller, sdn_port_mapping, wait=wait
)
default=None,
help="VIM specific config parameters in YAML or JSON file",
)
-@click.option("--account_type", help="VIM type")
+@click.option("--account_type", help="VIM type (openstack, aws, azure, gcp, vmware)")
@click.option("--description", help="human readable description")
@click.option(
"--sdn_controller",
vim_config = utils.create_config(config_file, config)
_check_ca_cert(vim_config)
if creds:
- with open(creds, "r") as cf:
- vim_config["credentials"] = yaml.safe_load(cf.read())
+ with open(creds, "rb") as cf:
+ creds_content = cf.read()
+ vim_config["credentials_base64"] = base64.b64encode(creds_content).decode(
+ "utf-8"
+ )
+ if account_type != "aws":
+ try:
+ # Convert binary content to text before loading as YAML
+ creds_text = creds_content.decode("utf-8")
+ vim_config["credentials"] = yaml.safe_load(creds_text)
+ except (UnicodeDecodeError, yaml.YAMLError) as e:
+ raise ClientException(f"Error decoding credentials file: {e}")
prometheus_config = {}
if prometheus_url:
prometheus_config["prometheus-url"] = prometheus_url