This patch also updates the chain_mapping policy driver and the Node Composition Plugin (NCP) to accomodate the transactional semantics of an async driver such as the aim_mapping driver which performs all operations in the pre_commit phase. Note that the chain_mapping driver and NCP will continue to work with the resource_mapping driver (or a similar driver) as before. Since the service chain plugin does not have any knowledge of pre- or post- commit transaction phases of the GBP plugin that drive the service chain plugin, a workaround (read hack!) has been introduced in the current patch to overcome this. Enhancing the service chain plugin structure is a bigger discussion and beyond the scope of this patch. It will be tackled in the context of enhancing and supporting the NFP framework for aim_mapping like single transaction drivers. All references to LOADBALANCER type have also been updated to LOADBALANCERV2 in the unit tests. Change-Id: I74f1b3d0d61bd6c3859fcaaf9a569ca3c6cc07ed
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import six
|
|
|
|
from oslo_config import cfg
|
|
|
|
from gbpservice.neutron.services.grouppolicy.common import constants as const
|
|
|
|
|
|
def convert_ip_pool_list_to_string(ip_pool):
|
|
if type(ip_pool) is not list:
|
|
msg = ("The type of %(ip_pool)s is not a list" %
|
|
{'ip_pool': ip_pool})
|
|
raise ValueError(msg)
|
|
return ', '.join(ip_pool)
|
|
|
|
|
|
def convert_ip_pool_string_to_list(ip_pool_string):
|
|
if ip_pool_string and not isinstance(ip_pool_string, six.string_types):
|
|
msg = ("The type of %(ip_pool_string)s is not a string "
|
|
"or unicode" % {'ip_pool_string': ip_pool_string})
|
|
raise ValueError(msg)
|
|
if ip_pool_string:
|
|
return [prefix.strip() for prefix in ip_pool_string.split(',')]
|
|
else:
|
|
return []
|
|
|
|
|
|
def is_precommit_policy_driver_configured():
|
|
# This method checks if exactly one of the policy drivers designated
|
|
# as a "pre-commit" driver, and defined in:
|
|
# const.PRECOMMIT_POLICY_DRIVERS
|
|
# is present in the list of configured policy drivers.
|
|
a = set(cfg.CONF.group_policy.policy_drivers)
|
|
if len(set(a) & set(const.PRECOMMIT_POLICY_DRIVERS)) == 1:
|
|
return True
|
|
return False
|