Skip to content

Commit 2b17fdb

Browse files
committed
changed unpublished endpoints to published ones
1 parent 413febe commit 2b17fdb

File tree

1 file changed

+39
-11
lines changed

1 file changed

+39
-11
lines changed

plugins/modules/dcnm_inventory.py

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ def update_create_params(self, inv):
752752
def get_have(self):
753753

754754
method = "GET"
755-
path = "/rest/control/fabrics/{0}/inventory".format(self.fabric)
755+
path = "/rest/control/fabrics/{0}/inventory/switchesByFabric".format(self.fabric)
756756
if self.nd:
757757
path = self.nd_prefix + path
758758
inv_objects = dcnm_send(self.module, method, path)
@@ -783,7 +783,7 @@ def get_have(self):
783783
get_switch.update({"sysName": inv["logicalName"]})
784784
get_switch.update({"serialNumber": inv["serialNumber"]})
785785
get_switch.update({"ipaddr": inv["ipAddress"]})
786-
get_switch.update({"platform": inv["nonMdsModel"]})
786+
get_switch.update({"platform": inv["model"]})
787787
get_switch.update({"version": inv["release"]})
788788
get_switch.update(
789789
{"deviceIndex": inv["logicalName"] + "(" + inv["serialNumber"] + ")"}
@@ -1219,7 +1219,7 @@ def rediscover_all_switches(self):
12191219

12201220
# Get Fabric Inventory Details
12211221
method = "GET"
1222-
path = "/rest/control/fabrics/{0}/inventory".format(self.fabric)
1222+
path = "/rest/control/fabrics/{0}/inventory/switchesByFabric".format(self.fabric)
12231223
if self.nd:
12241224
path = self.nd_prefix + path
12251225
get_inv = dcnm_send(self.module, method, path)
@@ -1339,7 +1339,7 @@ def all_switches_ok(self):
13391339
all_ok = True
13401340
# Get Fabric Inventory Details
13411341
method = "GET"
1342-
path = "/rest/control/fabrics/{0}/inventory".format(self.fabric)
1342+
path = "/rest/control/fabrics/{0}/inventory/switchesByFabric".format(self.fabric)
13431343
if self.nd:
13441344
path = self.nd_prefix + path
13451345
get_inv = dcnm_send(self.module, method, path)
@@ -1390,7 +1390,7 @@ def lancred_all_switches(self):
13901390
method = "GET"
13911391
path = "/fm/fmrest/lanConfig/getLanSwitchCredentials"
13921392
if self.nd:
1393-
path = self.nd_prefix + "/" + path[6:]
1393+
path = self.nd_prefix + "/" + path[6:] + "WithType"
13941394
# lan_path = '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/lanConfig/getLanSwitchCredentials'
13951395
get_lan = dcnm_send(self.module, method, path)
13961396
missing_fabric, not_ok = self.handle_response(get_lan, "query_dcnm")
@@ -1426,7 +1426,7 @@ def lancred_all_switches(self):
14261426
def assign_role(self):
14271427

14281428
method = "GET"
1429-
path = "/rest/control/fabrics/{0}/inventory".format(self.fabric)
1429+
path = "/rest/control/fabrics/{0}/inventory/switchesByFabric".format(self.fabric)
14301430
if self.nd:
14311431
path = self.nd_prefix + path
14321432
get_role = dcnm_send(self.module, method, path)
@@ -1447,14 +1447,28 @@ def assign_role(self):
14471447
self.fabric
14481448
)
14491449
self.module.fail_json(msg=msg)
1450+
if not role["serialNumber"]:
1451+
msg = "Unable to get serial number using getLanSwitchCredentials under fabric: {0}".format(
1452+
self.fabric
1453+
)
1454+
self.module.fail_json(msg=msg)
14501455
if role["ipAddress"] == create["switches"][0]["ipaddr"]:
14511456
method = "PUT"
14521457
path = "/fm/fmrest/topology/role/{0}?newRole={1}".format(
14531458
role["switchDbID"], create["role"].replace("_", "%20")
14541459
)
1460+
data = None
14551461
if self.nd:
1456-
path = self.nd_prefix + "/" + path[6:]
1457-
response = dcnm_send(self.module, method, path)
1462+
method = "POST"
1463+
path = "/rest/control/switches/roles"
1464+
path = self.nd_prefix + "/" + path
1465+
data = json.dumps(
1466+
{
1467+
"serialNumber": role["serialNumber"],
1468+
"role": create["role"],
1469+
}
1470+
)
1471+
response = dcnm_send(self.module, method, path, data)
14581472
self.result["response"].append(response)
14591473
fail, self.result["changed"] = self.handle_response(
14601474
response, "create"
@@ -1469,14 +1483,28 @@ def assign_role(self):
14691483
self.fabric
14701484
)
14711485
self.module.fail_json(msg=msg)
1486+
if not role["serialNumber"]:
1487+
msg = "Unable to get serial number using getLanSwitchCredentials under fabric: {0}".format(
1488+
self.fabric
1489+
)
1490+
self.module.fail_json(msg=msg)
14721491
if role["ipAddress"] == create["ipAddress"]:
14731492
method = "PUT"
14741493
path = "/fm/fmrest/topology/role/{0}?newRole={1}".format(
14751494
role["switchDbID"], create["role"].replace("_", "%20")
14761495
)
1496+
data = None
14771497
if self.nd:
1478-
path = self.nd_prefix + "/" + path[6:]
1479-
response = dcnm_send(self.module, method, path)
1498+
method = "POST"
1499+
path = "/rest/control/switches/roles"
1500+
path = self.nd_prefix + "/" + path
1501+
data = json.dumps(
1502+
{
1503+
"serialNumber": role["serialNumber"],
1504+
"role": create["role"],
1505+
}
1506+
)
1507+
response = dcnm_send(self.module, method, path, data)
14801508
self.result["response"].append(response)
14811509
fail, self.result["changed"] = self.handle_response(
14821510
response, "create"
@@ -1589,7 +1617,7 @@ def get_diff_query(self):
15891617
query_poap = self.params["query_poap"]
15901618

15911619
method = "GET"
1592-
path = "/rest/control/fabrics/{0}/inventory".format(self.fabric)
1620+
path = "/rest/control/fabrics/{0}/inventory/switchesByFabric".format(self.fabric)
15931621
if self.nd:
15941622
path = self.nd_prefix + path
15951623
inv_objects = dcnm_send(self.module, method, path)

0 commit comments

Comments
 (0)