NSX|P Fix different LBaaS issues
Change-Id: I7e5454e12445864cb377488c29135169fe0c7f2a
This commit is contained in:
parent
2114510a32
commit
9770f7f452
@ -1461,7 +1461,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
||||
if update_firewall:
|
||||
self.update_router_firewall(context, router_id)
|
||||
|
||||
def delete_service_router(self, project_id, router_id):
|
||||
def delete_service_router(self, router_id):
|
||||
try:
|
||||
# Disable standby relocation on this router
|
||||
self.nsxpolicy.tier1.set_standby_relocation(
|
||||
@ -1574,7 +1574,7 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
||||
router_subnets,
|
||||
advertise_ipv6_subnets)
|
||||
if actions['remove_service_router']:
|
||||
self.delete_service_router(router['project_id'], router_id)
|
||||
self.delete_service_router(router_id)
|
||||
|
||||
def _update_router_advertisement_rules(self, router_id, subnets,
|
||||
advertise_ipv6):
|
||||
|
@ -350,7 +350,7 @@ class NsxpFwaasCallbacksV2(com_callbacks.NsxCommonv3FwaasCallbacksV2):
|
||||
# No other services that require service router: delete it
|
||||
# This also deleted the gateway policy.
|
||||
self.core_plugin.delete_service_router(
|
||||
context, policy_constants.DEFAULT_DOMAIN, router_id)
|
||||
context, router_id)
|
||||
sr_exists_on_backend = False
|
||||
|
||||
if sr_exists_on_backend:
|
||||
|
@ -108,10 +108,7 @@ class EdgeHealthMonitorManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
||||
monitor_client = self._get_monitor_policy_client(new_hm)
|
||||
try:
|
||||
monitor_body = self._build_monitor_args(new_hm)
|
||||
monitor_name = utils.get_name_and_uuid(new_hm['name'] or 'monitor',
|
||||
new_hm['id'])
|
||||
monitor_client.update(new_hm['id'], name=monitor_name,
|
||||
**monitor_body)
|
||||
monitor_client.update(new_hm['id'], **monitor_body)
|
||||
except nsxlib_exc.ManagerError as exc:
|
||||
completor(success=False)
|
||||
msg = _('Failed to update monitor %(monitor)s with exception'
|
||||
|
@ -34,12 +34,13 @@ class EdgeL7PolicyManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
||||
vs_client = self.core_plugin.nsxpolicy.load_balancer.virtual_server
|
||||
policy_name = utils.get_name_and_uuid(policy['name'] or 'policy',
|
||||
policy['id'])
|
||||
rule_body = lb_utils.convert_l7policy_to_lb_rule(policy)
|
||||
rule_body = lb_utils.convert_l7policy_to_lb_rule(
|
||||
self.core_plugin.nsxpolicy, policy)
|
||||
try:
|
||||
|
||||
position = policy.get('position', 0) - 1
|
||||
vs_client.add_lb_rule(policy['listener_id'],
|
||||
name=policy_name,
|
||||
position=policy.get('position', 0) - 1,
|
||||
position=position,
|
||||
**rule_body)
|
||||
except nsxlib_exc.ManagerError:
|
||||
with excutils.save_and_reraise_exception():
|
||||
@ -55,7 +56,8 @@ class EdgeL7PolicyManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
||||
vs_client = self.core_plugin.nsxpolicy.load_balancer.virtual_server
|
||||
policy_name = utils.get_name_and_uuid(old_policy['name'] or 'policy',
|
||||
old_policy['id'])
|
||||
rule_body = lb_utils.convert_l7policy_to_lb_rule(context, new_policy)
|
||||
rule_body = lb_utils.convert_l7policy_to_lb_rule(
|
||||
self.core_plugin.nsxpolicy, new_policy)
|
||||
try:
|
||||
vs_client.update_lb_rule(
|
||||
new_policy['listener_id'],
|
||||
|
@ -35,7 +35,8 @@ class EdgeL7RuleManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
||||
lb_utils.remove_rule_from_policy(rule)
|
||||
else:
|
||||
lb_utils.update_rule_in_policy(rule)
|
||||
rule_body = lb_utils.convert_l7policy_to_lb_rule(rule['policy'])
|
||||
rule_body = lb_utils.convert_l7policy_to_lb_rule(
|
||||
self.core_plugin.nsxpolicy, rule['policy'])
|
||||
try:
|
||||
vs_client.update_lb_rule(policy['listener_id'],
|
||||
name=policy_name,
|
||||
|
@ -69,12 +69,13 @@ def get_rule_match_conditions(policy):
|
||||
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def get_rule_actions(l7policy):
|
||||
def get_rule_actions(nsxpolicy, l7policy):
|
||||
if l7policy['action'] == lb_const.L7_POLICY_ACTION_REDIRECT_TO_POOL:
|
||||
if l7policy['redirect_pool_id']:
|
||||
lb_pool_id = l7policy['redirect_pool_id']
|
||||
lb_pool_path = nsxpolicy.load_balancer.lb_pool.get_path(lb_pool_id)
|
||||
actions = [{'type': p_const.LB_SELECT_POOL_ACTION,
|
||||
'pool_id': lb_pool_id}]
|
||||
'pool_id': lb_pool_path}]
|
||||
else:
|
||||
msg = _('Failed to get LB pool binding from nsx db')
|
||||
raise n_exc.BadRequest(resource='lbaas-l7rule-create',
|
||||
@ -95,10 +96,10 @@ def get_rule_actions(l7policy):
|
||||
|
||||
|
||||
@log_helpers.log_method_call
|
||||
def convert_l7policy_to_lb_rule(policy):
|
||||
def convert_l7policy_to_lb_rule(nsxpolicy, policy):
|
||||
return {
|
||||
'match_conditions': get_rule_match_conditions(policy),
|
||||
'actions': get_rule_actions(policy),
|
||||
'actions': get_rule_actions(nsxpolicy, policy),
|
||||
'phase': lb_const.LB_RULE_HTTP_FORWARDING,
|
||||
'match_strategy': 'ALL'
|
||||
}
|
||||
|
@ -167,12 +167,10 @@ class EdgeListenerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
||||
tags = self._get_listener_tags(context, new_listener)
|
||||
|
||||
try:
|
||||
vs_id = new_listener['id']
|
||||
app_profile_id = new_listener['id']
|
||||
updated_kwargs = self._get_virtual_server_kwargs(
|
||||
context, new_listener, vs_name, tags, app_profile_id,
|
||||
certificate)
|
||||
vs_client.update(vs_id, **updated_kwargs)
|
||||
context, new_listener, vs_name, tags, certificate)
|
||||
vs_client.update(**updated_kwargs)
|
||||
if vs_name:
|
||||
app_client.update(app_profile_id, display_name=vs_name,
|
||||
tags=tags)
|
||||
|
@ -159,7 +159,7 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.NsxpLoadbalancerBaseManager):
|
||||
service_client = self.core_plugin.nsxpolicy.load_balancer.lb_service
|
||||
vs_list = self._get_lb_virtual_servers(context, lb)
|
||||
try:
|
||||
rsp = service_client.get_stats(lb['id'])
|
||||
rsp = service_client.get_usage(lb['id'])
|
||||
if rsp:
|
||||
for vs in rsp.get('virtual_servers', []):
|
||||
# Skip the virtual server that doesn't belong
|
||||
|
Loading…
x
Reference in New Issue
Block a user