Skip to content

Commit

Permalink
Merge "Adding md5 changes when a node is provisioned. md5 can configu…
Browse files Browse the repository at this point in the history
…red through testbed.py which will be taken care in provision.py. These changes are through provision_control.py whch has a new argument for md5."
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jun 18, 2015
2 parents 3d183ca + 9f0c9ba commit 68b599f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
16 changes: 14 additions & 2 deletions src/config/utils/provision_bgp.py
Expand Up @@ -41,7 +41,7 @@ def _get_rt_inst_obj(self):
return rt_inst_obj
# end _get_rt_inst_obj

def add_bgp_router(self, router_type, router_name, router_ip, router_asn):
def add_bgp_router(self, router_type, router_name, router_ip, router_asn, md5=None):
if router_type == 'contrail':
bgp_addr_fams = AddressFamilies(['route-target', 'inet-vpn',
'e-vpn', 'erm-vpn', 'inet6-vpn'])
Expand Down Expand Up @@ -70,6 +70,14 @@ def add_bgp_router(self, router_type, router_name, router_ip, router_asn):
try:
fq_name = bgp_router_obj.get_fq_name()
existing_obj = vnc_lib.bgp_router_read(fq_name=fq_name)
if md5:
bgp_params = existing_obj.get_bgp_router_parameters()
# set md5
print "Setting md5 on the existing uuid"
md5 = {'key_items': [ { 'key': md5 ,"key_id":0 } ], "key_type":"md5"}
bgp_params.set_auth_data(md5)
existing_obj.set_bgp_router_parameters(bgp_params)
vnc_lib.bgp_router_update(existing_obj)
print ("BGP Router " + pformat(fq_name) +
" already exists with uuid " + existing_obj.uuid)
return
Expand All @@ -93,7 +101,11 @@ def add_bgp_router(self, router_type, router_name, router_ip, router_asn):
continue

cur_obj.add_bgp_router(other_obj, bgp_peering_attrs)

if md5:
md5 = {'key_items': [ { 'key': md5 ,"key_id":0 } ], "key_type":"md5"}
rparams = cur_obj.bgp_router_parameters
rparams.set_auth_data(md5)
cur_obj.set_bgp_router_parameters(rparams)
vnc_lib.bgp_router_update(cur_obj)
# end add_bgp_router

Expand Down
10 changes: 6 additions & 4 deletions src/config/utils/provision_control.py
Expand Up @@ -2,7 +2,6 @@
#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#

import sys
import argparse
import ConfigParser
Expand Down Expand Up @@ -37,10 +36,9 @@ def __init__(self, args_str=None):
self._args.admin_user, self._args.admin_password,
self._args.admin_tenant_name,
self._args.api_server_ip, self._args.api_server_port)

if self._args.oper == 'add':
bp_obj.add_bgp_router('contrail', self._args.host_name,
self._args.host_ip, self._args.router_asn)
self._args.host_ip, self._args.router_asn, self._args.md5)
elif self._args.oper == 'del':
bp_obj.del_bgp_router(self._args.host_name)
else:
Expand All @@ -58,6 +56,7 @@ def _parse_args(self, args_str):
--api_server_ip 127.0.0.1
--api_server_port 8082
--oper <add | del>
--md5 <key value>|None(optional)
'''

# Source any specified config/ini file
Expand All @@ -76,7 +75,8 @@ def _parse_args(self, args_str):
'oper': None,
'admin_user': None,
'admin_password': None,
'admin_tenant_name': None
'admin_tenant_name': None,
'md5' : None
}

if args.conf_file:
Expand All @@ -101,6 +101,8 @@ def _parse_args(self, args_str):
parser.add_argument("--host_ip", help="IP address of control-node")
parser.add_argument(
"--router_asn", help="AS Number the control-node is in", required=True)
parser.add_argument(
"--md5", help="Md5 config for the node")
parser.add_argument(
"--ibgp_auto_mesh", help="Create iBGP mesh automatically", dest='ibgp_auto_mesh', action='store_true')
parser.add_argument(
Expand Down

0 comments on commit 68b599f

Please sign in to comment.