mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #25034 from s0undt3ch/features/spm-parser
Move SPM's parser to `salt.utils.parsers` and add `-y` to it
This commit is contained in:
commit
7a5497c5d9
@ -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())
|
||||
|
11
setup.py
11
setup.py
@ -749,7 +749,7 @@ class SaltDistribution(distutils.dist.Distribution):
|
||||
scripts.append('scripts/salt-ssh')
|
||||
if IS_WINDOWS_PLATFORM:
|
||||
return scripts
|
||||
scripts.extend(['scripts/salt-cloud', 'scripts/salt-run'])
|
||||
scripts.extend(['scripts/salt-cloud', 'scripts/salt-run', 'scripts/spm'])
|
||||
return scripts
|
||||
|
||||
if IS_WINDOWS_PLATFORM:
|
||||
@ -769,7 +769,8 @@ class SaltDistribution(distutils.dist.Distribution):
|
||||
'scripts/salt-run',
|
||||
'scripts/salt-ssh',
|
||||
'scripts/salt-syndic',
|
||||
'scripts/salt-unity'])
|
||||
'scripts/salt-unity',
|
||||
'scripts/spm'])
|
||||
return scripts
|
||||
|
||||
@property
|
||||
@ -787,7 +788,8 @@ class SaltDistribution(distutils.dist.Distribution):
|
||||
if IS_WINDOWS_PLATFORM:
|
||||
scripts.extend(['salt-cp = salt.scripts:salt_cp',
|
||||
'salt-minion = salt.scripts:salt_minion',
|
||||
'salt-unity = salt.scripts:salt_unity'])
|
||||
'salt-unity = salt.scripts:salt_unity',
|
||||
'spm = salt.scripts:salt_spm'])
|
||||
return {'console_scripts': scripts}
|
||||
|
||||
# *nix, so, we need all scripts
|
||||
@ -801,7 +803,8 @@ class SaltDistribution(distutils.dist.Distribution):
|
||||
'salt-run = salt.scripts:salt_run',
|
||||
'salt-ssh = salt.scripts:salt_ssh',
|
||||
'salt-syndic = salt.scripts:salt_syndic',
|
||||
'salt-unity = salt.scripts:salt_unity'])
|
||||
'salt-unity = salt.scripts:salt_unity',
|
||||
'spm = salt.scripts:salt_spm'])
|
||||
return {'console_scripts': scripts}
|
||||
# <---- Dynamic Data ---------------------------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user