mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Added service.config function
This commit is contained in:
parent
1c6c394d0e
commit
3937380b79
1 changed files with 117 additions and 0 deletions
|
@ -443,6 +443,123 @@ def create(name,
|
|||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
def config(name,
|
||||
bin_path=None,
|
||||
display_name=None,
|
||||
type=None,
|
||||
start=None,
|
||||
error=None,
|
||||
group=None,
|
||||
tag=None,
|
||||
depend=None,
|
||||
obj=None,
|
||||
password=None,
|
||||
**kwargs):
|
||||
r'''
|
||||
Modify the named service.
|
||||
|
||||
.. versionadded:: Boron
|
||||
|
||||
Required parameters:
|
||||
|
||||
:param str name: Specifies the service name returned by the getkeyname
|
||||
operation
|
||||
|
||||
|
||||
Optional parameters:
|
||||
|
||||
:param str bin_path: Specifies the path to the service binary file,
|
||||
backslashes must be escaped
|
||||
- eg: C:\\path\\to\\binary.exe
|
||||
|
||||
:param str display_name: the name to be displayed in the service manager
|
||||
Specifies a more descriptive name for identifying the service in user
|
||||
interface programs.
|
||||
|
||||
:param str type: Specifies the service type. Acceptable values are:
|
||||
- own (default): Service runs in its own process
|
||||
- share: Service runs as a shared process
|
||||
- interact: Service can interact with the desktop
|
||||
- kernel: Service is a driver
|
||||
- filesys: Service is a system driver
|
||||
- rec: Service is a file system-recognized driver that identifies
|
||||
filesystems on the computer
|
||||
- adapt: Service is an adapter driver that identifies hardware such as
|
||||
keyboards, mice and disk drives
|
||||
|
||||
:param str start: Specifies the start type for the service: Acceptable
|
||||
values are:
|
||||
- boot: Device driver that is loaded by the boot loader
|
||||
- system: Device driver that is started during kernel initialization
|
||||
- auto: Service that automatically starts
|
||||
- demand (default): Service must be started manually
|
||||
- disabled: Service cannot be started
|
||||
- delayed-auto: Service starts automatically after other auto-services
|
||||
start
|
||||
|
||||
:param str error: Specifies the severity of the error if the service
|
||||
fails to start. Acceptable values are:
|
||||
- normal (default): Error is logged and a message box is displayed
|
||||
- severe: Error is logged and computer attempts a restart with last
|
||||
known good configuration
|
||||
- critical: Error is logged, computer attempts to restart with last
|
||||
known good configuration, system halts on failure
|
||||
- ignore: Error is logged and startup continues, no notification is
|
||||
given to the user
|
||||
|
||||
:param str group: Specifies the name of the group of which this service
|
||||
is a member. The list of groups is stored in the registry, in the
|
||||
HKLM\System\CurrentControlSet\Control\ServiceGroupOrder subkey. The
|
||||
default is null.
|
||||
|
||||
:param str tag: Specifies whether or not to obtain a TagID from the
|
||||
CreateService call. For boot-start and system-start drivers only.
|
||||
Acceptable values are:
|
||||
- yes/no
|
||||
|
||||
:param str depend: Specifies the names of services or groups that must
|
||||
start before this service. The names are separated by forward slashes.
|
||||
|
||||
:param str obj: Specifies th name of an account in which a service will
|
||||
run or specifies a name of the Windows driver object in which the driver
|
||||
will run. Default is LocalSystem
|
||||
|
||||
:param str password: Specifies a password. Required if other than
|
||||
LocalSystem account is used.
|
||||
|
||||
:return: True if successful, False if not
|
||||
:rtype: bool
|
||||
|
||||
CLI Example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' service.config <service name> <path to exe> display_name='<display name>'
|
||||
'''
|
||||
|
||||
cmd = ['sc', 'config', name]
|
||||
if bin_path is not None:
|
||||
cmd.extend(['binpath=', bin_path])
|
||||
if type is not None:
|
||||
cmd.extend(['type=', type])
|
||||
if start is not None:
|
||||
cmd.extend(['start=', start])
|
||||
if error is not None:
|
||||
cmd.extend(['error=', error])
|
||||
if display_name is not None:
|
||||
cmd.extend(['DisplayName=', DisplayName])
|
||||
if group is not None:
|
||||
cmd.extend(['group=', group])
|
||||
if depend is not None:
|
||||
cmd.extend(['depend=', depend])
|
||||
if obj is not None:
|
||||
cmd.extend(['obj=', obj])
|
||||
if password is not None:
|
||||
cmd.extend(['password=', password])
|
||||
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False
|
||||
|
||||
|
||||
def delete(name):
|
||||
'''
|
||||
Delete the named service
|
||||
|
|
Loading…
Add table
Reference in a new issue