Merge "Remove remaining uses of SDK Proxy.session"
This commit is contained in:
commit
35c308ebad
@ -18,8 +18,6 @@
|
|||||||
import itertools
|
import itertools
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openstack import exceptions as sdk_exceptions
|
|
||||||
from openstack.network.v2 import quota as _quota
|
|
||||||
from osc_lib.command import command
|
from osc_lib.command import command
|
||||||
from osc_lib import utils
|
from osc_lib import utils
|
||||||
import six
|
import six
|
||||||
@ -253,38 +251,6 @@ class ShowQuota(command.ShowOne):
|
|||||||
project = self._get_project(parsed_args)
|
project = self._get_project(parsed_args)
|
||||||
client = self.app.client_manager.network
|
client = self.app.client_manager.network
|
||||||
if parsed_args.default:
|
if parsed_args.default:
|
||||||
# TODO(dtroyer): Remove the top of this if block once the
|
|
||||||
# fixed SDK QuotaDefault class is the minimum
|
|
||||||
# required version. This is expected to be
|
|
||||||
# SDK release 0.9.13
|
|
||||||
if hasattr(_quota.QuotaDefault, 'project'):
|
|
||||||
# hack 0.9.11+
|
|
||||||
quotadef_obj = client._get_resource(
|
|
||||||
_quota.QuotaDefault,
|
|
||||||
project,
|
|
||||||
)
|
|
||||||
quotadef_obj.base_path = quotadef_obj.base_path % {
|
|
||||||
'project': project,
|
|
||||||
}
|
|
||||||
try:
|
|
||||||
network_quota = quotadef_obj.get(
|
|
||||||
client.session,
|
|
||||||
requires_id=False,
|
|
||||||
)
|
|
||||||
except sdk_exceptions.NotFoundException as e:
|
|
||||||
raise sdk_exceptions.ResourceNotFound(
|
|
||||||
message="No %s found for %s" %
|
|
||||||
(_quota.QuotaDefault.__name__, project),
|
|
||||||
details=e.details,
|
|
||||||
response=e.response,
|
|
||||||
request_id=e.request_id,
|
|
||||||
url=e.url,
|
|
||||||
method=e.method,
|
|
||||||
http_status=e.http_status,
|
|
||||||
cause=e.cause,
|
|
||||||
)
|
|
||||||
# end hack-around
|
|
||||||
else:
|
|
||||||
network_quota = client.get_quota_default(project)
|
network_quota = client.get_quota_default(project)
|
||||||
else:
|
else:
|
||||||
network_quota = client.get_quota(project)
|
network_quota = client.get_quota(project)
|
||||||
|
@ -44,6 +44,11 @@ def make_client(instance):
|
|||||||
LOG.debug('Connection: %s', conn)
|
LOG.debug('Connection: %s', conn)
|
||||||
LOG.debug('Network client initialized using OpenStack SDK: %s',
|
LOG.debug('Network client initialized using OpenStack SDK: %s',
|
||||||
conn.network)
|
conn.network)
|
||||||
|
|
||||||
|
# NOTE(dtroyer): Horrible ugly hack since we don't actually save
|
||||||
|
# the connection anywhere yet, so stash it in the
|
||||||
|
# instance directly from here for other uses
|
||||||
|
instance.sdk_connection = conn
|
||||||
return conn.network
|
return conn.network
|
||||||
|
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ class DeleteFloatingIP(common.NetworkAndComputeDelete):
|
|||||||
|
|
||||||
def take_action_network(self, client, parsed_args):
|
def take_action_network(self, client, parsed_args):
|
||||||
(obj, self.ip_cache) = _find_floating_ip(
|
(obj, self.ip_cache) = _find_floating_ip(
|
||||||
client.session,
|
self.app.client_manager.sdk_connection.session,
|
||||||
self.ip_cache,
|
self.ip_cache,
|
||||||
self.r,
|
self.r,
|
||||||
ignore_missing=False,
|
ignore_missing=False,
|
||||||
@ -472,7 +472,7 @@ class ShowFloatingIP(common.NetworkAndComputeShowOne):
|
|||||||
|
|
||||||
def take_action_network(self, client, parsed_args):
|
def take_action_network(self, client, parsed_args):
|
||||||
(obj, self.ip_cache) = _find_floating_ip(
|
(obj, self.ip_cache) = _find_floating_ip(
|
||||||
client.session,
|
self.app.client_manager.sdk_connection.session,
|
||||||
[],
|
[],
|
||||||
parsed_args.floating_ip,
|
parsed_args.floating_ip,
|
||||||
ignore_missing=False,
|
ignore_missing=False,
|
||||||
|
@ -71,6 +71,10 @@ class TestNetworkV2(utils.TestCommand):
|
|||||||
token=fakes.AUTH_TOKEN,
|
token=fakes.AUTH_TOKEN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.app.client_manager.sdk_connection = mock.Mock()
|
||||||
|
self.app.client_manager.sdk_connection.network = \
|
||||||
|
self.app.client_manager.network
|
||||||
|
|
||||||
self.app.client_manager.identity = (
|
self.app.client_manager.identity = (
|
||||||
identity_fakes_v3.FakeIdentityv3Client(
|
identity_fakes_v3.FakeIdentityv3Client(
|
||||||
endpoint=fakes.AUTH_URL,
|
endpoint=fakes.AUTH_URL,
|
||||||
|
Loading…
Reference in New Issue
Block a user