diff --git a/confluent_client/bin/nodelicense b/confluent_client/bin/nodelicense index babb4abf..fe83281a 100755 --- a/confluent_client/bin/nodelicense +++ b/confluent_client/bin/nodelicense @@ -65,10 +65,6 @@ client.check_globbing(noderange) def install_license(session, filename): global exitcode - if not os.path.exists(filename): - sys.stderr.write('Unable to locate requested file {0}\n'.format( - filename)) - sys.exit(404) resource = '/noderange/{0}/configuration/' \ 'management_controller/licenses/'.format(noderange) filename = os.path.abspath(filename) @@ -87,10 +83,6 @@ def save_licenses(session, dirname): resource = '/noderange/{0}/configuration/' \ 'management_controller/save_licenses'.format(noderange) filename = os.path.abspath(dirname) - if not os.path.exists(filename): - sys.stderr.write('Unable to locate specified directory {0}\n'.format( - filename)) - sys.exit(404) instargs = {'dirname': filename} for res in session.create(resource, instargs): for node in res.get('databynode', {}): diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index a067f060..2aeb56a6 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -29,6 +29,7 @@ import eventlet.queue as queue import eventlet.support.greendns from fnmatch import fnmatch import os +import pwd import pyghmi.constants as pygconstants import pyghmi.exceptions as pygexc import pyghmi.storage as storage @@ -1503,14 +1504,17 @@ class IpmiHandler(object): def save_licenses(self): directory = self.inputdata.nodefile(self.node) checkdir = directory - if not os.path.isdir(checkdir): - checkdir = os.path.dirname(checkdir) - if not os.access(checkdir, os.W_OK): + if not os.access(directory, os.W_OK): raise exc.InvalidArgumentException( 'The confluent system user/group is unable to write to ' 'directory {0}, check ownership and permissions'.format( checkdir)) for saved in self.ipmicmd.save_licenses(directory): + try: + pwent = pwd.getpwnam(self.current_user) + os.chown(saved, pwent.pw_uid, pwent.pw_gid) + except KeyError: + pass self.output.put(msg.SavedFile(self.node, saved)) def handle_licenses(self): diff --git a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py index 277ee46e..bd0a1342 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/redfish.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/redfish.py @@ -27,6 +27,7 @@ import eventlet.queue as queue import eventlet.support.greendns from fnmatch import fnmatch import os +import pwd import pyghmi.constants as pygconstants import pyghmi.exceptions as pygexc import pyghmi.storage as storage @@ -1347,15 +1348,17 @@ class IpmiHandler(object): def save_licenses(self): directory = self.inputdata.nodefile(self.node) - checkdir = directory - if not os.path.isdir(checkdir): - checkdir = os.path.dirname(checkdir) - if not os.access(checkdir, os.W_OK): + if not os.access(directory, os.W_OK): raise exc.InvalidArgumentException( 'The confluent system user/group is unable to write to ' 'directory {0}, check ownership and permissions'.format( - checkdir)) + directory)) for saved in self.ipmicmd.save_licenses(directory): + try: + pwent = pwd.getpwnam(self.current_user) + os.chown(saved, pwent.pw_uid, pwent.pw_gid) + except KeyError: + pass self.output.put(msg.SavedFile(self.node, saved)) def handle_licenses(self):