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
1=== modified file 'landscape/lib/tests/test_vm_info.py'
2--- landscape/lib/tests/test_vm_info.py 2011-06-11 00:23:00 +0000
3+++ landscape/lib/tests/test_vm_info.py 2011-06-20 06:46:33 +0000
4@@ -118,4 +118,15 @@
5
6 cpuinfo_path = os.path.join(proc_path, "cpuinfo")
7 self.makeFile(path=cpuinfo_path, content="foo")
8- self.assertEqual(u"", get_vm_info(root_path=root_path))
9+ self.assertEqual("", get_vm_info(root_path=root_path))
10+
11+ def test_get_vm_info_with_vmware_sys_vendor(self):
12+ """
13+ L{get_vm_info} should return "vmware" when we detect the sys_vendor is
14+ VMware Inc.
15+ """
16+ root_path = self.makeDir()
17+ dmi_path = os.path.join(root_path, "sys", "class", "dmi", "id")
18+ os.makedirs(dmi_path)
19+ file(os.path.join(dmi_path, "sys_vendor"), "w+").write("VMware, Inc.")
20+ self.assertEqual("vmware", get_vm_info(root_path=root_path))
21
22=== modified file 'landscape/lib/vm_info.py'
23--- landscape/lib/vm_info.py 2011-06-11 00:23:00 +0000
24+++ landscape/lib/vm_info.py 2011-06-20 06:46:33 +0000
25@@ -36,4 +36,11 @@
26 finally:
27 fd.close()
28
29+ sys_vendor_path = os.path.join(root_path, "sys", "class", "dmi", "id",
30+ "sys_vendor")
31+ if os.path.exists(sys_vendor_path):
32+ file_content = open(sys_vendor_path).read()
33+ if "VMware, Inc." in file_content:
34+ virt_info = "vmware"
35+
36 return virt_info

Subscribers

People subscribed via source and target branches

to all changes: