Skip to content

Commit

Permalink
Merge pull request #71 from 205101-retr0/cdFMCsupport
Browse files Browse the repository at this point in the history
CdFMCsupport
  • Loading branch information
jeroenwittock authored Jan 21, 2025
2 parents 940a475 + 7382dcf commit 721fc80
Show file tree
Hide file tree
Showing 1,538 changed files with 28,049 additions and 1,721 deletions.
6 changes: 3 additions & 3 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ tags:
- "ftd"

dependencies:
community.general: '>=6.5.0'
community.general: '>=7.1.0'
community.network: 5.0.0
ansible.netcommon: 5.1.0
ansible.utils: 2.9.0
ansible.netcommon: 5.1.1
ansible.utils: 2.10.3

repository: https://github.com/CiscoDevNet/FMCAnsible
homepage: https://github.com/CiscoDevNet/FMCAnsible
Expand Down
2 changes: 1 addition & 1 deletion plugins/httpapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _send_request(self, url_path, data=None, method="GET", headers=None):
# ex:
# connection.send(url, data, method=http_method, headers=BASE_HEADERS)
method = method.upper()
conn = http.client.HTTPSConnection(self._host, timeout=10, context=ssl._create_unverified_context())
conn = http.client.HTTPSConnection(self._host, timeout=360, context=ssl._create_unverified_context())
conn.request(method, url_path, data, headers)
# response
response = conn.getresponse()
Expand Down
79 changes: 0 additions & 79 deletions plugins/module_utils/cache.py

This file was deleted.

46 changes: 3 additions & 43 deletions plugins/modules/fmc_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,11 @@

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.connection import Connection
from os import path, remove
from re import compile

from ansible_collections.cisco.fmcansible.plugins.module_utils.configuration import BaseConfigurationResource, CheckModeException, FmcInvalidOperationNameError
from ansible_collections.cisco.fmcansible.plugins.module_utils.fmc_swagger_client import ValidationError
from ansible_collections.cisco.fmcansible.plugins.module_utils.common import construct_ansible_facts, FmcConfigurationError, \
FmcServerError, FmcUnexpectedResponse
from ansible_collections.cisco.fmcansible.plugins.module_utils.cache import ResponseCache

CACHE_FILE = "/tmp/cache.json"
cache = ResponseCache(CACHE_FILE)


def extract_hosts(response_object):
ip_pattern = compile(r'\b(?:\d{1,3}\.){3}\d{1,3}\b')

if isinstance(response_object, list):
response_object = response_object[0]
elif not response_object.get('links', {}).get('self'):
return "default"

return ip_pattern.findall(response_object['links']['self'])[0]


def main():
Expand All @@ -136,35 +119,12 @@ def main():
connection = Connection(module._socket_path)
resource = BaseConfigurationResource(connection, module.check_mode)
op_name = params['operation']
cache_exists = path.exists(CACHE_FILE)
if op_name == "getAllDomain":
if cache_exists:
remove(CACHE_FILE)

try:
resp = resource.execute_operation(op_name, params)
facts = construct_ansible_facts(resp, module.params)

if not facts:
module.exit_json(changed=resource.config_changed,
response=resp, ansible_facts=facts)
if "update" in op_name:
module.exit_json(changed=resource.config_changed,
response=resp, ansible_facts=facts)

hostname = extract_hosts(resp)

facts_copy = facts.copy()
name, response_body = facts_copy.popitem()
cache.cache_response(name, response_body, hostname)

__facts_cache = cache.get_cached_responses(hostname)
if __facts_cache != {}:
module.exit_json(changed=resource.config_changed,
response=resp, ansible_facts=__facts_cache)
else:
module.exit_json(changed=resource.config_changed,
response=resp, ansible_facts=facts)
module.exit_json(changed=resource.config_changed,
response=resp, ansible_facts=construct_ansible_facts(resp, module.params))


except FmcInvalidOperationNameError as e:
module.fail_json(msg='Invalid operation name provided: %s' % e.operation_name)
Expand Down
19 changes: 19 additions & 0 deletions samples/docs/components/access_policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# AccessPolicy


**Type:** object

## Properties
* decryptionPolicySetting
* metadata
* description
* rules
* securityIntelligence
* type
* version
* defaultAction
* name
* identityPolicySetting
* links
* prefilterPolicySetting
* id
14 changes: 14 additions & 0 deletions samples/docs/components/access_policy_category.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# AccessPolicyCategory

## Description of Access Policy Category.

**Type:** object

## Properties
* metadata
* name
* description
* links
* id
* type
* version
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AccessPolicyCategoryListContainer


**Type:** object

## Properties
* links
* paging
* items
17 changes: 17 additions & 0 deletions samples/docs/components/access_policy_category_metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# AccessPolicyCategoryMetadata

## Description of Access Policy Category Metadata.

**Type:** object

## Properties
* startIndex
* lastUser
* endIndex
* domain
* readOnly
* section
* position
* accessPolicy
* matches
* timestamp
15 changes: 15 additions & 0 deletions samples/docs/components/access_policy_inheritance_setting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# AccessPolicyInheritanceSetting

## Description of Access Policy Inheritence Setting.

**Type:** object

## Properties
* metadata
* name
* basePolicy
* description
* links
* id
* type
* version
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AccessPolicyInheritanceSettingListContainer


**Type:** object

## Properties
* links
* paging
* items
9 changes: 9 additions & 0 deletions samples/docs/components/access_policy_list_container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AccessPolicyListContainer


**Type:** object

## Properties
* links
* paging
* items
22 changes: 22 additions & 0 deletions samples/docs/components/access_policy_logging_setting_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# AccessPolicyLoggingSettingModel


**Type:** object

## Properties
* fileAndMalwareSyslogConfig
* syslogConfigFromPlatformSetting
* metadata
* ipsSyslogSeverity
* description
* enableFileAndMalwareSyslog
* type
* version
* syslogConfig
* name
* fileAndMalwareSyslogSeverity
* severityForPlatformSettingSyslogConfig
* links
* id
* enableipsSyslog
* ipsSyslogConfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AccessPolicyLoggingSettingModelListContainer


**Type:** object

## Properties
* links
* paging
* items
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# AccessPolicySecurityIntelligencePolicy

## Object representing the association of security intelligence policy to specified access policy.

**Type:** object

## Properties
* dnsPolicy
* urls
* metadata
* umbrellaDNSPolicy
* name
* description
* links
* id
* type
* networks
* version
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AccessPolicySecurityIntelligencePolicyListContainer


**Type:** object

## Properties
* links
* paging
* items
49 changes: 49 additions & 0 deletions samples/docs/components/access_rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# AccessRule

## Represents Access Rule contained within an Access Policy.

**Type:** object

## Properties
* metadata
* snmpConfig
* timeRangeObjects
* sourceNetworks
* syslogSeverity
* sourceZones
* destinationZones
* destinationDynamicObjects
* description
* originalSourceNetworks
* enableSyslog
* type
* safeSearch
* enabled
* destSGTTypes
* syslogConfig
* urls
* endPointDeviceTypes
* destinationNetworks
* youTube
* action
* links
* networkAccessDeviceIPs
* id
* sourceSecurityGroupTags
* destinationSecurityGroupTags
* logEnd
* logBegin
* sendEventsToFMC
* destinationPorts
* sourcePorts
* ipsPolicy
* variableSet
* version
* users
* logFiles
* commentHistoryList
* filePolicy
* name
* sourceDynamicObjects
* vlanTags
* applications
9 changes: 9 additions & 0 deletions samples/docs/components/access_rule_list_container.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# AccessRuleListContainer


**Type:** object

## Properties
* links
* paging
* items
Loading

0 comments on commit 721fc80

Please sign in to comment.