
This patch will allow moving neutron from using the nsx_v3 plugin to the nsx_p plugin. This includes: - admin utility to move all resources to the policy api: nsxadmin -r nsx-migrate-t2p -o import (--verbose) This utility will: -- Migrate all neutron used & created resource using the nsx migration api -- roll back all resources in case it failed -- post migration fix some of the policy resources to better match the expectation of the policy plugin - admin utility that will cleanup left overs in the nsx_v3 db: nsxadmin -r nsx-migrate-t2p -o clean-all (can be used, but everything should work without calling it as well) - Some minor changes to the policy plugin and drivers to allow it to handle migrated resource which are a bit different than those created with the policy plugin -- Delete DHCP server config once a migrated network is deleted -- Update LB L7 rules by their name suffix as their full display name is unknown Change-Id: Ic17e0de1f4b2a2d95afa61ce33ffb0bc9e667b89
65 lines
2.6 KiB
Python
65 lines
2.6 KiB
Python
# Copyright 2018 VMware, Inc.
|
|
# All Rights Reserved
|
|
#
|
|
# 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.
|
|
|
|
from oslo_log import log as logging
|
|
from oslo_utils import excutils
|
|
|
|
from vmware_nsx.services.lbaas import base_mgr
|
|
from vmware_nsx.services.lbaas.nsx_p.implementation import lb_utils
|
|
from vmware_nsxlib.v3 import utils
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
|
|
|
|
class EdgeL7RuleManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
|
def _update_l7rule_change(self, rule, completor, delete=False):
|
|
vs_client = self.core_plugin.nsxpolicy.load_balancer.virtual_server
|
|
policy = rule['policy']
|
|
policy_name = utils.get_name_and_uuid(policy['name'] or 'policy',
|
|
policy['id'])
|
|
short_name = utils.get_name_short_uuid(policy['id'])
|
|
if delete:
|
|
lb_utils.remove_rule_from_policy(rule)
|
|
else:
|
|
lb_utils.update_rule_in_policy(rule)
|
|
rule_body = lb_utils.convert_l7policy_to_lb_rule(
|
|
self.core_plugin.nsxpolicy, rule['policy'])
|
|
try:
|
|
vs_client.update_lb_rule(policy['listener_id'],
|
|
policy_name,
|
|
position=policy.get('position', 0) - 1,
|
|
compare_name_suffix=short_name,
|
|
**rule_body)
|
|
except Exception as e:
|
|
with excutils.save_and_reraise_exception():
|
|
completor(success=False)
|
|
LOG.error('Failed to update L7policy %(policy)s: '
|
|
'%(err)s', {'policy': policy['id'], 'err': e})
|
|
|
|
completor(success=True)
|
|
|
|
def create(self, context, rule, completor):
|
|
self._update_l7rule_change(rule, completor)
|
|
|
|
def update(self, context, old_rule, new_rule, completor):
|
|
self._update_l7rule_change(new_rule, completor)
|
|
|
|
def delete(self, context, rule, completor):
|
|
self._update_l7rule_change(rule, completor, delete=True)
|
|
|
|
def delete_cascade(self, context, rule, completor):
|
|
# No action should be taken on rules delete cascade
|
|
pass
|