nuagenetworks / bambou

low level rest communication library for vsp style apis
BSD 3-Clause "New" or "Revised" License
7 stars 11 forks source link

Fetching VRSs causes error #1

Closed pdellaert closed 9 years ago

pdellaert commented 9 years ago

If you request the VRSs from a VSC. It will return an error: 400 Bad request.

It is using the wrong URL to fetch the VRSs (.../vscs/ID/vrs instead of .../vscs/ID/vrss)

Code example:

import logging
from vspk.vsdk import v3_2 as vsdk
from vspk.vsdk.v3_2.utils import set_log_level

log_level = logging.INFO
set_log_level(log_level)
nc = vsdk.NUVSDSession(username="csproot", password="PASSWORD", enterprise="csp", api_url="https://VSD-IP:8443")
nc.start()
nc.user.vsps.get()[0].vscs.get()[0].vrss.get()

Return:

Bambou Sending >>>>>>
GET https://10.167.43.64/nuage/api/v3_2/vscs/589de448-d016-4cd3-91d9-3f8d258e93e3/vrs with following data:
null
Bambou <<<<< Response [400] for
GET https://10.167.43.64/nuage/api/v3_2/vscs/589de448-d016-4cd3-91d9-3f8d258e93e3/vrs
null
---------------------------------------------------------------------------
BambouHTTPError                           Traceback (most recent call last)
<ipython-input-8-9570ff7866a4> in <module>()
----> 1 nc.user.vsps.get()[0].vscs.get()[0].vrss.get()

/usr/lib/python2.7/site-packages/bambou/nurest_fetcher.pyc in get(self, filter, order_by, group_by, page, page_size, commit, async, callback)
    351                 [<NUChildren at xxx>, <NUChildren at yyyy>, <NUChildren at zzz>]
    352         """
--> 353         return self.fetch(filter=filter, order_by=order_by, group_by=group_by, page=page, page_size=page_size, commit=False)[2]
    354
    355     def get_first(self, filter=None, order_by=None, group_by=[], page=None, page_size=None, commit=True, async=False, callback=None):

/usr/lib/python2.7/site-packages/bambou/nurest_fetcher.pyc in fetch(self, filter, order_by, group_by, page, page_size, commit, async, callback)
    271
    272         connection = self.parent_object.send_request(request=request, user_info={'commit': commit})
--> 273         return self._did_fetch(connection=connection)
    274
    275     def _did_fetch(self, connection):

/usr/lib/python2.7/site-packages/bambou/nurest_fetcher.pyc in _did_fetch(self, connection)
    281
    282         if connection.response.status_code >= 400 and BambouConfig._should_raise_bambou_http_error:
--> 283             raise BambouHTTPError(connection=connection)
    284
    285         if response.status_code != 200:

BambouHTTPError: [HTTP 400(Bad Request)] {}
pdellaert commented 9 years ago

Temporary fix (but it's not the clean way) possible, see (closed) pull request #2 . Final solution will have to come from developers, as i don't know the entire codebase structure ;)

pdellaert commented 9 years ago

Proposed fix without touching Bambou, but using vspk instead: https://github.com/pdellaert/vspk/commit/e13744f1d252564619d3cccf650dbecbf23618ab

Up to you guys to decide if you want to pull it or not.

t00f commented 9 years ago

@pdellaert,

I am currently working on a clean fix. I'll keep you updated.

pdellaert commented 9 years ago

Great! Thank you :)

pdellaert commented 9 years ago

Was just wondering if a clean/permanent fix has been implemented yet?

This is also affecting the CLI, btw:

[root@ent-43001 ~]# vsd list vrs --in vsc d5e4c8a5-53f1-4254-95d8-549f1ab2f5f8
[Error] Unknown object named vrs
[root@ent-43001 ~]# vsd list vrss --in vsc d5e4c8a5-53f1-4254-95d8-549f1ab2f5f8
[Error] Unknown object named vrs
[root@ent-43001 ~]# vsd list vrsss --in vsc d5e4c8a5-53f1-4254-95d8-549f1ab2f5f8
[Success] 5 vrss have been retrieved