Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
# Copyright (c) 2014 TrilioData, Inc.
# All Rights Reserved.

"""OpenStackClient plugin for Tvault's workloads manager service."""

import logging
from osc_lib import utils

LOG = logging.getLogger(__name__)


DEFAULT_API_VERSION = "1.0"
# TODO: find out what should go here
API_VERSION_OPTION = "os-workload-api-version"
API_NAME = "workloadmgr"
API_VERSIONS = {
    "1.0": "workloadmgrclient.v1.client.Client",
    "1": "workloadmgrclient.v1.client.Client",
}


def make_client(instance):
    """Returns an Tvault' workloads manager client."""
    workloadmgr_client = utils.get_client_class(
        API_NAME, instance._api_version[API_NAME], API_VERSIONS
    )
    LOG.debug("Instantiating workloadmgr client: %s", workloadmgr_client)
    config = instance.get_configuration()
    auth_config = config.get("auth", {})
    client = workloadmgr_client(
        auth_url=auth_config["auth_url"],
        project_id=auth_config["project_name"],
        username=auth_config["username"],
        password=auth_config["password"],
        region_name=config["region_name"],
        cacert=config["cacert"],
        domain_name=config["default_domain"],
        os_user_domain_id=auth_config.get("user_domain_id", None),
        os_project_domain_id=auth_config.get("project_domain_id", None),
        user_domain_name=auth_config.get("user_domain_name", None),
        project_domain_name=auth_config.get("project_domain_name", None),
        insecure=config.get('insecure', False),
    )
    client.authenticate()
    return client


def build_option_parser(parser):
    """Hook to add global options"""

    # NOTE(amotoki): At now we register no option.
    # OSC itself has an option for Network API version # and we refer to it.
    parser.add_argument(
        "--os-workload-api-version",
        metavar="<os-workload-api-version>",
        help="Tvault workload manager Plugin API version, default="
        + DEFAULT_API_VERSION
        + " (Env: DEFAULT_API_VERSION)",
    )
    return parser