cisco-open / cisco-catalyst-wan-sdk

Cisco Catalyst WAN SDK
Apache License 2.0
17 stars 3 forks source link

no information about failure attach #563

Closed JimOverholt closed 6 months ago

JimOverholt commented 6 months ago

Summary

No information about the inability to attach the template due to an error in the template. There is only information about attach timeout. Trying to attach a template with an error:

(Pdb) templates.attach(cli_template.name, device)

Operatrion status not achieved in the given time, exception: None
False 

Logs and external information

No response

Reproduction script

from vmngclient.session import create_vManageSession
from ciscoconfparse.ciscoconfparse import CiscoConfParse
from vmngclient.api.basic_api import DeviceField, DevicesAPI
from vmngclient.api.templates import CliTemplate, TemplateAPI
from vmngclient.utils.device_model import DeviceModel

URL = 'x.x.x.x'
USER = 'admin'
PASS = 'Cisco#123@Viptela'
PORT = '9912'

# Create session to vManage
API_SESSION = create_vManageSession(
    url=URL,
    username=USER,
    password=PASS,
    port=PORT,
)

# Get device 
device_name = 'vm1'
device = DevicesAPI(API_SESSION).get(DeviceField.HOSTNAME, device_name)

# Create empty CLI template for select device
name_template = 'test'
desc_template = 'template for testing'

cli_template = CliTemplate(API_SESSION, DeviceModel(device.model), name_template, desc_template)

# Loading a working config from the machine
cli_template.load_running(device)

# Add something to config

"""
 !\n
 tacacs\n
  server 192.168.1.1\n
   vpn vpn 512\n
   secret-key a\n
   auth-port 151\n
  exit
"""

# Part of config to be add    
data_tacacs = "!\n  tacacs\n  server 192.168.1.1\n   vpn vpn 512\n   secret-key a\n   auth-port 151\n exit".splitlines()

for conf in CiscoConfParse(data_tacacs).ioscfg:
    cli_template.config.insert_after(r"\s+aaa$", conf, atomic=True, exactmatch=True, new_val_indent=2)

# Send to device
cli_template.send_to_device()

# Load all template in vManage
templates = TemplateAPI(API_SESSION)

# Attach template to device
templates.attach(cli_template.name, device)

On what platform(s) does it occur?

Not Applicable

Issue Severity

Medium: There is a workaround

JimOverholt commented 6 months ago

This issue was migrated from an old repository: https://github.com/CiscoDevNet/catalystwan/issues/48