1
# Copyright 2013 vArmour Networks Inc.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
16
ROUTER_OBJ_PREFIX = 'r-'
18
TRUST_ZONE = '_z_trust'
19
UNTRUST_ZONE = '_z_untrust'
24
REST_URL_CONF = '/config'
25
REST_URL_AUTH = '/auth'
26
REST_URL_COMMIT = '/commit'
27
REST_URL_INTF_MAP = '/operation/interface/mapping'
29
REST_URL_CONF_NAT_RULE = REST_URL_CONF + '/nat/rule'
30
REST_URL_CONF_ZONE = REST_URL_CONF + '/zone'
31
REST_URL_CONF_POLICY = REST_URL_CONF + '/policy'
32
REST_URL_CONF_ADDR = REST_URL_CONF + '/address'
33
REST_URL_CONF_SERVICE = REST_URL_CONF + '/service'
35
REST_ZONE_NAME = '/zone/"name:%s"'
36
REST_INTF_NAME = '/interface/"name:%s"'
37
REST_LOGIC_NAME = '/logical/"name:%s"'
38
REST_SERVICE_NAME = '/service/"name:%s"/rule'
41
def get_router_object_prefix(ri):
42
return ROUTER_OBJ_PREFIX + ri.router['id'][:OBJ_PREFIX_LEN]
45
def get_firewall_object_prefix(ri, fw):
46
return get_router_object_prefix(ri) + '-' + fw['id'][:OBJ_PREFIX_LEN]
49
def get_trusted_zone_name(ri):
50
return get_router_object_prefix(ri) + TRUST_ZONE
53
def get_untrusted_zone_name(ri):
54
return get_router_object_prefix(ri) + UNTRUST_ZONE
57
def get_snat_rule_name(ri):
58
return get_router_object_prefix(ri) + SNAT_RULE
61
def get_dnat_rule_name(ri):
62
return get_router_object_prefix(ri) + DNAT_RULE
65
def get_router_policy_name(ri):
66
return get_router_object_prefix(ri) + ROUTER_POLICY
69
def get_firewall_policy_name(ri, fw, rule):
70
return get_firewall_object_prefix(ri, fw) + rule['id'][:OBJ_PREFIX_LEN]