~corey.bryant/ubuntu/vivid/neutron-fwaas/dh-python2

« back to all changes in this revision

Viewing changes to neutron_fwaas/services/firewall/agents/varmour/varmour_utils.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-01-14 10:11:07 UTC
  • Revision ID: package-import@ubuntu.com-20150114101107-bl78obogfk23jnra
Tags: upstream-2015.1~b1
ImportĀ upstreamĀ versionĀ 2015.1~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2013 vArmour Networks Inc.
 
2
# All Rights Reserved.
 
3
#
 
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
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
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
 
14
#    under the License.
 
15
 
 
16
ROUTER_OBJ_PREFIX = 'r-'
 
17
OBJ_PREFIX_LEN = 8
 
18
TRUST_ZONE = '_z_trust'
 
19
UNTRUST_ZONE = '_z_untrust'
 
20
SNAT_RULE = '_snat'
 
21
DNAT_RULE = '_dnat'
 
22
ROUTER_POLICY = '_p'
 
23
 
 
24
REST_URL_CONF = '/config'
 
25
REST_URL_AUTH = '/auth'
 
26
REST_URL_COMMIT = '/commit'
 
27
REST_URL_INTF_MAP = '/operation/interface/mapping'
 
28
 
 
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'
 
34
 
 
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'
 
39
 
 
40
 
 
41
def get_router_object_prefix(ri):
 
42
    return ROUTER_OBJ_PREFIX + ri.router['id'][:OBJ_PREFIX_LEN]
 
43
 
 
44
 
 
45
def get_firewall_object_prefix(ri, fw):
 
46
    return get_router_object_prefix(ri) + '-' + fw['id'][:OBJ_PREFIX_LEN]
 
47
 
 
48
 
 
49
def get_trusted_zone_name(ri):
 
50
    return get_router_object_prefix(ri) + TRUST_ZONE
 
51
 
 
52
 
 
53
def get_untrusted_zone_name(ri):
 
54
    return get_router_object_prefix(ri) + UNTRUST_ZONE
 
55
 
 
56
 
 
57
def get_snat_rule_name(ri):
 
58
    return get_router_object_prefix(ri) + SNAT_RULE
 
59
 
 
60
 
 
61
def get_dnat_rule_name(ri):
 
62
    return get_router_object_prefix(ri) + DNAT_RULE
 
63
 
 
64
 
 
65
def get_router_policy_name(ri):
 
66
    return get_router_object_prefix(ri) + ROUTER_POLICY
 
67
 
 
68
 
 
69
def get_firewall_policy_name(ri, fw, rule):
 
70
    return get_firewall_object_prefix(ri, fw) + rule['id'][:OBJ_PREFIX_LEN]