NSX|V: Support pagination in get virtual wires
Change-Id: I1d531d5bee8c852c3221fd0248876f4ba46d355b
This commit is contained in:
parent
baf20bb4c7
commit
abfe98d528
@ -520,10 +520,27 @@ class Vcns(object):
|
||||
uri = '/api/2.0/vdn/virtualwires/%s' % virtualwire_id
|
||||
return self.do_request(HTTP_DELETE, uri, format='xml')
|
||||
|
||||
def _get_virtual_wires(self, startindex=0):
|
||||
uri_prefix = '/api/2.0/vdn/virtualwires'
|
||||
uri = '%s?startIndex=%d' % (uri_prefix, startindex)
|
||||
return self.do_request(HTTP_GET, uri, decode=True)
|
||||
|
||||
def get_virtual_wires(self):
|
||||
"""Deletes a virtual wire."""
|
||||
uri = '/api/2.0/vdn/virtualwires'
|
||||
return self.do_request(HTTP_GET, uri)
|
||||
"""Get all virtual wires"""
|
||||
vws = []
|
||||
h, d = self._get_virtual_wires()
|
||||
vws.extend(d['dataPage']['data'])
|
||||
paging_info = d['dataPage']['pagingInfo']
|
||||
page_size = int(paging_info['pageSize'])
|
||||
count = int(paging_info['totalCount'])
|
||||
LOG.debug("There are total %s virtual wires and page size is %s",
|
||||
count, page_size)
|
||||
pages = int(count / page_size + 1)
|
||||
for i in range(1, pages):
|
||||
start_index = page_size * i
|
||||
h, d = self._get_virtual_wires(start_index)
|
||||
vws.extend(d['dataPage']['data'])
|
||||
return vws
|
||||
|
||||
def create_port_group(self, dvs_id, request):
|
||||
"""Creates a port group on a DVS
|
||||
|
@ -46,8 +46,7 @@ def get_networks_from_backend():
|
||||
def get_virtual_wires():
|
||||
"""Return a hash of the backend virtual wires by their id"""
|
||||
nsxv = utils.get_nsxv_client()
|
||||
h, res = nsxv.get_virtual_wires()
|
||||
vw_list = res['dataPage']['data']
|
||||
vw_list = nsxv.get_virtual_wires()
|
||||
vw_hash = {}
|
||||
for vw in vw_list:
|
||||
vw_hash[vw['objectId']] = vw
|
||||
@ -306,7 +305,7 @@ def get_dvs_id_from_backend_name(backend_name):
|
||||
return reg.group(0)
|
||||
|
||||
|
||||
def list_intenrnal_virtual_wires(vws):
|
||||
def list_internal_virtual_wires(vws):
|
||||
# List the virtualwires matching plr-dlr connection with their vni
|
||||
table_results = []
|
||||
map_results = {}
|
||||
@ -361,7 +360,7 @@ def list_nsx_virtual_wires(resource, event, trigger, **kwargs):
|
||||
|
||||
vws = get_virtual_wires()
|
||||
if internal:
|
||||
table_results, map_results = list_intenrnal_virtual_wires(vws)
|
||||
table_results, map_results = list_internal_virtual_wires(vws)
|
||||
else:
|
||||
table_results, map_results = list_neutron_virtual_wires(vws)
|
||||
|
||||
|
@ -172,11 +172,7 @@ class FakeVcns(object):
|
||||
return (header, response)
|
||||
|
||||
def get_virtual_wires(self):
|
||||
header = {
|
||||
'status': 200
|
||||
}
|
||||
response = {"dataPage": {"data": []}}
|
||||
return (header, response)
|
||||
return []
|
||||
|
||||
def update_vdr_internal_interface(
|
||||
self, edge_id, interface_index, interface):
|
||||
|
Loading…
x
Reference in New Issue
Block a user