Merge lp:~bigkevmcd/landscape-client/detect-vmware into lp:~landscape/landscape-client/trunk

Proposed by Kevin McDermott
Status: Merged
Approved by: Thomas Herve
Approved revision: 334
Merged at revision: 336
Proposed branch: lp:~bigkevmcd/landscape-client/detect-vmware
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 36 lines (+19/-1)
2 files modified
landscape/lib/tests/test_vm_info.py (+12/-1)
landscape/lib/vm_info.py (+7/-0)
To merge this branch: bzr merge lp:~bigkevmcd/landscape-client/detect-vmware
Reviewer Review Type Date Requested Status
Thomas Herve (community) Approve
Alberto Donato (community) Approve
Review via email: mp+65015@code.launchpad.net

Description of the change

This is a trivial change to detect vmware...

To post a comment you must log in.
Revision history for this message
Kevin McDermott (bigkevmcd) wrote :

I've confirmed this works as far back as Hardy...

Revision history for this message
Alberto Donato (ack) wrote :

+1!

[1]
+ virt_info = u"vmware"

In this case virt_info is unicode, in the others is a string.
It would be better to have the same type for all cases.

review: Approve
Revision history for this message
Thomas Herve (therve) wrote :

What Alberto says, plus you can't use "with" on hardy.

review: Approve
335. By Kevin McDermott

Don't return a unicode string from get_vm_info

336. By Kevin McDermott

Drop use of Python2.5 incompatible 'with'

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'landscape/lib/tests/test_vm_info.py'
--- landscape/lib/tests/test_vm_info.py 2011-06-11 00:23:00 +0000
+++ landscape/lib/tests/test_vm_info.py 2011-06-20 06:46:33 +0000
@@ -118,4 +118,15 @@
118118
119 cpuinfo_path = os.path.join(proc_path, "cpuinfo")119 cpuinfo_path = os.path.join(proc_path, "cpuinfo")
120 self.makeFile(path=cpuinfo_path, content="foo")120 self.makeFile(path=cpuinfo_path, content="foo")
121 self.assertEqual(u"", get_vm_info(root_path=root_path))121 self.assertEqual("", get_vm_info(root_path=root_path))
122
123 def test_get_vm_info_with_vmware_sys_vendor(self):
124 """
125 L{get_vm_info} should return "vmware" when we detect the sys_vendor is
126 VMware Inc.
127 """
128 root_path = self.makeDir()
129 dmi_path = os.path.join(root_path, "sys", "class", "dmi", "id")
130 os.makedirs(dmi_path)
131 file(os.path.join(dmi_path, "sys_vendor"), "w+").write("VMware, Inc.")
132 self.assertEqual("vmware", get_vm_info(root_path=root_path))
122133
=== modified file 'landscape/lib/vm_info.py'
--- landscape/lib/vm_info.py 2011-06-11 00:23:00 +0000
+++ landscape/lib/vm_info.py 2011-06-20 06:46:33 +0000
@@ -36,4 +36,11 @@
36 finally:36 finally:
37 fd.close()37 fd.close()
3838
39 sys_vendor_path = os.path.join(root_path, "sys", "class", "dmi", "id",
40 "sys_vendor")
41 if os.path.exists(sys_vendor_path):
42 file_content = open(sys_vendor_path).read()
43 if "VMware, Inc." in file_content:
44 virt_info = "vmware"
45
39 return virt_info46 return virt_info

Subscribers

People subscribed via source and target branches

to all changes: