Add CLI options for introspection command

--node-timeout - Maximum timeout for node introspection
--max-retries - Maximum introspection retries
--retry-timeout - Maximum timeout between introspection retries

Change-Id: I9c245dbc258c9714bb5a581d6d4d23b42cf53198
(cherry picked from commit c9d057651e)
This commit is contained in:
Sagi Shnaidman 2020-06-23 18:58:54 +03:00
parent 20303eda3e
commit f45b95fa57
5 changed files with 65 additions and 10 deletions

View File

@ -211,7 +211,10 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
extra_vars={ extra_vars={
'node_uuids': [], 'node_uuids': [],
'run_validations': False, 'run_validations': False,
'concurrency': 20 'concurrency': 20,
'node_timeout': 1200,
'max_retries': 1,
'retry_timeout': 120,
} }
) )
@ -252,7 +255,10 @@ class TestIntrospectNode(fakes.TestOvercloudNode):
extra_vars={ extra_vars={
'node_uuids': nodes, 'node_uuids': nodes,
'run_validations': False, 'run_validations': False,
'concurrency': 20 'concurrency': 20,
'node_timeout': 1200,
'max_retries': 1,
'retry_timeout': 120,
} }
) )

View File

@ -72,11 +72,14 @@ class TestBaremetalWorkflows(fakes.FakePlaybookExecution):
def test_introspect_success(self): def test_introspect_success(self):
baremetal.introspect(self.app.client_manager, node_uuids=[], baremetal.introspect(self.app.client_manager, node_uuids=[],
run_validations=True, concurrency=20) run_validations=True, concurrency=20,
node_timeout=1200, max_retries=1,
retry_timeout=120)
def test_introspect_manageable_nodes_success(self): def test_introspect_manageable_nodes_success(self):
baremetal.introspect_manageable_nodes( baremetal.introspect_manageable_nodes(
self.app.client_manager, run_validations=False, concurrency=20 self.app.client_manager, run_validations=False, concurrency=20,
node_timeout=1200, max_retries=1, retry_timeout=120,
) )
def test_provide_manageable_nodes_success(self): def test_provide_manageable_nodes_success(self):

View File

@ -394,6 +394,16 @@ class DiscoverNode(command.Command):
default=20, default=20,
help=_('Maximum number of nodes to introspect at ' help=_('Maximum number of nodes to introspect at '
'once.')) 'once.'))
parser.add_argument('--node-timeout', type=int,
default=1200,
help=_('Maximum timeout for node introspection.'))
parser.add_argument('--max-retries', type=int,
default=1,
help=_('Maximum introspection retries.'))
parser.add_argument('--retry-timeout', type=int,
default=120,
help=_('Maximum timeout between introspection'
'retries'))
return parser return parser
# FIXME(tonyb): This is not multi-arch safe :( # FIXME(tonyb): This is not multi-arch safe :(
@ -434,7 +444,10 @@ class DiscoverNode(command.Command):
self.app.client_manager, self.app.client_manager,
node_uuids=nodes_uuids, node_uuids=nodes_uuids,
run_validations=parsed_args.run_validations, run_validations=parsed_args.run_validations,
concurrency=parsed_args.concurrency concurrency=parsed_args.concurrency,
node_timeout=parsed_args.node_timeout,
max_retries=parsed_args.max_retries,
retry_timeout=parsed_args.retry_timeout,
) )
if parsed_args.provide: if parsed_args.provide:

View File

@ -164,6 +164,16 @@ class IntrospectNode(command.Command):
default=20, default=20,
help=_('Maximum number of nodes to introspect at ' help=_('Maximum number of nodes to introspect at '
'once.')) 'once.'))
parser.add_argument('--node-timeout', type=int,
default=1200,
help=_('Maximum timeout for node introspection.'))
parser.add_argument('--max-retries', type=int,
default=1,
help=_('Maximum introspection retries.'))
parser.add_argument('--retry-timeout', type=int,
default=120,
help=_('Maximum timeout between introspection'
'retries'))
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -174,6 +184,9 @@ class IntrospectNode(command.Command):
self.app.client_manager, self.app.client_manager,
run_validations=parsed_args.run_validations, run_validations=parsed_args.run_validations,
concurrency=parsed_args.concurrency, concurrency=parsed_args.concurrency,
node_timeout=parsed_args.node_timeout,
max_retries=parsed_args.max_retries,
retry_timeout=parsed_args.retry_timeout,
verbosity=oooutils.playbook_verbosity(self=self) verbosity=oooutils.playbook_verbosity(self=self)
) )
else: else:
@ -182,6 +195,9 @@ class IntrospectNode(command.Command):
node_uuids=parsed_args.node_uuids, node_uuids=parsed_args.node_uuids,
run_validations=parsed_args.run_validations, run_validations=parsed_args.run_validations,
concurrency=parsed_args.concurrency, concurrency=parsed_args.concurrency,
node_timeout=parsed_args.node_timeout,
max_retries=parsed_args.max_retries,
retry_timeout=parsed_args.retry_timeout,
verbosity=oooutils.playbook_verbosity(self=self) verbosity=oooutils.playbook_verbosity(self=self)
) )

View File

@ -158,7 +158,7 @@ def provide_manageable_nodes(clients, verbosity=0):
def introspect(clients, node_uuids, run_validations, concurrency, def introspect(clients, node_uuids, run_validations, concurrency,
verbosity=0): node_timeout, max_retries, retry_timeout, verbosity=0):
"""Introspect Baremetal Nodes """Introspect Baremetal Nodes
:param clients: Application client object. :param clients: Application client object.
@ -188,6 +188,10 @@ def introspect(clients, node_uuids, run_validations, concurrency,
"node_uuids": node_uuids, "node_uuids": node_uuids,
"run_validations": run_validations, "run_validations": run_validations,
"concurrency": concurrency, "concurrency": concurrency,
"node_timeout": node_timeout,
"max_retries": max_retries,
"retry_timeout": retry_timeout,
} }
) )
@ -195,17 +199,27 @@ def introspect(clients, node_uuids, run_validations, concurrency,
def introspect_manageable_nodes(clients, run_validations, concurrency, def introspect_manageable_nodes(clients, run_validations, concurrency,
node_timeout, max_retries, retry_timeout,
verbosity=0): verbosity=0):
"""Introspect all manageable nodes """Introspect all manageable nodes
:param clients: Application client object. :param clients: Application client object.
:type clients: Object :type clients: Object
:param verbosity: Enable or disable validations :param run_validations: Enable or disable validations
:type verbosity: Boolean :type run_validations: Boolean
:param verbosity: concurrency level :param concurrency: Concurrency level
:type verbosity: Integer :type concurrency: Integer
:param node_timeout: Node timeout for introspection
:type node_timeout: Integer
:param max_retries: Max retries for introspection
:type max_retries: Integer
:param retry_timeout: Max timeout to wait between retries
:type retry_timeout: Integer
:param verbosity: Verbosity level :param verbosity: Verbosity level
:type verbosity: Integer :type verbosity: Integer
@ -219,6 +233,9 @@ def introspect_manageable_nodes(clients, run_validations, concurrency,
], ],
run_validations=run_validations, run_validations=run_validations,
concurrency=concurrency, concurrency=concurrency,
node_timeout=node_timeout,
max_retries=max_retries,
retry_timeout=retry_timeout,
verbosity=verbosity verbosity=verbosity
) )