Move osc-lib to test-requirements
We're only using the bits that are proxied into cliff and two tiny helpers. Use cliff directly and only use osc-lib in tests. Change-Id: I1fadee5c9c2cc4debfe09ad9b2c2aed48804475a
This commit is contained in:
parent
159a91b136
commit
c9b1afff70
|
@ -16,15 +16,16 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from osc_lib.command import command
|
from cliff import command
|
||||||
from osc_lib import exceptions
|
from cliff import lister
|
||||||
from osc_lib.i18n import _
|
from cliff import show
|
||||||
from osc_lib import utils
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
import ironic_inspector_client
|
import ironic_inspector_client
|
||||||
|
from ironic_inspector_client.common.i18n import _
|
||||||
from ironic_inspector_client import resource as res
|
from ironic_inspector_client import resource as res
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,18 +58,18 @@ def make_client(instance):
|
||||||
def build_option_parser(parser):
|
def build_option_parser(parser):
|
||||||
# TODO(dtantsur): deprecate these options in favor of more generic OS_*
|
# TODO(dtantsur): deprecate these options in favor of more generic OS_*
|
||||||
parser.add_argument('--inspector-api-version',
|
parser.add_argument('--inspector-api-version',
|
||||||
default=utils.env('INSPECTOR_VERSION',
|
default=(os.environ.get('INSPECTOR_VERSION')
|
||||||
default=DEFAULT_API_VERSION),
|
or DEFAULT_API_VERSION),
|
||||||
help='inspector API version, only 1 is supported now '
|
help='inspector API version, only 1 is supported now '
|
||||||
'(env: INSPECTOR_VERSION).')
|
'(env: INSPECTOR_VERSION).')
|
||||||
parser.add_argument('--inspector-url',
|
parser.add_argument('--inspector-url',
|
||||||
default=utils.env('INSPECTOR_URL', default=None),
|
default=os.environ.get('INSPECTOR_URL'),
|
||||||
help='inspector URL, defaults to localhost '
|
help='inspector URL, defaults to localhost '
|
||||||
'(env: INSPECTOR_URL).')
|
'(env: INSPECTOR_URL).')
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
|
|
||||||
class StartCommand(command.Lister):
|
class StartCommand(lister.Lister):
|
||||||
"""Start the introspection."""
|
"""Start the introspection."""
|
||||||
|
|
||||||
COLUMNS = ('UUID', 'Error')
|
COLUMNS = ('UUID', 'Error')
|
||||||
|
@ -91,7 +92,7 @@ class StartCommand(command.Lister):
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
if parsed_args.check_errors and not parsed_args.wait:
|
if parsed_args.check_errors and not parsed_args.wait:
|
||||||
raise exceptions.CommandError(
|
raise RuntimeError(
|
||||||
_("--check-errors can only be used with --wait"))
|
_("--check-errors can only be used with --wait"))
|
||||||
|
|
||||||
client = self.app.client_manager.baremetal_introspection
|
client = self.app.client_manager.baremetal_introspection
|
||||||
|
@ -130,7 +131,7 @@ class ReprocessCommand(command.Command):
|
||||||
client.reprocess(parsed_args.node)
|
client.reprocess(parsed_args.node)
|
||||||
|
|
||||||
|
|
||||||
class StatusCommand(command.ShowOne):
|
class StatusCommand(show.ShowOne):
|
||||||
"""Get introspection status."""
|
"""Get introspection status."""
|
||||||
hidden_status_items = {'links'}
|
hidden_status_items = {'links'}
|
||||||
|
|
||||||
|
@ -157,10 +158,12 @@ class StatusCommand(command.ShowOne):
|
||||||
return zip(*sorted(self.status_attributes(status)))
|
return zip(*sorted(self.status_attributes(status)))
|
||||||
|
|
||||||
|
|
||||||
class StatusListCommand(command.Lister):
|
class StatusListCommand(lister.Lister):
|
||||||
"""List introspection statuses"""
|
"""List introspection statuses"""
|
||||||
|
|
||||||
COLUMNS = ('UUID', 'Started at', 'Finished at', 'Error')
|
COLUMNS = ('UUID', 'Started at', 'Finished at', 'Error')
|
||||||
|
MAPPING = dict(zip(COLUMNS,
|
||||||
|
['uuid', 'started_at', 'finished_at', 'error']))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def status_row(cls, client_item):
|
def status_row(cls, client_item):
|
||||||
|
@ -173,7 +176,7 @@ class StatusListCommand(command.Lister):
|
||||||
:return: a list of client_item attributes as the row
|
:return: a list of client_item attributes as the row
|
||||||
"""
|
"""
|
||||||
status = dict(StatusCommand.status_attributes(client_item))
|
status = dict(StatusCommand.status_attributes(client_item))
|
||||||
return utils.get_dict_properties(status, cls.COLUMNS)
|
return tuple(status.get(cls.MAPPING[item]) for item in cls.COLUMNS)
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
parser = super(StatusListCommand, self).get_parser(prog_name)
|
parser = super(StatusListCommand, self).get_parser(prog_name)
|
||||||
|
@ -204,7 +207,7 @@ class AbortCommand(command.Command):
|
||||||
client.abort(parsed_args.node)
|
client.abort(parsed_args.node)
|
||||||
|
|
||||||
|
|
||||||
class RuleImportCommand(command.Lister):
|
class RuleImportCommand(lister.Lister):
|
||||||
"""Import one or several introspection rules from a JSON/YAML file."""
|
"""Import one or several introspection rules from a JSON/YAML file."""
|
||||||
|
|
||||||
COLUMNS = ("UUID", "Description")
|
COLUMNS = ("UUID", "Description")
|
||||||
|
@ -229,7 +232,7 @@ class RuleImportCommand(command.Lister):
|
||||||
return self.COLUMNS, result
|
return self.COLUMNS, result
|
||||||
|
|
||||||
|
|
||||||
class RuleListCommand(command.Lister):
|
class RuleListCommand(lister.Lister):
|
||||||
"""List all introspection rules."""
|
"""List all introspection rules."""
|
||||||
|
|
||||||
COLUMNS = ("UUID", "Description")
|
COLUMNS = ("UUID", "Description")
|
||||||
|
@ -242,7 +245,7 @@ class RuleListCommand(command.Lister):
|
||||||
return self.COLUMNS, rules
|
return self.COLUMNS, rules
|
||||||
|
|
||||||
|
|
||||||
class RuleShowCommand(command.ShowOne):
|
class RuleShowCommand(show.ShowOne):
|
||||||
"""Show an introspection rule."""
|
"""Show an introspection rule."""
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
|
@ -300,7 +303,7 @@ class DataSaveCommand(command.Command):
|
||||||
json.dump(data, sys.stdout)
|
json.dump(data, sys.stdout)
|
||||||
|
|
||||||
|
|
||||||
class InterfaceListCommand(command.Lister):
|
class InterfaceListCommand(lister.Lister):
|
||||||
"""List interface data including attached switch port information."""
|
"""List interface data including attached switch port information."""
|
||||||
|
|
||||||
def get_parser(self, prog_name):
|
def get_parser(self, prog_name):
|
||||||
|
@ -340,7 +343,7 @@ class InterfaceListCommand(command.Lister):
|
||||||
return interface_res.labels, rows
|
return interface_res.labels, rows
|
||||||
|
|
||||||
|
|
||||||
class InterfaceShowCommand(command.ShowOne):
|
class InterfaceShowCommand(show.ShowOne):
|
||||||
"""Show interface data including attached switch port information."""
|
"""Show interface data including attached switch port information."""
|
||||||
|
|
||||||
COLUMNS = ("Field", "Value")
|
COLUMNS = ("Field", "Value")
|
||||||
|
|
|
@ -17,7 +17,6 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
from osc_lib import exceptions
|
|
||||||
from osc_lib.tests import utils
|
from osc_lib.tests import utils
|
||||||
|
|
||||||
from ironic_inspector_client import shell
|
from ironic_inspector_client import shell
|
||||||
|
@ -149,7 +148,7 @@ class TestIntrospect(BaseTest):
|
||||||
cmd = shell.StartCommand(self.app, None)
|
cmd = shell.StartCommand(self.app, None)
|
||||||
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
parsed_args = self.check_parser(cmd, arglist, verifylist)
|
||||||
msg = "--check-errors can only be used with --wait"
|
msg = "--check-errors can only be used with --wait"
|
||||||
self.assertRaisesRegex(exceptions.CommandError, msg, cmd.take_action,
|
self.assertRaisesRegex(RuntimeError, msg, cmd.take_action,
|
||||||
parsed_args)
|
parsed_args)
|
||||||
|
|
||||||
def test_abort(self):
|
def test_abort(self):
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# The order of packages is significant, because pip processes them in the order
|
# 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
|
# of appearance. Changing the order has an impact on the overall integration
|
||||||
# process, which may cause wedges in the gate later.
|
# process, which may cause wedges in the gate later.
|
||||||
|
cliff!=2.9.0,>=2.8.0 # Apache-2.0
|
||||||
keystoneauth1>=3.4.0 # Apache-2.0
|
keystoneauth1>=3.4.0 # Apache-2.0
|
||||||
osc-lib>=1.8.0 # Apache-2.0
|
|
||||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||||
PyYAML>=3.12 # MIT
|
PyYAML>=3.12 # MIT
|
||||||
requests>=2.14.2 # Apache-2.0
|
requests>=2.14.2 # Apache-2.0
|
||||||
|
|
|
@ -9,4 +9,5 @@ hacking>=3.0.0,<3.1.0 # Apache-2.0
|
||||||
mock>=2.0.0 # BSD
|
mock>=2.0.0 # BSD
|
||||||
requests-mock>=1.2.0 # Apache-2.0
|
requests-mock>=1.2.0 # Apache-2.0
|
||||||
oslo.concurrency>=3.25.0 # Apache-2.0
|
oslo.concurrency>=3.25.0 # Apache-2.0
|
||||||
|
osc-lib>=1.8.0 # Apache-2.0
|
||||||
python-openstackclient>=3.12.0 # Apache-2.0
|
python-openstackclient>=3.12.0 # Apache-2.0
|
||||||
|
|
Loading…
Reference in New Issue