]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: make upgrade ls output structured
authorSage Weil <sage@newdream.net>
Fri, 15 Oct 2021 15:09:07 +0000 (11:09 -0400)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 2 Nov 2021 09:01:22 +0000 (10:01 +0100)
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit be3fd05fc59bd523c1171d18cb0a0784f6a6d5c1)

src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/upgrade.py
src/pybind/mgr/orchestrator/_interface.py

index e226500af24d666bebcc9354db85a1a9d4b63ef3..b1793535aded024cc8fcf5ecfad1cac9f87374ae 100644 (file)
@@ -2611,7 +2611,7 @@ Then run the following:
         return self.upgrade.upgrade_status()
 
     @handle_orch_error
-    def upgrade_ls(self, image: Optional[str], tags: bool) -> List[str]:
+    def upgrade_ls(self, image: Optional[str], tags: bool) -> Dict[Any, Any]:
         return self.upgrade.upgrade_ls(image, tags)
 
     @handle_orch_error
index 3057307f6e4813676bb04d47384017b92846f0e6..f6b638b466328d2c915a073277de57d08f714c0f 100644 (file)
@@ -2,7 +2,7 @@ import json
 import logging
 import time
 import uuid
-from typing import TYPE_CHECKING, Optional, Dict, List, Tuple
+from typing import TYPE_CHECKING, Optional, Dict, List, Tuple, Any
 
 import orchestrator
 from cephadm.registry import Registry
@@ -183,15 +183,18 @@ class CephadmUpgrade:
 
         return None
 
-    def upgrade_ls(self, image: Optional[str], tags: bool) -> List[str]:
-        if image:
-            reg_name, image = image.split('/', 1)
-        else:
-            reg_name, image = self.mgr.container_image_base.split('/', 1)
-        self.mgr.log.info(f'reg_name {reg_name} image {image}')
+    def upgrade_ls(self, image: Optional[str], tags: bool) -> Dict:
+        if not image:
+            image = self.mgr.container_image_base
+        reg_name, bare_image = image.split('/', 1)
         reg = Registry(reg_name)
         versions = []
-        ls = reg.get_tags(image)
+        r: Dict[Any, Any] = {
+            "image": image,
+            "registry": reg_name,
+            "bare_image": bare_image,
+        }
+        ls = reg.get_tags(bare_image)
         if not tags:
             for t in ls:
                 if t[0] != 'v':
@@ -202,14 +205,14 @@ class CephadmUpgrade:
                 if '-' in v[2]:
                     continue
                 versions.append('.'.join(v))
-            ls = sorted(
+            r["versions"] = sorted(
                 versions,
                 key=lambda k: list(map(int, k.split('.'))),
                 reverse=True
             )
         else:
-            ls = sorted(ls)
-        return ls
+            r["tags"] = sorted(ls)
+        return r
 
     def upgrade_start(self, image: str, version: str) -> str:
         if self.mgr.mode != 'root':
index 1770206476485e1d505c83f645a5f56f9efb21f6..52cba997c155dab27f7e4133ed995c275d05cd8d 100644 (file)
@@ -647,7 +647,7 @@ class Orchestrator(object):
     def upgrade_check(self, image: Optional[str], version: Optional[str]) -> OrchResult[str]:
         raise NotImplementedError()
 
-    def upgrade_ls(self, image: Optional[str], tags: bool) -> OrchResult[List[str]]:
+    def upgrade_ls(self, image: Optional[str], tags: bool) -> OrchResult[Dict[Any, Any]]:
         raise NotImplementedError()
 
     def upgrade_start(self, image: Optional[str], version: Optional[str]) -> OrchResult[str]: