Skip to content

Commit

Permalink
Merge pull request #26346 from noahdesu/mgr-orch-cache-refresh
Browse files Browse the repository at this point in the history
mgr/orch: refresh option for inventory query

Reviewed-by: Sebastian Wagner <sebastian.wagner@suse.com>
  • Loading branch information
sebastian-philipp committed Feb 13, 2019
2 parents 8cda5ea + 96c8a48 commit b8fe155
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
4 changes: 4 additions & 0 deletions qa/tasks/mgr/test_orchestrator_cli.py
Expand Up @@ -39,6 +39,10 @@ def test_device_ls(self):
ret = self._orch_cmd("device", "ls")
self.assertIn("localhost:", ret)

def test_device_ls_refresh(self):
ret = self._orch_cmd("device", "ls", "--refresh")
self.assertIn("localhost:", ret)

def test_device_ls_hoshs(self):
ret = self._orch_cmd("device", "ls", "localhost", "host1")
self.assertIn("localhost:", ret)
Expand Down
3 changes: 2 additions & 1 deletion src/pybind/mgr/ansible/module.py
Expand Up @@ -267,10 +267,11 @@ def shutdown(self):
self.log.info('Stopping Ansible orchestrator module')
self.run = False

def get_inventory(self, node_filter=None):
def get_inventory(self, node_filter=None, refresh=False):
"""
:param : node_filter instance
:param : refresh any cached state
:Return : A AnsibleReadOperation instance (Completion Object)
"""

Expand Down
2 changes: 1 addition & 1 deletion src/pybind/mgr/deepsea/module.py
Expand Up @@ -120,7 +120,7 @@ def available(self):
return True, ""


def get_inventory(self, node_filter=None):
def get_inventory(self, node_filter=None, refresh=False):
"""
Note that this will raise an exception (e.g. if the salt-api is down,
or the username/password is incorret). Same for other methods.
Expand Down
4 changes: 2 additions & 2 deletions src/pybind/mgr/orchestrator.py
Expand Up @@ -216,8 +216,8 @@ def get_hosts(self):
"""
return self.get_inventory()

def get_inventory(self, node_filter=None):
# type: (InventoryFilter) -> ReadCompletion[List[InventoryNode]]
def get_inventory(self, node_filter=None, refresh=False):
# type: (InventoryFilter, bool) -> ReadCompletion[List[InventoryNode]]
"""
Returns something that was created by `ceph-volume inventory`.
Expand Down
9 changes: 5 additions & 4 deletions src/pybind/mgr/orchestrator_cli/module.py
Expand Up @@ -71,11 +71,12 @@ def _get_hosts(self):

@CLIReadCommand('orchestrator device ls',
"name=host,type=CephString,n=N,req=false "
"name=format,type=CephChoices,strings=json|plain,req=false",
"name=format,type=CephChoices,strings=json|plain,req=false "
"name=refresh,type=CephBool,req=false",
'List devices on a node')
@handle_exceptions
def _list_devices(self, host=None, format='plain'):
# type: (List[str], str) -> HandleCommandResult
def _list_devices(self, host=None, format='plain', refresh=False):
# type: (List[str], str, bool) -> HandleCommandResult
"""
Provide information about storage devices present in cluster hosts
Expand All @@ -85,7 +86,7 @@ def _list_devices(self, host=None, format='plain'):
"""
nf = orchestrator.InventoryFilter(nodes=host) if host else None

completion = self.get_inventory(node_filter=nf)
completion = self.get_inventory(node_filter=nf, refresh=refresh)

self._orchestrator_wait([completion])

Expand Down
2 changes: 1 addition & 1 deletion src/pybind/mgr/rook/module.py
Expand Up @@ -294,7 +294,7 @@ def serve(self):
# things look a bit out of sync?

@deferred_read
def get_inventory(self, node_filter=None):
def get_inventory(self, node_filter=None, refresh=False):
node_list = None
if node_filter and node_filter.nodes:
# Explicit node list
Expand Down
2 changes: 1 addition & 1 deletion src/pybind/mgr/test_orchestrator/module.py
Expand Up @@ -202,7 +202,7 @@ def serve(self):
self._shutdown.wait(5)

@deferred_read
def get_inventory(self, node_filter=None):
def get_inventory(self, node_filter=None, refresh=False):
"""
There is no guarantee which devices are returned by get_inventory.
"""
Expand Down

0 comments on commit b8fe155

Please sign in to comment.