Merge lp:~doanac/utah/bug1158743 into lp:utah

Proposed by Andy Doan
Status: Superseded
Proposed branch: lp:~doanac/utah/bug1158743
Merge into: lp:utah
Diff against target: 74 lines (+26/-9)
2 files modified
debian/changelog (+6/-0)
utah/provisioning/baremetal/inventory.py (+20/-9)
To merge this branch: bzr merge lp:~doanac/utah/bug1158743
Reviewer Review Type Date Requested Status
UTAH Dev Pending
Review via email: mp+155069@code.launchpad.net

This proposal has been superseded by a proposal from 2013-03-25.

Description of the change

This should add the logging Javier was suggesting to understand what processes are actually using a machine.

To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote :

I see that you fixed the bug in a branch based on trunk and created the merge
for dev (which actually reveals an entry in debian/changelog that isn't in
dev). Is this the expected way to work with bugs?

Revision history for this message
Javier Collado (javier.collado) wrote :

The use of a static private method suggests that `_in_use` is a utility method,
so I believe it should be moved to the `process` module which is expected to
have that kind of methods.

Revision history for this message
Andy Doan (doanac) wrote :

On 03/25/2013 04:16 AM, Javier Collado wrote:
> I see that you fixed the bug in a branch based on trunk and created the merge
> for dev (which actually reveals an entry in debian/changelog that isn't in
> dev). Is this the expected way to work with bugs?
>
Nope - that was a mechanical error. I'll correct

lp:~doanac/utah/bug1158743 updated
270. By Andy Doan

move pid _in_use to process.py

As per Javier's review comment this moves the function to become a
generic helper. I also added some unit-testing logic for it

271. By Andy Doan

fix pep257 issues

272. By Andy Doan

add changelog entry

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2013-03-21 08:27:02 +0000
3+++ debian/changelog 2013-03-22 21:18:28 +0000
4@@ -2259,6 +2259,12 @@
5
6 -- Max Brustkern <max@canonical.com> Mon, 02 Jul 2012 10:13:46 -0400
7
8+utah (0.2ubuntu365) quantal; urgency=low
9+
10+ * Updated to add CustomKVM provisioning
11+
12+ -- Max Brustkern <max@canonical.com> Mon, 02 Jul 2012 10:13:09 -0400
13+
14 utah (0.2ubuntu364) quantal; urgency=low
15
16 * Updated script to warn user should logout and back in to pick up
17
18=== added file 'utah-client_0.1_all.deb'
19Binary files utah-client_0.1_all.deb 1970-01-01 00:00:00 +0000 and utah-client_0.1_all.deb 2013-03-22 21:18:28 +0000 differ
20=== modified file 'utah/provisioning/baremetal/inventory.py'
21--- utah/provisioning/baremetal/inventory.py 2013-01-22 14:13:17 +0000
22+++ utah/provisioning/baremetal/inventory.py 2013-03-22 21:18:28 +0000
23@@ -17,8 +17,10 @@
24 Provide inventory functions specific to bare metal deployments.
25 """
26
27+import logging
28 import os
29 import psutil
30+
31 from utah.provisioning.inventory.exceptions import \
32 UTAHProvisioningInventoryException
33 from utah.provisioning.inventory.sqlite import SQLiteInventory
34@@ -47,6 +49,19 @@
35 raise UTAHProvisioningInventoryException('No machines in database')
36 self.machines = []
37
38+ @staticmethod
39+ def _in_use(pid):
40+ try:
41+ proc = psutil.Process(pid)
42+ except (psutil.error.NoSuchProcess, TypeError, ValueError):
43+ return None
44+
45+ cmdline = ' '.join(proc.cmdline)
46+ if 'utah' in cmdline or 'run_test' in cmdline:
47+ return proc
48+
49+ return None
50+
51 def request(self, machinetype, name=None, *args, **kw):
52 query = 'SELECT * FROM machines'
53 queryvars = []
54@@ -65,15 +80,11 @@
55 for minfo in result:
56 machineinfo = dict(minfo)
57 pid = machineinfo['pid']
58- try:
59- if not (psutil.pid_exists(pid) and ('utah' in
60- ' '.join(psutil.Process(pid).cmdline)
61- or 'run_test' in
62- ' '.join(psutil.Process(pid).cmdline))):
63- return self._take(machineinfo, machinetype,
64- *args, **kw)
65- except ValueError:
66- continue
67+ proc = self._in_use(pid)
68+ if not proc:
69+ return self._take(machineinfo, machinetype, *args, **kw)
70+ else:
71+ logging.info('machine in use by: %s', proc.cmdline)
72
73 raise UTAHProvisioningInventoryException(
74 'All machines meeting criteria are currently unavailable')

Subscribers

People subscribed via source and target branches

to all changes: