Browse Source

Added support for pagination and optimized mapping.sync() call.

Added wapi_paging as configurable variable to support pagination.
By default its value will be False, if user passes True in neutron.conf
then based on wapi_max_results it will create page_size and do wapi calls
using infoblox_client.

Also, Optimized mapping.sync() to fetch only those data which belongs to
configured cloud_data_center_id.

Changes in infoblox-client is raised at: https://github.com/infobloxopen/infoblox-client/pull/174

Change-Id: Ieb4313cb4c37c5f43882f0048356ea65e64de569
changes/18/515718/4
Akash Deep 4 years ago
parent
commit
e2a22a0b3d
6 changed files with 63 additions and 46 deletions
  1. +2
    -0
      devstack/README.rst
  2. +1
    -0
      devstack/plugin.sh
  3. +6
    -0
      doc/source/installation.rst
  4. +7
    -1
      networking_infoblox/neutron/common/config.py
  5. +3
    -2
      networking_infoblox/neutron/common/grid.py
  6. +44
    -43
      networking_infoblox/neutron/common/mapping.py

+ 2
- 0
devstack/README.rst View File

@ -41,6 +41,8 @@ corresponding variables:
- NETWORKING_INFOBLOX_DC_HTTP_REQUEST_TIMEOUT
* - wapi_max_results
- NETWORKING_INFOBLOX_DC_WAPI_MAX_RESULTS
* - wapi_paging
- NETWORKING_INFOBLOX_DC_WAPI_PAGING
* - n/a (DevStack only)
- NETWORKING_INFOBLOX_SUPERUSER_USERNAME
* - n/a (DevStack only)


+ 1
- 0
devstack/plugin.sh View File

@ -73,6 +73,7 @@ function configure_networking_infoblox {
iniset $NEUTRON_CONF infoblox-dc:$NETWORKING_INFOBLOX_CLOUD_DATA_CENTER_ID http_pool_maxsize $NETWORKING_INFOBLOX_DC_HTTP_POOL_MAXSIZE
iniset $NEUTRON_CONF infoblox-dc:$NETWORKING_INFOBLOX_CLOUD_DATA_CENTER_ID http_request_timeout $NETWORKING_INFOBLOX_DC_HTTP_REQUEST_TIMEOUT
iniset $NEUTRON_CONF infoblox-dc:$NETWORKING_INFOBLOX_CLOUD_DATA_CENTER_ID wapi_max_results $NETWORKING_INFOBLOX_DC_WAPI_MAX_RESULTS
iniset $NEUTRON_CONF infoblox-dc:$NETWORKING_INFOBLOX_CLOUD_DATA_CENTER_ID wapi_paging ${NETWORKING_INFOBLOX_DC_WAPI_PAGING:-"False"}
# Update options that are non Infoblox specific
NOVA_CONF=/etc/nova/nova.conf


+ 6
- 0
doc/source/installation.rst View File

@ -337,6 +337,11 @@ Keystone configuration for TLS Support add:
objects would exceed the setting. If this is set to a positive number,
the results will be truncated when necessary. The default is -1000.
If you experience "Result set too large" error, increase this value.
* - wapi_paging
- Enables paging to wapi calls by configuring wapi_paging = True,
it uses `wapi_max_results` to set paging size of the wapi calls.
If `wapi_max_results` is negative it will take paging size as 1000.
The default is `False`
* - ssl_verify
- Set to false if you use a self-signed SSL certificate, and true
if you use a certificate signed by a known certificate authority. You
@ -382,6 +387,7 @@ installation):
admin_password = PASSWORD
wapi_version = 2.3
wapi_max_results = -50000
wapi_paging = True
In addition to these options, you must enable the notifications options
within Neutron, if they are not already enabled.


+ 7
- 1
networking_infoblox/neutron/common/config.py View File

@ -86,7 +86,13 @@ data_center_opts = [
"negative number the appliance will return an error "
"when the number of returned objects would exceed the "
"setting. If this is set to a positive number, the "
"results will be truncated when necessary."))
"results will be truncated when necessary.")),
cfg.BoolOpt('wapi_paging',
default=False,
help=_("Enables paging to wapi calls by configuring"
"wapi_paging = True,it uses wapi_max_results to set"
"paging size of the wapi calls.If wapi_max_results is"
"negative it will take paging size as 1000."))
]
CONF = cfg.CONF


+ 3
- 2
networking_infoblox/neutron/common/grid.py View File

@ -117,7 +117,7 @@ class GridManager(object):
grid_conf.http_pool_connections = grid_opts['http_pool_connections']
grid_conf.http_pool_maxsize = grid_opts['http_pool_maxsize']
grid_conf.wapi_max_results = grid_opts['wapi_max_results']
grid_conf.wapi_paging = grid_opts['wapi_paging']
# cloud user is used as admin, it needs to have proper permissions to
# deal with non-delegated objects.
gm_connection_opts = {
@ -130,7 +130,8 @@ class GridManager(object):
'http_request_timeout': grid_conf.http_request_timeout,
'http_pool_connections': grid_conf.http_pool_connections,
'http_pool_maxsize': grid_conf.http_pool_maxsize,
'max_results': grid_conf.wapi_max_results}
'max_results': grid_conf.wapi_max_results,
'paging': grid_conf.wapi_paging}
# Silent ssl warnings, if certificate verification is not enabled
if gm_connection_opts['ssl_verify'] == 'False':
gm_connection_opts['silent_ssl_warnings'] = True


+ 44
- 43
networking_infoblox/neutron/common/mapping.py View File

@ -55,19 +55,18 @@ class GridMappingManager(object):
"""
session = self._context.session
self.db_members = dbi.get_members(session, grid_id=self._grid_id)
discovered_network_views = self._discover_network_views()
if not discovered_network_views:
associated_network_views = self._discover_network_views()
if not associated_network_views:
return
discovered_dns_views = self._discover_dns_views()
dns_views = self.get_dns_views(discovered_dns_views)
associated_dns_views = self._discover_dns_views(
associated_network_views)
dns_views = self.get_dns_views(associated_dns_views)
discovered_delegations = self._sync_network_views(
discovered_network_views, dns_views)
associated_network_views, dns_views)
discovered_networks = self._discover_networks()
self._sync_network_mapping(discovered_networks, discovered_delegations)
associated_networks = self._discover_networks(associated_network_views)
self._sync_network_mapping(associated_networks, discovered_delegations)
def _load_persisted_mappings(self):
session = self._context.session
@ -92,7 +91,7 @@ class GridMappingManager(object):
dns_views[netview_name] = dnsview_name
return dns_views
def _sync_network_views(self, discovered_netviews, dns_views):
def _sync_network_views(self, associated_netviews, dns_views):
"""Discover network views and sync with db.
The discovered network view json contains the following data:
@ -114,24 +113,14 @@ class GridMappingManager(object):
'id', self.db_network_views)
discovered_netview_ids = []
for netview in discovered_netviews:
for netview in associated_netviews:
# participated flag is True for all associated network view
participated = True
netview_name = netview['name']
is_default = netview[const.IS_DEFAULT]
netview_id = utils.get_network_view_id(self._grid_id,
netview['_ref'])
cloud_adapter_id_vals = utils.get_ea_value(
const.EA_CLOUD_ADAPTER_ID, netview, True)
if cloud_adapter_id_vals is None:
participated = False
else:
cloud_adapter_ids = [gid for gid in cloud_adapter_id_vals
if int(gid) == self._grid_id]
participated = True if cloud_adapter_ids else False
if not participated:
continue
shared_val = utils.get_ea_value(const.EA_IS_SHARED, netview)
is_shared = types.Boolean()(shared_val) if shared_val else False
@ -266,36 +255,48 @@ class GridMappingManager(object):
if self._grid_config.is_cloud_wapi:
return_fields.append('cloud_info')
netviews = self._connector.get_object('networkview',
return_fields=return_fields)
# Fetch network_view associated to this cloud adapter.
netviews = self._connector.get_object(
'networkview', return_fields=return_fields,
extattrs={const.EA_CLOUD_ADAPTER_ID: {'value': [self._grid_id]}})
if not netviews:
return []
return netviews
def _discover_networks(self):
def _discover_networks(self, associated_network_views):
return_fields = ['members', 'network_view', 'network', 'options']
if self._grid_config.is_cloud_wapi:
return_fields.append('cloud_info')
# TODO(pbondar): Consider using NetworkV4 and NetworkV6 objects
# from infoblox-client to interact with NIOS
ipv4networks = self._connector.get_object('network',
return_fields=return_fields)
ipv6networks = self._connector.get_object('ipv6network',
return_fields=return_fields)
# get_object returns None if nothing was found, so convert results
if not ipv4networks:
ipv4networks = []
if not ipv6networks:
ipv6networks = []
ipv4networks = []
ipv6networks = []
for network_view in associated_network_views:
payload = {'network_view': network_view['name']}
# TODO(pbondar): Consider using NetworkV4 and NetworkV6 objects
# from infoblox-client to interact with NIOS
_ipv4networks = self._connector.get_object(
'network', return_fields=return_fields, payload=payload)
_ipv6networks = self._connector.get_object(
'ipv6network', return_fields=return_fields, payload=payload)
# get_object returns None if nothing was found, so convert results
if not _ipv4networks:
_ipv4networks = []
if not _ipv6networks:
_ipv6networks = []
ipv4networks.extend(_ipv4networks)
ipv6networks.extend(_ipv6networks)
return ipv4networks + ipv6networks
def _discover_dns_views(self):
def _discover_dns_views(self, associated_network_views):
return_fields = ['name', 'network_view']
dns_views = self._connector.get_object('view',
return_fields=return_fields)
if not dns_views:
return []
dns_views = []
for network_view in associated_network_views:
payload = {'network_view': network_view['name']}
_dns_views = self._connector.get_object(
'view', return_fields=return_fields, payload=payload)
if not _dns_views:
_dns_views = []
dns_views.extend(_dns_views)
return dns_views
def _get_member_mapping(self, discovered_networks, discovered_delegations):


Loading…
Cancel
Save