From 21f2bcf0613fbc64cc54a4c0ff17d61a5ec58b58 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 2 Dec 2019 16:02:46 -0600 Subject: [PATCH] mgr/orchestrator_cli: upgrade {start,pause,resume,stop} Signed-off-by: Sage Weil --- doc/mgr/orchestrator_modules.rst | 1 - src/pybind/mgr/orchestrator.py | 26 ++++++----- src/pybind/mgr/orchestrator_cli/module.py | 54 +++++++++++++++++++++++ 3 files changed, 69 insertions(+), 12 deletions(-) diff --git a/doc/mgr/orchestrator_modules.rst b/doc/mgr/orchestrator_modules.rst index faa1c675f29..52ca56d8819 100644 --- a/doc/mgr/orchestrator_modules.rst +++ b/doc/mgr/orchestrator_modules.rst @@ -314,7 +314,6 @@ Upgrades .. automethod:: Orchestrator.upgrade_available .. automethod:: Orchestrator.upgrade_start .. automethod:: Orchestrator.upgrade_status -.. autoclass:: UpgradeSpec .. autoclass:: UpgradeStatusSpec Utility diff --git a/src/pybind/mgr/orchestrator.py b/src/pybind/mgr/orchestrator.py index 58b460b4e0f..a8790879859 100644 --- a/src/pybind/mgr/orchestrator.py +++ b/src/pybind/mgr/orchestrator.py @@ -1008,12 +1008,22 @@ class Orchestrator(object): # type: (Optional[str], Optional[str]) -> Completion raise NotImplementedError() - @_hide_in_features - def upgrade_start(self, upgrade_spec): - # type: (UpgradeSpec) -> Completion + def upgrade_start(self, image, version): + # type: (Optional[str], Optional[str]) -> Completion + raise NotImplementedError() + + def upgrade_pause(self): + # type: () -> Completion + raise NotImplementedError() + + def upgrade_resume(self): + # type: () -> Completion + raise NotImplementedError() + + def upgrade_stop(self): + # type: () -> Completion raise NotImplementedError() - @_hide_in_features def upgrade_status(self): # type: () -> Completion """ @@ -1035,17 +1045,11 @@ class Orchestrator(object): raise NotImplementedError() -class UpgradeSpec(object): - # Request to orchestrator to initiate an upgrade to a particular - # version of Ceph - def __init__(self): - self.target_version = None - - class UpgradeStatusSpec(object): # Orchestrator's report on what's going on with any ongoing upgrade def __init__(self): self.in_progress = False # Is an upgrade underway? + self.target_image = None self.services_complete = [] # Which daemon types are fully updated? self.message = "" # Freeform description diff --git a/src/pybind/mgr/orchestrator_cli/module.py b/src/pybind/mgr/orchestrator_cli/module.py index 64391f428ba..82b3f38ca9d 100644 --- a/src/pybind/mgr/orchestrator_cli/module.py +++ b/src/pybind/mgr/orchestrator_cli/module.py @@ -745,3 +745,57 @@ Usage: self._orchestrator_wait([completion]) orchestrator.raise_if_exception(completion) return HandleCommandResult(stdout=completion.result_str()) + + @orchestrator._cli_write_command( + 'upgrade status', + desc='Check service versions vs available and target containers') + def _upgrade_status(self): + completion = self.upgrade_status() + self._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + r = { + 'target_image': completion.result.target_image, + 'in_progress': completion.result.in_progress, + 'services_complete': completion.result.services_complete, + 'message': completion.result.message, + } + out = json.dumps(r, indent=4) + return HandleCommandResult(stdout=out) + + @orchestrator._cli_write_command( + 'upgrade start', + 'name=image,type=CephString,req=false ' + 'name=ceph_version,type=CephString,req=false', + desc='Initiate upgrade') + def _upgrade_start(self, image=None, ceph_version=None): + completion = self.upgrade_start(image, ceph_version) + self._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) + + @orchestrator._cli_write_command( + 'upgrade pause', + desc='Pause an in-progress upgrade') + def _upgrade_pause(self): + completion = self.upgrade_pause() + self._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) + + @orchestrator._cli_write_command( + 'upgrade resume', + desc='Resume paused upgrade') + def _upgrade_resume(self): + completion = self.upgrade_resume() + self._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) + + @orchestrator._cli_write_command( + 'upgrade stop', + desc='Stop an in-progress upgrade') + def _upgrade_stop(self): + completion = self.upgrade_stop() + self._orchestrator_wait([completion]) + orchestrator.raise_if_exception(completion) + return HandleCommandResult(stdout=completion.result_str()) -- 2.39.5