"hypervisor list --matching" showed the wrong result
Previously, using the "--matching" option shows empty results. Previously, the "--matching" option called the "find_hypervisor method", so we used to call the "hypervisor method" like any other "--limit, --marker" options. Depending on the nova api version, the api that is basically called is as follows 2.53 >= : /os-hypervisors/detail?hypervisor_hostname_pattern=$HOSTNAME 2.53 < : /os-hypervisors/{pattern}/search Hypervisor Type and Host IP are not returned when using microversion 2.52 or lower Co-authored-by: Jipyo Hong <hongsbien@naver.com> Co-authored-by: Jieon Lee <dlwldjs7544@naver.com> Co-authored-by: YoonSoo LIM <msdbtjd123@naver.com> story: 2010670 task: 47726 Change-Id: I7b47acf48def7d4c5f4b74e4dba1c23d8ac7abf2
This commit is contained in:
parent
65b667af20
commit
e74f2d94fe
openstackclient
@ -69,7 +69,11 @@ class ListHypervisor(command.Lister):
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--matching',
|
'--matching',
|
||||||
metavar='<hostname>',
|
metavar='<hostname>',
|
||||||
help=_("Filter hypervisors using <hostname> substring")
|
help=_(
|
||||||
|
"Filter hypervisors using <hostname> substring"
|
||||||
|
"Hypervisor Type and Host IP are not returned "
|
||||||
|
"when using microversion 2.52 or lower"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--marker',
|
'--marker',
|
||||||
@ -128,6 +132,9 @@ class ListHypervisor(command.Lister):
|
|||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
list_opts['limit'] = parsed_args.limit
|
list_opts['limit'] = parsed_args.limit
|
||||||
|
|
||||||
|
if parsed_args.matching:
|
||||||
|
list_opts['hypervisor_hostname_pattern'] = parsed_args.matching
|
||||||
|
|
||||||
column_headers = (
|
column_headers = (
|
||||||
"ID",
|
"ID",
|
||||||
"Hypervisor Hostname",
|
"Hypervisor Hostname",
|
||||||
@ -142,6 +149,7 @@ class ListHypervisor(command.Lister):
|
|||||||
'host_ip',
|
'host_ip',
|
||||||
'state'
|
'state'
|
||||||
)
|
)
|
||||||
|
|
||||||
if parsed_args.long:
|
if parsed_args.long:
|
||||||
if not sdk_utils.supports_microversion(compute_client, '2.88'):
|
if not sdk_utils.supports_microversion(compute_client, '2.88'):
|
||||||
column_headers += (
|
column_headers += (
|
||||||
@ -157,11 +165,7 @@ class ListHypervisor(command.Lister):
|
|||||||
'memory_size'
|
'memory_size'
|
||||||
)
|
)
|
||||||
|
|
||||||
if parsed_args.matching:
|
data = compute_client.hypervisors(**list_opts, details=True)
|
||||||
data = compute_client.find_hypervisor(
|
|
||||||
parsed_args.matching, ignore_missing=False)
|
|
||||||
else:
|
|
||||||
data = compute_client.hypervisors(**list_opts, details=True)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
column_headers,
|
column_headers,
|
||||||
|
@ -131,7 +131,8 @@ class TestHypervisorList(TestHypervisor):
|
|||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
# Fake the return value of search()
|
# Fake the return value of search()
|
||||||
self.sdk_client.find_hypervisor.return_value = [self.hypervisors[0]]
|
self.sdk_client.hypervisors.return_value = [self.hypervisors[0]]
|
||||||
|
|
||||||
self.data = (
|
self.data = (
|
||||||
(
|
(
|
||||||
self.hypervisors[0].id,
|
self.hypervisors[0].id,
|
||||||
@ -147,10 +148,9 @@ class TestHypervisorList(TestHypervisor):
|
|||||||
# containing the data to be listed.
|
# containing the data to be listed.
|
||||||
columns, data = self.cmd.take_action(parsed_args)
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
self.sdk_client.find_hypervisor.assert_called_with(
|
self.sdk_client.hypervisors.assert_called_with(
|
||||||
self.hypervisors[0].name,
|
hypervisor_hostname_pattern=self.hypervisors[0].name,
|
||||||
ignore_missing=False
|
details=True)
|
||||||
)
|
|
||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, tuple(data))
|
self.assertEqual(self.data, tuple(data))
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ class TestHypervisorList(TestHypervisor):
|
|||||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
# Fake exception raised from search()
|
# Fake exception raised from search()
|
||||||
self.sdk_client.find_hypervisor.side_effect = \
|
self.sdk_client.hypervisors.side_effect = \
|
||||||
exceptions.NotFound(None)
|
exceptions.NotFound(None)
|
||||||
|
|
||||||
self.assertRaises(exceptions.NotFound,
|
self.assertRaises(exceptions.NotFound,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user