Bump hacking version
Current hacking version is incompatible with the one in the global requirements. Match the hacking module version and made the necessary changes to pass the tests. Change-Id: Ie6b13a4ea112084d4c50dc27f97329dfad5777a1
This commit is contained in:
@@ -54,8 +54,7 @@ def _get_endpoint(client, **kwargs):
|
|||||||
|
|
||||||
|
|
||||||
def get_client(api_version, **kwargs):
|
def get_client(api_version, **kwargs):
|
||||||
"""Get an authenticated client, based on the credentials
|
"""Get an authenticated client, based on the credentials in args.
|
||||||
in the keyword args.
|
|
||||||
|
|
||||||
:param api_version: the API version to use. Valid value: '1'.
|
:param api_version: the API version to use. Valid value: '1'.
|
||||||
:param kwargs: keyword args containing credentials, either:
|
:param kwargs: keyword args containing credentials, either:
|
||||||
@@ -94,8 +93,8 @@ def get_client(api_version, **kwargs):
|
|||||||
else _ksclient.auth_token)
|
else _ksclient.auth_token)
|
||||||
|
|
||||||
ks_kwargs['region_name'] = kwargs.get('os_region_name')
|
ks_kwargs['region_name'] = kwargs.get('os_region_name')
|
||||||
endpoint = kwargs.get('ironic_url') or \
|
endpoint = (kwargs.get('ironic_url') or
|
||||||
_get_endpoint(_ksclient, **ks_kwargs)
|
_get_endpoint(_ksclient, **ks_kwargs))
|
||||||
|
|
||||||
auth_ref = _ksclient.auth_ref
|
auth_ref = _ksclient.auth_ref
|
||||||
|
|
||||||
|
@@ -27,7 +27,9 @@ from ironicclient.openstack.common.apiclient import base
|
|||||||
|
|
||||||
|
|
||||||
def getid(obj):
|
def getid(obj):
|
||||||
"""Abstracts the common pattern of allowing both an object or an
|
"""Wrapper to get object's ID.
|
||||||
|
|
||||||
|
Abstracts the common pattern of allowing both an object or an
|
||||||
object's ID (UUID) as a parameter when dealing with relationships.
|
object's ID (UUID) as a parameter when dealing with relationships.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
@@ -37,9 +39,7 @@ def getid(obj):
|
|||||||
|
|
||||||
|
|
||||||
class Manager(object):
|
class Manager(object):
|
||||||
"""Managers interact with a particular type of API and provide CRUD
|
"""Provides CRUD operations with a particular API."""
|
||||||
operations for them.
|
|
||||||
"""
|
|
||||||
resource_class = None
|
resource_class = None
|
||||||
|
|
||||||
def __init__(self, api):
|
def __init__(self, api):
|
||||||
@@ -137,8 +137,9 @@ class Manager(object):
|
|||||||
|
|
||||||
|
|
||||||
class Resource(base.Resource):
|
class Resource(base.Resource):
|
||||||
"""A resource represents a particular instance of an object (tenant, user,
|
"""Represents a particular instance of an object (tenant, user, etc).
|
||||||
etc). This is pretty much just a bag for attributes.
|
|
||||||
|
This is pretty much just a bag for attributes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
|
@@ -239,6 +239,7 @@ class VerifiedHTTPSConnection(six.moves.http_client.HTTPSConnection):
|
|||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""Connect to a host on a given (SSL) port.
|
"""Connect to a host on a given (SSL) port.
|
||||||
|
|
||||||
If ca_file is pointing somewhere, use it to check Server Certificate.
|
If ca_file is pointing somewhere, use it to check Server Certificate.
|
||||||
|
|
||||||
Redefined/copied and extended from httplib.py:1105 (Python 2.6.x).
|
Redefined/copied and extended from httplib.py:1105 (Python 2.6.x).
|
||||||
|
@@ -54,9 +54,8 @@ def define_command(subparsers, command, callback, cmd_mapper):
|
|||||||
|
|
||||||
|
|
||||||
def define_commands_from_module(subparsers, command_module, cmd_mapper):
|
def define_commands_from_module(subparsers, command_module, cmd_mapper):
|
||||||
'''Find all methods beginning with 'do_' in a module, and add them
|
"""Add 'do_' methods in a module and add as commands into a subparsers."""
|
||||||
as commands into a subparsers collection.
|
|
||||||
'''
|
|
||||||
for method_name in (a for a in dir(command_module) if a.startswith('do_')):
|
for method_name in (a for a in dir(command_module) if a.startswith('do_')):
|
||||||
# Commands should be hypen-separated instead of underscores.
|
# Commands should be hypen-separated instead of underscores.
|
||||||
command = method_name[3:].replace('_', '-')
|
command = method_name[3:].replace('_', '-')
|
||||||
|
@@ -40,9 +40,7 @@ class InvalidAttribute(ClientException):
|
|||||||
|
|
||||||
def from_response(response, message=None, traceback=None, method=None,
|
def from_response(response, message=None, traceback=None, method=None,
|
||||||
url=None):
|
url=None):
|
||||||
"""Return an instance of an HttpError based on response from
|
"""Return an HttpError instance based on response from httplib/requests."""
|
||||||
httplib/requests.
|
|
||||||
"""
|
|
||||||
|
|
||||||
error_body = {}
|
error_body = {}
|
||||||
if message:
|
if message:
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright 2013 Hewlett-Packard Development Company, L.P.
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from ironicclient.common import http
|
from ironicclient.common import http
|
||||||
@@ -68,8 +69,8 @@ class HttpClientTest(utils.BaseTestCase):
|
|||||||
version=1,
|
version=1,
|
||||||
status=500)
|
status=500)
|
||||||
client = http.HTTPClient('http://localhost/')
|
client = http.HTTPClient('http://localhost/')
|
||||||
client.get_connection = \
|
client.get_connection = (
|
||||||
lambda *a, **kw: utils.FakeConnection(fake_resp)
|
lambda *a, **kw: utils.FakeConnection(fake_resp))
|
||||||
|
|
||||||
error = self.assertRaises(exc.InternalServerError,
|
error = self.assertRaises(exc.InternalServerError,
|
||||||
client.json_request,
|
client.json_request,
|
||||||
@@ -84,8 +85,8 @@ class HttpClientTest(utils.BaseTestCase):
|
|||||||
version=1,
|
version=1,
|
||||||
status=500)
|
status=500)
|
||||||
client = http.HTTPClient('http://localhost/')
|
client = http.HTTPClient('http://localhost/')
|
||||||
client.get_connection = \
|
client.get_connection = (
|
||||||
lambda *a, **kw: utils.FakeConnection(fake_resp)
|
lambda *a, **kw: utils.FakeConnection(fake_resp))
|
||||||
|
|
||||||
error = self.assertRaises(exc.InternalServerError,
|
error = self.assertRaises(exc.InternalServerError,
|
||||||
client.json_request,
|
client.json_request,
|
||||||
@@ -94,16 +95,16 @@ class HttpClientTest(utils.BaseTestCase):
|
|||||||
|
|
||||||
def test_server_exception_msg_and_traceback(self):
|
def test_server_exception_msg_and_traceback(self):
|
||||||
error_msg = 'another test error'
|
error_msg = 'another test error'
|
||||||
error_trace = "\"Traceback (most recent call last):\\n\\n " \
|
error_trace = ("\"Traceback (most recent call last):\\n\\n "
|
||||||
"File \\\"/usr/local/lib/python2.7/..."
|
"File \\\"/usr/local/lib/python2.7/...")
|
||||||
error_body = self._get_error_body(error_msg, error_trace)
|
error_body = self._get_error_body(error_msg, error_trace)
|
||||||
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
fake_resp = utils.FakeResponse({'content-type': 'application/json'},
|
||||||
six.StringIO(error_body),
|
six.StringIO(error_body),
|
||||||
version=1,
|
version=1,
|
||||||
status=500)
|
status=500)
|
||||||
client = http.HTTPClient('http://localhost/')
|
client = http.HTTPClient('http://localhost/')
|
||||||
client.get_connection = \
|
client.get_connection = (
|
||||||
lambda *a, **kw: utils.FakeConnection(fake_resp)
|
lambda *a, **kw: utils.FakeConnection(fake_resp))
|
||||||
|
|
||||||
error = self.assertRaises(exc.InternalServerError,
|
error = self.assertRaises(exc.InternalServerError,
|
||||||
client.json_request,
|
client.json_request,
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import six
|
import six
|
||||||
import testtools
|
import testtools
|
||||||
@@ -69,7 +70,9 @@ class FakeConnection(object):
|
|||||||
class FakeResponse(object):
|
class FakeResponse(object):
|
||||||
def __init__(self, headers, body=None, version=None, status=None,
|
def __init__(self, headers, body=None, version=None, status=None,
|
||||||
reason=None):
|
reason=None):
|
||||||
""":param headers: dict representing HTTP response headers
|
"""Fake object to help testing.
|
||||||
|
|
||||||
|
:param headers: dict representing HTTP response headers
|
||||||
:param body: file-like object
|
:param body: file-like object
|
||||||
"""
|
"""
|
||||||
self.headers = headers
|
self.headers = headers
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import testtools
|
import testtools
|
||||||
from testtools.matchers import HasLength
|
from testtools.matchers import HasLength
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Copyright 2013 Red Hat, Inc.
|
|
||||||
# All Rights Reserved.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
@@ -216,8 +216,8 @@ def do_node_vendor_passthru(cc, args):
|
|||||||
metavar='<limit>',
|
metavar='<limit>',
|
||||||
type=int,
|
type=int,
|
||||||
help='Maximum number of ports to return per request, '
|
help='Maximum number of ports to return per request, '
|
||||||
'0 for no limit. Default is the maximum number used '
|
'0 for no limit. Default is the maximum number used '
|
||||||
'by the Ironic API Service.')
|
'by the Ironic API Service.')
|
||||||
@cliutils.arg(
|
@cliutils.arg(
|
||||||
'--marker',
|
'--marker',
|
||||||
metavar='<marker>',
|
metavar='<marker>',
|
||||||
|
@@ -28,12 +28,14 @@ COMMAND_MODULES = [
|
|||||||
|
|
||||||
|
|
||||||
def enhance_parser(parser, subparsers, cmd_mapper):
|
def enhance_parser(parser, subparsers, cmd_mapper):
|
||||||
'''Take a basic (nonversioned) parser and enhance it with
|
"""Enhance parser with API version specific options.
|
||||||
|
|
||||||
|
Take a basic (nonversioned) parser and enhance it with
|
||||||
commands and options specific for this version of API.
|
commands and options specific for this version of API.
|
||||||
|
|
||||||
:param parser: top level parser :param subparsers: top level
|
:param parser: top level parser :param subparsers: top level
|
||||||
parser's subparsers collection where subcommands will go
|
parser's subparsers collection where subcommands will go
|
||||||
'''
|
"""
|
||||||
for command_module in COMMAND_MODULES:
|
for command_module in COMMAND_MODULES:
|
||||||
utils.define_commands_from_module(subparsers, command_module,
|
utils.define_commands_from_module(subparsers, command_module,
|
||||||
cmd_mapper)
|
cmd_mapper)
|
||||||
|
@@ -5,7 +5,7 @@ Babel>=1.3
|
|||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
discover
|
discover
|
||||||
fixtures>=0.3.14
|
fixtures>=0.3.14
|
||||||
hacking>=0.8.0,<0.9
|
hacking>=0.9.2,<0.10
|
||||||
mock>=1.0
|
mock>=1.0
|
||||||
oslosphinx>=2.2.0 # Apache-2.0
|
oslosphinx>=2.2.0 # Apache-2.0
|
||||||
python-subunit>=0.0.18
|
python-subunit>=0.0.18
|
||||||
|
Reference in New Issue
Block a user