diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2014-09-18 00:55:58 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2017-04-11 02:08:04 -0500 |
| commit | 4289ddd47a9c92eb3033eccf39966915caae05db (patch) | |
| tree | 691754545d754da44af2d6f0d78002abb1a02410 /openstackclient/compute | |
| parent | 09286ad8583bb7771b2ca4e9bed23a90056687d6 (diff) | |
| download | python-openstackclient-4289ddd47a9c92eb3033eccf39966915caae05db.tar.gz | |
Low-level Compute v2 API: security group
api.compute.APIv2 starts with security group functions.
novaclient 8.0 is now released without support for the previously
deprecated nova-net functions, so include a new low-level REST
implementation of the removed APIs.
Change-Id: Id007535f0598226a8202716232313e37fe6247f9
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): |
