Merge lp:~therve/landscape-client/hal-soft-dep into lp:~landscape/landscape-client/trunk

Proposed by Thomas Herve
Status: Merged
Approved by: Jamu Kakar
Approved revision: 319
Merged at revision: 315
Proposed branch: lp:~therve/landscape-client/hal-soft-dep
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 243 lines (+91/-14)
8 files modified
debian/control (+2/-2)
debian/landscape-client.init (+2/-2)
debian/rules (+10/-4)
landscape/monitor/hardwareinventory.py (+11/-2)
landscape/monitor/mountinfo.py (+29/-2)
landscape/monitor/tests/test_mountinfo.py (+30/-0)
landscape/monitor/tests/test_service.py (+1/-0)
landscape/service.py (+6/-2)
To merge this branch: bzr merge lp:~therve/landscape-client/hal-soft-dep
Reviewer Review Type Date Requested Status
Jamu Kakar (community) Approve
Free Ekanayaka (community) Approve
Review via email: mp+47992@code.launchpad.net

Description of the change

The branch:
 * Handles import error from Hal and Dbus
 * Disable the hardware plugin when hal is not there
 * Use gudev in the mount plugin when hal is not there
 * Makes the packaging changes so that hal and python-dbus are suggested in natty, and depends on gudev instead.

To post a comment you must log in.
319. By Thomas Herve

Ignore pygi log errors

Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Looks good, though I didn't test it for real. +1!

review: Approve
Revision history for this message
Jamu Kakar (jkakar) wrote :

I've run the tests, but like Free, not tested it for real. Looks good
to me, +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2011-01-10 21:24:47 +0000
+++ debian/control 2011-01-31 13:37:33 +0000
@@ -35,8 +35,8 @@
35Architecture: any35Architecture: any
36Depends: ${python:Depends}, ${misc:Depends}, ${extra:Depends},36Depends: ${python:Depends}, ${misc:Depends}, ${extra:Depends},
37 python-twisted-web,37 python-twisted-web,
38 landscape-common (>= ${Source-Version}),38 landscape-common (>= ${Source-Version})
39 hal39Suggests: ${extra:Suggests}
40Description: The Landscape administration system client40Description: The Landscape administration system client
41 Landscape is a web-based tool for managing Ubuntu systems. This41 Landscape is a web-based tool for managing Ubuntu systems. This
42 package is necessary if you want your machine to be managed in a42 package is necessary if you want your machine to be managed in a
4343
=== modified file 'debian/landscape-client.init'
--- debian/landscape-client.init 2010-09-07 15:37:59 +0000
+++ debian/landscape-client.init 2011-01-31 13:37:33 +0000
@@ -2,8 +2,8 @@
22
3### BEGIN INIT INFO3### BEGIN INIT INFO
4# Provides: landscape-client4# Provides: landscape-client
5# Required-Start: $local_fs $remote_fs hal5# Required-Start: $local_fs $remote_fs
6# Required-Stop: $local_fs $remote_fs hal6# Required-Stop: $local_fs $remote_fs
7# Default-Start: 2 3 4 57# Default-Start: 2 3 4 5
8# Default-Stop: 0 1 68# Default-Stop: 0 1 6
9# Short-Description: Landscape client daemons9# Short-Description: Landscape client daemons
1010
=== modified file 'debian/rules'
--- debian/rules 2011-01-11 23:04:59 +0000
+++ debian/rules 2011-01-31 13:37:33 +0000
@@ -82,17 +82,23 @@
82ifneq (,$(findstring $(dist_release),"dapper"))82ifneq (,$(findstring $(dist_release),"dapper"))
83 # We need python2.4-pysqlite2 and a non-buggy libcurl3-gnutls on dapper83 # We need python2.4-pysqlite2 and a non-buggy libcurl3-gnutls on dapper
84 echo "extra:Depends=python2.4-pysqlite2, libcurl3-gnutls (>= 7.15.1-1ubuntu3), python-smartpm (>= 1.1.1~bzr20081010-0ubuntu1.6.06.0), python2.4-dbus" >> $(landscape_common_substvars)84 echo "extra:Depends=python2.4-pysqlite2, libcurl3-gnutls (>= 7.15.1-1ubuntu3), python-smartpm (>= 1.1.1~bzr20081010-0ubuntu1.6.06.0), python2.4-dbus" >> $(landscape_common_substvars)
85 echo "extra:Depends=python2.4-pycurl" >> $(landscape_client_substvars)85 echo "extra:Depends=python2.4-pycurl, hal" >> $(landscape_client_substvars)
86endif86endif
87ifneq (,$(findstring $(dist_release),"hardy"))87ifneq (,$(findstring $(dist_release),"hardy"))
88 # We want the smart 1.1.1 from the Landscape repository on hardy88 # We want the smart 1.1.1 from the Landscape repository on hardy
89 echo "extra:Depends=python-smartpm (>= 1.1.1~bzr20081010-0ubuntu1.8.04.1), python2.4-dbus" >> $(landscape_common_substvars)89 echo "extra:Depends=python-smartpm (>= 1.1.1~bzr20081010-0ubuntu1.8.04.1), python2.4-dbus" >> $(landscape_common_substvars)
90 echo "extra:Depends=python2.4-pycurl" >> $(landscape_client_substvars)90 echo "extra:Depends=python2.4-pycurl, hal" >> $(landscape_client_substvars)
91endif91endif
92ifeq (,$(filter $(dist_release),dapper hardy))92ifneq (,$(filter $(dist_release),karmic lucid maverick))
93 # We want libpam-modules in karmic, and smart 1.293 # We want libpam-modules in karmic, and smart 1.2
94 echo "extra:Depends=libpam-modules (>= 1.0.1-9ubuntu3), python-smartpm (>= 1.2-4), python-dbus" >> $(landscape_common_substvars)94 echo "extra:Depends=libpam-modules (>= 1.0.1-9ubuntu3), python-smartpm (>= 1.2-4), python-dbus" >> $(landscape_common_substvars)
95 echo "extra:Depends=python-pycurl" >> $(landscape_client_substvars)95 echo "extra:Depends=python-pycurl, hal" >> $(landscape_client_substvars)
96endif
97ifeq (,$(filter $(dist_release),dapper hardy karmic lucid maverick))
98 # Starting natty, no more hal or dbus
99 echo "extra:Depends=libpam-modules (>= 1.0.1-9ubuntu3), python-smartpm (>= 1.2-4)" >> $(landscape_common_substvars)
100 echo "extra:Depends=python-pycurl, gir1.2-gudev-1.0 (>= 165-0ubuntu2)" >> $(landscape_client_substvars)
101 echo "extra:Suggests=python-dbus, hal" >> $(landscape_client_substvars)
96endif102endif
97ifeq (,$(filter $(dist_release),dapper hardy karmic))103ifeq (,$(filter $(dist_release),dapper hardy karmic))
98 # The python-image-store-proxy package is needed for the eucalyptus plugin104 # The python-image-store-proxy package is needed for the eucalyptus plugin
99105
=== modified file 'landscape/monitor/hardwareinventory.py'
--- landscape/monitor/hardwareinventory.py 2010-12-10 13:57:11 +0000
+++ landscape/monitor/hardwareinventory.py 2011-01-31 13:37:33 +0000
@@ -5,7 +5,6 @@
5from landscape.lib.log import log_failure5from landscape.lib.log import log_failure
66
7from landscape.diff import diff7from landscape.diff import diff
8from landscape.hal import HALManager
9from landscape.monitor.plugin import MonitorPlugin8from landscape.monitor.plugin import MonitorPlugin
109
1110
@@ -17,9 +16,17 @@
17 super(HardwareInventory, self).__init__()16 super(HardwareInventory, self).__init__()
18 self._persist_sets = []17 self._persist_sets = []
19 self._persist_removes = []18 self._persist_removes = []
20 self._hal_manager = hal_manager or HALManager()19 self.enabled = True
20 try:
21 from landscape.hal import HALManager
22 except ImportError:
23 self.enabled = False
24 else:
25 self._hal_manager = hal_manager or HALManager()
2126
22 def register(self, manager):27 def register(self, manager):
28 if not self.enabled:
29 return
23 super(HardwareInventory, self).register(manager)30 super(HardwareInventory, self).register(manager)
24 self.call_on_accepted("hardware-inventory", self.exchange, True)31 self.call_on_accepted("hardware-inventory", self.exchange, True)
2532
@@ -37,6 +44,8 @@
37 return result44 return result
3845
39 def exchange(self, urgent=False):46 def exchange(self, urgent=False):
47 if not self.enabled:
48 return
40 return self.registry.broker.call_if_accepted("hardware-inventory",49 return self.registry.broker.call_if_accepted("hardware-inventory",
41 self.send_message, urgent)50 self.send_message, urgent)
4251
4352
=== modified file 'landscape/monitor/mountinfo.py'
--- landscape/monitor/mountinfo.py 2010-12-16 14:58:05 +0000
+++ landscape/monitor/mountinfo.py 2011-01-31 13:37:33 +0000
@@ -4,7 +4,6 @@
4from landscape.lib.disk import get_mount_info4from landscape.lib.disk import get_mount_info
5from landscape.lib.monitor import CoverageMonitor5from landscape.lib.monitor import CoverageMonitor
6from landscape.accumulate import Accumulator6from landscape.accumulate import Accumulator
7from landscape.hal import HALManager
8from landscape.monitor.plugin import MonitorPlugin7from landscape.monitor.plugin import MonitorPlugin
98
109
@@ -29,7 +28,18 @@
29 self._free_space = []28 self._free_space = []
30 self._mount_info = []29 self._mount_info = []
31 self._mount_info_to_persist = None30 self._mount_info_to_persist = None
32 self._hal_manager = hal_manager or HALManager()31 try:
32 from landscape.hal import HALManager
33 except ImportError:
34 self._hal_manager = hal_manager
35 else:
36 self._hal_manager = hal_manager or HALManager()
37 try:
38 from gi.repository import GUdev
39 except ImportError:
40 self._gudev_client = None
41 else:
42 self._gudev_client = GUdev.Client.new([])
3343
34 def register(self, registry):44 def register(self, registry):
35 super(MountInfo, self).register(registry)45 super(MountInfo, self).register(registry)
@@ -108,6 +118,23 @@
108 current_mount_points.add(mount_point)118 current_mount_points.add(mount_point)
109119
110 def _get_removable_devices(self):120 def _get_removable_devices(self):
121 if self._hal_manager is not None:
122 return self._get_hal_removable_devices()
123 elif self._gudev_client is not None:
124 return self._get_udev_removable_devices()
125 else:
126 return set()
127
128 def _get_udev_removable_devices(self):
129 class is_removable(object):
130 def __contains__(oself, device_name):
131 device = self._gudev_client.query_by_device_file(device_name)
132 if device:
133 return device.get_sysfs_attr_as_boolean("removable")
134 return False
135 return is_removable()
136
137 def _get_hal_removable_devices(self):
111 block_devices = {} # {udi: [device, ...]}138 block_devices = {} # {udi: [device, ...]}
112 children = {} # {parent_udi: [child_udi, ...]}139 children = {} # {parent_udi: [child_udi, ...]}
113 removable = set()140 removable = set()
114141
=== modified file 'landscape/monitor/tests/test_mountinfo.py'
--- landscape/monitor/tests/test_mountinfo.py 2010-12-10 11:17:11 +0000
+++ landscape/monitor/tests/test_mountinfo.py 2011-01-31 13:37:33 +0000
@@ -19,6 +19,7 @@
19 def setUp(self):19 def setUp(self):
20 LandscapeTest.setUp(self)20 LandscapeTest.setUp(self)
21 self.mstore.set_accepted_types(["mount-info", "free-space"])21 self.mstore.set_accepted_types(["mount-info", "free-space"])
22 self.log_helper.ignore_errors("Typelib file for namespace")
2223
23 def get_mount_info(self, *args, **kwargs):24 def get_mount_info(self, *args, **kwargs):
24 hal_devices = kwargs.pop("hal_devices", [])25 hal_devices = kwargs.pop("hal_devices", [])
@@ -365,6 +366,35 @@
365 message = plugin.create_mount_info_message()366 message = plugin.create_mount_info_message()
366 self.assertEquals(message, None)367 self.assertEquals(message, None)
367368
369 def test_ignore_removable_devices_gudev(self):
370 """
371 The mount info plugin uses gudev to retrieve removable information
372 about devices.
373 """
374 filename = self.makeFile("""\
375/dev/scd0 /media/Xerox_M750 iso9660 ro,nosuid,nodev,uid=1000,utf8 0 0
376""")
377 plugin = self.get_mount_info(mounts_file=filename,
378 mtab_file=filename)
379 plugin._hal_manager = None
380
381 class MockDevice(object):
382 def get_sysfs_attr_as_boolean(self, attr):
383 if attr == "removable":
384 return True
385
386 class MockGudevClient(object):
387 def query_by_device_file(self, name):
388 if name == "/dev/scd0":
389 return MockDevice()
390
391 plugin._gudev_client = MockGudevClient()
392 self.monitor.add(plugin)
393 plugin.run()
394
395 message = plugin.create_mount_info_message()
396 self.assertEquals(message, None)
397
368 def test_ignore_multiparented_removable_devices(self):398 def test_ignore_multiparented_removable_devices(self):
369 """399 """
370 Some removable devices might be the grand-children of a device that is400 Some removable devices might be the grand-children of a device that is
371401
=== modified file 'landscape/monitor/tests/test_service.py'
--- landscape/monitor/tests/test_service.py 2010-08-11 11:56:29 +0000
+++ landscape/monitor/tests/test_service.py 2011-01-31 13:37:33 +0000
@@ -20,6 +20,7 @@
20 reactor_factory = FakeReactor20 reactor_factory = FakeReactor
2121
22 self.service = FakeMonitorService(config)22 self.service = FakeMonitorService(config)
23 self.log_helper.ignore_errors("Typelib file for namespace")
2324
24 def test_plugins(self):25 def test_plugins(self):
25 """26 """
2627
=== modified file 'landscape/service.py'
--- landscape/service.py 2010-08-11 11:56:29 +0000
+++ landscape/service.py 2011-01-31 13:37:33 +0000
@@ -8,7 +8,6 @@
8from landscape.log import rotate_logs8from landscape.log import rotate_logs
9from landscape.reactor import TwistedReactor9from landscape.reactor import TwistedReactor
10from landscape.deployment import get_versioned_persist, init_logging10from landscape.deployment import get_versioned_persist, init_logging
11from landscape.lib import bpickle_dbus
1211
1312
14class LandscapeService(Service, object):13class LandscapeService(Service, object):
@@ -29,7 +28,12 @@
2928
30 def __init__(self, config):29 def __init__(self, config):
31 self.config = config30 self.config = config
32 bpickle_dbus.install()31 try:
32 from landscape.lib import bpickle_dbus
33 except ImportError:
34 pass
35 else:
36 bpickle_dbus.install()
33 self.reactor = self.reactor_factory()37 self.reactor = self.reactor_factory()
34 if self.persist_filename:38 if self.persist_filename:
35 self.persist = get_versioned_persist(self)39 self.persist = get_versioned_persist(self)

Subscribers

People subscribed via source and target branches

to all changes: