Skip to content

Commit 35c308e

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Remove remaining uses of SDK Proxy.session"
2 parents bc4a3f4 + 73809a9 commit 35c308e

4 files changed

Lines changed: 12 additions & 37 deletions

File tree

openstackclient/common/quota.py

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import itertools
1919
import sys
2020

21-
from openstack import exceptions as sdk_exceptions
22-
from openstack.network.v2 import quota as _quota
2321
from osc_lib.command import command
2422
from osc_lib import utils
2523
import six
@@ -253,39 +251,7 @@ def get_network_quota(self, parsed_args):
253251
project = self._get_project(parsed_args)
254252
client = self.app.client_manager.network
255253
if parsed_args.default:
256-
# TODO(dtroyer): Remove the top of this if block once the
257-
# fixed SDK QuotaDefault class is the minimum
258-
# required version. This is expected to be
259-
# SDK release 0.9.13
260-
if hasattr(_quota.QuotaDefault, 'project'):
261-
# hack 0.9.11+
262-
quotadef_obj = client._get_resource(
263-
_quota.QuotaDefault,
264-
project,
265-
)
266-
quotadef_obj.base_path = quotadef_obj.base_path % {
267-
'project': project,
268-
}
269-
try:
270-
network_quota = quotadef_obj.get(
271-
client.session,
272-
requires_id=False,
273-
)
274-
except sdk_exceptions.NotFoundException as e:
275-
raise sdk_exceptions.ResourceNotFound(
276-
message="No %s found for %s" %
277-
(_quota.QuotaDefault.__name__, project),
278-
details=e.details,
279-
response=e.response,
280-
request_id=e.request_id,
281-
url=e.url,
282-
method=e.method,
283-
http_status=e.http_status,
284-
cause=e.cause,
285-
)
286-
# end hack-around
287-
else:
288-
network_quota = client.get_quota_default(project)
254+
network_quota = client.get_quota_default(project)
289255
else:
290256
network_quota = client.get_quota(project)
291257
return network_quota

openstackclient/network/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ def make_client(instance):
4444
LOG.debug('Connection: %s', conn)
4545
LOG.debug('Network client initialized using OpenStack SDK: %s',
4646
conn.network)
47+
48+
# NOTE(dtroyer): Horrible ugly hack since we don't actually save
49+
# the connection anywhere yet, so stash it in the
50+
# instance directly from here for other uses
51+
instance.sdk_connection = conn
4752
return conn.network
4853

4954

openstackclient/network/v2/floating_ip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def update_parser_common(self, parser):
241241

242242
def take_action_network(self, client, parsed_args):
243243
(obj, self.ip_cache) = _find_floating_ip(
244-
client.session,
244+
self.app.client_manager.sdk_connection.session,
245245
self.ip_cache,
246246
self.r,
247247
ignore_missing=False,
@@ -472,7 +472,7 @@ def update_parser_common(self, parser):
472472

473473
def take_action_network(self, client, parsed_args):
474474
(obj, self.ip_cache) = _find_floating_ip(
475-
client.session,
475+
self.app.client_manager.sdk_connection.session,
476476
[],
477477
parsed_args.floating_ip,
478478
ignore_missing=False,

openstackclient/tests/unit/network/v2/fakes.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def setUp(self):
7171
token=fakes.AUTH_TOKEN,
7272
)
7373

74+
self.app.client_manager.sdk_connection = mock.Mock()
75+
self.app.client_manager.sdk_connection.network = \
76+
self.app.client_manager.network
77+
7478
self.app.client_manager.identity = (
7579
identity_fakes_v3.FakeIdentityv3Client(
7680
endpoint=fakes.AUTH_URL,

0 commit comments

Comments
 (0)