diff --git a/HISTORY.rst b/HISTORY.rst index 99ae622..abb2bf3 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,7 @@ History - Accept id field set to None on resource creation. - Disabling of sudo command wasn't working. - Fix volume cloning on XtremIO + - Fix iSCSI detach issue related to privsep 0.1.0 (2017-11-03) ------------------ diff --git a/cinderlib/cinderlib.py b/cinderlib/cinderlib.py index b7cdcf0..aecedff 100644 --- a/cinderlib/cinderlib.py +++ b/cinderlib/cinderlib.py @@ -226,6 +226,19 @@ class Backend(object): volume_cmd.logging.setup(volume_cmd.CONF, 'cinder') volume_cmd.python_logging.captureWarnings(True) + @staticmethod + def unlink_root(*links, **kwargs): + no_errors = kwargs.get('no_errors', False) + raise_at_end = kwargs.get('raise_at_end', False) + exc = brick_exception.ExceptionChainer() + catch_exception = no_errors or raise_at_end + for link in links: + with exc.context(catch_exception, 'Unlink failed for %s', link): + putils.execute('unlink', link, run_as_root=True, + root_helper=Backend.root_helper) + if not no_errors and raise_at_end and exc: + raise exc + @classmethod def _set_priv_helper(cls, root_helper): utils.get_root_helper = lambda: root_helper @@ -254,6 +267,8 @@ class Backend(object): utils.connector.get_connector_properties = my_bgcp utils.connector.InitiatorConnector.factory = staticmethod(my_bgc) + if hasattr(rootwrap, 'unlink_root'): + rootwrap.unlink_root = cls.unlink_root @classmethod def _set_coordinator(cls, file_locks_path):