summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--neutronclient/neutron/v2_0/__init__.py2
-rw-r--r--neutronclient/neutron/v2_0/lb/v2/loadbalancer.py1
-rw-r--r--neutronclient/neutron/v2_0/rbac.py1
-rw-r--r--neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py4
-rw-r--r--neutronclient/tests/unit/test_cli20.py54
-rw-r--r--neutronclient/tests/unit/test_cli20_tag.py5
-rw-r--r--neutronclient/v2_0/client.py2
7 files changed, 23 insertions, 46 deletions
diff --git a/neutronclient/neutron/v2_0/__init__.py b/neutronclient/neutron/v2_0/__init__.py
index a980fe1..b1b675a 100644
--- a/neutronclient/neutron/v2_0/__init__.py
+++ b/neutronclient/neutron/v2_0/__init__.py
@@ -336,7 +336,7 @@ class NeutronCommand(command.Command):
parser = super(NeutronCommand, self).get_parser(prog_name)
parser.add_argument(
'--request-format',
- help=_('DEPRECATED! Only JSON request format is supported.'),
+ help=argparse.SUPPRESS,
default='json',
choices=['json', ], )
parser.add_argument(
diff --git a/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py b/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py
index 8cc6dff..c40809f 100644
--- a/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py
+++ b/neutronclient/neutron/v2_0/lb/v2/loadbalancer.py
@@ -124,7 +124,6 @@ class RetrieveLoadBalancerStats(neutronV20.ShowCommand):
def take_action(self, parsed_args):
neutron_client = self.get_client()
- neutron_client.format = parsed_args.request_format
loadbalancer_id = neutronV20.find_resourceid_by_name_or_id(
self.get_client(), 'loadbalancer', parsed_args.id)
params = {}
diff --git a/neutronclient/neutron/v2_0/rbac.py b/neutronclient/neutron/v2_0/rbac.py
index e1153b0..8b356d3 100644
--- a/neutronclient/neutron/v2_0/rbac.py
+++ b/neutronclient/neutron/v2_0/rbac.py
@@ -82,7 +82,6 @@ class CreateRBACPolicy(neutronV20.CreateCommand):
def args2body(self, parsed_args):
neutron_client = self.get_client()
- neutron_client.format = parsed_args.request_format
_object_id, _object_type = get_rbac_obj_params(neutron_client,
parsed_args.type,
parsed_args.name)
diff --git a/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py b/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py
index 8ec611c..1b425e6 100644
--- a/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py
+++ b/neutronclient/tests/unit/fw/test_cli20_firewallpolicy.py
@@ -173,7 +173,7 @@ class CLITestV20FirewallPolicyJSON(test_cli20.CLITestV20Base):
path = getattr(self.client, resource + "_insert_path")
self.client.httpclient.request(
test_cli20.MyUrlComparator(
- test_cli20.end_url(path % myid, format=self.format),
+ test_cli20.end_url(path % myid),
self.client),
'PUT', body=test_cli20.MyComparator(body, self.client),
headers=mox.ContainsKeyValue(
@@ -202,7 +202,7 @@ class CLITestV20FirewallPolicyJSON(test_cli20.CLITestV20Base):
path = getattr(self.client, resource + "_remove_path")
self.client.httpclient.request(
test_cli20.MyUrlComparator(
- test_cli20.end_url(path % myid, format=self.format),
+ test_cli20.end_url(path % myid),
self.client),
'PUT', body=test_cli20.MyComparator(body, self.client),
headers=mox.ContainsKeyValue(
diff --git a/neutronclient/tests/unit/test_cli20.py b/neutronclient/tests/unit/test_cli20.py
index 4ff306a..3437a8f 100644
--- a/neutronclient/tests/unit/test_cli20.py
+++ b/neutronclient/tests/unit/test_cli20.py
@@ -37,7 +37,6 @@ from neutronclient import shell
from neutronclient.v2_0 import client
API_VERSION = "2.0"
-FORMAT = 'json'
TOKEN = 'testtoken'
ENDURL = 'localurl'
REQUEST_ID = 'test_request_id'
@@ -89,8 +88,8 @@ class MyApp(object):
self.stdout = _stdout
-def end_url(path, query=None, format=FORMAT):
- _url_str = ENDURL + "/v" + API_VERSION + path + "." + format
+def end_url(path, query=None):
+ _url_str = ENDURL + "/v" + API_VERSION + path
return query and _url_str + "?" + query or _url_str
@@ -113,16 +112,6 @@ class MyUrlComparator(mox.Comparator):
set(lhs_qs) == set(rhs_qs))
def __str__(self):
- if self.client and self.client.format != FORMAT:
- lhs_parts = self.lhs.split("?", 1)
- if len(lhs_parts) == 2:
- lhs = ("%s.%s?%s" % (lhs_parts[0][:-4],
- self.client.format,
- lhs_parts[1]))
- else:
- lhs = ("%s.%s" % (lhs_parts[0][:-4],
- self.client.format))
- return lhs
return self.lhs
def __repr__(self):
@@ -183,7 +172,6 @@ class MyComparator(mox.Comparator):
class CLITestV20Base(base.BaseTestCase):
- format = 'json'
test_id = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
id_field = 'id'
@@ -212,7 +200,6 @@ class CLITestV20Base(base.BaseTestCase):
new=self._find_resourceid).start()
self.client = client.Client(token=TOKEN, endpoint_url=self.endurl)
- self.client.format = self.format
def register_non_admin_status_resource(self, resource_name):
# TODO(amotoki):
@@ -269,7 +256,7 @@ class CLITestV20Base(base.BaseTestCase):
if not no_api_call:
self.client.httpclient.request(
- end_url(path, format=self.format), 'POST',
+ end_url(path), 'POST',
body=mox_body,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr))
@@ -302,7 +289,7 @@ class CLITestV20Base(base.BaseTestCase):
if parent_id:
path = path % parent_id
self.client.httpclient.request(
- end_url(path, format=self.format), 'GET',
+ end_url(path), 'GET',
body=None,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr))
@@ -396,7 +383,7 @@ class CLITestV20Base(base.BaseTestCase):
args.append('-f')
args.append(output_format)
self.client.httpclient.request(
- MyUrlComparator(end_url(path, query, format=self.format),
+ MyUrlComparator(end_url(path, query),
self.client),
'GET',
body=None,
@@ -435,12 +422,12 @@ class CLITestV20Base(base.BaseTestCase):
resstr1 = self.client.serialize(reses1)
resstr2 = self.client.serialize(reses2)
self.client.httpclient.request(
- end_url(path, query, format=self.format), 'GET',
+ end_url(path, query), 'GET',
body=None,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr1))
self.client.httpclient.request(
- MyUrlComparator(end_url(path, fake_query, format=self.format),
+ MyUrlComparator(end_url(path, fake_query),
self.client), 'GET',
body=None,
headers=mox.ContainsKeyValue(
@@ -469,8 +456,7 @@ class CLITestV20Base(base.BaseTestCase):
mox_body = MyComparator(body, self.client)
self.client.httpclient.request(
- MyUrlComparator(end_url(path, format=self.format),
- self.client),
+ MyUrlComparator(end_url(path), self.client),
'PUT',
body=mox_body,
headers=mox.ContainsKeyValue(
@@ -502,7 +488,7 @@ class CLITestV20Base(base.BaseTestCase):
else:
path = path % myid
self.client.httpclient.request(
- end_url(path, query, format=self.format), 'GET',
+ end_url(path, query), 'GET',
body=None,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200), resstr))
@@ -523,7 +509,7 @@ class CLITestV20Base(base.BaseTestCase):
else:
path = path % (myid)
self.client.httpclient.request(
- end_url(path, format=self.format), 'DELETE',
+ end_url(path), 'DELETE',
body=None,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(
@@ -563,7 +549,7 @@ class CLITestV20Base(base.BaseTestCase):
path = getattr(self.client, cmd_resource + "_path")
path_action = '%s/%s' % (myid, action)
self.client.httpclient.request(
- end_url(path % path_action, format=self.format), 'PUT',
+ end_url(path % path_action), 'PUT',
body=MyComparator(body, self.client),
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(204), retval))
@@ -670,7 +656,7 @@ class ClientV2TestJson(CLITestV20Base):
resp_headers = {'x-openstack-request-id': REQUEST_ID}
self.client.httpclient.request(
- end_url(expected_action, query=expect_query, format=self.format),
+ end_url(expected_action, query=expect_query),
'PUT', body=expect_body,
headers=mox.ContainsKeyValue(
'X-Auth-Token',
@@ -694,8 +680,7 @@ class ClientV2TestJson(CLITestV20Base):
resp_headers = {'x-openstack-request-id': REQUEST_ID}
self.client.httpclient.request(
- MyUrlComparator(end_url(
- '/test', query=expect_query, format=self.format), self.client),
+ MyUrlComparator(end_url('/test', query=expect_query), self.client),
'PUT', body='',
headers=mox.ContainsKeyValue('X-Auth-Token', 'token')
).AndReturn((MyResp(400, headers=resp_headers, reason='An error'), ''))
@@ -727,9 +712,7 @@ class ClientV2TestJson(CLITestV20Base):
expect_body = self.client.serialize(body)
resp_headers = {'x-openstack-request-id': REQUEST_ID}
self.client.httpclient.request(
- MyUrlComparator(end_url(
- '/test', query=expect_query,
- format=self.format), self.client),
+ MyUrlComparator(end_url('/test', query=expect_query), self.client),
'PUT', body=expect_body,
headers=mox.ContainsKeyValue('X-Auth-Token', 'token')
).AndReturn((MyResp(200, resp_headers), expect_body))
@@ -759,13 +742,13 @@ class ClientV2TestJson(CLITestV20Base):
resstr2 = self.client.serialize(reses2)
resp_headers = {'x-openstack-request-id': REQUEST_ID}
self.client.httpclient.request(
- end_url(path, "", format=self.format), 'GET',
+ end_url(path, ""), 'GET',
body=None,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200, resp_headers),
resstr1))
self.client.httpclient.request(
- MyUrlComparator(end_url(path, fake_query, format=self.format),
+ MyUrlComparator(end_url(path, fake_query),
self.client), 'GET',
body=None,
headers=mox.ContainsKeyValue(
@@ -795,14 +778,13 @@ class ClientV2TestJson(CLITestV20Base):
resstr2 = self.client.serialize(reses2)
resp_headers = {'x-openstack-request-id': REQUEST_ID}
self.client.httpclient.request(
- end_url(path, "", format=self.format), 'GET',
+ end_url(path, ""), 'GET',
body=None,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200, resp_headers),
resstr1))
self.client.httpclient.request(
- MyUrlComparator(end_url(path, fake_query, format=self.format),
- self.client), 'GET',
+ MyUrlComparator(end_url(path, fake_query), self.client), 'GET',
body=None,
headers=mox.ContainsKeyValue(
'X-Auth-Token', TOKEN)).AndReturn((MyResp(200, resp_headers),
diff --git a/neutronclient/tests/unit/test_cli20_tag.py b/neutronclient/tests/unit/test_cli20_tag.py
index 09b99ab..edd70a7 100644
--- a/neutronclient/tests/unit/test_cli20_tag.py
+++ b/neutronclient/tests/unit/test_cli20_tag.py
@@ -30,8 +30,7 @@ class CLITestV20Tag(test_cli20.CLITestV20Base):
if body:
body = test_cli20.MyComparator(body, self.client)
self.client.httpclient.request(
- test_cli20.MyUrlComparator(
- test_cli20.end_url(path, format=self.format), self.client),
+ test_cli20.MyUrlComparator(test_cli20.end_url(path), self.client),
method, body=body,
headers=mox.ContainsKeyValue(
'X-Auth-Token', test_cli20.TOKEN)).AndReturn(
@@ -51,7 +50,7 @@ class CLITestV20Tag(test_cli20.CLITestV20Base):
resstr = self.client.serialize(res)
self.client.httpclient.request(
test_cli20.MyUrlComparator(
- test_cli20.end_url(path, query, format=self.format),
+ test_cli20.end_url(path, query),
self.client),
'GET', body=None,
headers=mox.ContainsKeyValue(
diff --git a/neutronclient/v2_0/client.py b/neutronclient/v2_0/client.py
index 759f776..d2ace80 100644
--- a/neutronclient/v2_0/client.py
+++ b/neutronclient/v2_0/client.py
@@ -250,7 +250,6 @@ class ClientBase(object):
self.raise_errors = kwargs.pop('raise_errors', True)
self.httpclient = client.construct_http_client(**kwargs)
self.version = '2.0'
- self.format = 'json'
self.action_prefix = "/v%s" % (self.version)
self.retry_interval = 1
@@ -270,7 +269,6 @@ class ClientBase(object):
def do_request(self, method, action, body=None, headers=None, params=None):
# Add format and project_id
- action += ".%s" % self.format
action = self.action_prefix + action
if isinstance(params, dict) and params:
params = utils.safe_encode_dict(params)