get_option instead of internal dict (#33191)

* get_option instead of internal dict

* fix slack issue

* not a pugin, revert get_option
This commit is contained in:
Brian Coca 2017-11-28 12:00:22 -05:00 committed by GitHub
commit 22d983c5c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 50 additions and 60 deletions

View file

@ -91,7 +91,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
self._read_config_data(path)
strict = self._options['strict']
strict = self.get_option('strict')
fact_cache = FactCache()
try:
# Go over hosts (less var copies)
@ -103,7 +103,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
hostvars = combine_vars(hostvars, fact_cache[host])
# create composite vars
self._set_composite_vars(self._options['compose'], hostvars, host, strict=strict)
self._set_composite_vars(self.get_option('compose'), hostvars, host, strict=strict)
# refetch host vars in case new ones have been created above
hostvars = inventory.hosts[host].get_vars()
@ -111,10 +111,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
hostvars = combine_vars(hostvars, self._cache[host])
# constructed groups based on conditionals
self._add_host_to_composed_groups(self._options['groups'], hostvars, host, strict=strict)
self._add_host_to_composed_groups(self.get_option('groups'), hostvars, host, strict=strict)
# constructed groups based variable values
self._add_host_to_keyed_groups(self._options['keyed_groups'], hostvars, host, strict=strict)
self._add_host_to_keyed_groups(self.get_option('keyed_groups'), hostvars, host, strict=strict)
except Exception as e:
raise AnsibleParserError("failed to parse %s: %s " % (to_native(path), to_native(e)))

View file

@ -77,7 +77,7 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
super(InventoryModule, self).parse(inventory, loader, path)
if cache is None:
cache = self._options['cache']
cache = self.get_option('cache')
# Support inventory scripts that are not prefixed with some
# path information but happen to be in the current working

View file

@ -75,21 +75,21 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
# set vars in inventory from hostvars
for host in hostvars:
query = self._options['query']
query = self.get_option('query')
# create vars from vbox properties
if query and isinstance(query, MutableMapping):
for varname in query:
hostvars[host][varname] = self._query_vbox_data(host, query[varname])
# create composite vars
self._set_composite_vars(self._options['compose'], hostvars, host)
self._set_composite_vars(self.get_option('compose'), hostvars, host)
# actually update inventory
for key in hostvars[host]:
self.inventory.set_variable(host, key, hostvars[host][key])
# constructed groups based on conditionals
self._add_host_to_composed_groups(self._options['groups'], hostvars, host)
self._add_host_to_composed_groups(self.get_option('groups'), hostvars, host)
def _populate_from_source(self, source_data):
hostvars = {}
@ -97,7 +97,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
current_host = None
# needed to possibly set ansible_host
netinfo = self._options['network_info_path']
netinfo = self.get_option('network_info_path')
for line in source_data:
try:
@ -173,8 +173,8 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
pass
if not source_data:
b_pwfile = to_bytes(self._options['settings_password_file'], errors='surrogate_or_strict')
running = self._options['running_only']
b_pwfile = to_bytes(self.get_option('settings_password_file'), errors='surrogate_or_strict')
running = self.get_option('running_only')
# start getting data
cmd = [self.VBOX, b'list', b'-l']

View file

@ -81,7 +81,7 @@ class InventoryModule(BaseFileInventoryPlugin):
valid = False
if super(InventoryModule, self).verify_file(path):
file_name, ext = os.path.splitext(path)
if not ext or ext in self._options['yaml_extensions']:
if not ext or ext in self.get_option('yaml_extensions'):
valid = True
return valid