charmhelpers.core.services.base¶
ManagerCallback |
Special case of a callback that takes the ServiceManager instance in addition to the service name. |
PortManagerCallback |
Callback class that will open or close ports, for use as either a start or stop action. |
ServiceManager |
|
close_ports |
Callback class that will open or close ports, for use as either a start or stop action. |
manage_ports |
Callback class that will open or close ports, for use as either a start or stop action. |
open_ports |
Callback class that will open or close ports, for use as either a start or stop action. |
service_restart |
Wrapper around host.service_restart to prevent spurious “unknown service” messages in the logs. |
service_stop |
Wrapper around host.service_stop to prevent spurious “unknown service” messages in the logs. |
-
class
charmhelpers.core.services.base.
ServiceManager
(services=None)¶ Bases:
object
-
fire_event
(event_name, service_name, default=None)¶ Fire a data_ready, data_lost, start, or stop event on a given service.
-
get_service
(service_name)¶ Given the name of a registered service, return its service definition.
-
is_ready
(service_name)¶ Determine if a registered service is ready, by checking its ‘required_data’.
A ‘required_data’ item can be any mapping type, and is considered ready if bool(item) evaluates as True.
-
manage
()¶ Handle the current hook by doing The Right Thing with the registered services.
-
provide_data
()¶ Set the relation data for each provider in the
provided_data
list.A provider must have a name attribute, which indicates which relation to set data on, and a provide_data() method, which returns a dict of data to set.
The provide_data() method can optionally accept two parameters:
remote_service
The name of the remote service that the data will be provided to. The provide_data() method will be called once for each connected service (not unit). This allows the method to tailor its data to the given service.service_ready
Whether or not the service definition had all of its requirements met, and thus thedata_ready
callbacks run.
Note that the
provided_data
methods are now called after thedata_ready
callbacks are run. This gives thedata_ready
callbacks a chance to generate any data necessary for the providing to the remote services.
-
reconfigure_services
(*service_names)¶ Update all files for one or more registered services, and, if ready, optionally restart them.
If no service names are given, reconfigures all registered services.
-
save_lost
(service_name)¶ Save an indicator that the given service is no longer data_ready.
-
save_ready
(service_name)¶ Save an indicator that the given service is now data_ready.
-
stop_services
(*service_names)¶ Stop one or more registered services, by name.
If no service names are given, stops all registered services.
-
was_ready
(service_name)¶ Determine if the given service was previously data_ready.
-
-
class
charmhelpers.core.services.base.
ManagerCallback
¶ Bases:
object
Special case of a callback that takes the ServiceManager instance in addition to the service name.
Subclasses should implement __call__ which should accept three parameters:
- manager The ServiceManager instance
- service_name The name of the service it’s being triggered for
- event_name The name of the event that this callback is handling
-
class
charmhelpers.core.services.base.
PortManagerCallback
¶ Bases:
charmhelpers.core.services.base.ManagerCallback
Callback class that will open or close ports, for use as either a start or stop action.
-
ports_contains
(port, ports)¶
-
-
charmhelpers.core.services.base.
service_restart
(service_name)¶ Wrapper around host.service_restart to prevent spurious “unknown service” messages in the logs.
-
charmhelpers.core.services.base.
service_stop
(service_name)¶ Wrapper around host.service_stop to prevent spurious “unknown service” messages in the logs.