From ea4e0482ae9b18433888d5c7a626a0949014b911 Mon Sep 17 00:00:00 2001 From: Magesh GV Date: Wed, 18 Mar 2015 17:15:08 +0530 Subject: [PATCH] Update GBPClient to work with NeutronClient Master (Post Juno) Change-Id: I2e2de42b3c367430509de9eb31eddb0cb5a568e3 Closes-bug: 1433530 --- gbpclient/gbp/v2_0/groupbasedpolicy.py | 2 +- gbpclient/gbp/v2_0/servicechain.py | 2 +- gbpclient/gbpshell.py | 6 +++--- gbpclient/tests/unit/test_auth.py | 4 ++-- gbpclient/v2_0/client.py | 9 +++------ test-requirements.txt | 2 +- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/gbpclient/gbp/v2_0/groupbasedpolicy.py b/gbpclient/gbp/v2_0/groupbasedpolicy.py index c999470..e089339 100644 --- a/gbpclient/gbp/v2_0/groupbasedpolicy.py +++ b/gbpclient/gbp/v2_0/groupbasedpolicy.py @@ -15,8 +15,8 @@ import logging import string from neutronclient.common import utils +from neutronclient.i18n import _ from neutronclient.neutron import v2_0 as neutronV20 -from neutronclient.openstack.common.gettextutils import _ from oslo.serialization import jsonutils diff --git a/gbpclient/gbp/v2_0/servicechain.py b/gbpclient/gbp/v2_0/servicechain.py index 09ead7d..d832628 100644 --- a/gbpclient/gbp/v2_0/servicechain.py +++ b/gbpclient/gbp/v2_0/servicechain.py @@ -22,8 +22,8 @@ import string from heatclient.common import template_utils from neutronclient.common import exceptions as exc +from neutronclient.i18n import _ from neutronclient.neutron import v2_0 as neutronV20 -from neutronclient.openstack.common.gettextutils import _ class ListServiceChainInstance(neutronV20.ListCommand): diff --git a/gbpclient/gbpshell.py b/gbpclient/gbpshell.py index 9648e4d..d5a335e 100644 --- a/gbpclient/gbpshell.py +++ b/gbpclient/gbpshell.py @@ -27,6 +27,7 @@ from keystoneclient.auth.identity import v3 as v3_auth from keystoneclient import discover from keystoneclient.openstack.common.apiclient import exceptions as ks_exc from keystoneclient import session +from oslo.utils import encodeutils import six.moves.urllib.parse as urlparse from cliff import app @@ -34,8 +35,7 @@ from cliff import commandmanager from neutronclient.common import clientmanager from neutronclient.common import exceptions as exc from neutronclient.common import utils -from neutronclient.openstack.common.gettextutils import _ -from neutronclient.openstack.common import strutils +from neutronclient.i18n import _ from neutronclient.version import __version__ from gbpclient.gbp.v2_0 import groupbasedpolicy as gbp @@ -826,7 +826,7 @@ class GBPShell(app.App): def main(argv=sys.argv[1:]): try: - return GBPShell(NEUTRON_API_VERSION).run(map(strutils.safe_decode, + return GBPShell(NEUTRON_API_VERSION).run(map(encodeutils.safe_decode, argv)) except exc.NeutronClientException: return 1 diff --git a/gbpclient/tests/unit/test_auth.py b/gbpclient/tests/unit/test_auth.py index 6e00b62..be36c08 100644 --- a/gbpclient/tests/unit/test_auth.py +++ b/gbpclient/tests/unit/test_auth.py @@ -33,7 +33,7 @@ from keystoneclient import session from neutronclient import client from neutronclient.common import exceptions from neutronclient.common import utils -from neutronclient.openstack.common import jsonutils +from oslo_serialization import jsonutils USERNAME = 'testuser' @@ -450,7 +450,7 @@ class CLITestAuthKeystone(testtools.TestCase): self.assertRaises( ks_exceptions.EndpointNotFound, - self.client.authenticate) + getattr, self.client, 'endpoint_url') def test_strip_credentials_from_log(self): def verify_no_credentials(kwargs): diff --git a/gbpclient/v2_0/client.py b/gbpclient/v2_0/client.py index 22f02ea..b258d73 100644 --- a/gbpclient/v2_0/client.py +++ b/gbpclient/v2_0/client.py @@ -16,11 +16,11 @@ import time import urllib from neutronclient import client -from neutronclient.common import _ from neutronclient.common import constants from neutronclient.common import exceptions from neutronclient.common import serializer from neutronclient.common import utils +from neutronclient.i18n import _ import requests import six.moves.urllib.parse as urlparse @@ -703,14 +703,11 @@ class Client(object): if type(params) is dict and params: params = utils.safe_encode_dict(params) action += '?' + urllib.urlencode(params, doseq=1) - # Ensure client always has correct uri - do not guesstimate anything - self.httpclient.authenticate_and_fetch_endpoint_url() - self._check_uri_length(action) if body: body = self.serialize(body) - self.httpclient.content_type = self.content_type() - resp, replybody = self.httpclient.do_request(action, method, body=body) + resp, replybody = self.httpclient.do_request( + action, method, body=body, content_type=self.content_type()) status_code = resp.status_code if status_code in (requests.codes.ok, requests.codes.created, diff --git a/test-requirements.txt b/test-requirements.txt index 1f71a3c..c430f14 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,7 +1,7 @@ # The order of packages is significant, because pip processes them in the order # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. --e git://github.com/openstack/python-neutronclient.git@f8e2e42835e6f3bc0ab321d3a7c25e0109ff5e0a#egg=python-neutronclient +-e git://github.com/openstack/python-neutronclient.git#egg=python-neutronclient hacking>=0.8.0,<0.9 cliff-tablib>=1.0