OpenIxia / BreakingPoint

Sample scripts for Breaking Point
MIT License
18 stars 11 forks source link

Unable to get network model #5

Closed mbdraks closed 4 years ago

mbdraks commented 4 years ago

Hi,

I'm trying to run the samples from the repo. I'm able to login and get stats from running tests but when I tried something else like getting the network model (to update it next) I'm getting this error:

In [8]: bps.network.networkModel.get()                                                                                                                                                                    
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-8-aee85ddb9688> in <module>
----> 1 bps.network.networkModel.get()

~/root/bps_restpy/restPyWrapper3.py in get(self, responseDepth, **kwargs)
   5873 
   5874     def get(self, responseDepth=None, **kwargs):
-> 5875         return self._wrapper._get(self._path+'/'+self._name, responseDepth, **kwargs)
   5876 
   5877     def __cached_get__(self, field):

~/root/bps_restpy/restPyWrapper3.py in _get(self, path, responseDepth, **kwargs)
    135         if(r.status_code in [200, 204]):
    136             return json.loads(r.content) if jsonContent else r.content.decode() if r.content is not None else None
--> 137         raise Exception({'status_code': r.status_code, 'content': json.loads(r.content) if jsonContent else r.content})
    138 
    139     ### Get from data model

Exception: {'status_code': 500, 'content': {'error': 'Internal Server Error'}}

Here's my code:

In [10]: bps.login()                                                                                                                                                                                      
Successfully connected to 10.10.1.1.
Login successful.
Welcome admin. 
Your session id is 593005e8-e0c4-4fb4-91a2-ad7b74acc28a

In [11]: network_name = "template_nn_mb"                                                                                                                                                                  

In [12]: bps.network.load(template=network_name)                                                                                                                                                          
Out[12]: 
{'createdOn': 1598562840360,
 'revision': 2,
 'author': 'mbarbosa',
 'createdBy': 'mbarbosa',
 'networkModel': [{'type': 'interface'}, {'type': 'interface'}],
 'name': 'template_nn_mb',
 'label': 'template_nn_mb',
 'type': 'custom'}

In [13]: network_model = bps.network.networkModel.get()                                                                                                                                                   
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
...

My BP is on 9.00.101.21. Should I use API v1 or v2?

nutu commented 4 years ago

HI Michael,

I tried with a canned network and it worked for me with the same BP version. I wonder what is so special about the network you have. Could you export it and send it?

bps.network.load(template="BreakingPoint Switching")
{u'author': None, u'createdBy': None, u'createdOn': None, u'label': u'BreakingPoint Switching', u'name': u'BreakingPoint Switching', u'networkModel': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, ...], u'revision': None, u'type': u'canned'} bps.network.get() {u'author': None, u'createdBy': None, u'createdOn': None, u'label': u'BreakingPoint Switching', u'name': u'BreakingPoint Switching', u'networkModel': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, ...], u'revision': None, u'type': u'canned'} bps.network.networkModel.get() {u'dhcpv6c_cfg': None, u'dhcpv6c_req_opts_cfg': None, u'dhcpv6c_tout_and_retr_cfg': None, u'ds_lite_aftr': None, u'ds_lite_b4': None, u'enodeb': None, u'enodeb6': None, u'enodeb_mme': None, u'enodeb_mme6': None, u'enodeb_mme_sgw': None, u'enodeb_mme_sgw6': None, u'ggsn': None, u'ggsn6': None, u'interface': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, ...], ...}

As a note : 9.0update3(9.00.108.26) or newer should be much better for RESTv2 a lot of issues were ironed out. But for this issue 9.0 should be fine also.

mbdraks commented 4 years ago

@nutu Thanks for the tip!

It was a simple empty NN with the definition of two interfaces. I followed your suggestion and tried with a canned NN and it worked, after copying it and removing the elements I was still able to do a get model so I'll keep using this one now.

Have a nice weekend!