@@ -752,7 +752,7 @@ def update_create_params(self, inv):
752
752
def get_have (self ):
753
753
754
754
method = "GET"
755
- path = "/rest/control/fabrics/{0}/inventory" .format (self .fabric )
755
+ path = "/rest/control/fabrics/{0}/inventory/switchesByFabric " .format (self .fabric )
756
756
if self .nd :
757
757
path = self .nd_prefix + path
758
758
inv_objects = dcnm_send (self .module , method , path )
@@ -783,7 +783,7 @@ def get_have(self):
783
783
get_switch .update ({"sysName" : inv ["logicalName" ]})
784
784
get_switch .update ({"serialNumber" : inv ["serialNumber" ]})
785
785
get_switch .update ({"ipaddr" : inv ["ipAddress" ]})
786
- get_switch .update ({"platform" : inv ["nonMdsModel " ]})
786
+ get_switch .update ({"platform" : inv ["model " ]})
787
787
get_switch .update ({"version" : inv ["release" ]})
788
788
get_switch .update (
789
789
{"deviceIndex" : inv ["logicalName" ] + "(" + inv ["serialNumber" ] + ")" }
@@ -1219,7 +1219,7 @@ def rediscover_all_switches(self):
1219
1219
1220
1220
# Get Fabric Inventory Details
1221
1221
method = "GET"
1222
- path = "/rest/control/fabrics/{0}/inventory" .format (self .fabric )
1222
+ path = "/rest/control/fabrics/{0}/inventory/switchesByFabric " .format (self .fabric )
1223
1223
if self .nd :
1224
1224
path = self .nd_prefix + path
1225
1225
get_inv = dcnm_send (self .module , method , path )
@@ -1339,7 +1339,7 @@ def all_switches_ok(self):
1339
1339
all_ok = True
1340
1340
# Get Fabric Inventory Details
1341
1341
method = "GET"
1342
- path = "/rest/control/fabrics/{0}/inventory" .format (self .fabric )
1342
+ path = "/rest/control/fabrics/{0}/inventory/switchesByFabric " .format (self .fabric )
1343
1343
if self .nd :
1344
1344
path = self .nd_prefix + path
1345
1345
get_inv = dcnm_send (self .module , method , path )
@@ -1390,7 +1390,7 @@ def lancred_all_switches(self):
1390
1390
method = "GET"
1391
1391
path = "/fm/fmrest/lanConfig/getLanSwitchCredentials"
1392
1392
if self .nd :
1393
- path = self .nd_prefix + "/" + path [6 :]
1393
+ path = self .nd_prefix + "/" + path [6 :] + "WithType"
1394
1394
# lan_path = '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/lanConfig/getLanSwitchCredentials'
1395
1395
get_lan = dcnm_send (self .module , method , path )
1396
1396
missing_fabric , not_ok = self .handle_response (get_lan , "query_dcnm" )
@@ -1426,7 +1426,7 @@ def lancred_all_switches(self):
1426
1426
def assign_role (self ):
1427
1427
1428
1428
method = "GET"
1429
- path = "/rest/control/fabrics/{0}/inventory" .format (self .fabric )
1429
+ path = "/rest/control/fabrics/{0}/inventory/switchesByFabric " .format (self .fabric )
1430
1430
if self .nd :
1431
1431
path = self .nd_prefix + path
1432
1432
get_role = dcnm_send (self .module , method , path )
@@ -1447,14 +1447,28 @@ def assign_role(self):
1447
1447
self .fabric
1448
1448
)
1449
1449
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 )
1450
1455
if role ["ipAddress" ] == create ["switches" ][0 ]["ipaddr" ]:
1451
1456
method = "PUT"
1452
1457
path = "/fm/fmrest/topology/role/{0}?newRole={1}" .format (
1453
1458
role ["switchDbID" ], create ["role" ].replace ("_" , "%20" )
1454
1459
)
1460
+ data = None
1455
1461
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 )
1458
1472
self .result ["response" ].append (response )
1459
1473
fail , self .result ["changed" ] = self .handle_response (
1460
1474
response , "create"
@@ -1469,14 +1483,28 @@ def assign_role(self):
1469
1483
self .fabric
1470
1484
)
1471
1485
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 )
1472
1491
if role ["ipAddress" ] == create ["ipAddress" ]:
1473
1492
method = "PUT"
1474
1493
path = "/fm/fmrest/topology/role/{0}?newRole={1}" .format (
1475
1494
role ["switchDbID" ], create ["role" ].replace ("_" , "%20" )
1476
1495
)
1496
+ data = None
1477
1497
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 )
1480
1508
self .result ["response" ].append (response )
1481
1509
fail , self .result ["changed" ] = self .handle_response (
1482
1510
response , "create"
@@ -1589,7 +1617,7 @@ def get_diff_query(self):
1589
1617
query_poap = self .params ["query_poap" ]
1590
1618
1591
1619
method = "GET"
1592
- path = "/rest/control/fabrics/{0}/inventory" .format (self .fabric )
1620
+ path = "/rest/control/fabrics/{0}/inventory/switchesByFabric " .format (self .fabric )
1593
1621
if self .nd :
1594
1622
path = self .nd_prefix + path
1595
1623
inv_objects = dcnm_send (self .module , method , path )
0 commit comments