Merge lp:~therve/landscape-client/hyper-v-detection into lp:~landscape/landscape-client/trunk

Proposed by Thomas Herve
Status: Merged
Approved by: Alberto Donato
Approved revision: 594
Merged at revision: 593
Proposed branch: lp:~therve/landscape-client/hyper-v-detection
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 42 lines (+17/-1)
2 files modified
landscape/lib/tests/test_vm_info.py (+15/-1)
landscape/lib/vm_info.py (+2/-0)
To merge this branch: bzr merge lp:~therve/landscape-client/hyper-v-detection
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Geoff Teale (community) Approve
Review via email: mp+138409@code.launchpad.net

Description of the change

The detection is not awesome. It came after some investigation on an Azure guest. The only other thing we can do is using the VGA card, but it implies either calling an external tool or hardcode the PCI ids. I think it does the trick for now.

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

Don't use with

Revision history for this message
Geoff Teale (tealeg) wrote :

+1 I was trying to think of another case where we could get a false positive on the VGA card vendor, but I can't think of one.

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

Looks good, +1!

review: Approve

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 2012-01-30 09:50:52 +0000
3+++ landscape/lib/tests/test_vm_info.py 2012-12-06 10:20:28 +0000
4@@ -135,7 +135,9 @@
5 root_path = self.makeDir()
6 dmi_path = os.path.join(root_path, "sys", "class", "dmi", "id")
7 os.makedirs(dmi_path)
8- file(os.path.join(dmi_path, "sys_vendor"), "w+").write("VMware, Inc.")
9+ fd = file(os.path.join(dmi_path, "sys_vendor"), "w")
10+ fd.write("VMware, Inc.")
11+ fd.close()
12 self.assertEqual("vmware", get_vm_info(root_path=root_path))
13
14 def test_get_vm_info_is_empty_without_xen_devices(self):
15@@ -157,3 +159,15 @@
16 self.makeDir(path=devices_xen_path)
17
18 self.assertEqual("", get_vm_info(root_path=root_path))
19+
20+ def test_get_vm_info_with_microsoft_sys_vendor(self):
21+ """
22+ L{get_vm_info} returns "hyperv" if the sys_vendor is Microsoft.
23+ """
24+ root_path = self.makeDir()
25+ dmi_path = os.path.join(root_path, "sys", "class", "dmi", "id")
26+ os.makedirs(dmi_path)
27+ fd = file(os.path.join(dmi_path, "sys_vendor"), "w")
28+ fd.write("Microsoft Corporation")
29+ fd.close()
30+ self.assertEqual("hyperv", get_vm_info(root_path=root_path))
31
32=== modified file 'landscape/lib/vm_info.py'
33--- landscape/lib/vm_info.py 2012-01-30 09:27:09 +0000
34+++ landscape/lib/vm_info.py 2012-12-06 10:20:28 +0000
35@@ -48,6 +48,8 @@
36 file_content = fd.read()
37 if "VMware, Inc." in file_content:
38 return "vmware"
39+ elif "Microsoft Corporation" in file_content:
40+ return "hyperv"
41 finally:
42 fd.close()
43

Subscribers

People subscribed via source and target branches

to all changes: