~ahasenack/landscape-client/landscape-client-1.5.5.1-0ubuntu0.10.10.0

« back to all changes in this revision

Viewing changes to landscape/monitor/networkdevice.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2010-04-21 19:58:10 UTC
  • mfrom: (1.1.16 upstream)
  • Revision ID: james.westby@ubuntu.com-20100421195810-s30uv3s6i27lue38
Tags: 1.5.2-0ubuntu0.10.10.0
* New upstream version (LP: #594594):
  - A new includes information about active network devices and their
    IP address in sysinfo output (LP: #272344).
  - A new plugin collects information about network traffic (#LP :284662).
  - Report information about which packages requested a reboot (LP: #538253).
  - Fix breakage on Lucid AMIs having no ramdisk (LP: #574810).
  - Migrate the inter-process communication system from DBus to Twisted AMP.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
A monitor plugin that collects data on a machine's network devices.
 
3
"""
 
4
 
 
5
from landscape.monitor.plugin import DataWatcher
 
6
from landscape.lib.network import get_active_device_info
 
7
 
 
8
 
 
9
class NetworkDevice(DataWatcher):
 
10
 
 
11
    message_type = "network-device"
 
12
    message_key = "devices"
 
13
    persist_name = message_type
 
14
 
 
15
    def __init__(self, device_info=get_active_device_info):
 
16
        super(NetworkDevice, self).__init__()
 
17
        self._device_info = device_info
 
18
 
 
19
    def register(self, registry):
 
20
        super(NetworkDevice, self).register(registry)
 
21
        self.call_on_accepted(self.message_type, self.exchange, True)
 
22
        self.registry.reactor.call_on("resynchronize", self._resynchronize)
 
23
 
 
24
    def _resynchronize(self):
 
25
        """Resynchronize active network device information."""
 
26
        self._persist.set("data", [])
 
27
 
 
28
    def get_data(self):
 
29
        return self._device_info()