diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-04-17 17:35:33 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-04-17 17:35:33 +0000 |
| commit | 9a1c9cabd4e806f81d162d2f4136e6d39ae2c456 (patch) | |
| tree | f886594609e38c987efc940adb2146848499e1e2 /openstackclient/compute | |
| parent | 62d71aa2435b2257670480dce73d2192652bb14d (diff) | |
| parent | 4289ddd47a9c92eb3033eccf39966915caae05db (diff) | |
| download | python-openstackclient-9a1c9cabd4e806f81d162d2f4136e6d39ae2c456.tar.gz | |
Merge "Low-level Compute v2 API: security group"
Diffstat (limited to 'openstackclient/compute')
| -rw-r--r-- | openstackclient/compute/client.py | 22 | ||||
| -rw-r--r-- | openstackclient/compute/v2/server.py | 16 |
2 files changed, 27 insertions, 11 deletions
diff --git a/openstackclient/compute/client.py b/openstackclient/compute/client.py index b4b463b4..6abfef04 100644 --- a/openstackclient/compute/client.py +++ b/openstackclient/compute/client.py @@ -31,6 +31,11 @@ API_VERSIONS = { "2.1": "novaclient.client", } +COMPUTE_API_TYPE = 'compute' +COMPUTE_API_VERSIONS = { + '2': 'openstackclient.api.compute_v2.APIv2', +} + # Save the microversion if in use _compute_api_version = None @@ -58,6 +63,13 @@ def make_client(instance): LOG.debug('Instantiating compute client for %s', version) + compute_api = utils.get_client_class( + API_NAME, + version.ver_major, + COMPUTE_API_VERSIONS, + ) + LOG.debug('Instantiating compute api: %s', compute_api) + # Set client http_log_debug to True if verbosity level is high enough http_log_debug = utils.get_effective_log_level() <= logging.DEBUG @@ -77,6 +89,16 @@ def make_client(instance): **kwargs ) + client.api = compute_api( + session=instance.session, + service_type=COMPUTE_API_TYPE, + endpoint=instance.get_endpoint_for_service_type( + COMPUTE_API_TYPE, + region_name=instance.region_name, + interface=instance.interface, + ) + ) + return client diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index ae839677..7cd4588b 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -22,6 +22,7 @@ import logging import os import sys +from novaclient.v2 import servers from osc_lib.cli import parseractions from osc_lib.command import command from osc_lib import exceptions @@ -29,11 +30,6 @@ from osc_lib import utils from oslo_utils import timeutils import six -try: - from novaclient.v2 import servers -except ImportError: - from novaclient.v1_1 import servers - from openstackclient.i18n import _ from openstackclient.identity import common as identity_common @@ -316,12 +312,11 @@ class AddServerSecurityGroup(command.Command): compute_client.servers, parsed_args.server, ) - security_group = utils.find_resource( - compute_client.security_groups, + security_group = compute_client.api.security_group_find( parsed_args.group, ) - server.add_security_group(security_group.id) + server.add_security_group(security_group['id']) class AddServerVolume(command.Command): @@ -1437,12 +1432,11 @@ class RemoveServerSecurityGroup(command.Command): compute_client.servers, parsed_args.server, ) - security_group = utils.find_resource( - compute_client.security_groups, + security_group = compute_client.api.security_group_find( parsed_args.group, ) - server.remove_security_group(security_group.id) + server.remove_security_group(security_group['id']) class RemoveServerVolume(command.Command): |
