Update network common code to support new states (#65534)

*  Update the network common code to support the
   new resource modules state - parsed, rendered
   and gathered.
*  For states parsed and rendered active connection
   to remote host is not required.
This commit is contained in:
Ganesh Nalawade 2019-12-05 13:21:01 +05:30 committed by GitHub
parent 96df2bdcf3
commit 4352e39989
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View file

@ -13,6 +13,12 @@ from ansible.module_utils.network.common.network import get_resource_connection
class ConfigBase(object):
""" The base class for all resource modules
"""
ACTION_STATES = ['merged', 'replaced', 'overridden', 'deleted']
def __init__(self, module):
self._module = module
self._connection = get_resource_connection(module)
self.state = module.params['state']
self._connection = None
if self.state not in ['rendered', 'parsed']:
self._connection = get_resource_connection(module)

View file

@ -20,7 +20,9 @@ class FactsBase(object):
self._warnings = []
self._gather_subset = module.params.get('gather_subset')
self._gather_network_resources = module.params.get('gather_network_resources')
self._connection = get_resource_connection(module)
self._connection = None
if module.params.get('state') not in ['rendered', 'parsed']:
self._connection = get_resource_connection(module)
self.ansible_facts = {'ansible_network_resources': {}}
self.ansible_facts['ansible_net_gather_network_resources'] = list()