/usr/lib/python3/dist-packages/provisioningserver/service_monitor.py is in python3-maas-provisioningserver 2.0.0~beta3+bzr4941-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | # Copyright 2015-2016 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Services monitored on rackd."""
__all__ = [
]
from provisioningserver.utils.service_monitor import (
AlwaysOnService,
Service,
SERVICE_STATE,
ServiceMonitor,
)
class DHCPService(Service):
"""Abstract monitored dhcp service."""
def __init__(self):
super(DHCPService, self).__init__()
self.expected_state = SERVICE_STATE.OFF
def get_expected_state(self):
"""Return a the expected state for the dhcp service.
The dhcp service always starts as off. Once the rackd starts dhcp
`expected_state` will be set to ON.
"""
return (self.expected_state, None)
def is_on(self):
"""Return true if the service should be on."""
return self.expected_state == SERVICE_STATE.ON
def on(self):
"""Set the expected state of the service to `ON`."""
self.expected_state = SERVICE_STATE.ON
def off(self):
"""Set the expected state of the service to `OFF`."""
self.expected_state = SERVICE_STATE.OFF
class DHCPv4Service(DHCPService):
name = "dhcpd"
service_name = "maas-dhcpd"
class DHCPv6Service(DHCPService):
name = "dhcpd6"
service_name = "maas-dhcpd6"
class TGTService(AlwaysOnService):
"""Monitored tgt service."""
name = "tgt"
service_name = "tgt"
# Global service monitor for rackd.
service_monitor = ServiceMonitor(
DHCPv4Service(),
DHCPv6Service(),
TGTService(),
)
|