Skip to content

Commit 9d54dcc

Browse files
authored
Merge pull request #315 from CiscoDevNet/dcnm_image_upgrade_v2_backup
Dcnm image upgrade v2
2 parents 1a81138 + 16d897a commit 9d54dcc

File tree

106 files changed

+16162
-19137
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+16162
-19137
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
all:
2+
vars:
3+
ansible_user: "admin"
4+
ansible_password: "password-ndfc"
5+
switch_password: "password-switch"
6+
ansible_python_interpreter: python
7+
ansible_httpapi_validate_certs: False
8+
ansible_httpapi_use_ssl: True
9+
children:
10+
ndfc:
11+
vars:
12+
ansible_connection: ansible.netcommon.httpapi
13+
ansible_network_os: cisco.dcnm.dcnm
14+
hosts:
15+
192.168.1.1:
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
# This playbook can be used to execute integration tests for
3+
# the role located in:
4+
#
5+
# tests/integration/targets/dcnm_image_upgrade
6+
#
7+
# Modify the hosts and vars sections with details for your testing
8+
# setup and uncomment the testcase you want to run.
9+
#
10+
- hosts: dcnm
11+
gather_facts: no
12+
connection: ansible.netcommon.httpapi
13+
14+
vars:
15+
# testcase: 00_setup_create_fabric
16+
# testcase: 01_setup_add_switches_to_fabric
17+
# testcase: 02_setup_replace_image_policies
18+
# testcase: deleted
19+
# testcase: deleted_1x_switch
20+
# testcase: merged_global_config
21+
# testcase: merged_override_global_config
22+
# testcase: query
23+
fabric_name: LAN_Classic_Fabric
24+
switch_username: admin
25+
switch_password: "{{ switch_password }}"
26+
leaf1: 192.168.1.2
27+
leaf2: 192.168.1.3
28+
spine1: 192.168.1.4
29+
# for dcnm_image_policy and dcnm_image_upgrade roles
30+
image_policy_1: NR1F
31+
image_policy_2: NR2F
32+
# for dcnm_image_policy role
33+
epld_image_1: n9000-epld.10.3.1.F.img
34+
epld_image_2: n9000-epld.10.3.1.F.img
35+
nxos_image_1: nxos64-cs.10.3.1.F.bin
36+
nxos_image_2: nxos64-cs.10.3.2.F.bin
37+
nxos_release_1: 10.3.1_nxos64-cs_64bit
38+
nxos_release_2: 10.3.2_nxos64-cs_64bit
39+
# for dcnm_image_upgrade role
40+
fabric_name_1: "{{ fabric_name }}"
41+
ansible_switch_1: "{{ leaf1 }}"
42+
ansible_switch_2: "{{ leaf2 }}"
43+
ansible_switch_3: "{{ spine1 }}"
44+
45+
roles:
46+
- dcnm_image_upgrade
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright (c) 2024 Cisco and/or its affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from __future__ import absolute_import, division, print_function
16+
17+
__metaclass__ = type
18+
__author__ = "Allen Robel"
19+
20+
import logging
21+
22+
from ansible_collections.cisco.dcnm.plugins.module_utils.common.api.v1.imagemanagement.rest.rest import \
23+
Rest
24+
25+
26+
class PackageMgnt(Rest):
27+
"""
28+
## api.v1.imagemanagement.rest.packagemgnt.PackageMgnt()
29+
30+
### Description
31+
Common methods and properties for PackageMgnt() subclasses
32+
33+
### Path
34+
``/appcenter/cisco/ndfc/api/v1/imagemanagement/rest/packagemgnt``
35+
"""
36+
37+
def __init__(self):
38+
super().__init__()
39+
self.class_name = self.__class__.__name__
40+
self.log = logging.getLogger(f"dcnm.{self.class_name}")
41+
self.packagemgnt = f"{self.rest}/packagemgnt"
42+
self.log.debug("ENTERED api.v1.PackageMgnt()")
43+
44+
45+
class EpIssu(PackageMgnt):
46+
"""
47+
## api.v1.imagemanagement.rest.packagemgnt.EpIssu()
48+
49+
### Description
50+
Return endpoint information.
51+
52+
### Raises
53+
- None
54+
55+
### Path
56+
- ``/api/v1/imagemanagement/rest/packagemgnt/issu``
57+
58+
### Verb
59+
- GET
60+
61+
### Parameters
62+
- path: retrieve the path for the endpoint
63+
- verb: retrieve the verb for the endpoint
64+
65+
### Usage
66+
```python
67+
instance = EpIssu()
68+
path = instance.path
69+
verb = instance.verb
70+
```
71+
"""
72+
73+
def __init__(self):
74+
super().__init__()
75+
self.class_name = self.__class__.__name__
76+
self.log = logging.getLogger(f"dcnm.{self.class_name}")
77+
msg = "ENTERED api.v1.imagemanagement.rest."
78+
msg += f"packagemgnt.{self.class_name}"
79+
self.log.debug(msg)
80+
81+
@property
82+
def path(self):
83+
return f"{self.packagemgnt}/issu"
84+
85+
@property
86+
def verb(self):
87+
return "GET"

plugins/module_utils/common/api/v1/imagemanagement/rest/policymgnt/policymgnt.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,18 +299,52 @@ def __init__(self):
299299
super().__init__()
300300
self.class_name = self.__class__.__name__
301301
self.log = logging.getLogger(f"dcnm.{self.class_name}")
302+
self._serial_numbers = None
302303
msg = "ENTERED api.v1.imagemanagement.rest."
303304
msg += f"policymgnt.{self.class_name}"
304305
self.log.debug(msg)
305306

306307
@property
307308
def path(self):
308-
return f"{self.policymgnt}/detach-policy"
309+
"""
310+
### Summary
311+
The endpoint path.
312+
313+
### Raises
314+
- ``ValueError`` if:
315+
- ``path`` is accessed before setting ``serial_numbers``.
316+
"""
317+
if self.serial_numbers is None:
318+
msg = f"{self.class_name}.serial_numbers must be set before "
319+
msg += f"accessing {self.class_name}.path."
320+
raise ValueError(msg)
321+
query_param = ",".join(self.serial_numbers)
322+
return f"{self.policymgnt}/detach-policy?serialNumber={query_param}"
309323

310324
@property
311325
def verb(self):
312326
return "DELETE"
313327

328+
@property
329+
def serial_numbers(self):
330+
"""
331+
### Summary
332+
A ``list`` of switch serial numbers.
333+
334+
### Raises
335+
- ``TypeError`` if:
336+
- ``serial_numbers`` is not a ``list``.
337+
"""
338+
return self._serial_numbers
339+
340+
@serial_numbers.setter
341+
def serial_numbers(self, value):
342+
if not isinstance(value, list):
343+
msg = f"{self.class_name}.serial_numbers must be a list "
344+
msg += "of switch serial numbers."
345+
raise TypeError(msg)
346+
self._serial_numbers = value
347+
314348

315349
class EpPolicyEdit(PolicyMgnt):
316350
"""

0 commit comments

Comments
 (0)