diff options
author | Chuck Short <chucks@redhat.com> | 2018-09-16 22:02:53 -0400 |
---|---|---|
committer | Chuck Short <chucks@redhat.com> | 2018-09-17 09:09:42 -0400 |
commit | 4d54ceaa1936482b809a7c3bc6c901b564e1481c (patch) | |
tree | 199eb71432b13980116963ff74740c4bb83b869b /cinder/privsep | |
parent | 6b3456532c6f07cfe8577a1185e4b7f3ca4aedfd (diff) | |
download | cinder-4d54ceaa1936482b809a7c3bc6c901b564e1481c.tar.gz |
Move hscli to privsep
Move the hscli usage to privsep, this is basically a straight
copy of the hsexecute function.
Change-Id: I0a8f1502506b32fdd6599bc2d0c385ebeb968172
Signed-off-by: Chuck Short <chucks@redhat.com>
Diffstat (limited to 'cinder/privsep')
-rw-r--r-- | cinder/privsep/hscli.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cinder/privsep/hscli.py b/cinder/privsep/hscli.py new file mode 100644 index 000000000..4d7f85d66 --- /dev/null +++ b/cinder/privsep/hscli.py @@ -0,0 +1,45 @@ +# Copyright 2018 Red Hat, Inc +# Copyright (c) 2017 Veritas Technologies LLC. All rights reserved. +# Copyright 2017 Rackspace Australia +# Copyright 2018 Michael Still and Aptira +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +Helpers for hscli related routines +""" +from oslo_concurrency import processutils as putils +from oslo_log import log as logging + +from cinder import exception +import cinder.privsep + +LOG = logging.getLogger(__name__) + + +@cinder.privsep.sys_admin_pctxt.entrypoint +def hsexecute(cmdarg_json): + + cmd_out = None + cmd_err = None + try: + # call hyperscale cli + (cmd_out, cmd_err) = putils.execute("hscli", cmdarg_json) + except (putils.UnknownArgumentError, putils.ProcessExecutionError, + OSError): + LOG.error("Exception in running the command for %s", + cmdarg_json, + exc_info=True) + raise exception.UnableToExecuteHyperScaleCmd(command=cmdarg_json) + + return (cmd_out, cmd_err) |