nuagenetworks / vspk-python

A Python library for managing Nuage through its API
http://www.nuagenetworks.net
BSD 3-Clause "New" or "Revised" License
17 stars 19 forks source link

NUNetworkMacroGroup cannot accept child of NUEnterpriseNetwork ... why ? #25

Closed zerxen closed 6 years ago

zerxen commented 6 years ago

Hi, I am working on (quick&dirty CLI interface to Nuage) using vspk and some other APIs for automating our LAB and I hit a roadblock that I cannot get a network macro (NUEnterpriseNetwork ) registered as a child for NUNetworkMacroGroup to finish an ACL section

Any reason for "Method Not Allowed" ?

(Pdb) macro_group
<vspk.v4_0.nunetworkmacrogroup.NUNetworkMacroGroup object at 0x000000000550DEF0>
(Pdb) macro
<vspk.v4_0.nuenterprisenetwork.NUEnterpriseNetwork object at 0x00000000055CE4A8>
(Pdb) macro_group.create_child(macro)
*** BambouHTTPError: [HTTP 405(Method Not Allowed)] {}

I tried both as Enterprise admin and csproot, I am using v4_0 still from vspk 5.1.2 (from pip repo)

hellt commented 6 years ago

Hi @zerxen The reason is because NetwMacroGroup and NetworkMacro do not form parent->child relationship, but rather form a container. Thus, assign method should be used instead of create_child.

For instance a snippet from my lib shows how its done:

group_obj.assign(existing_children + [child_obj], getattr(vspk, child_vspk_name))
zerxen commented 6 years ago

Ok.... how would one know that looking at the documentation ? https://nuagenetworks.github.io/vspkdoc/v5_0/nunetworkmacrogroup.html

Since NUEnterpriseNetwork is listed as Children's list item ?

PS/EDIT: Yep worked now as "macro_group.assign([macro],vsdk.NUEnterpriseNetwork)"

hellt commented 6 years ago

I was confused myself when I first met this behavior. And VSPK doc shows no difference, you're right. What helps is to watch real API flow via Chrome/FF developer console when you do the operation in the Architect.

Additionally, this block here in the API specification shows that the relationship is of "member" type. A regular child would have relationship child instead of member.