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
d4a89c8e
Commit
d4a89c8e
authored
Jan 30, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved from callback_output to popen to keep 2.6 compat
parent
368285b3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
plugins/inventory/vbox.py
+8
-7
No files found.
plugins/inventory/vbox.py
View file @
d4a89c8e
...
...
@@ -16,7 +16,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import
sys
from
subprocess
import
check_output
from
subprocess
import
Popen
,
PIPE
try
:
import
json
...
...
@@ -32,17 +32,17 @@ def get_hosts(host=None):
returned
=
{}
try
:
if
host
:
results
=
check_output
([
VBOX
,
'showvminfo'
,
host
]
)
p
=
Popen
([
VBOX
,
'showvminfo'
,
host
],
stdout
=
PIPE
)
else
:
returned
=
{
'all'
:
set
(),
'_metadata'
:
{}
}
results
=
check_output
([
VBOX
,
'list'
,
'-l'
,
'vms'
]
)
p
=
Popen
([
VBOX
,
'list'
,
'-l'
,
'vms'
],
stdout
=
PIPE
)
except
:
sys
.
exit
(
1
)
hostvars
=
{}
prevkey
=
pref_k
=
''
for
line
in
results
.
split
lines
():
for
line
in
p
.
stdout
.
read
lines
():
try
:
k
,
v
=
line
.
split
(
':'
,
1
)
...
...
@@ -58,9 +58,10 @@ def get_hosts(host=None):
curname
=
v
hostvars
[
curname
]
=
{}
try
:
# try to get network info
ip_info
=
check_output
([
VBOX
,
'guestproperty'
,
'get'
,
curname
,
"/VirtualBox/GuestInfo/Net/0/V4/IP"
])
if
'Value'
in
ip_info
:
a
,
ip
=
ip_info
.
split
(
':'
,
1
)
x
=
Popen
([
VBOX
,
'guestproperty'
,
'get'
,
curname
,
"/VirtualBox/GuestInfo/Net/0/V4/IP"
],
stdout
=
PIPE
)
ipinfo
=
x
.
stdout
.
read
()
if
'Value'
in
ipinfo
:
a
,
ip
=
ipinfo
.
split
(
':'
,
1
)
hostvars
[
curname
][
'ansible_ssh_host'
]
=
ip
.
strip
()
except
:
pass
...
...
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