Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
e0765be1
Commit
e0765be1
authored
Aug 11, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #850 from akhayyat/virt-facts
Add openvz detection to virtualization facts, and some cleanup
parents
32922e40
916fcdb9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
18 deletions
+23
-18
library/setup
+23
-18
No files found.
library/setup
View file @
e0765be1
...
...
@@ -565,10 +565,31 @@ class LinuxVirtual(Virtual):
def
get_virtual_facts
(
self
):
if
os
.
path
.
exists
(
"/proc/xen"
):
self
.
facts
[
'virtualization_type'
]
=
'xen'
if
os
.
path
.
exists
(
'/proc/xen/capabilities'
):
self
.
facts
[
'virtualization_role'
]
=
'host'
else
:
self
.
facts
[
'virtualization_role'
]
=
'guest'
if
os
.
path
.
exists
(
"/proc/xen/capabilities"
):
elif
os
.
path
.
exists
(
'/proc/vz'
):
self
.
facts
[
'virtualization_type'
]
=
'openvz'
if
os
.
path
.
exists
(
'/proc/vz/version'
):
self
.
facts
[
'virtualization_role'
]
=
'host'
if
os
.
path
.
exists
(
"/proc/modules"
):
else
:
self
.
facts
[
'virtualization_role'
]
=
'guest'
elif
get_file_content
(
'/sys/devices/virtual/dmi/id/product_name'
)
in
[
'KVM'
,
'Bochs'
]:
self
.
facts
[
'virtualization_type'
]
=
'kvm'
self
.
facts
[
'virtualization_role'
]
=
'guest'
elif
get_file_content
(
'/sys/devices/virtual/dmi/id/sys_vendor'
)
==
'VMware, Inc.'
:
self
.
facts
[
'virtualization_type'
]
=
'VMware'
self
.
facts
[
'virtualization_role'
]
=
'guest'
elif
get_file_content
(
'/sys/devices/virtual/dmi/id/sys_vendor'
)
==
'Microsoft Corporation'
:
self
.
facts
[
'virtualization_type'
]
=
'VirtualPC'
self
.
facts
[
'virtualization_role'
]
=
'guest'
elif
os
.
path
.
exists
(
"/proc/modules"
):
modules
=
[]
for
line
in
open
(
"/proc/modules"
)
.
readlines
():
data
=
line
.
split
(
" "
,
1
)
...
...
@@ -582,22 +603,6 @@ class LinuxVirtual(Virtual):
elif
'vboxguest'
in
modules
:
self
.
facts
[
'virtualization_type'
]
=
'virtualbox'
self
.
facts
[
'virtualization_role'
]
=
'guest'
data
=
get_file_content
(
'/proc/cpuinfo'
)
if
'QEMU'
in
data
:
self
.
facts
[
'virtualization_type'
]
=
'kvm'
self
.
facts
[
'virtualization_role'
]
=
'guest'
if
'distribution'
in
self
.
facts
and
self
.
facts
[
'distribution'
]
==
'VMwareESX'
:
self
.
facts
[
'virtualization_type'
]
=
'VMware'
self
.
facts
[
'virtualization_role'
]
=
'host'
# You can spawn a dmidecode process and parse that or infer from devices
for
dev_model
in
glob
.
glob
(
'/sys/block/?da/device/vendor'
):
info
=
open
(
dev_model
)
.
read
()
if
'VMware'
in
info
:
self
.
facts
[
'virtualization_type'
]
=
'VMware'
self
.
facts
[
'virtualization_role'
]
=
'guest'
elif
'Virtual HD'
in
info
or
'Virtual CD'
in
info
:
self
.
facts
[
'virtualization_type'
]
=
'VirtualPC'
self
.
facts
[
'virtualization_role'
]
=
'guest'
def
get_file_content
(
path
):
data
=
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment