2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-25 11:01:09 +00:00

Fix nodelicense save with expansion

Client side checking will not suffice.  Move it server side.

Additionally ,fix ownership of downloaded files.
This commit is contained in:
Jarrod Johnson 2020-04-09 08:20:55 -04:00
parent 017f3fb372
commit 8d1d19d9a8
3 changed files with 15 additions and 16 deletions

View File

@ -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', {}):

View File

@ -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):

View File

@ -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):