]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/orch: add refresh option to inventory query 26346/head
authorNoah Watkins <noahwatkins@gmail.com>
Fri, 8 Feb 2019 23:25:55 +0000 (15:25 -0800)
committerNoah Watkins <noahwatkins@gmail.com>
Mon, 11 Feb 2019 23:27:21 +0000 (15:27 -0800)
allow a user of the orchestrator interface to express that the inventory
query should not read from any cached inventory state.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
qa/tasks/mgr/test_orchestrator_cli.py
src/pybind/mgr/ansible/module.py
src/pybind/mgr/deepsea/module.py
src/pybind/mgr/orchestrator.py
src/pybind/mgr/orchestrator_cli/module.py
src/pybind/mgr/rook/module.py
src/pybind/mgr/test_orchestrator/module.py

index 3caa956e3b0fe6e16ba54edd502705cf64c5eee8..aed68f21acc010061ff24fe821c075e76b7913f7 100644 (file)
@@ -39,6 +39,10 @@ class TestOrchestratorCli(MgrTestCase):
         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)
index 0183d8389e12020e2d5e8b2417d4f35fdbc757bc..b94f0057325bd2deded1e4a2dc2f158c46b560cf 100644 (file)
@@ -267,10 +267,11 @@ class Module(MgrModule, orchestrator.Orchestrator):
         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)
         """
 
index 344770be6e8958d612774a5505f495e97dbdeebb..e31a18c4bbbf81928243af61ae02d328d7cc0950 100644 (file)
@@ -120,7 +120,7 @@ class DeepSeaOrchestrator(MgrModule, orchestrator.Orchestrator):
         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.
index 0ace09d714e36c2f17a68a9ebee15d712ec4995f..c6b300c2ccc11e14e3b2472cdc676d7216d90576 100644 (file)
@@ -216,8 +216,8 @@ class Orchestrator(object):
         """
         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`.
 
index 211b6c957ac3711cca76e62ac72fde185ccd9799..f6043cd9b641f9dce58c45aa03b495992935dfff 100644 (file)
@@ -44,11 +44,12 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
 
     @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
 
@@ -58,7 +59,7 @@ class OrchestratorCli(orchestrator.OrchestratorClientMixin, MgrModule):
         """
         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])
 
index 2199b43a819d68b14c7e727c1bac48c8201ee98b..f9ae9d07a6a159cdce1f0106322dffceb8e55e3b 100644 (file)
@@ -294,7 +294,7 @@ class RookOrchestrator(MgrModule, orchestrator.Orchestrator):
         # 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
index de0a819eab953c276f4da134136174e98dfa5c29..116ef220083e67104a6d32c56b118e170b06f993 100644 (file)
@@ -203,7 +203,7 @@ class TestOrchestrator(MgrModule, orchestrator.Orchestrator):
             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.
         """