NSX|V: Support pagination in get virtual wires
Change-Id: I1d531d5bee8c852c3221fd0248876f4ba46d355b
This commit is contained in:
parent
cec2c15377
commit
7b1ef1e1e6
|
@ -521,10 +521,27 @@ class Vcns(object):
|
||||||
uri = '/api/2.0/vdn/virtualwires/%s' % virtualwire_id
|
uri = '/api/2.0/vdn/virtualwires/%s' % virtualwire_id
|
||||||
return self.do_request(HTTP_DELETE, uri, format='xml')
|
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):
|
def get_virtual_wires(self):
|
||||||
"""Deletes a virtual wire."""
|
"""Get all virtual wires"""
|
||||||
uri = '/api/2.0/vdn/virtualwires'
|
vws = []
|
||||||
return self.do_request(HTTP_GET, uri)
|
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):
|
def create_port_group(self, dvs_id, request):
|
||||||
"""Creates a port group on a DVS
|
"""Creates a port group on a DVS
|
||||||
|
|
|
@ -47,8 +47,7 @@ def get_networks_from_backend():
|
||||||
def get_virtual_wires():
|
def get_virtual_wires():
|
||||||
"""Return a hash of the backend virtual wires by their id"""
|
"""Return a hash of the backend virtual wires by their id"""
|
||||||
nsxv = utils.get_nsxv_client()
|
nsxv = utils.get_nsxv_client()
|
||||||
h, res = nsxv.get_virtual_wires()
|
vw_list = nsxv.get_virtual_wires()
|
||||||
vw_list = res['dataPage']['data']
|
|
||||||
vw_hash = {}
|
vw_hash = {}
|
||||||
for vw in vw_list:
|
for vw in vw_list:
|
||||||
vw_hash[vw['objectId']] = vw
|
vw_hash[vw['objectId']] = vw
|
||||||
|
@ -307,7 +306,7 @@ def get_dvs_id_from_backend_name(backend_name):
|
||||||
return reg.group(0)
|
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
|
# List the virtualwires matching plr-dlr connection with their vni
|
||||||
table_results = []
|
table_results = []
|
||||||
map_results = {}
|
map_results = {}
|
||||||
|
@ -362,7 +361,7 @@ def list_nsx_virtual_wires(resource, event, trigger, **kwargs):
|
||||||
|
|
||||||
vws = get_virtual_wires()
|
vws = get_virtual_wires()
|
||||||
if internal:
|
if internal:
|
||||||
table_results, map_results = list_intenrnal_virtual_wires(vws)
|
table_results, map_results = list_internal_virtual_wires(vws)
|
||||||
else:
|
else:
|
||||||
table_results, map_results = list_neutron_virtual_wires(vws)
|
table_results, map_results = list_neutron_virtual_wires(vws)
|
||||||
|
|
||||||
|
|
|
@ -173,11 +173,7 @@ class FakeVcns(object):
|
||||||
return (header, response)
|
return (header, response)
|
||||||
|
|
||||||
def get_virtual_wires(self):
|
def get_virtual_wires(self):
|
||||||
header = {
|
return []
|
||||||
'status': 200
|
|
||||||
}
|
|
||||||
response = {"dataPage": {"data": []}}
|
|
||||||
return (header, response)
|
|
||||||
|
|
||||||
def update_vdr_internal_interface(
|
def update_vdr_internal_interface(
|
||||||
self, edge_id, interface_index, interface):
|
self, edge_id, interface_index, interface):
|
||||||
|
|
Loading…
Reference in New Issue