From 1c75a213def71e52cb100952dab896f9e94c415f Mon Sep 17 00:00:00 2001 From: Kobi Samoray Date: Mon, 25 Feb 2019 15:58:48 +0200 Subject: [PATCH] NSXP: Allow setting of LB L7 rule order Rules can be created in in any order, position parameter sets the place where the rule will be inserted. Change-Id: Id3aa79a19e48204a16b19f69141e3ad544553e9f --- vmware_nsxlib/v3/policy/lb_resources.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vmware_nsxlib/v3/policy/lb_resources.py b/vmware_nsxlib/v3/policy/lb_resources.py index a69f01a8..477a1f3b 100644 --- a/vmware_nsxlib/v3/policy/lb_resources.py +++ b/vmware_nsxlib/v3/policy/lb_resources.py @@ -715,7 +715,7 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase): def add_lb_rule(self, virtual_server_id, actions=None, name=None, match_conditions=None, - match_strategy=None, phase=None): + match_strategy=None, phase=None, position=0): lb_rule = lb_defs.LBRuleDef( actions, match_conditions, name, match_strategy, phase) lbvs_def = self.entry_def( @@ -724,6 +724,10 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase): body = self.policy_api.get(lbvs_def) app_profile_id = body['application_profile_path'].split('/')[-1] lb_rules = body.get('rules', []) + if position and len(lb_rules) < position: + lb_rules.append(lb_rule) + else: + lb_rules.insert(position - 1, lb_rule) lb_rules.append(lb_rule) return self.update(virtual_server_id, rules=lb_rules, ip_address=body['ip_address'],