Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network settings #12

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions playbooks/network_settings_intent.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
- hosts: dnac_servers
vars_files:
- credentials_245.yml
gather_facts: no
connection: local
tasks:
#
# Project Info Section
#

- name: Create global pool, reserve subpool and network functions
cisco.dnac.network_settings_intent:
dnac_host: "{{ dnac_host }}"
dnac_port: "{{ dnac_port }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_debug: "{{ dnac_debug }}"
dnac_log: True
state: merged
config:
- GlobalPoolDetails:
settings:
ippool:
- ipPoolName: Global_Pool2
gateway: "" #use this for updating
IpAddressSpace: IPv6 #required when we are creating
ipPoolCidr: 2001:db8::/64 #required when we are creating
type: Generic
dhcpServerIps: [] #use this for updating
dnsServerIps: [] #use this for updating
# prev_name: Global_Pool2
ReservePoolDetails:
ipv6AddressSpace: True
ipv4GlobalPool: 100.0.0.0/8
ipv4Prefix: True
ipv4PrefixLength: 9
ipv4Subnet: 100.128.0.0
# ipv4DnsServers: [100.128.0.1]
name: IP_Pool_3
ipv6Prefix: True
ipv6PrefixLength: 64
ipv6GlobalPool: 2001:db8::/64
ipv6Subnet: "2001:db8::"
siteName: Global/Chennai/Trill
slaacSupport: True
# prev_name: IP_Pool_4
type: LAN
NetworkManagementDetails:
settings:
dhcpServer:
- 10.0.0.1
dnsServer:
domainName: cisco.com
primaryIpAddress: 10.0.0.2
secondaryIpAddress: 10.0.0.3
clientAndEndpoint_aaa: #works only if we system settigns is set
# ipAddress: 10.197.156.42 #Mandatory for ISE, sec ip for AAA
network: 10.0.0.20
protocol: RADIUS
servers: AAA
# sharedSecret: string #ISE
messageOfTheday:
bannerMessage: hello
retainExistingBanner: "true"
netflowcollector:
ipAddress: 10.0.0.4
port: 443
network_aaa: #works only if we system settigns is set
# ipAddress: string #Mandatory for ISE, sec ip for AAA
network: 10.0.0.20
protocol: TACACS
servers: AAA
# sharedSecret: string #ISE
ntpServer:
- 10.0.0.5
snmpServer:
configureDnacIP: True
ipAddresses:
- 10.0.0.6
syslogServer:
configureDnacIP: True
ipAddresses:
- 10.0.0.7
timezone: GMT
siteName: Global/Chennai
57 changes: 57 additions & 0 deletions plugins/module_utils/dnac.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,63 @@ def reset_values(self):
self.have.clear()
self.want.clear()

def get_execution_details(self, execid):
"""Check if the execution performed is sucessfull or not

Parameters:
execid - Id for executing the API

Returns:
response - Status for executing the API
"""

self.log("Execution Id " + str(execid))
response = self.dnac._exec(
family="task",
function='get_business_api_execution_details',
params={"execution_id": execid}
)
self.log("Response for the current execution" + str(response))
return response

def check_execution_response_status(self, response):
"""
Checks the reponse status provided by API in the DNAC

Parameters:
response - API response

Returns:
self
"""

self.log(str(response))
if not response:
self.msg = "response is empty"
self.status = "failed"
return self

if not isinstance(response, dict):
self.msg ="response is not a dictionary"
self.status="failed"
return self

executionid = response.get("executionId")
while True:
execution_details = self.get_execution_details(executionid)
if execution_details.get("status") == "SUCCESS":
self.result['changed'] = True
self.msg = "Successfully executed"
self.status = "success"
break

if execution_details.get("bapiError"):
self.msg = execution_details.get("bapiError")
self.status = "failed"
break

return self


def log(msg, frameIncrement=0):
with open('dnac.log', 'a') as of:
Expand Down
Loading