Service Script python reference¶
LMI service provider client library.
- lmi.scripts.service.enable_service(ns, service, enable=True)¶
Enable or disable service.
Parameters: - service (string or lmi.shell.LMIInstanceName) – Service name or instance.
- enable (boolean) – Whether the service should be enabled or disabled. Enabled service is started on system boot.
- lmi.scripts.service.get_enabled_string(ns, service)¶
Return human friendly string for enabled state.
Parameters: service – Either a service instance of its name. Returns: Status description. One of: { Yes, No, Static }. Where Static represents a service that can not be enabled or disabled, and are run only if something depends on them. It lacks [Install] section. Return type: string
- lmi.scripts.service.get_service(ns, service)¶
Return lmi.shell.LMIInstance object matching the given service name.
Parameters: service (string) – Service name.
- lmi.scripts.service.get_status_string(ns, service)¶
Return human friendly status description.
Parameters: service – Either a service instance or its name. Returns: Status description. One of { OK, Running, Stopped - OK, Stopped - Error }. Return type: string
- lmi.scripts.service.invoke_on_service(ns, method, service, description)¶
Invoke parameter-less method on given service.
Parameters: - method (string) – Name of method of LMI_Service to invoke.
- service (string or lmi.shell.LMIInstanceName) – Name of service or an instance to operate upon.
- description (string) – Description of what has been done with service. This is used just for logging.
Returns: Success flag.
Return type: boolean
- lmi.scripts.service.list_services(ns, kind='enabled')¶
List services. Yields service instances.
Parameters: kind (string) – What kind of services to list. Possible options are:
- ‘enabled’ - list only enabled services
- ‘disabled’ - list only disabled services
- ‘all’ - list all services
Returns: Instances of LMI_Service. Return type: generator over lmi.shell.LMIInstance.
- lmi.scripts.service.reload_service(ns, service, force=False, just_try=False)¶
Reload service.
Parameters: - service (string or lmi.shell.LMIInstanceName) – Service name or instance.
- force (boolean) – Whether the service should be restarted if the reload can no be done.
- just_try (boolean) – This applies only when force is True. If True, only the the running service will be restarted. Nothing is done for stopped service.
- lmi.scripts.service.restart_service(ns, service, just_try=False)¶
Restart service.
Parameters: - service (string or lmi.shell.LMIInstanceName) – Service name or instance.
- just_try (boolean) – When False, the service will be started even if it is not running. Otherwise only running service will be restarted.
- lmi.scripts.service.start_service(ns, service)¶
Start service.
Parameters: service (string or lmi.shell.LMIInstanceName) – Service name.
- lmi.scripts.service.stop_service(ns, service)¶
Stop service.
Parameters: service (string or lmi.shell.LMIInstanceName) – Service name or instance.