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
d72eaa3f
Commit
d72eaa3f
authored
Sep 16, 2012
by
Romeo Theriault
Committed by
Romeo Theriault
Sep 16, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding SunOSVirtual facts
parent
7df0e525
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
library/setup
+58
-0
No files found.
library/setup
View file @
d72eaa3f
...
...
@@ -599,6 +599,7 @@ class Virtual(Facts):
you should define:
- virtualization_type
- virtualization_role
- container (e.g. solaris zones, freebsd jails, linux containers)
All subclasses MUST define platform.
"""
...
...
@@ -673,6 +674,63 @@ class LinuxVirtual(Virtual):
self
.
facts
[
'virtualization_type'
]
=
'virtualbox'
self
.
facts
[
'virtualization_role'
]
=
'guest'
class
SunOSVirtual
(
Virtual
):
"""
This is a SunOS-specific subclass of Virtual. It defines
- virtualization_type
- virtualization_role
- container
"""
platform
=
'SunOS'
def
__init__
(
self
):
Virtual
.
__init__
(
self
)
def
populate
(
self
):
self
.
get_virtual_facts
()
return
self
.
facts
def
get_virtual_facts
(
self
):
cmd
=
subprocess
.
Popen
(
"/usr/sbin/prtdiag"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
cmd
.
communicate
()
for
line
in
out
.
split
(
'
\n
'
):
if
'VMware'
in
line
:
self
.
facts
[
'virtualization_type'
]
=
'vmware'
self
.
facts
[
'virtualization_role'
]
=
'guest'
if
'Parallels'
in
line
:
self
.
facts
[
'virtualization_type'
]
=
'parallels'
self
.
facts
[
'virtualization_role'
]
=
'guest'
if
'VirtualBox'
in
line
:
self
.
facts
[
'virtualization_type'
]
=
'virtualbox'
self
.
facts
[
'virtualization_role'
]
=
'guest'
if
'HVM domU'
in
line
:
self
.
facts
[
'virtualization_type'
]
=
'xen'
self
.
facts
[
'virtualization_role'
]
=
'guest'
# Check if it's a zone
if
os
.
path
.
exists
(
"/usr/bin/zonename"
):
cmd
=
subprocess
.
Popen
(
"/usr/bin/zonename"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
cmd
.
communicate
()
if
out
.
rstrip
()
!=
"global"
:
self
.
facts
[
'container'
]
=
'zone'
# Check if it's a branded zone (i.e. Solaris 8/9 zone)
if
os
.
path
.
isdir
(
'/.SUNWnative'
):
self
.
facts
[
'container'
]
=
'zone'
# If it's a zone check if we can detect if our global zone is itself virtualized.
# Relies on the "guest tools" (e.g. vmware tools) to be installed
if
'container'
in
self
.
facts
and
self
.
facts
[
'container'
]
==
'zone'
:
cmd
=
subprocess
.
Popen
(
"/usr/sbin/modinfo"
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
out
,
err
=
cmd
.
communicate
()
for
line
in
out
.
split
(
'
\n
'
):
if
'VMware'
in
line
:
self
.
facts
[
'virtualization_type'
]
=
'vmware'
self
.
facts
[
'virtualization_role'
]
=
'guest'
if
'VirtualBox'
in
line
:
self
.
facts
[
'virtualization_type'
]
=
'virtualbox'
self
.
facts
[
'virtualization_role'
]
=
'guest'
def
get_file_content
(
path
):
data
=
None
if
os
.
path
.
exists
(
path
)
and
os
.
access
(
path
,
os
.
R_OK
):
...
...
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