Example #1
0
def register_power_device(sender, instance, created, **kwargs):
    from chroma_core.services.power_control.rpc import PowerControlRpc
    if instance.not_deleted is None:
        return

    if not created:
        PowerControlRpc().reregister_device(instance.id)
    else:
        PowerControlRpc().register_device(instance.id)
    def run(self):
        from chroma_core.services.power_control.manager import PowerControlManager
        from chroma_core.services.power_control.monitor_daemon import PowerMonitorDaemon
        from chroma_core.services.power_control.rpc import PowerControlRpc

        super(Service, self).run()

        manager = PowerControlManager()
        monitor_daemon = PowerMonitorDaemon(manager)

        self._rpc_thread = ServiceThread(PowerControlRpc(manager))
        self._monitor_daemon_thread = ServiceThread(monitor_daemon)

        self._rpc_thread.start()
        self._monitor_daemon_thread.start()

        self._children_started.set()
        self._complete.wait()
Example #3
0
 def remove_device(cls, sockaddr):
     return PowerControlRpc().remove_device(sockaddr)
Example #4
0
    def create_device(cls, device_data):
        from chroma_core.models import PowerControlDevice

        device_id = PowerControlRpc().create_device(device_data)
        return PowerControlDevice.objects.get(pk=device_id)
Example #5
0
 def toggle_device_outlets(cls, toggle_state, outlets):
     outlet_ids = [o.id for o in outlets]
     return PowerControlRpc().toggle_device_outlets(toggle_state, outlet_ids)
Example #6
0
 def query_device_outlets(cls, device):
     return PowerControlRpc().query_device_outlets(device.id)
Example #7
0
def unregister_power_device(sender, instance, **kwargs):
    from chroma_core.services.power_control.rpc import PowerControlRpc
    PowerControlRpc().unregister_device(instance.sockaddr)