Add root-only warning when exporting system with Kiwi

This commit is contained in:
Bo Maryniuk 2016-06-11 15:06:38 +02:00
parent 9bd80f02fc
commit c87fff3680

View file

@ -20,6 +20,7 @@ Module for full system inspection.
from __future__ import absolute_import
import logging
import os
import getpass
from salt.modules.inspectlib.exceptions import (InspectorQueryException,
InspectorSnapshotException,
InspectorKiwiProcessorException)
@ -206,11 +207,13 @@ def export(local=False, path="/tmp", format='qcow2'):
* **path**: If `local=True`, then specifies the path where file with the Kiwi description is written.
Default: `/tmp`.
'''
#try:
description = _("query").Query('all', cachedir=__opts__['cachedir'])()
return _("collector").Inspector().export(description, local=local, path=path, format=format)
#except InspectorKiwiProcessorException as ex:
# raise CommandExecutionError(ex)
#except Exception as ex:
# log.error(_get_error_message(ex))
# raise Exception(ex)
if getpass.getuser() != 'root':
raise CommandExecutionError('In order to export system, the minion should run as "root".')
try:
description = _("query").Query('all', cachedir=__opts__['cachedir'])()
return _("collector").Inspector().export(description, local=local, path=path, format=format)
except InspectorKiwiProcessorException as ex:
raise CommandExecutionError(ex)
except Exception as ex:
log.error(_get_error_message(ex))
raise Exception(ex)