|
|
@ -328,7 +328,8 @@ def map_obj_to_commands(updates):
|
|
|
|
|
|
|
|
|
|
|
|
def check_declarative_intent_params(module, want, result):
|
|
|
|
def check_declarative_intent_params(module, want, result):
|
|
|
|
failed_conditions = []
|
|
|
|
failed_conditions = []
|
|
|
|
have_neighbors = None
|
|
|
|
have_neighbors_lldp = None
|
|
|
|
|
|
|
|
have_neighbors_cdp = None
|
|
|
|
for w in want:
|
|
|
|
for w in want:
|
|
|
|
want_state = w.get('state')
|
|
|
|
want_state = w.get('state')
|
|
|
|
want_tx_rate = w.get('tx_rate')
|
|
|
|
want_tx_rate = w.get('tx_rate')
|
|
|
@ -375,13 +376,15 @@ def check_declarative_intent_params(module, want, result):
|
|
|
|
if want_neighbors:
|
|
|
|
if want_neighbors:
|
|
|
|
have_host = []
|
|
|
|
have_host = []
|
|
|
|
have_port = []
|
|
|
|
have_port = []
|
|
|
|
if have_neighbors is None:
|
|
|
|
|
|
|
|
rc, have_neighbors, err = exec_command(module, 'show lldp neighbors detail')
|
|
|
|
# Process LLDP neighbors
|
|
|
|
|
|
|
|
if have_neighbors_lldp is None:
|
|
|
|
|
|
|
|
rc, have_neighbors_lldp, err = exec_command(module, 'show lldp neighbors detail')
|
|
|
|
if rc != 0:
|
|
|
|
if rc != 0:
|
|
|
|
module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), command=command, rc=rc)
|
|
|
|
module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), command=command, rc=rc)
|
|
|
|
|
|
|
|
|
|
|
|
if have_neighbors:
|
|
|
|
if have_neighbors_lldp:
|
|
|
|
lines = have_neighbors.strip().split('Local Intf: ')
|
|
|
|
lines = have_neighbors_lldp.strip().split('Local Intf: ')
|
|
|
|
for line in lines:
|
|
|
|
for line in lines:
|
|
|
|
field = line.split('\n')
|
|
|
|
field = line.split('\n')
|
|
|
|
if field[0].strip() == w['name']:
|
|
|
|
if field[0].strip() == w['name']:
|
|
|
@ -390,6 +393,20 @@ def check_declarative_intent_params(module, want, result):
|
|
|
|
have_host.append(item.split(':')[1].strip())
|
|
|
|
have_host.append(item.split(':')[1].strip())
|
|
|
|
if item.startswith('Port Description:'):
|
|
|
|
if item.startswith('Port Description:'):
|
|
|
|
have_port.append(item.split(':')[1].strip())
|
|
|
|
have_port.append(item.split(':')[1].strip())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Process CDP neighbors
|
|
|
|
|
|
|
|
if have_neighbors_cdp is None:
|
|
|
|
|
|
|
|
rc, have_neighbors_cdp, err = exec_command(module, 'show cdp neighbors detail')
|
|
|
|
|
|
|
|
if rc != 0:
|
|
|
|
|
|
|
|
module.fail_json(msg=to_text(err, errors='surrogate_then_replace'), command=command, rc=rc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if have_neighbors_cdp:
|
|
|
|
|
|
|
|
neighbors_cdp = re.findall('Device ID: (.*?)\n.*?Interface: (.*?), Port ID .outgoing port.: (.*?)\n', have_neighbors_cdp, re.S)
|
|
|
|
|
|
|
|
for host, localif, remoteif in neighbors_cdp:
|
|
|
|
|
|
|
|
if localif == w['name']:
|
|
|
|
|
|
|
|
have_host.append(host)
|
|
|
|
|
|
|
|
have_port.append(remoteif)
|
|
|
|
|
|
|
|
|
|
|
|
for item in want_neighbors:
|
|
|
|
for item in want_neighbors:
|
|
|
|
host = item.get('host')
|
|
|
|
host = item.get('host')
|
|
|
|
port = item.get('port')
|
|
|
|
port = item.get('port')
|
|
|
|