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
2ad8e7c9
Commit
2ad8e7c9
authored
Jun 17, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11300 from aioue/devel
add simple prefix filtering to vmware inventory
parents
0c273156
410285ec
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
+13
-1
plugins/inventory/vmware.ini
+4
-0
plugins/inventory/vmware.py
+9
-1
No files found.
plugins/inventory/vmware.ini
View file @
2ad8e7c9
...
@@ -23,6 +23,10 @@ guests_only = True
...
@@ -23,6 +23,10 @@ guests_only = True
# caching will be disabled.
# caching will be disabled.
#cache_dir = ~/.cache/ansible
#cache_dir = ~/.cache/ansible
# Specify a prefix filter. Any VMs with names beginning with this string will
# not be returned.
# prefix_filter = test_
[auth]
[auth]
# Specify hostname or IP address of vCenter/ESXi server. A port may be
# Specify hostname or IP address of vCenter/ESXi server. A port may be
...
...
plugins/inventory/vmware.py
View file @
2ad8e7c9
...
@@ -55,7 +55,7 @@ from suds.sudsobject import Object as SudsObject
...
@@ -55,7 +55,7 @@ from suds.sudsobject import Object as SudsObject
class
VMwareInventory
(
object
):
class
VMwareInventory
(
object
):
def
__init__
(
self
,
guests_only
=
None
):
def
__init__
(
self
,
guests_only
=
None
):
self
.
config
=
ConfigParser
.
SafeConfigParser
()
self
.
config
=
ConfigParser
.
SafeConfigParser
()
if
os
.
environ
.
get
(
'VMWARE_INI'
,
''
):
if
os
.
environ
.
get
(
'VMWARE_INI'
,
''
):
...
@@ -305,6 +305,11 @@ class VMwareInventory(object):
...
@@ -305,6 +305,11 @@ class VMwareInventory(object):
else
:
else
:
vm_group
=
default_group
+
'_vm'
vm_group
=
default_group
+
'_vm'
if
self
.
config
.
has_option
(
'defaults'
,
'prefix_filter'
):
prefix_filter
=
self
.
config
.
get
(
'defaults'
,
'prefix_filter'
)
else
:
prefix_filter
=
None
# Loop through physical hosts:
# Loop through physical hosts:
for
host
in
HostSystem
.
all
(
self
.
client
):
for
host
in
HostSystem
.
all
(
self
.
client
):
...
@@ -318,6 +323,9 @@ class VMwareInventory(object):
...
@@ -318,6 +323,9 @@ class VMwareInventory(object):
# Loop through all VMs on physical host.
# Loop through all VMs on physical host.
for
vm
in
host
.
vm
:
for
vm
in
host
.
vm
:
if
prefix_filter
:
if
vm
.
name
.
startswith
(
prefix_filter
):
continue
self
.
_add_host
(
inv
,
'all'
,
vm
.
name
)
self
.
_add_host
(
inv
,
'all'
,
vm
.
name
)
self
.
_add_host
(
inv
,
vm_group
,
vm
.
name
)
self
.
_add_host
(
inv
,
vm_group
,
vm
.
name
)
vm_info
=
self
.
_get_vm_info
(
vm
)
vm_info
=
self
.
_get_vm_info
(
vm
)
...
...
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