VPN policy rules update

The NSX policy rules changed on the nSX.
The session rules will always be 'protect' rules,
and bypass rules were added to the vpn service.

Change-Id: I2dbf54544e7b49b828c5372f792e55fb1bd19d7c
This commit is contained in:
Adit Sarfaty 2018-02-15 11:27:36 +02:00
parent 2656e43357
commit 3d4cb671fb
1 changed files with 5 additions and 10 deletions

View File

@ -109,11 +109,6 @@ class IkeLogLevelTypes(object):
LOG_LEVEL_ERROR = 'ERROR' LOG_LEVEL_ERROR = 'ERROR'
class PolicyRuleActionTypes(object):
POLICY_RULE_ACTION_BYPASS = 'BYPASS'
POLICY_RULE_ACTION_PROTECT = 'PROTECT'
class IkeProfile(utils.NsxLibApiBase): class IkeProfile(utils.NsxLibApiBase):
@property @property
@ -386,14 +381,12 @@ class Session(utils.NsxLibApiBase):
body['tags'] = tags body['tags'] = tags
return self.client.create(self.get_path(), body=body) return self.client.create(self.get_path(), body=body)
def get_rule_obj(self, sources, destinations, def get_rule_obj(self, sources, destinations):
action=PolicyRuleActionTypes.POLICY_RULE_ACTION_PROTECT):
src_subnets = [{'subnet': src} for src in sources] src_subnets = [{'subnet': src} for src in sources]
dst_subnets = [{'subnet': dst} for dst in destinations] dst_subnets = [{'subnet': dst} for dst in destinations]
return { return {
'sources': src_subnets, 'sources': src_subnets,
'destinations': dst_subnets, 'destinations': dst_subnets
'action': action
} }
def update(self, uuid, name=None, description=None, policy_rules=None, def update(self, uuid, name=None, description=None, policy_rules=None,
@ -422,7 +415,7 @@ class Service(utils.NsxLibApiBase):
def create(self, name, logical_router_id, def create(self, name, logical_router_id,
enabled=True, ike_log_level="ERROR", enabled=True, ike_log_level="ERROR",
tags=None): tags=None, bypass_rules=None):
# mandatory parameters # mandatory parameters
body = {'display_name': name, body = {'display_name': name,
@ -434,6 +427,8 @@ class Service(utils.NsxLibApiBase):
body['enabled'] = enabled body['enabled'] = enabled
if tags: if tags:
body['tags'] = tags body['tags'] = tags
if bypass_rules:
body['bypass_rules'] = bypass_rules
return self.client.create(self.get_path(), body=body) return self.client.create(self.get_path(), body=body)