Esempio n. 1
0
    def get_all_objects_by_name(self, path, name, tenant='', tenant_uuid='',
                           timeout=None, params=None, api_version=None,
                           **kwargs):
        '''
        Helper function which works like the SDK's get_object_by_name but returns a list
        of matches rather than just the first match
        '''

        obj = None
        if not params:
            params = {}
        params['name'] = name
        resp = self.api.get(path, tenant, tenant_uuid, timeout=timeout,
                        params=params, api_version=api_version, **kwargs)
        if resp.status_code in (401, 419):
            ApiSession.reset_session(self.api)
            resp = self.api.get_object_by_name(
                    path, name, tenant, tenant_uuid, timeout=timeout,
                    params=params, **kwargs)
        if resp.status_code < 300:
            obj = resp.json()['results']

        self.api._update_session_last_used()
        
        return obj
Esempio n. 2
0
 def test_session_multi_reset(self):
     papi = ApiSession(api.controller_ip,
                       api.username,
                       api.password,
                       verify=False,
                       api_version=api.api_version)
     papi.reset_session()
     papi.reset_session()
Esempio n. 3
0
 def test_session_multi_reset(self):
     papi = ApiSession(controller_ip=api.avi_credentials.controller,
                       username=api.avi_credentials.username,
                       password=api.avi_credentials.password,
                       verify=False,
                       api_version=api.avi_credentials.api_version,
                       data_log=api.data_log)
     papi.reset_session()
     papi.reset_session()
Esempio n. 4
0
 def test_session_reset(self):
     papi = ApiSession(api.controller_ip, api.username, api.password,
                       verify=False, api_version=api.api_version)
     res = papi.get('pool', params={'fields': 'name'})
     assert res.status_code == 200
     papi.reset_session()
     res = papi.get('pool', params={'fields': 'name'})
     assert res.status_code == 200
     data = {'name': 'test-reset'}
     res = papi.post('pool', data=data)
     assert res.status_code == 201
     papi.reset_session()
     res = papi.delete_by_name('pool', 'test-reset')
     assert res.status_code == 204
Esempio n. 5
0
 def test_session_reset(self):
     papi = ApiSession(controller_ip=api.avi_credentials.controller,
                       username=api.avi_credentials.username,
                       password=api.avi_credentials.password, verify=False,
                       api_version=api.avi_credentials.api_version,
                       data_log=api.data_log)
     res = papi.get('pool', params={'fields': 'name'})
     assert res.status_code == 200
     papi.reset_session()
     res = papi.get('pool', params={'fields': 'name'})
     assert res.status_code == 200
     data = {'name': 'test-reset'}
     res = papi.post('pool', data=data)
     assert res.status_code == 201
     papi.reset_session()
     res = papi.delete_by_name('pool', 'test-reset')
     assert res.status_code == 204
Esempio n. 6
0
 def test_session_multi_reset(self):
     papi = ApiSession(api.controller_ip, api.username, api.password,
                       verify=False, api_version=api.api_version)
     papi.reset_session()
     papi.reset_session()