mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Move SPM's parser to salt.utils.parsers
and add -y
to it
This commit is contained in:
parent
cfd904d3a8
commit
b86ff4dc90
2 changed files with 29 additions and 24 deletions
|
@ -9,43 +9,22 @@
|
|||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function
|
||||
import os.path
|
||||
import logging
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Salt libs
|
||||
import salt.client.spm
|
||||
import salt.utils.parsers as parsers
|
||||
import salt.version
|
||||
import salt.syspaths as syspaths
|
||||
|
||||
# Import 3rd-party libs
|
||||
import salt.ext.six as six
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SPM(six.with_metaclass(parsers.OptionParserMeta, # pylint: disable=W0232
|
||||
parsers.OptionParser, parsers.ConfigDirMixIn,
|
||||
parsers.LogLevelMixIn, parsers.MergeConfigMixIn)):
|
||||
class SPM(parsers.SPMParser):
|
||||
'''
|
||||
The cli parser object used to fire up the salt spm system.
|
||||
'''
|
||||
|
||||
VERSION = salt.version.__version__
|
||||
|
||||
# ConfigDirMixIn config filename attribute
|
||||
_config_filename_ = 'spm'
|
||||
# LogLevelMixIn attributes
|
||||
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'spm')
|
||||
|
||||
def setup_config(self):
|
||||
return salt.config.spm_config(self.get_config_file_path())
|
||||
|
||||
def run(self):
|
||||
'''
|
||||
Run the api
|
||||
'''
|
||||
import salt.client.spm
|
||||
self.parse_args()
|
||||
self.setup_logfile_logger()
|
||||
client = salt.client.spm.SPMClient(self.config)
|
||||
|
|
|
@ -2598,3 +2598,29 @@ class SaltCloudParser(six.with_metaclass(OptionParserMeta,
|
|||
return config.cloud_config(self.get_config_file_path())
|
||||
except salt.exceptions.SaltCloudConfigError as exc:
|
||||
self.error(exc)
|
||||
|
||||
|
||||
class SPMParser(six.with_metaclass(OptionParserMeta,
|
||||
OptionParser,
|
||||
ConfigDirMixIn,
|
||||
LogLevelMixIn,
|
||||
MergeConfigMixIn)):
|
||||
'''
|
||||
The cli parser object used to fire up the salt spm system.
|
||||
'''
|
||||
|
||||
# ConfigDirMixIn config filename attribute
|
||||
_config_filename_ = 'spm'
|
||||
# LogLevelMixIn attributes
|
||||
_default_logging_logfile_ = os.path.join(syspaths.LOGS_DIR, 'spm')
|
||||
|
||||
def _mixin_setup(self):
|
||||
self.add_option(
|
||||
'-y', '--assume-yes',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Default yes in answer to all confirmation questions.'
|
||||
)
|
||||
|
||||
def setup_config(self):
|
||||
return salt.config.spm_config(self.get_config_file_path())
|
||||
|
|
Loading…
Add table
Reference in a new issue