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

Develop to v6.6.2 #87

Merged
merged 8 commits into from
Dec 19, 2022
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Other versions of this collection have support for previous Cisco DNA Center ver
| 2.1.1 | 3.0.0 | 2.2.5 |
| 2.2.2.3 | 3.3.1 | 2.3.3 |
| 2.2.3.3 | 6.4.0 | 2.4.11 |
| 2.3.3.0 | 6.6.1 | 2.5.5 |
| 2.3.3.0 | 6.6.2 | 2.5.5 |

*Notes*:

Expand Down
10 changes: 9 additions & 1 deletion changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -607,4 +607,12 @@ releases:
release_summary: Added the ability to export DNA Center credentials as environment variables and rennamed some vars.
bugfixes:
- DNA Center credentials can now be exported and used as env vars.
- sda_virtual_network_ip_pool - Now pass the site_name_hierarchy correctly in get method.
- sda_virtual_network_ip_pool - Now pass the site_name_hierarchy correctly in get method.
6.6.2:
release_date: "2022-12-19"
changes:
release_summary:
bugfixes:
- sda_fabric_border_device - fix Create example at EXAMPLES block
- site_intent - fix Case_1 return example at RETURN block
- swim_intent - fix functionality and tests
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: dnac
version: 6.6.1
version: 6.6.2
readme: README.md
authors:
- Rafael Campos <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/sda_fabric_border_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
vlanName: string
l3Handoff:
- virtualNetwork:
- virtualNetworkName: string
virtualNetworkName: string
vlanId: string
externalDomainRoutingProtocolName: string
internalAutonomouSystemNumber: string
Expand Down
21 changes: 15 additions & 6 deletions plugins/modules/site_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@
"endTime": String,
"endTimeEpoch": 0,
"runtimeInstanceId": String,
"siteId": String,
"startTime": String,
"startTimeEpoch": 0,
"status": String,
"timeDuration": 0

}
},
"msg": "string"
}

Expand All @@ -165,7 +166,12 @@
type: dict
sample: >
{
"response": {},
"response":
{
"site": {},
"siteId": String,
"type": String
},
"msg": String
}

Expand All @@ -190,7 +196,7 @@
"status": String,
"timeDuration": 0

}
},
"msg": "string"
}

Expand Down Expand Up @@ -301,7 +307,7 @@ def get_current_site(self, site):
building=dict(
name=site[0].get("name"),
parentName=site[0].get("siteNameHierarchy").split("/" + site[0].get("name"))[0],
address=location.get("attributes").get("address"),
address=location.get("attributes").get("address", ""),
latitude=location.get("attributes").get("latitude"),
longitude=location.get("attributes").get("longitude"),
)
Expand All @@ -326,7 +332,7 @@ def get_current_site(self, site):
current_site = dict(
type=typeinfo,
site=site_info,
site_id=site[0].get("id")
siteId=site[0].get("id")
)

if self.log:
Expand Down Expand Up @@ -430,7 +436,7 @@ def get_have(self):
log("Site Exists: " + str(site_exists) + "\n Current Site:" + str(current_site))

if site_exists:
have["site_id"] = current_site.get("site_id")
have["site_id"] = current_site.get("siteId")
have["site_exists"] = site_exists
have["current_site"] = current_site

Expand Down Expand Up @@ -501,6 +507,7 @@ def get_diff_merge(self):
if site_updated:
log("Site Updated Successfully")
self.result['msg'] = "Site Updated Successfully"
self.result['response'].update({"siteId": self.have.get("site_id")})

else:
# Get the site id of the newly created site.
Expand All @@ -510,6 +517,7 @@ def get_diff_merge(self):
log("Site Created Successfully")
log("Current site:" + str(current_site))
self.result['msg'] = "Site Created Successfully"
self.result['response'].update({"siteId": current_site.get('site_id')})

def get_diff_delete(self):
site_exists = self.have.get("site_exists")
Expand All @@ -528,6 +536,7 @@ def get_diff_delete(self):
if execution_details.get("status") == "SUCCESS":
self.result['changed'] = True
self.result['response'] = execution_details
self.result['response'].update({"siteId": self.have.get("site_id")})
self.result['msg'] = "Site deleted successfully"
break

Expand Down
12 changes: 9 additions & 3 deletions plugins/modules/swim_intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ def get_device_family_identifier(self, family_name):
family="software_image_management_swim",
function='get_device_family_identifiers',
)
if self.log:
log(str(response))
device_family_db = response.get("response")
if device_family_db:
device_family_details = get_dict_result(device_family_db, 'deviceFamily', family_name)
Expand All @@ -402,7 +404,7 @@ def get_device_family_identifier(self, family_name):
if self.log:
log("Family device indentifier:" + str(device_family_identifier))
else:
self.module.fail_json(msg="Family Device Name not found")
self.module.fail_json(msg="Family Device Name not found", response=[])
self.have.update(have)

def get_have(self):
Expand Down Expand Up @@ -535,13 +537,17 @@ def get_diff_import(self):

if task_details and task_details.get("isError"):
if "Image already exists" in task_details.get("failureReason"):
self.result['msg'] = "Image already exists."
break
else:
self.module.fail_json(msg=task_details.get("failureReason"),
response=task_details)

self.result['response'] = task_details if task_details else response
# Fetch image_id if the imported image for further use
if not (self.want.get("tagging_details") or self.want.get("distribution_details")
or self.want.get("activation_details")):
return
# Fetch image_id for the imported image for further use
image_name = self.want.get("url_import_details").get("payload")[0].get("sourceURL")
image_name = image_name.split('/')[-1]
image_id = self.get_image_id(image_name)
Expand Down Expand Up @@ -571,7 +577,7 @@ def get_diff_tagging(self):
else:
image_params = dict(
image_id=self.have.get("tagging_image_id"),
ite_id=self.have.get("site_id"),
site_id=self.have.get("site_id"),
device_family_identifier=self.have.get("device_family_identifier"),
device_role=tagging_details.get("deviceRole")
)
Expand Down
211 changes: 211 additions & 0 deletions tests/unit/modules/dnac/fixtures/swim_intent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
{
"playbook_config": [{
"importImageDetails": {
"type": "url",
"urlDetails": {
"payload": [{
"sourceURL":"http://10.104.118.10/swim/17.9/cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin",
"isThirdParty": 0
}]
}
},
"taggingDetails": {
"deviceRole": "ALL",
"deviceFamilyName": "Cisco Catalyst 9606R Switch-Cisco Catalyst 9600 Series Supervisor Engine 1",
"tagging": true
},
"imageDistributionDetails": {
"deviceSerialNumber": "FXS2325Q01C"
},
"imageActivationDetails": {
"scehduleValidate": false,
"activateLowerImageVersion": true,
"deviceSerialNumber": "FXS2325Q01C"
}
}],
"playbook_config_image_import": [{
"importImageDetails": {
"type": "url",
"urlDetails": {
"payload": [{
"sourceURL":"http://10.104.118.10/swim/17.9/cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin",
"isThirdParty": 0
}]
}
}
}],
"playbook_config_untag_golden_image":[{
"taggingDetails": {
"imageName": "cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin",
"deviceRole": "ALL",
"deviceFamilyName": "Cisco Catalyst 9606R Switch-Cisco Catalyst 9600 Series Supervisor Engine 1",
"tagging": false,
"siteName": "Global/Bangalore/Trill"
}
}],
"playbook_config_tag_golden_image_missing_param":[{
"taggingDetails": {
"deviceRole": "ALL",
"deviceFamilyName": "Cisco Catalyst 9606R Switch-Cisco Catalyst 9600 Series Supervisor Engine 1",
"tagging": true,
"siteName": "Global/Bangalore/Trill"
}
}],
"playbook_config_tag_golden_image_incorrect_family_name":[{
"taggingDetails": {
"imageName": "cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin",
"deviceRole": "ALL",
"deviceFamilyName": "Cisco Catalyst 9600 Series Supervisor Engine 1",
"tagging": true,
"siteName": "Global/Bangalore/Trill"
}
}],
"playbook_config_activation_missing_param":[{
"imageActivationDetails": {
"scehduleValidate": false,
"activateLowerImageVersion": true,
"deviceSerialNumber": "FXS2325Q01C"
}
}],
"playbook_config_distribution":[{
"imageDistributionDetails": {
"deviceSerialNumber": "FXS2325Q01C",
"imageName": "cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin"
}
}],
"playbook_config_activation":[{
"imageActivationDetails": {
"scehduleValidate": false,
"activateLowerImageVersion": true,
"deviceSerialNumber": "FXS2325Q01C",
"imageName": "cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin"
}
}],
"playbook_config_distribution_missing_param":[{
"imageDistributionDetails": {
"deviceSerialNumber": "FXS2325Q01C"
}
}],
"task_info_response": {
"response": {
"taskId": "0df54111-93ed-41e9-9c6d-2590e395dd45"
}
},
"image_imported_successfully_response": {
"response": {
"data": "import",
"progress": "completed successfully. Success = 1, Failure = 0, Running = 0, Pending = 0, Total = 1",
"version": 1663130446725,
"endTime": 1663130659133,
"startTime": 1663130446717,
"serviceType": "Swim Service",
"isError": false,
"rootId": "0df54111-93ed-41e9-9c6d-2590e395dd45",
"additionalStatusURL": "/api/v1/image/task?taskUuid=0df54111-93ed-41e9-9c6d-2590e395dd45",
"lastUpdate": 1663130446725,
"instanceTenantId": "626aafc1ceaf922ba8951626",
"id": "0df54111-93ed-41e9-9c6d-2590e395dd45"
},
"version": "1.0"
},
"image_id_fetched_successfully_response": {
"response": [{
"imageUuid": "b03146ee-f93d-457c-a1c1-87f31219f902",
"name": "cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin",
"family": "CAT9K",
"version": "17.09.01.0.29",
"displayVersion": "17.09.01",
"imageName": "cat9k_iosxe.BLD_V179_THROTTLE_LATEST_20220429_033422.SSA.bin",
"isTaggedGolden": false
}]
},
"image_already_exists_response":{
"response": {
"data": "import",
"progress": "Workflow Image Import failed. Success = 0, Failure = 1, Running = 0, Pending = 0, Total = 1",
"errorCode": "400",
"serviceType": "Swim Service",
"isError": true,
"failureReason": "NCSW10042: Image already exists"
},
"version": "1.0"
},
"image_doesnot_exist_response": {
"response": [],
"version": "1.0"
},
"device_family_fetched_successfully": {
"response": [{
"deviceFamily": "Cisco Catalyst 9606R Switch-Cisco Catalyst 9600 Series Supervisor Engine 1",
"deviceFamilyIdentifier": "286322137-286323141"
}]
},
"device_id_fetched_successfully_response": {
"response": [{
"type": "Cisco Catalyst 9606R Switch",
"macAddress": "2c:4f:52:05:a9:40",
"serialNumber": "FXS2325Q01C",
"family": "Switches and Hubs",
"platformId": "C9606R",
"series": "Cisco Catalyst 9600 Series Switches",
"instanceUuid": "108d726f-be89-4d7a-8234-44e4808cca4f",
"id": "108d726f-be89-4d7a-8234-44e4808cca4f"
}]
},
"device_doesnot_exist_response":{
"response": [],
"version": "1.0"
},
"tagging_image_successful_response": {
"response": {
"data": "Golden-Tagging",
"progress": "Tagging image as Golden.",
"serviceType": "Swim Service",
"isError": false,
"id": "a98068db-1867-49a5-a470-5c3d2b3c514f"
}
},
"untagging_image_successful_response": {
"response": {
"data": "Golden-Tagging",
"progress": "Un-tagging image as Golden.",
"serviceType": "Swim Service",
"isError": false,
"id": "a98068db-1867-49a5-a470-5c3d2b3c514f"
}
},
"image_distribution_successful_response": {
"response": {
"data": "distribute",
"progress": "completed successfully. Success = 1, Failure = 0, Running = 0, Pending = 0, Total = 1", "serviceType": "Swim Service",
"isError": false,
"id": "ba152b35-afde-490f-8575-82c1fce0fab4"
}
},
"image_activation_successful_response": {
"response": {
"data": "activate",
"progress": "completed successfully. Success = 1, Failure = 0, Running = 0, Pending = 0, Total = 1", "serviceType": "Swim Service",
"isError": false,
"id": "b6f3b7dd-f2b1-46ee-9111-32137226adc0"
}
},
"fetch_site_id_response": {
"response": [{
"parentId": "597dba2d-c09f-4bae-ae61-8b0d9c8cd268",
"additionalInfo": [{
"nameSpace": "Location",
"attributes": {
"country": "India",
"latitude": "12.933971097851867",
"addressInheritedFrom": "597dba2d-c09f-4bae-ae61-8b0d9c8cd268",
"type": "building",
"longitude": "80.2467681804189"
}
}],
"name": "Trill",
"id": "87169daa-7de2-4f9d-814a-d8746de41be6",
"siteNameHierarchy": "Global/Chennai/Trill"
}]
}
}
Loading