def _raw_cmd(self, *args):
return self.get_ceph_cmd_stdout(args)
- def __check_clone_state(self, state, clone, clone_group=None, timo=120):
+ def __check_clone_state(self, states, clone, clone_group=None, timo=120):
+ if isinstance(states, str):
+ states = (states, )
+
check = 0
args = ["clone", "status", self.volname, clone]
if clone_group:
args = tuple(args)
while check < timo:
result = json.loads(self._fs_cmd(*args))
- if result["status"]["state"] == state:
+ if result["status"]["state"] in states:
break
check += 1
time.sleep(1)
result = json.loads(self._fs_cmd(*args))
return result
+ def _wait_for_clone_to_be_pending(self, clone, clone_group=None,
+ timo=120):
+ # check for "in-progress" state too along with "pending" state, because
+ # if former has occurred it means latter has occured before (which can
+ # happen for such a small time that it is easy to miss) and it won't
+ # occur again.
+ states = ('pending', 'in-progress')
+ self.__check_clone_state(states, clone, clone_group, timo)
+
+ def _wait_for_clone_to_be_canceled(self, clone, clone_group=None,
+ timo=120):
+ # check for "cancelled" state too along with "complete" state, because
+ # it takes some time for a clone job to be cancelled and in that time
+ # a clone job might finish.
+ states = ('canceled', 'complete')
+ self.__check_clone_state(states, clone, clone_group, timo)
+
def _wait_for_clone_to_complete(self, clone, clone_group=None, timo=120):
self.__check_clone_state("complete", clone, clone_group, timo)