datacenter / acitoolkit

A basic toolkit for accessing the Cisco APIC
Other
348 stars 266 forks source link

Input validation needed for naming properties #24

Open mtimm opened 9 years ago

mtimm commented 9 years ago

In the simple aci toolkit is possible to add a naming property that is greater than 64 characters long or contains invalid characters per the naming property input validator and the toolkit does not catch it until the property is sent to the APIC and an error is returned. This is problematic in several ways:

There may be other reasons but this seems sufficient for one issue report.

mtimm commented 9 years ago

Here's an example of using the cli script where something obviously wrong happened and yet the script failed in a totally unexpected way. I alluded to it in the comments when I opened the issue. The behavior is now different on the exact same setup so it appears that the fabric I was using may have had an issue at the time that this occurred but the error that is returned is not what one would expect I think:

fabric(config)# tenant mtimm-acitoolkit
Executing create tenant command
fabric(config)# exit
fabric# switchto mtimm-acitoolkit
Traceback (most recent call last):
  File "acitoolkitcli.py", line 1126, in <module>
    cmdLine.cmdloop()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/cmd.py", line 221, in onecmd
    return func(arg)
  File "acitoolkitcli.py", line 1019, in do_switchto
    if Tenant.exists(self.apic, tenant):
  File "/local/insieme/Simple-ACI-Toolkit/acitoolkit.py", line 37, in exists
    apic_tenants = cls.get(session)
  File "/local/insieme/Simple-ACI-Toolkit/acitoolkit.py", line 28, in get
    return BaseACIObject.get(session, cls, 'fvTenant')
  File "/local/insieme/Simple-ACI-Toolkit/acibaseobject.py", line 302, in get
    name = str(object_data[apic_class]['attributes']['name'])
KeyError: 'fvTenant'