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", {})
    param_dict = {
        'username': auth_config.get("username"),
        'password':auth_config.get("password"),
        'token':auth_config.get("token"),
        'auth_url': auth_config["auth_url"],
        'project_id': auth_config.get("project_id"),
        'project_name': auth_config.get("project_name"),
        'auth_type': config.get("auth_type","password"),
        'region_name': config["region_name"],
        'endpoint_type': config.get("interface","publicURL"),
        'cacert': config["cacert"],
        'domain_name': config["default_domain"],
        'user_domain_name': auth_config.get("user_domain_name"),
        'project_domain_name': auth_config.get("project_domain_name"),
        'os_user_domain_id': auth_config.get("user_domain_id"),
        'os_project_domain_id': auth_config.get("project_domain_id"),
        'insecure': config.get('insecure', False),
        'http_log_debug': config.get('debug', False),
    }
    client = workloadmgr_client(**param_dict)
    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