Skip to content

Commit

Permalink
Merge "Added a config knob for logical_routers_enabled" into R3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Dec 22, 2016
2 parents 1368983 + 935b75e commit bd2c84a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 57 deletions.
69 changes: 40 additions & 29 deletions src/config/schema-transformer/config_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,38 +1154,49 @@ def evaluate(self):
acl = AclRuleType(match, action)
acl_list.append(acl)

for rule in static_acl_entries.get_acl_rule():
src_address = copy.deepcopy(rule.match_condition.src_address)
dst_address = copy.deepcopy(rule.match_condition.dst_address)
if src_address.virtual_network:
src_address.subnet = None
src_address.subnet_list = []
if dst_address.virtual_network:
dst_address.subnet = None
dst_address.subnet_list = []
match = MatchConditionType("any", src_address, PortType(),
dst_address, PortType())

acl = AclRuleType(match, ActionListType("deny"),
rule.get_rule_uuid())
if self._manager._args.logical_routers_enabled:
for rule in static_acl_entries.get_acl_rule():
src_address = copy.deepcopy(rule.match_condition.src_address)
dst_address = copy.deepcopy(rule.match_condition.dst_address)
if src_address.virtual_network:
src_address.subnet = None
src_address.subnet_list = []
if dst_address.virtual_network:
dst_address.subnet = None
dst_address.subnet_list = []
match = MatchConditionType("any", src_address, PortType(),
dst_address, PortType())

acl = AclRuleType(match, ActionListType("deny"),
rule.get_rule_uuid())
acl_list.append(acl)

match = MatchConditionType("any", dst_address, PortType(),
src_address, PortType())

acl = AclRuleType(match, ActionListType("deny"),
rule.get_rule_uuid())
acl_list.append(acl)
# end for rule

# Create any-vn to any-vn allow
match = MatchConditionType(
"any", AddressType(virtual_network="any"), PortType(),
AddressType(virtual_network="any"), PortType())
action = ActionListType("pass")
acl = AclRuleType(match, action)
acl_list.append(acl)

match = MatchConditionType("any", dst_address, PortType(),
src_address, PortType())

acl = AclRuleType(match, ActionListType("deny"),
rule.get_rule_uuid())
acl_list.update_acl_entries(static_acl_entries)
else:
# Create any-vn to any-vn deny
match = MatchConditionType(
"any", AddressType(virtual_network="any"), PortType(),
AddressType(virtual_network="any"), PortType())
action = ActionListType("deny")
acl = AclRuleType(match, action)
acl_list.append(acl)
# end for rule
acl_list.update_acl_entries(static_acl_entries)

# Create any-vn to any-vn allow
match = MatchConditionType(
"any", AddressType(virtual_network="any"), PortType(),
AddressType(virtual_network="any"), PortType())
action = ActionListType("pass")
acl = AclRuleType(match, action)
acl_list.append(acl)
acl_list.update_acl_entries(static_acl_entries)

self.acl = _access_control_list_update(self.acl, self.obj.name,
self.obj, static_acl_entries)
Expand Down
36 changes: 8 additions & 28 deletions src/config/schema-transformer/to_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,34 +618,6 @@ def reset(self):


def parse_args(args_str):
'''
Eg. python to_bgp.py --rabbit_server localhost
--rabbit_port 5672
--rabbit_user guest
--rabbit_password guest
--cassandra_server_list 10.1.2.3:9160
--api_server_ip 10.1.2.3
--api_server_port 8082
--api_server_use_ssl False
--zk_server_ip 10.1.2.3
--zk_server_port 2181
--collectors 127.0.0.1:8086
--disc_server_ip 127.0.0.1
--disc_server_port 5998
--http_server_port 8090
--log_local
--log_level SYS_DEBUG
--log_category test
--log_file <stdout>
--trace_file /var/log/contrail/schema.err
--use_syslog
--syslog_facility LOG_USER
--cluster_id <testbed-name>
--zk_timeout 400
[--reset_config]
'''

# Source any specified config/ini file
# Turn off help, so we all options in response to -h
conf_parser = argparse.ArgumentParser(add_help=False)

Expand Down Expand Up @@ -689,6 +661,7 @@ def parse_args(args_str):
'kombu_ssl_certfile': '',
'kombu_ssl_ca_certs': '',
'zk_timeout': 400,
'logical_routers_enabled': True,
}
secopts = {
'use_certs': False,
Expand Down Expand Up @@ -735,6 +708,11 @@ def parse_args(args_str):
defaults.update(ksopts)
defaults.update(cassandraopts)
parser.set_defaults(**defaults)
def _bool(s):
"""Convert string to bool (in argparse context)."""
if s.lower() not in ['true', 'false']:
raise ValueError('Need bool; got %r' % s)
return {'true': True, 'false': False}[s.lower()]

parser.add_argument(
"--cassandra_server_list",
Expand Down Expand Up @@ -807,6 +785,8 @@ def parse_args(args_str):
help="End port for bgp-as-a-service proxy")
parser.add_argument("--zk_timeout",
help="Timeout for ZookeeperClient")
parser.add_argument("--logical_routers_enabled", type=_bool,
help="Enabled logical routers")

args = parser.parse_args(remaining_argv)
if type(args.cassandra_server_list) is str:
Expand Down

0 comments on commit bd2c84a

Please sign in to comment.