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
3d62e55a
Commit
3d62e55a
authored
Oct 07, 2014
by
Mathieu GAUTHIER-LAFAYE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add host variables (proxmox_vmid, proxmox_uptime, proxmox_maxmem, ...)
parent
76f473cd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
plugins/inventory/proxmox.py
+23
-3
No files found.
plugins/inventory/proxmox.py
View file @
3d62e55a
...
...
@@ -33,6 +33,10 @@ class ProxmoxQemuList(list):
def
get_names
(
self
):
return
[
qemu
[
'name'
]
for
qemu
in
self
if
qemu
[
'template'
]
!=
1
]
def
get_by_name
(
self
,
name
):
results
=
[
qemu
for
qemu
in
self
if
qemu
[
'name'
]
==
name
]
return
results
[
0
]
if
len
(
results
)
>
0
else
None
class
ProxmoxPoolList
(
list
):
def
get_names
(
self
):
return
[
pool
[
'poolid'
]
for
pool
in
self
]
...
...
@@ -107,8 +111,24 @@ def main_list(options):
print
json
.
dumps
(
result
)
def
main_host
():
print
json
.
dumps
({})
def
main_host
(
options
):
results
=
{}
proxmox_api
=
ProxmoxAPI
(
options
)
proxmox_api
.
auth
()
host
=
None
for
node
in
proxmox_api
.
nodes
()
.
get_names
():
qemu_list
=
proxmox_api
.
node_qemu
(
node
)
qemu
=
qemu_list
.
get_by_name
(
options
.
host
)
if
qemu
:
break
if
qemu
:
for
key
,
value
in
qemu
.
iteritems
():
results
[
'proxmox_'
+
key
]
=
value
print
json
.
dumps
(
results
)
def
main
():
parser
=
OptionParser
(
usage
=
'
%
prog [options] --list | --host HOSTNAME'
)
...
...
@@ -122,7 +142,7 @@ def main():
if
options
.
list
:
main_list
(
options
)
elif
options
.
host
:
main_host
()
main_host
(
options
)
else
:
parser
.
print_help
()
sys
.
exit
(
1
)
...
...
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