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
1=== modified file 'debian/control'
2--- debian/control 2011-01-10 21:24:47 +0000
3+++ debian/control 2011-01-31 13:37:33 +0000
4@@ -35,8 +35,8 @@
5 Architecture: any
6 Depends: ${python:Depends}, ${misc:Depends}, ${extra:Depends},
7 python-twisted-web,
8- landscape-common (>= ${Source-Version}),
9- hal
10+ landscape-common (>= ${Source-Version})
11+Suggests: ${extra:Suggests}
12 Description: The Landscape administration system client
13 Landscape is a web-based tool for managing Ubuntu systems. This
14 package is necessary if you want your machine to be managed in a
15
16=== modified file 'debian/landscape-client.init'
17--- debian/landscape-client.init 2010-09-07 15:37:59 +0000
18+++ debian/landscape-client.init 2011-01-31 13:37:33 +0000
19@@ -2,8 +2,8 @@
20
21 ### BEGIN INIT INFO
22 # Provides: landscape-client
23-# Required-Start: $local_fs $remote_fs hal
24-# Required-Stop: $local_fs $remote_fs hal
25+# Required-Start: $local_fs $remote_fs
26+# Required-Stop: $local_fs $remote_fs
27 # Default-Start: 2 3 4 5
28 # Default-Stop: 0 1 6
29 # Short-Description: Landscape client daemons
30
31=== modified file 'debian/rules'
32--- debian/rules 2011-01-11 23:04:59 +0000
33+++ debian/rules 2011-01-31 13:37:33 +0000
34@@ -82,17 +82,23 @@
35 ifneq (,$(findstring $(dist_release),"dapper"))
36 # We need python2.4-pysqlite2 and a non-buggy libcurl3-gnutls on dapper
37 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)
38- echo "extra:Depends=python2.4-pycurl" >> $(landscape_client_substvars)
39+ echo "extra:Depends=python2.4-pycurl, hal" >> $(landscape_client_substvars)
40 endif
41 ifneq (,$(findstring $(dist_release),"hardy"))
42 # We want the smart 1.1.1 from the Landscape repository on hardy
43 echo "extra:Depends=python-smartpm (>= 1.1.1~bzr20081010-0ubuntu1.8.04.1), python2.4-dbus" >> $(landscape_common_substvars)
44- echo "extra:Depends=python2.4-pycurl" >> $(landscape_client_substvars)
45+ echo "extra:Depends=python2.4-pycurl, hal" >> $(landscape_client_substvars)
46 endif
47-ifeq (,$(filter $(dist_release),dapper hardy))
48+ifneq (,$(filter $(dist_release),karmic lucid maverick))
49 # We want libpam-modules in karmic, and smart 1.2
50 echo "extra:Depends=libpam-modules (>= 1.0.1-9ubuntu3), python-smartpm (>= 1.2-4), python-dbus" >> $(landscape_common_substvars)
51- echo "extra:Depends=python-pycurl" >> $(landscape_client_substvars)
52+ echo "extra:Depends=python-pycurl, hal" >> $(landscape_client_substvars)
53+endif
54+ifeq (,$(filter $(dist_release),dapper hardy karmic lucid maverick))
55+ # Starting natty, no more hal or dbus
56+ echo "extra:Depends=libpam-modules (>= 1.0.1-9ubuntu3), python-smartpm (>= 1.2-4)" >> $(landscape_common_substvars)
57+ echo "extra:Depends=python-pycurl, gir1.2-gudev-1.0 (>= 165-0ubuntu2)" >> $(landscape_client_substvars)
58+ echo "extra:Suggests=python-dbus, hal" >> $(landscape_client_substvars)
59 endif
60 ifeq (,$(filter $(dist_release),dapper hardy karmic))
61 # The python-image-store-proxy package is needed for the eucalyptus plugin
62
63=== modified file 'landscape/monitor/hardwareinventory.py'
64--- landscape/monitor/hardwareinventory.py 2010-12-10 13:57:11 +0000
65+++ landscape/monitor/hardwareinventory.py 2011-01-31 13:37:33 +0000
66@@ -5,7 +5,6 @@
67 from landscape.lib.log import log_failure
68
69 from landscape.diff import diff
70-from landscape.hal import HALManager
71 from landscape.monitor.plugin import MonitorPlugin
72
73
74@@ -17,9 +16,17 @@
75 super(HardwareInventory, self).__init__()
76 self._persist_sets = []
77 self._persist_removes = []
78- self._hal_manager = hal_manager or HALManager()
79+ self.enabled = True
80+ try:
81+ from landscape.hal import HALManager
82+ except ImportError:
83+ self.enabled = False
84+ else:
85+ self._hal_manager = hal_manager or HALManager()
86
87 def register(self, manager):
88+ if not self.enabled:
89+ return
90 super(HardwareInventory, self).register(manager)
91 self.call_on_accepted("hardware-inventory", self.exchange, True)
92
93@@ -37,6 +44,8 @@
94 return result
95
96 def exchange(self, urgent=False):
97+ if not self.enabled:
98+ return
99 return self.registry.broker.call_if_accepted("hardware-inventory",
100 self.send_message, urgent)
101
102
103=== modified file 'landscape/monitor/mountinfo.py'
104--- landscape/monitor/mountinfo.py 2010-12-16 14:58:05 +0000
105+++ landscape/monitor/mountinfo.py 2011-01-31 13:37:33 +0000
106@@ -4,7 +4,6 @@
107 from landscape.lib.disk import get_mount_info
108 from landscape.lib.monitor import CoverageMonitor
109 from landscape.accumulate import Accumulator
110-from landscape.hal import HALManager
111 from landscape.monitor.plugin import MonitorPlugin
112
113
114@@ -29,7 +28,18 @@
115 self._free_space = []
116 self._mount_info = []
117 self._mount_info_to_persist = None
118- self._hal_manager = hal_manager or HALManager()
119+ try:
120+ from landscape.hal import HALManager
121+ except ImportError:
122+ self._hal_manager = hal_manager
123+ else:
124+ self._hal_manager = hal_manager or HALManager()
125+ try:
126+ from gi.repository import GUdev
127+ except ImportError:
128+ self._gudev_client = None
129+ else:
130+ self._gudev_client = GUdev.Client.new([])
131
132 def register(self, registry):
133 super(MountInfo, self).register(registry)
134@@ -108,6 +118,23 @@
135 current_mount_points.add(mount_point)
136
137 def _get_removable_devices(self):
138+ if self._hal_manager is not None:
139+ return self._get_hal_removable_devices()
140+ elif self._gudev_client is not None:
141+ return self._get_udev_removable_devices()
142+ else:
143+ return set()
144+
145+ def _get_udev_removable_devices(self):
146+ class is_removable(object):
147+ def __contains__(oself, device_name):
148+ device = self._gudev_client.query_by_device_file(device_name)
149+ if device:
150+ return device.get_sysfs_attr_as_boolean("removable")
151+ return False
152+ return is_removable()
153+
154+ def _get_hal_removable_devices(self):
155 block_devices = {} # {udi: [device, ...]}
156 children = {} # {parent_udi: [child_udi, ...]}
157 removable = set()
158
159=== modified file 'landscape/monitor/tests/test_mountinfo.py'
160--- landscape/monitor/tests/test_mountinfo.py 2010-12-10 11:17:11 +0000
161+++ landscape/monitor/tests/test_mountinfo.py 2011-01-31 13:37:33 +0000
162@@ -19,6 +19,7 @@
163 def setUp(self):
164 LandscapeTest.setUp(self)
165 self.mstore.set_accepted_types(["mount-info", "free-space"])
166+ self.log_helper.ignore_errors("Typelib file for namespace")
167
168 def get_mount_info(self, *args, **kwargs):
169 hal_devices = kwargs.pop("hal_devices", [])
170@@ -365,6 +366,35 @@
171 message = plugin.create_mount_info_message()
172 self.assertEquals(message, None)
173
174+ def test_ignore_removable_devices_gudev(self):
175+ """
176+ The mount info plugin uses gudev to retrieve removable information
177+ about devices.
178+ """
179+ filename = self.makeFile("""\
180+/dev/scd0 /media/Xerox_M750 iso9660 ro,nosuid,nodev,uid=1000,utf8 0 0
181+""")
182+ plugin = self.get_mount_info(mounts_file=filename,
183+ mtab_file=filename)
184+ plugin._hal_manager = None
185+
186+ class MockDevice(object):
187+ def get_sysfs_attr_as_boolean(self, attr):
188+ if attr == "removable":
189+ return True
190+
191+ class MockGudevClient(object):
192+ def query_by_device_file(self, name):
193+ if name == "/dev/scd0":
194+ return MockDevice()
195+
196+ plugin._gudev_client = MockGudevClient()
197+ self.monitor.add(plugin)
198+ plugin.run()
199+
200+ message = plugin.create_mount_info_message()
201+ self.assertEquals(message, None)
202+
203 def test_ignore_multiparented_removable_devices(self):
204 """
205 Some removable devices might be the grand-children of a device that is
206
207=== modified file 'landscape/monitor/tests/test_service.py'
208--- landscape/monitor/tests/test_service.py 2010-08-11 11:56:29 +0000
209+++ landscape/monitor/tests/test_service.py 2011-01-31 13:37:33 +0000
210@@ -20,6 +20,7 @@
211 reactor_factory = FakeReactor
212
213 self.service = FakeMonitorService(config)
214+ self.log_helper.ignore_errors("Typelib file for namespace")
215
216 def test_plugins(self):
217 """
218
219=== modified file 'landscape/service.py'
220--- landscape/service.py 2010-08-11 11:56:29 +0000
221+++ landscape/service.py 2011-01-31 13:37:33 +0000
222@@ -8,7 +8,6 @@
223 from landscape.log import rotate_logs
224 from landscape.reactor import TwistedReactor
225 from landscape.deployment import get_versioned_persist, init_logging
226-from landscape.lib import bpickle_dbus
227
228
229 class LandscapeService(Service, object):
230@@ -29,7 +28,12 @@
231
232 def __init__(self, config):
233 self.config = config
234- bpickle_dbus.install()
235+ try:
236+ from landscape.lib import bpickle_dbus
237+ except ImportError:
238+ pass
239+ else:
240+ bpickle_dbus.install()
241 self.reactor = self.reactor_factory()
242 if self.persist_filename:
243 self.persist = get_versioned_persist(self)

Subscribers

People subscribed via source and target branches

to all changes: