From 26495b75bb2ace278214d5961eefbd21014811b9 Mon Sep 17 00:00:00 2001 From: Lucian Petrut Date: Tue, 9 Feb 2021 13:22:59 +0200 Subject: [PATCH] Fix Windows support With a single line change, we can use this cinder client extension on Windows. This patch will avoid the os.getuid call, which is unavailable on Windows. Note that on Windows, we aren't doing any privilege escalation, assuming that we already have the required rights. Here's a sample: http://paste.openstack.org/raw/802466/ Change-Id: Ic554b5df2adee38b97665c578ca69b33c8694ca7 --- README.rst | 2 +- brick_cinderclient_ext/brick_utils.py | 2 +- releasenotes/notes/windows-support-c12b7b922aa43272.yaml | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/windows-support-c12b7b922aa43272.yaml diff --git a/README.rst b/README.rst index 7e44035..61e3aff 100644 --- a/README.rst +++ b/README.rst @@ -30,7 +30,7 @@ Optional dependencies based on Cinder driver's protocol:: * open-iscsi, udev - for volume attachment via iSCSI -NOTE (e0ne): current version is tested only on Linux hosts +NOTE (e0ne): current version is tested on Linux and Windows hosts For any other information, refer to the parent projects, Cinder and python-cinderclient:: diff --git a/brick_cinderclient_ext/brick_utils.py b/brick_cinderclient_ext/brick_utils.py index b814341..1d2946e 100644 --- a/brick_cinderclient_ext/brick_utils.py +++ b/brick_cinderclient_ext/brick_utils.py @@ -62,7 +62,7 @@ def get_root_helper(): def require_root(f): def wrapper(*args, **kwargs): - if os.getuid() != 0: + if hasattr(os, 'getuid') and os.getuid() != 0: raise exceptions.CommandError( "This command requires root permissions.") return f(*args, **kwargs) diff --git a/releasenotes/notes/windows-support-c12b7b922aa43272.yaml b/releasenotes/notes/windows-support-c12b7b922aa43272.yaml new file mode 100644 index 0000000..5487421 --- /dev/null +++ b/releasenotes/notes/windows-support-c12b7b922aa43272.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Added Windows support.