├── contrail-screen.png ├── devstack-screen.png ├── docs ├── MultinodeSetup_Deployment_GuideV0.1.pdf ├── Open Contrail LogLevel Usage Document.pdf ├── Auto_Build_and_CI_Utility_Usage_Guide_V0.2.pdf └── OpenStack_OpenContrail_SingleNodeSetup_Deployment_Guide_V0.3.pdf ├── devstack ├── lib │ ├── neutron_thirdparty │ │ └── opencontrail │ └── neutron_plugins │ │ └── opencontrail └── samples │ ├── localrc-all │ └── localrc-ci ├── utilities ├── contrail-status ├── contrail-sanity ├── report_generation.py ├── auto.conf ├── task.sh └── sanity.sh ├── cassandra-env.sh.patch ├── README.txt ├── test_domainlist.py ├── contrail ├── installer.xml ├── samples └── localrc-all ├── test_network_simple.sh ├── clean.py ├── install_pip.sh ├── setup_devstack.sh ├── Contrail_user_guide.txt ├── README.md ├── service.sh ├── contrail_config_templates.py ├── contrail_config_functions └── setup_contrail.py /contrail-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-installer/HEAD/contrail-screen.png -------------------------------------------------------------------------------- /devstack-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-installer/HEAD/devstack-screen.png -------------------------------------------------------------------------------- /docs/MultinodeSetup_Deployment_GuideV0.1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-installer/HEAD/docs/MultinodeSetup_Deployment_GuideV0.1.pdf -------------------------------------------------------------------------------- /docs/Open Contrail LogLevel Usage Document.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-installer/HEAD/docs/Open Contrail LogLevel Usage Document.pdf -------------------------------------------------------------------------------- /docs/Auto_Build_and_CI_Utility_Usage_Guide_V0.2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-installer/HEAD/docs/Auto_Build_and_CI_Utility_Usage_Guide_V0.2.pdf -------------------------------------------------------------------------------- /docs/OpenStack_OpenContrail_SingleNodeSetup_Deployment_Guide_V0.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Juniper/contrail-installer/HEAD/docs/OpenStack_OpenContrail_SingleNodeSetup_Deployment_Guide_V0.3.pdf -------------------------------------------------------------------------------- /devstack/lib/neutron_thirdparty/opencontrail: -------------------------------------------------------------------------------- 1 | function configure_opencontrail() { 2 | : 3 | } 4 | 5 | function init_opencontrail() { 6 | : 7 | } 8 | 9 | function install_opencontrail() { 10 | } 11 | 12 | function start_opencontrail() { 13 | : 14 | } 15 | 16 | function stop_opencontrail() { 17 | : 18 | } 19 | 20 | function check_opencontrail() { 21 | : 22 | } 23 | -------------------------------------------------------------------------------- /utilities/contrail-status: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | 4 | if [ -z "$CONTRAIL_DIR" ]; then 5 | echo "CONTRAIL_DIR must be set to location of contrail-installer" 6 | exit 1 7 | fi 8 | export CLONE_DIR=$CONTRAIL_DIR 9 | 10 | loc=$(dirname $0) 11 | source $loc/sanity.sh 12 | mkdir -p $CLONE_DIR/sanity_status 13 | contrail_service_running_report 14 | cat $CLONE_DIR/sanity_status/Opencontrail_services_status 15 | -------------------------------------------------------------------------------- /cassandra-env.sh.patch: -------------------------------------------------------------------------------- 1 | --- cassandra-env.sh-orig 2013-11-01 22:39:23.899752001 +0000 2 | +++ cassandra-env.sh 2013-11-01 22:39:58.067752000 +0000 3 | @@ -72,8 +72,8 @@ 4 | # times. If in doubt, and if you do not particularly want to tweak, go with 5 | # 100 MB per physical CPU core. 6 | 7 | -#MAX_HEAP_SIZE="4G" 8 | -#HEAP_NEWSIZE="800M" 9 | +MAX_HEAP_SIZE="4G" 10 | +HEAP_NEWSIZE="800M" 11 | 12 | if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" ]; then 13 | calculate_heap_sizes 14 | -------------------------------------------------------------------------------- /utilities/contrail-sanity: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | 4 | if [ -z "$CONTRAIL_DIR" ]; then 5 | echo "CONTRAIL_DIR must be set to location of contrail-installer" 6 | exit 1 7 | fi 8 | if [ -z "$DEVSTACK_DIR" ]; then 9 | echo "DEVSTACK_DIR must be set to location of contrail-installer" 10 | exit 1 11 | fi 12 | export CLONE_DIR=$CONTRAIL_DIR 13 | 14 | loc=$(dirname $0) 15 | source $loc/sanity.sh 16 | mkdir -p $CLONE_DIR/sanity_status 17 | start_sanity_script 18 | cat $CLONE_DIR/sanity_status/Opencontrail_services_status 19 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This is a repository containing scripts to provision stand alone contrail system. 2 | The script contrail.sh is the executive to invoke in different modes. 3 | The command and its usage is as follows: 4 | 5 | contrail.sh build 6 | - Downloads the dependencies, source code and builds the contrail system based on INSTALL_PROFILE 7 | 8 | contrail.sh install 9 | - Installs the contrail system by placing the binaries (generated from build) and configuration files in the corresponding directories 10 | 11 | contrail.sh configure 12 | - Overrides the environment values in localrc and replaces the values in configuration files. 13 | 14 | contrail.sh start 15 | - Starts the daemons with out screen as default. If USE_SCREEN is set as True in localrc, it starts daemons with screen. 16 | 17 | contrail.sh stop 18 | - Stops the daemons 19 | 20 | contrail.sh clean 21 | - cleanup the database. 22 | -------------------------------------------------------------------------------- /devstack/samples/localrc-all: -------------------------------------------------------------------------------- 1 | STACK_DIR=$(cd $(dirname $0) && pwd) 2 | 3 | LOG_DIR=$STACK_DIR/log/screens 4 | LOG=True 5 | DEBUG=True 6 | LOGFILE=$STACK_DIR/log/stack.log 7 | LOGDAYS=1 8 | SCREEN_LOGDIR=$LOG_DIR 9 | 10 | disable_service n-net 11 | enable_service q-svc 12 | enable_service q-meta 13 | enable_service neutron 14 | 15 | # not used by contrail 16 | disable_service q-agt 17 | disable_service q-dhcp 18 | disable_service q-l3 19 | 20 | DATABASE_PASSWORD=contrail123 21 | RABBIT_PASSWORD=contrail123 22 | SERVICE_TOKEN=contrail123 23 | SERVICE_PASSWORD=contrail123 24 | ADMIN_PASSWORD=contrail123 25 | 26 | Q_PLUGIN=opencontrail 27 | PHYSICAL_INTERFACE=eth0 28 | 29 | # proto for openstack bits. Use HTTPS if git is firewalled 30 | GIT_BASE=https://git.openstack.org 31 | 32 | # opencontrail nova plugin 33 | # NOVA_VIF_DRIVER=nova_contrail_vif.contrailvif.VRouterVIFDriver 34 | 35 | Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin.NeutronPluginContrailCoreV2 36 | -------------------------------------------------------------------------------- /test_domainlist.py: -------------------------------------------------------------------------------- 1 | from vnc_api.vnc_api import VncApi 2 | def main(): 3 | client=VncApi() 4 | virtual_networks=client.virtual_networks_list() 5 | virtual_machine_interfaces=client.virtual_machine_interfaces_list() 6 | virtual_machines=client.virtual_machines_list() 7 | instance_ips=client.instance_ips_list() 8 | projects=client.projects_list() 9 | domains=client.domains_list() 10 | floating_ip_pools=client.floating_ip_pools_list() 11 | access_control_lists=client.access_control_lists_list() 12 | print domains 13 | for project in projects['projects']: 14 | id=project['uuid'] 15 | name=project['fq_name'] 16 | print id,name 17 | print projects 18 | print virtual_networks 19 | print virtual_machine_interfaces 20 | print virtual_machines 21 | print instance_ips 22 | print access_control_lists 23 | print floating_ip_pools 24 | 25 | 26 | 27 | 28 | 29 | if __name__=='__main__': 30 | main() 31 | -------------------------------------------------------------------------------- /devstack/samples/localrc-ci: -------------------------------------------------------------------------------- 1 | HOST_IP= 2 | APISERVER_IP= 3 | 4 | STACK_DIR=$(cd $(dirname $0) && pwd) 5 | 6 | LOG_DIR=$STACK_DIR/log/screens 7 | LOG=True 8 | DEBUG=True 9 | LOGFILE=$STACK_DIR/log/stack.log 10 | LOGDAYS=1 11 | SCREEN_LOGDIR=$LOG_DIR 12 | 13 | disable_service n-net 14 | enable_service q-svc 15 | enable_service q-meta 16 | enable_service neutron 17 | 18 | # not used by contrail 19 | disable_service q-agt 20 | disable_service q-dhcp 21 | disable_service q-l3 22 | 23 | DATABASE_PASSWORD=contrail123 24 | RABBIT_PASSWORD=contrail123 25 | SERVICE_TOKEN=contrail123 26 | SERVICE_PASSWORD=contrail123 27 | ADMIN_PASSWORD=contrail123 28 | 29 | Q_PLUGIN=opencontrail 30 | PHYSICAL_INTERFACE=eth0 31 | 32 | # proto for openstack bits. Use HTTPS if git is firewalled 33 | GIT_BASE=https://git.openstack.org 34 | 35 | # opencontrail nova plugin 36 | NOVA_VIF_DRIVER=nova_contrail_vif.contrailvif.VRouterVIFDriver 37 | 38 | # may need the following for older trunk snapshot 39 | # validate against /usr/lib/python2.7/dist-packages/neutron_plugin_contrail/plugins/opencontrail/ 40 | Q_PLUGIN_CLASS=neutron.plugins.opencontrail.contrail_plugin_v3.NeutronPluginContrailCoreV3 41 | Q_PLUGIN_CONF_PATH=etc/neutron/plugins/opencontrail 42 | Q_PLUGIN_CONF_FILENAME=contrailplugin.ini 43 | -------------------------------------------------------------------------------- /utilities/report_generation.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import argparse 3 | from prettytable import PrettyTable 4 | from prettytable import from_csv 5 | import os.path 6 | 7 | def finalreport(args): 8 | if(not os.path.isfile(args.FILE)): 9 | fa=open(args.FILE,'a') 10 | fa.write("Testcase,Status,Log path\n") 11 | else: 12 | fa=open(args.FILE,'a') 13 | 14 | fa.write(args.testcase+','+args.status+','+args.log_path+'\n') 15 | fa.close() 16 | 17 | def display(args): 18 | if(os.path.isfile(args.FILE)): 19 | fp = open(args.FILE,'r') 20 | mytable=from_csv(fp) 21 | print(mytable) 22 | fp.close() 23 | else: 24 | print("ERROR IN FILE DISPLAY\n") 25 | 26 | 27 | 28 | if __name__=='__main__': 29 | parser = argparse.ArgumentParser() 30 | parser.add_argument("arg1",metavar='vmdetail/nwdetail', help = "enter operation to perform vmdetail/nwdetail",default="vmdetail") 31 | parser.add_argument("--testcase","-a2", help = "testcase executed") 32 | parser.add_argument("--status","-a3", help = "status of testcase pass/fail") 33 | parser.add_argument("--log_path","-a4", help = "reference log path", default="") 34 | parser.add_argument("--FILE","-f", help = "file to store ex: --file filename.csv") 35 | args = parser.parse_args() 36 | locals()[args.arg1](args) 37 | 38 | #python prt_arg.py function --vm_id --vm_name --vm_ 39 | 40 | -------------------------------------------------------------------------------- /contrail: -------------------------------------------------------------------------------- 1 | # Juniper/Contrail Neutron Plugin 2 | # ------------------------------- 3 | 4 | # Save trace settings 5 | MY_XTRACE=$(set +o | grep xtrace) 6 | set +o xtrace 7 | 8 | function neutron_plugin_create_nova_conf() { 9 | 10 | NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"} 11 | } 12 | 13 | function neutron_plugin_setup_interface_driver() { 14 | : 15 | } 16 | 17 | function neutron_plugin_configure_common() { 18 | Q_PLUGIN_CONF_PATH=${Q_PLUGIN_CONF_PATH:-etc/neutron/plugins/juniper/contrail} 19 | Q_PLUGIN_CONF_FILENAME=${Q_PLUGIN_CONF_FILENAME:-ContrailPlugin.ini} 20 | Q_DB_NAME="contrail_neutron" 21 | Q_PLUGIN_CLASS=${Q_PLUGIN_CLASS:-"neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2"} 22 | } 23 | 24 | function neutron_plugin_configure_service() { 25 | iniset $NEUTRON_CONF DEFAULT api_extensions_path $DEST/contrail/openstack/neutron_plugin/neutron_plugin_contrail/extensions/ 26 | iniset $NEUTRON_CONF quotas quota_driver neutron.quota.ConfDriver 27 | } 28 | 29 | function neutron_plugin_configure_debug_command() { 30 | : 31 | } 32 | 33 | function is_neutron_ovs_base_plugin() { 34 | # False 35 | return 1 36 | } 37 | 38 | function has_neutron_plugin_security_group() { 39 | # True 40 | return 0 41 | } 42 | 43 | function neutron_plugin_check_adv_test_requirements() { 44 | return 0 45 | } 46 | # Restore xtrace 47 | $MY_XTRACE 48 | -------------------------------------------------------------------------------- /installer.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | zookeeper 19 | https://archive.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz 20 | tgz 21 | 971c379ba65714fd25dc5fe8f14e9ad1 22 | 23 | 24 | ncclient 25 | https://code.grnet.gr/attachments/download/1172/ncclient-v0.3.2.tar.gz 26 | file 27 | 5e2912270ed3b5c534b97702f41f56ed 28 | 29 | 30 | NodeJS 31 | http://nodejs.org/dist/v0.10.35/node-v0.10.35.tar.gz 32 | tgz 33 | 2c00d8cf243753996eecdc4f6e2a2d11 34 | 35 | 36 | -------------------------------------------------------------------------------- /samples/localrc-all: -------------------------------------------------------------------------------- 1 | STACK_DIR=$(cd $(dirname $0) && pwd) 2 | 3 | LOG_DIR=$STACK_DIR/log/screens 4 | LOG=True 5 | DEBUG=True 6 | LOGFILE=$STACK_DIR/log/contrail.log 7 | LOGDAYS=1 8 | USE_SCREEN=True 9 | 10 | DATABASE_PASSWORD=contrail123 11 | RABBIT_PASSWORD=contrail123 12 | SERVICE_TOKEN=contrail123 13 | SERVICE_PASSWORD=contrail123 14 | ADMIN_PASSWORD=contrail123 15 | 16 | #set loglevel to 1/2/3 . Always stderr into logfile,console. 17 | #For LOG_LEVEL 1 stdout into logfile. 18 | #For LOG_LEVEL 2 stdout into logfile and xtrace commands into console. 19 | #For LOG_LEVEL 3 stdout and xtrace into logfile,console. 20 | 21 | LOG_LEVEL=3 22 | 23 | SERVICE_TIMEOUT=180 24 | SERVICE_HOST=localhost 25 | 26 | #use only when INSTALL_PROFILE=COMPUTE, provide IP of compute node 27 | #COMPUTE_HOST_IP= 28 | 29 | INSTALL_PROFILE=ALL 30 | PHYSICAL_INTERFACE=eth0 31 | 32 | # to get source code make it as False 33 | CONTRAIL_DEFAULT_INSTALL=False 34 | 35 | # default branch is master 36 | # CONTRAIL_BRANCH=R3.0 37 | 38 | # to get the ppa packages uncomment 39 | # LAUNCHPAD_BRANCH=r2.20 40 | 41 | # repo proto is https or (default) ssh. Leave commented for ssh 42 | # CONTRAIL_REPO_PROTO=https 43 | 44 | # proto for openstack bits. Use HTTPS if git is firewalled 45 | GIT_BASE=https://github.com 46 | 47 | CASS_MAX_HEAP_SIZE=500M 48 | CASS_HEAP_NEWSIZE=100M 49 | 50 | # number of jobs used to build 51 | # NB_JOBS=1 52 | 53 | # target of the build debug/production 54 | # TARGET=production 55 | 56 | CONTRAIL_VGW_INTERFACE=vgw 57 | CONTRAIL_VGW_PUBLIC_SUBNET=11.0.0.0/24 58 | CONTRAIL_VGW_PUBLIC_NETWORK=default-domain:demo:net:net 59 | -------------------------------------------------------------------------------- /test_network_simple.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # test_network_simple.sh 4 | # 5 | # Set up a couple of test VMs on two networks on a single 6 | # node setup 7 | # 8 | # uses localrc-single 9 | # 10 | 11 | 12 | die() { 13 | echo "ERROR: " "$@" >&2 14 | exit 1 15 | } 16 | 17 | . ./openrc admin demo 18 | 19 | # allow ping and ssh 20 | nova secgroup-list 21 | if ! nova secgroup-list-rules default | grep tcp | grep 22; then 22 | nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 23 | fi 24 | if ! nova secgroup-list-rules default | grep icmp | grep "\-1"; then 25 | nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 26 | fi 27 | nova secgroup-list-rules default 28 | 29 | # net1 30 | eval $(neutron net-create -f shell -c id net1 | sed -ne '/^id=/p') 31 | net1_id=$id 32 | echo "net1_id=$net1_id" 33 | neutron subnet-create --name net1-subnet1 $net1_id 10.1.0.0/24 34 | 35 | # net2 (cloud) 36 | eval $(neutron net-create -f shell -c id net2 | sed -ne '/^id=/p') 37 | net2_id=$id 38 | echo "net2_id=$net2_id" 39 | neutron subnet-create --name net2-subnet1 $net2_id 10.2.0.0/24 40 | 41 | # if the net_policy_join script exists, then use it to join net1 and net2 42 | # use ${BASH_SOURCE[0]} instead of $0, because it works when this script is sourced 43 | THIS_DIR=$(dirname ${BASH_SOURCE[0]}) 44 | PATH=$THIS_DIR:$PATH 45 | if which net_policy_join.py; then 46 | net_policy_join.py $net1_id $net2_id 47 | fi 48 | 49 | 50 | # stock image form vms 51 | image=cirros-0.3.2-x86_64-uec # default stock image 52 | 53 | flavor=m1.tiny 54 | vmargs="--image $image --flavor $flavor" 55 | 56 | # vm1: net1 57 | nova boot $vmargs --nic net-id=$net1_id vm1 58 | 59 | # vm2: net2 60 | nova boot $vmargs --nic net-id=$net2_id vm2 61 | 62 | # allow VM to come up 63 | sleep 2 64 | 65 | # show where the vms ended up 66 | nova list --fields name,status,Networks,OS-EXT-SRV-ATTR:host 67 | -------------------------------------------------------------------------------- /utilities/auto.conf: -------------------------------------------------------------------------------- 1 | #This variable if set to False to install the script from contrail-installer/utilites. 2 | #The false setting will not perform the cloning of contrail-installation. 3 | #Set to True means task.sh runs from outside the contrail-installation folder and 4 | #cloning of contrail-installation will be perfomed in the same folder where task.sh executed 5 | # 6 | 7 | WITH_CONTRAIL_CLONE=False 8 | 9 | 10 | #The branch of contrail-installer to be cloned(ex: "R1.06") 11 | #Comment the below line to use default branch "master" 12 | CONTRAIL_INSTALLER_BRANCH=master 13 | 14 | 15 | #Binary installation(set True) or source code installation(set False) 16 | #Comment the below line to use default value "False" for source code installation 17 | ENABLE_BINARY=False 18 | 19 | #if binary installation is True, uncomment and set LAUNCHPAD_BRANCH appropriately 20 | # snapshots - latest packages (default) 21 | # r2.20 - R2.20 pacakages 22 | #LAUNCHPAD_BRANCH=snapshots 23 | 24 | 25 | #The branch of devstack to be cloned (ex: "stable/icehouse") 26 | #Comment the below line to use default branch "stable/havana" 27 | DEVSTACK_CLONE_BRANCH=stable/kilo 28 | 29 | #Setting True will enable Continuous Integration mode, False will do AutoBuild 30 | #Comment the below line to use default value "False" 31 | ENABLE_CI=False 32 | 33 | 34 | #The location of contrail source directory when ENBALE_CI=True 35 | #Comment the below line to use default location "/home/USER/" 36 | CONTRAIL_SRC=/opt/stack/contrail 37 | 38 | 39 | #name of VM network to be created 40 | #Default network name "net" Uncomment the below line to use diffenent VM name 41 | NETWORK_NAME=net 42 | 43 | 44 | #name of VM subnet to be created 45 | #Default Subnet name "sub". Uncomment the below line to use custom subnet name 46 | SUBNET_NAME=sub 47 | 48 | 49 | #subnet CIDR address 50 | #Default Subnet "11.0.0.0/24". Uncomment the below line to use custom CIDR address 51 | SUBNET_CIDR=11.0.0.0/24 52 | 53 | 54 | #name of the tenant 55 | #Default Tenant "demo". Uncomment the below line to use custome name 56 | TENANT_NAME=demo 57 | 58 | -------------------------------------------------------------------------------- /devstack/lib/neutron_plugins/opencontrail: -------------------------------------------------------------------------------- 1 | # Opencontrail Neutron Plugin 2 | # ------------------------------- 3 | 4 | # Save trace settings 5 | MY_XTRACE=$(set +o | grep xtrace) 6 | set +o xtrace 7 | 8 | CONTRAIL_CONF_DIR=/etc/contrail 9 | 10 | function neutron_plugin_create_nova_conf() { 11 | : 12 | } 13 | 14 | function neutron_plugin_configure_common() { 15 | Q_PLUGIN_CONF_PATH=${Q_PLUGIN_CONF_PATH:-etc/neutron/plugins/opencontrail} 16 | Q_PLUGIN_CONF_FILENAME=${Q_PLUGIN_CONF_FILENAME:-ContrailPlugin.ini} 17 | Q_DB_NAME=neutron 18 | Q_PLUGIN_CLASS=${Q_PLUGIN_CLASS:-neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_v3.NeutronPluginContrailCoreV3} 19 | 20 | local NEUTRON_CONF_PLUGIN_DIR=$NEUTRON_DIR/$Q_PLUGIN_CONF_PATH 21 | mkdir -p $NEUTRON_CONF_PLUGIN_DIR 22 | local NEUTRON_PLUGIN_CONF=$NEUTRON_CONF_PLUGIN_DIR/$Q_PLUGIN_CONF_FILENAME 23 | touch $NEUTRON_PLUGIN_CONF 24 | 25 | local MULTI_TENANCY=${MULTI_TENANCY:-False} 26 | local APISERVER_PORT=${APISERVER_PORT:-8082} 27 | local APISERVER_IP=${APISERVER_IP:-localhost} 28 | 29 | iniset $NEUTRON_PLUGIN_CONF CONTRAIL multi_tenancy $MULTI_TENANCY 30 | iniset $NEUTRON_PLUGIN_CONF CONTRAIL api_server_port $APISERVER_PORT 31 | iniset $NEUTRON_PLUGIN_CONF CONTRAIL api_server_ip $APISERVER_IP 32 | } 33 | 34 | function neutron_plugin_configure_service() { 35 | iniset $NEUTRON_CONF quotas quota_driver neutron.quota.ConfDriver 36 | local PY_PLUGIN_PATH=$(python -c "import neutron_plugin_contrail; print neutron_plugin_contrail.__path__[0]") 37 | iniset $NEUTRON_CONF DEFAULT api_extensions_path extensions:$PY_PLUGIN_PATH/extensions 38 | iniset $NEUTRON_CONF keystone_authtoken auth_protocol http 39 | } 40 | 41 | function neutron_plugin_setup_interface_driver() { 42 | : 43 | } 44 | 45 | function neutron_plugin_configure_debug_command() { 46 | : 47 | } 48 | 49 | function is_neutron_ovs_base_plugin() { 50 | # False 51 | return 1 52 | } 53 | 54 | function has_neutron_plugin_security_group() { 55 | # True 56 | return 0 57 | } 58 | 59 | function neutron_plugin_check_adv_test_requirements() { 60 | return 0 61 | } 62 | 63 | # kilo and later don't require setting network_api_class 64 | 65 | # Restore xtrace 66 | $MY_XTRACE 67 | -------------------------------------------------------------------------------- /clean.py: -------------------------------------------------------------------------------- 1 | #clean database 2 | import pycassa 3 | import pycassa.cassandra.ttypes 4 | from pycassa.system_manager import * 5 | import ConfigParser 6 | from cfgm_common.zkclient import ZookeeperClient, IndexAllocator 7 | import gevent.event 8 | import logging 9 | import logging.handlers 10 | 11 | def main(): 12 | #removing config_db_uuid,useragent keyspaces 13 | config = None 14 | server_list = [] 15 | config = ConfigParser.SafeConfigParser({'admin_token': None}) 16 | config.read('/etc/contrail/contrail-api.conf') 17 | server_list_str=config.get('DEFAULTS','cassandra_server_list') 18 | server_list=server_list_str.split() 19 | server_idx = 0 20 | num_dbnodes = len(server_list) 21 | connected = False 22 | cass_server = None 23 | while not connected: 24 | try: 25 | cass_server = server_list[server_idx] 26 | sys_mgr = SystemManager(cass_server) 27 | connected = True 28 | except Exception as e: 29 | server_idx = (server_idx + 1) % num_dbnodes 30 | time.sleep(3) 31 | 32 | uuid_keyspace_name = 'config_db_uuid' 33 | agent_keyspace_name = 'useragent' 34 | try: 35 | print "deleting config_db_uuid keyspace" 36 | sys_mgr.drop_keyspace(uuid_keyspace_name) 37 | except pycassa.cassandra.ttypes.InvalidRequestException as e: 38 | print "Warning! " + str(e) 39 | try: 40 | print "deleting useragent keyspace" 41 | sys_mgr.drop_keyspace(agent_keyspace_name) 42 | except pycassa.cassandra.ttypes.InvalidRequestException as e: 43 | print "Warning! " + str(e) 44 | 45 | #deleting znodes 46 | _SUBNET_PATH = "/api-server/subnets" 47 | _FQ_NAME_TO_UUID_PATH = "/fq-name-to-uuid" 48 | _zk_client = None 49 | while True: 50 | try: 51 | _zk_client = ZookeeperClient("api-" + '0', '127.0.0.1:2181') 52 | break 53 | except gevent.event.Timeout as e: 54 | pass 55 | print "deleting nodes at ",_SUBNET_PATH 56 | _zk_client.delete_node(_SUBNET_PATH, True); 57 | print "deleting nodes at ",_FQ_NAME_TO_UUID_PATH 58 | _zk_client.delete_node(_FQ_NAME_TO_UUID_PATH, True); 59 | if __name__=='__main__': 60 | main() 61 | 62 | -------------------------------------------------------------------------------- /install_pip.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # **install_pip.sh** 4 | 5 | # install_pip.sh [--pip-version ] [--use-get-pip] [--force] 6 | # 7 | # Update pip and friends to a known common version 8 | 9 | # Assumptions: 10 | # - update pip to $INSTALL_PIP_VERSION 11 | 12 | 13 | # Keep track of the current directory 14 | TOP_DIR=`pwd` 15 | 16 | # Change dir to top of devstack 17 | cd $TOP_DIR 18 | 19 | # Import common functions 20 | source $TOP_DIR/functions 21 | 22 | 23 | # Handle arguments 24 | 25 | USE_GET_PIP=${USE_GET_PIP:-0} 26 | INSTALL_PIP_VERSION=${INSTALL_PIP_VERSION:-"1.5.6"} 27 | while [[ -n "$1" ]]; do 28 | case $1 in 29 | --force) 30 | FORCE=1 31 | ;; 32 | --pip-version) 33 | INSTALL_PIP_VERSION="$2" 34 | shift 35 | ;; 36 | --use-get-pip) 37 | USE_GET_PIP=1; 38 | ;; 39 | esac 40 | shift 41 | done 42 | 43 | PIP_GET_PIP_URL=https://raw.github.com/pypa/pip/master/contrib/get-pip.py 44 | PIP_TAR_URL=https://pypi.python.org/packages/source/p/pip/pip-$INSTALL_PIP_VERSION.tar.gz 45 | 46 | GetDistro 47 | echo "Distro: $DISTRO" 48 | 49 | function get_versions() { 50 | PIP=$(which pip 2>/dev/null || which pip-python 2>/dev/null || true) 51 | if [[ -n $PIP ]]; then 52 | PIP_VERSION=$($PIP --version | awk '{ print $2}') 53 | echo "pip: $PIP_VERSION" 54 | else 55 | echo "pip: Not Installed" 56 | fi 57 | } 58 | 59 | 60 | function install_get_pip() { 61 | ( 62 | curl -O $PIP_GET_PIP_URL; \ 63 | ) 64 | } 65 | 66 | function install_pip_tarball() { 67 | if [[ -f pip-$INSTALL_PIP_VERSION.tar.gz ]]; then 68 | echo "Skipping downloading of pip-$INSTALL_PIP_VERSION.tar.gz" 69 | ( 70 | tar xvfz pip-$INSTALL_PIP_VERSION.tar.gz 1>/dev/null; \ 71 | cd pip-$INSTALL_PIP_VERSION; \ 72 | sudo -E python setup.py install 1>/dev/null; \ 73 | ) 74 | else 75 | ( 76 | curl -O $PIP_TAR_URL; \ 77 | tar xvfz pip-$INSTALL_PIP_VERSION.tar.gz 1>/dev/null; \ 78 | cd pip-$INSTALL_PIP_VERSION; \ 79 | sudo -E python setup.py install 1>/dev/null; \ 80 | ) 81 | fi 82 | } 83 | 84 | # Show starting versions 85 | get_versions 86 | 87 | 88 | # Eradicate any and all system packages 89 | uninstall_package python-pip 90 | 91 | if [[ "$USE_GET_PIP" == "1" ]]; then 92 | install_get_pip 93 | else 94 | install_pip_tarball 95 | fi 96 | 97 | get_versions 98 | -------------------------------------------------------------------------------- /setup_devstack.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -e "Devstack Branch you want to setup: \n [ex: stable/havana]" 4 | 5 | read dvstk 6 | 7 | 8 | DEVSTACK_CLONE_URL="https://github.com/openstack-dev/devstack.git" 9 | DEVSTACK_CLONE_BRANCH="$dvstk" 10 | CONTRAIL_DIR=`pwd` 11 | DEVSTACK_CLONE_DIR=$CONTRAIL_DIR/../ 12 | DEVSTACK_DIR=$DEVSTACK_CLONE_DIR/devstack 13 | RECLONE=${RECLONE:-False} 14 | 15 | #echo $RECLONE 16 | 17 | Clone_Devstack () { 18 | if [ "$RECLONE" = "True" ]; then 19 | echo "Removing the current devstack and recloning again" 20 | sudo rm -r $DEVSTACK_DIR 21 | fi 22 | if [ -d $DEVSTACK_DIR ]; then 23 | echo "devstack is already cloned using that devstack to work" 24 | else 25 | if [ $DEVSTACK_CLONE_BRANCH ];then 26 | echo "cloning the branch $DEVSTACK_CLONE_BRANCH" 27 | CLONE_BRANCH="-b $DEVSTACK_CLONE_BRANCH" 28 | fi 29 | cd $DEVSTACK_CLONE_DIR 30 | git clone $CLONE_BRANCH $DEVSTACK_CLONE_URL 31 | fi 32 | 33 | } 34 | 35 | Changes_Devstack_localrc () { 36 | cd $CONTRAIL_DIR 37 | 38 | #checks if there is devstack folder cloned or not 39 | if [ -d $DEVSTACK_DIR ] ; then 40 | if [ -f $DEVSTACK_DIR/lib/neutron_plugins/opencontrail ]; then 41 | echo "opencontrail plugin file is already new in devstack" 42 | else 43 | cp $CONTRAIL_DIR/devstack/lib/neutron_plugins/opencontrail $DEVSTACK_DIR/lib/neutron_plugins/ 44 | fi 45 | if [ -f $DEVSTACK_DIR/localrc ]; then 46 | echo "localrc is already new" 47 | else 48 | cp $CONTRAIL_DIR/devstack/samples/localrc-all $DEVSTACK_DIR/localrc 49 | fi 50 | cd $DEVSTACK_DIR 51 | if [ -f $DEVSTACK_DIR/localrc ]; then 52 | # Changes in $DEVSTACK_DIR/localrc 53 | sed -i '/ADMIN_PASSWORD/ a USE_SCREENS=True' $DEVSTACK_DIR/localrc 54 | grep -q "Q_PLUGIN=opencontrail" $DEVSTACK_DIR/localrc 55 | [ $? -eq 1 ] && sed -i '/ADMIN_PASSWORD/ a Q_PLUGIN=opencontrail' $DEVSTACK_DIR/localrc 56 | sed -i 's/^#*GIT_BASE/GIT_BASE/g' $DEVSTACK_DIR/localrc 57 | sed -i 's/^#*NOVA_VIF_DRIVER/NOVA_VIF_DRIVER/g' $DEVSTACK_DIR/localrc 58 | sed -i "s/^HOST_IP=.*/HOST_IP=`ifconfig | head -n2 | tail -1 | cut -d: -f2 | cut -d' ' -f1`/" $DEVSTACK_DIR/localrc 59 | if [ -f $CONTRAIL_DIR/localrc ] ; then 60 | ENABLE_BINARY=`grep "CONTRAIL_DEFAULT_INSTALL" $CONTRAIL_DIR/localrc | cut -d'=' -f2` 61 | 62 | #Changes regarding Q_PLUGIN 63 | if [ "$ENABLE_BINARY" = "True" ]; then 64 | [ `grep "^ *LAUNCHPAD_BRANCH=PPA" $CONTRAIL_DIR/localrc` ] && sed -i "s/.*Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2.*/#Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2/" ./localrc || sed -i "s/.*#Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2.*/Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2/" ./localrc 65 | else 66 | sed -i "s/.*Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2.*/#Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2/" ./localrc 67 | fi 68 | fi 69 | fi 70 | 71 | fi 72 | 73 | } 74 | 75 | Setup_Devstack () { 76 | 77 | Clone_Devstack #Cloning devstack into the directory where contrail-installer presents 78 | Changes_Devstack_localrc #Changing localrc in devstack 79 | } 80 | 81 | Setup_Devstack 82 | 83 | echo "Devstack $dvstk : setup completed successfully" 84 | 85 | -------------------------------------------------------------------------------- /Contrail_user_guide.txt: -------------------------------------------------------------------------------- 1 | ######################################################################################### 2 | @@@@@@ Procedure to install contrail-installer with source code enabled @@@@@@ 3 | ######################################################################################### 4 | 5 | 1. Clone the fresh contrail-installer repository from the git by using command below 6 | 7 | git clone https://github.com/shravani89/contrail-installer -b test-m1-build 8 | 9 | 2. Copy the file localrc-all from samples directory to the current directory as localrc and 10 | make sure that localrc file have the following changes 11 | 12 | To disable the binary installation and download, 13 | CONTRAIL_DEFAULT_INSTALL=False 14 | If binaries need to be downloaded and installed make above “True” 15 | 16 | Branch that points to the changes made in scons directory 17 | CONTRAIL_BRANCH=test-m1-build 18 | 19 | To download the ALL dependencies, 20 | INSTALL_PROFILE=ALL 21 | If only COMPUTE source code needs to be downloaded and installed, use “COMPUTE”. 22 | 23 | To use screens, 24 | USE_SCREEN=True 25 | 26 | 3. Build the contrail with all the required packages using the command 27 | 28 | ./contrail.sh build 29 | 30 | 4. To install contrail modules and its dependencies, run “./contrail.sh install “, which will Install 31 | all the necessary Modules to start the contrail services 32 | 33 | 34 | 5. Configure the contrail using “./contrail.sh configure” such that it makes the necessary changes in 35 | the files in /etc/contrail which are used by the contrail services 36 | 37 | Files that are modified in configure phase are 38 | /etc/contrail/contrail-api.conf 39 | /etc/contrail/contrail_plugin.ini 40 | /etc/contrail/contrail-schema.conf 41 | /etc/contrail/svc-monitor.conf 42 | /etc/contrail/discovery.conf 43 | /etc/contrail/vnc_api_lib.ini 44 | /etc/contrail/ContrailPlugin.ini 45 | /etc/contrail/contrail-control.conf 46 | /etc/contrail/dns.conf 47 | /etc/contrail/contrail-compute.conf 48 | /etc/contrail/contrail-vrouter-agent.conf 49 | /etc/ifmap-server/basicauthusers.properties 50 | /etc/contrail/default_pmac 51 | /etc/contrail/ifcfg-vhost0 52 | /etc/libvirt/qemu.conf 53 | /etc/contrail/ctrl-details 54 | /etc/contrail/contrail-collector.conf 55 | /etc/contrail/contrail-query-engine.conf 56 | /etc/contrail/contrail-analytics-api.conf 57 | 58 | 6. Start the contrail services using the command 59 | 60 | ./contrail.sh start 61 | 62 | 7. To stop the contrail services at any time use 63 | 64 | ./contrail.sh stop 65 | 66 | 8. Clean is enabled in this version so that we can run clean using 67 | 68 | ./contrail.sh clean 69 | 70 | NOTE: Clean option should be run when all the contrail services are UP and Running 71 | 72 | 9. ‘setup_devstack.sh’ script will clone the specified devstack repository to the previous directory 73 | from current working directory. Copies the localrc-multinode-server file from contrail-installer/samples 74 | directory to the devstack directory as localrc. 75 | ‘contrail’ file is added to the devstack/lib/neutron_plugins/ directory from the current working directory. 76 | By default, localrc file will have all the changes required for the muiltiserver node. 77 | 'contrail' file will act as an interface between the contrail and the openstack. 78 | 79 | In 'stackrc', NEUTRON_REPO, NEUTRON_BRANCH variable values are changed and CONTRAIL_GIT_BASE variable 80 | is added in this script so that neutron repo points to the juniper neutron repo 81 | 82 | CONTRAIL_GIT_BASE=https://github.com/juniper 83 | NEUTRON_REPO=contrail/havana 84 | NEUTRON_BRANCH=${CONTRAIL_GIT_BASE}/neutron.git 85 | 86 | NOTE: Current working directory implies the directory where the repository contrail-installer is cloned. 87 | 88 | 10. 'service.sh' script is used to start, stop and restart the services if USE_SCREEN is False. 89 | 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | contrail-installer 2 | ================== 3 | 4 | contrail-installer is a set of scripts and utilities to quickly 5 | build, install, configure and deploy OpenContrail. It can be used 6 | with pre-build packages (e.g. Launchpad PPA) or from sources. It 7 | is typically used in conjunction with devstack. 8 | 9 | # Versions 10 | 11 | The contrail-installer master branch generally points to trunk versions 12 | of OpenContrail components whether sources or snapshots. For older, 13 | stable versions, use appropriate release name. 14 | 15 | Currently contrail-installer supports the following: 16 | 17 | contrail-installer: sources master, devstack: stable/mitaka 18 | contrail-installer: sources R3.0, devstack: stable/mitaka 19 | contrail-installer: packages R2.20, devstack: stable/mitaka 20 | 21 | # OpenContrail localrc 22 | 23 | OpenContrail uses ``localrc`` to contain all local configuration and customizations. 24 | Best to start with a sample localrc. 25 | 26 | cd contrail-installer 27 | cp samples/localrc-all localrc 28 | 29 | CONTRAIL_DEFAULT_INSTALL - Set this to True for installation from OpenContrail binary 30 | packages. When set to False, trunk OpenContrail bits will be downloaded and compiled. 31 | 32 | LAUNCHPAD_BRANCH=PPA - Applicable only when CONTRAIL_DEFAULT_INSTALL is set to True. 33 | It specifies to use released binary packages for installation instead of compiling and 34 | building from sources. Default is to use latest snapshots as this knob is commented out 35 | by default in sample localrc. 36 | 37 | PHYSICAL_INTERFACE - This is external interface Vrouter should bind to. It should have 38 | a valid IP address configured. For example eth0 39 | 40 | INSTALL_PROFILE - Set this to ALL to for an all in one node. 41 | 42 | USE_SCREEN - Set this to True to launch contrail modules in a screen session called 43 | "contrail". Connect to screen session for any troubleshooting of contrail modules. 44 | 45 | LOGFILE - Specify logfile for contrail.sh runs. By default this is log/contrail.log 46 | in contrail-installer directory 47 | 48 | # OpenContrail script 49 | 50 | Contrail.sh is the main script that supports following options: 51 | 52 | build ... to build OpenContrail 53 | Install ... to Install OpenContrail 54 | configure ... to Configure & Provision 55 | start ... to Start OpenContrail Modules 56 | stop ... to Stop OpenContrail Modules 57 | restart ... to Restart OpenContrail Modules without resetting data 58 | 59 | # Launching OpenContrail 60 | 61 | Run the following NOT AS ROOT: 62 | 63 | cd contrail-installer 64 | cp samples/localrc-all localrc (edit localrc as needed) 65 | ./contrail.sh build 66 | ./contrail.sh install 67 | ./contrail.sh configure 68 | ./contrail.sh start 69 | 70 | Upon successful run of last command, output similar to below should appear: 71 | 72 | #:~/contrail-installer$ 2017-04-26 12:50:29 +++ echo -ne '\015' 73 | ++ clean 74 | ++ local r=0 75 | ++ echo 'exited with status :0' 76 | exited with status :0 77 | ++ exit 0 78 | 79 | This will create a screen names "contrail" with a tab corresponding to each contrail service: 80 | 81 | #:~/contrail-installer$ screen -ls 82 | There are screens on: 83 | 2427.contrail (04/26/2017 12:48:59 PM) (Detached) 84 | 1 Sockets in /var/run/screen/S-jenkins. 85 | 86 | ![alt text](contrail-screen.png) 87 | 88 | # Devstack 89 | 90 | Trunk of contrail-installer currently works with stable/mitaka of devstack. 91 | 92 | git clone git@github.com:openstack-dev/devstack 93 | cd devstack 94 | git checkout stable/mitaka 95 | 96 | A glue file is needed for devstack to use Contrail neutron plugin 97 | 98 | cp ~/contrail-installer/devstack/lib/neutron_plugins/opencontrail lib/neutron_plugins/ 99 | 100 | Use provided sample localrc for devstack. Note that this disables some neutron networking services 101 | because these services are provided by Contrail networking plugin. Edit localrc as needed to reflect 102 | your physical interface and host: 103 | 104 | cp ~/contrail-installer/devstack/samples/localrc-all localrc 105 | HOST_IP= 106 | PHYSICAL_INTERFACE=eth0 107 | 108 | Run stack.sh 109 | ./stack.sh 110 | 111 | if devstack installs successfully, output similar to following will be shown: 112 | 113 | ======================== 114 | DevStack Components Timed 115 | ======================== 116 | 117 | run_process - 71 secs 118 | test_with_retry - 7 secs 119 | apt-get-update - 17 secs 120 | pip_install - 269 secs 121 | restart_apache_server - 10 secs 122 | wait_for_service - 29 secs 123 | apt-get - 9 secs 124 | 125 | This is your host IP address: 192.168.0.175 126 | This is your host IPv6 address: ::1 127 | Horizon is now available at http://192.168.0.175/dashboard 128 | Keystone is serving at http://192.168.0.175:5000/ 129 | The default users are: admin and demo 130 | The password: contrail123 131 | 132 | ![alt text](devstack-screen.png) 133 | 134 | # Restarting OpenContrail+Devstack 135 | 136 | If you need to restart OpenContrail or Devstack for some reason, currently they 137 | need to be synchronized. So 138 | 139 | cd ~/devstack 140 | ./unstack.sh 141 | 142 | cd ~/contrail-installer 143 | ./contrail.sh restart 144 | cd ~/devstack 145 | ./stack.sh 146 | 147 | if issues persist, it might be helpful to reboot server or VM and repeat the steps 148 | below 149 | 150 | cd ~/contrail-installer 151 | ./contrail.sh start 152 | cd ~/devstack 153 | ./stack.sh 154 | 155 | 156 | # Verify installation 157 | 1) screen -x contrail and run through various tabs to see various contrail modules are running 158 | 2) Run utilities/contrail-status to see if all services are running 159 | 160 | 161 | # Running sanity 162 | Note that default sample localrc enables simple gateway. A script is available that will 163 | create a virtual network, launch two VMs, ping each VM from host and then SSH into it. 164 | Follow the steps below: 165 | 166 | cd ~/contrail-installer/utilities 167 | export CONTRAIL_DIR=~/contrail-installer 168 | export DEVSTACK_DIR=~/devstack 169 | ./contrail-sanity 170 | 171 | # Opencontrail UI 172 | OpenContrail UI runs on http port 8080. It will automatically redirect to https port 8143. 173 | username is "admin", and the password is mentioned in the localrc (default: "contrail123") 174 | 175 | # Automating contrail.sh and devstack 176 | contrail-installer/utilities/task.sh attempts to automate steps required by sequential runs 177 | of contrail.sh and devstack. It works off a configuration file. Default called auto.conf is 178 | provided. Following example launches task.sh in binary PPA mode while using R2.20 packages. 179 | See auto.conf for more options to launch in source mode or with use of snapshots 180 | 181 | $ cd ~/contrail-installer/utilities 182 | $ diff auto.conf my.conf 183 | 17c17 184 | < ENABLE_BINARY=False 185 | --- 186 | > ENABLE_BINARY=True 187 | 22a23 188 | > LAUNCHPAD_BRANCH=r2.20 189 | 190 | $ ./task.sh my.conf 191 | -------------------------------------------------------------------------------- /service.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | TOP_DIR=`pwd` 4 | CONTRAIL_USER=$(whoami) 5 | CONTRAIL_SRC=${CONTRAIL_SRC:-/opt/stack/contrail} 6 | source functions 7 | source localrc 8 | 9 | function pywhere() 10 | { 11 | module=$1 12 | python -c "import $module; import os; print os.path.dirname($module.__file__)" 13 | } 14 | 15 | 16 | function _start_service() 17 | { 18 | service=$1 19 | if is_ubuntu; then 20 | REDIS_CONF="/etc/redis/redis.conf" 21 | CASS_PATH="/usr/sbin/cassandra" 22 | else 23 | REDIS_CONF="/etc/redis.conf" 24 | CASS_PATH="$CONTRAIL_SRC/third_party/apache-cassandra-2.0.2/bin/cassandra" 25 | fi 26 | if [ "$INSTALL_PROFILE" = "ALL" ]; then 27 | case $service in 28 | redis) echo "starting redis" 29 | redis-cli flushall 30 | screen_it redis "sudo redis-server $REDIS_CONF" 31 | ;; 32 | 33 | cass) echo "starting cassandra" 34 | screen_it cass "sudo $CASS_PATH -f" 35 | ;; 36 | 37 | zk) echo "starting zookeeper" 38 | screen_it zk "cd $CONTRAIL_SRC/third_party/zookeeper-3.4.6; ./bin/zkServer.sh start" 39 | 40 | ;; 41 | 42 | ifmap) echo "starting ifmap" 43 | if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then 44 | screen_it ifmap "cd $CONTRAIL_SRC/build/packages/ifmap-server; java -jar ./irond.jar" 45 | else 46 | screen_it ifmap "cd /usr/share/ifmap-server; java -jar ./irond.jar" 47 | fi 48 | ;; 49 | 50 | disco) echo "starting disco" 51 | screen_it disco "python $(pywhere discovery)/disc_server_zk.py --reset_config --conf_file /etc/contrail/discovery.conf" 52 | ;; 53 | 54 | apisrv) echo "starting apiserver" 55 | screen_it apiSrv "python $(pywhere vnc_cfg_api_server)/vnc_cfg_api_server.py --conf_file /etc/contrail/contrail-api.conf --rabbit_password ${RABBIT_PASSWORD}" 56 | ;; 57 | 58 | schema) echo "starting schema" 59 | screen_it schema "python $(pywhere schema_transformer)/to_bgp.py --reset_config --conf_file /etc/contrail/contrail-schema.conf" 60 | ;; 61 | 62 | svc-mon) echo "starting svc-mon" 63 | screen_it svc-mon "python $(pywhere svc_monitor)/svc_monitor.py --reset_config --conf_file /etc/contrail/svc-monitor.conf" 64 | ;; 65 | 66 | control) echo "starting control" 67 | if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then 68 | screen_it control "export LD_LIBRARY_PATH=/opt/stack/contrail/build/lib; $CONTRAIL_SRC/build/production/control-node/control-node --conf_file /etc/contrail/contrail-control.conf ${CERT_OPTS} ${LOG_LOCAL}" 69 | else 70 | screen_it control "export LD_LIBRARY_PATH=/usr/lib; /usr/bin/control-node --conf_file /etc/contrail/contrail-control.conf ${CERT_OPTS} ${LOG_LOCAL}" 71 | fi 72 | ;; 73 | 74 | collector) echo "starting collector" 75 | if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then 76 | screen_it collector "sudo PATH=$PATH:$TOP_DIR/bin LD_LIBRARY_PATH=/opt/stack/contrail/build/lib $CONTRAIL_SRC/build/production/analytics/vizd" 77 | else 78 | screen_it collector "sudo PATH=$PATH:/usr/bin LD_LIBRARY_PATH=/usr/lib /usr/bin/contrail-collector" 79 | fi 80 | ;; 81 | 82 | analytics-api) echo "starting analytics-api" 83 | screen_it analytics-api "python $(pywhere opserver)/opserver.py" 84 | ;; 85 | 86 | query-engine) echo "starting query-engine" 87 | if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then 88 | screen_it query-engine "sudo PATH=$PATH:$TOP_DIR/bin LD_LIBRARY_PATH=/opt/stack/contrail/build/lib $CONTRAIL_SRC/build/production/query_engine/qed" 89 | else 90 | screen_it query-engine "sudo PATH=$PATH:/usr/bin LD_LIBRARY_PATH=/usr/lib /usr/bin/contrail-query-engine" 91 | fi 92 | ;; 93 | 94 | agent) echo "starting agent" 95 | screen_it agent "sudo $TOP_DIR/bin/vnsw.hlpr" 96 | ;; 97 | 98 | redis-w ) echo "starting redis-w " 99 | screen_it redis-w "sudo redis-server /etc/contrail/redis-webui.conf" 100 | 101 | ;; 102 | 103 | ui-jobs) echo "starting ui-jobs" 104 | if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then 105 | screen_it ui-jobs "cd /opt/stack/contrail/contrail-web-core; sudo node jobServerStart.js" 106 | else 107 | screen_it ui-jobs "cd /var/lib/contrail-webui-bundle; sudo node jobServerStart.js" 108 | fi 109 | ;; 110 | 111 | ui-webs) echo "starting ui-webs" 112 | if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then 113 | screen_it ui-webs "cd /opt/stack/contrail/contrail-web-core; sudo node webServerStart.js" 114 | else 115 | screen_it ui-webs "cd /var/lib/contrail-webui-bundle; sudo node webServerStart.js" 116 | fi 117 | 118 | ;; 119 | *) echo "please verify the service entered" 120 | ;; 121 | esac 122 | else 123 | case $service in 124 | agent) echo "starting agent" 125 | screen_it agent "sudo $TOP_DIR/bin/vnsw.hlpr" 126 | ;; 127 | *) echo "please verify the service entered in compute mode" 128 | ;; 129 | esac 130 | fi 131 | 132 | } 133 | 134 | function start_service() 135 | { 136 | if [[ -f $TOP_DIR/status/contrail/$1.pid ]]; then 137 | echo "$1 is already running" 138 | exit 139 | else 140 | _start_service $1 141 | fi 142 | } 143 | 144 | function stop_service() 145 | { 146 | echo "stopping the service $1" 147 | screen_stop $1 148 | } 149 | 150 | function restart_service() 151 | { 152 | if [[ -f $TOP_DIR/status/contrail/$1.pid ]]; then 153 | echo "$1 is already running,stopping it" 154 | stop_service $1 155 | fi 156 | echo "restarting service $1" 157 | _start_service $1 158 | 159 | } 160 | 161 | OPTION=$2 162 | ARGS_COUNT=$# 163 | if [ "$USE_SCREEN" = "False" ]; then 164 | if [ $ARGS_COUNT -eq 2 ] && [ "$OPTION" == "start" ] || [ "$OPTION" == "restart" ] || [ "$OPTION" == "stop" ] ; 165 | then 166 | ${OPTION}_service $1 167 | else 168 | echo "Usage :: service.sh servicename [option]" 169 | echo "ex: service.sh servicename start" 170 | echo "[options]:" 171 | echo "start" 172 | echo "stop" 173 | echo "restart" 174 | fi 175 | else 176 | echo "screens enabled" 177 | fi 178 | -------------------------------------------------------------------------------- /contrail_config_templates.py: -------------------------------------------------------------------------------- 1 | import string 2 | 3 | api_server_conf_template = string.Template(""" 4 | [DEFAULTS] 5 | ifmap_server_ip=$__contrail_ifmap_server_ip__ 6 | ifmap_server_port=$__contrail_ifmap_server_port__ 7 | ifmap_username=$__contrail_ifmap_username__ 8 | ifmap_password=$__contrail_ifmap_password__ 9 | redis_server_port=6379 10 | cassandra_server_list=$__contrail_cassandra_server_list__ 11 | listen_ip_addr=$__contrail_listen_ip_addr__ 12 | listen_port=$__contrail_listen_port__ 13 | auth=keystone 14 | multi_tenancy=$__contrail_multi_tenancy__ 15 | log_file=$__contrail_log_file__ 16 | disc_server_ip=$__contrail_disc_server_ip__ 17 | disc_server_port=$__contrail_disc_server_port__ 18 | 19 | [SECURITY] 20 | use_certs=$__contrail_use_certs__ 21 | keyfile=$__contrail_keyfile_location__ 22 | certfile=$__contrail_certfile_location__ 23 | ca_certs=$__contrail_cacertfile_location__ 24 | 25 | [KEYSTONE] 26 | auth_host=$__contrail_openstack_ip__ 27 | auth_protocol=http 28 | admin_user=$__contrail_admin_user__ 29 | admin_password=$__contrail_admin_password__ 30 | admin_tenant_name=$__contrail_admin_tenant_name__ 31 | $__contrail_memcached_opt__ 32 | """) 33 | 34 | quantum_conf_template = string.Template(""" 35 | [APISERVER] 36 | api_server_ip = $__contrail_api_server_ip__ 37 | api_server_port = $__contrail_api_server_port__ 38 | multi_tenancy = $__contrail_multi_tenancy__ 39 | 40 | [KEYSTONE] 41 | ;auth_url = http://$__contrail_keystone_ip__:35357/v2.0 42 | ;admin_token = $__contrail_admin_token__ 43 | admin_user=$__contrail_admin_user__ 44 | admin_password=$__contrail_admin_password__ 45 | admin_tenant_name=$__contrail_admin_tenant_name__ 46 | """) 47 | 48 | schema_transformer_conf_template = string.Template(""" 49 | [DEFAULTS] 50 | ifmap_server_ip=$__contrail_ifmap_server_ip__ 51 | ifmap_server_port=$__contrail_ifmap_server_port__ 52 | ifmap_username=$__contrail_ifmap_username__ 53 | ifmap_password=$__contrail_ifmap_password__ 54 | api_server_ip=$__contrail_api_server_ip__ 55 | api_server_port=$__contrail_api_server_port__ 56 | zk_server_ip=$__contrail_zookeeper_server_ip__ 57 | zk_server_port=$__contrail_zookeeper_server_port__ 58 | log_file=$__contrail_log_file__ 59 | cassandra_server_list=$__contrail_cassandra_server_list__ 60 | disc_server_ip=$__contrail_disc_server_ip__ 61 | disc_server_port=$__contrail_disc_server_port__ 62 | 63 | [SECURITY] 64 | use_certs=$__contrail_use_certs__ 65 | keyfile=$__contrail_keyfile_location__ 66 | certfile=$__contrail_certfile_location__ 67 | ca_certs=$__contrail_cacertfile_location__ 68 | 69 | [KEYSTONE] 70 | admin_user=$__contrail_admin_user__ 71 | admin_password=$__contrail_admin_password__ 72 | admin_tenant_name=$__contrail_admin_tenant_name__ 73 | """) 74 | 75 | svc_monitor_conf_template = string.Template(""" 76 | [DEFAULTS] 77 | ifmap_server_ip=$__contrail_ifmap_server_ip__ 78 | ifmap_server_port=$__contrail_ifmap_server_port__ 79 | ifmap_username=$__contrail_ifmap_username__ 80 | ifmap_password=$__contrail_ifmap_password__ 81 | api_server_ip=$__contrail_api_server_ip__ 82 | api_server_port=$__contrail_api_server_port__ 83 | zk_server_ip=$__contrail_zookeeper_server_ip__ 84 | zk_server_port=$__contrail_zookeeper_server_port__ 85 | log_file=$__contrail_log_file__ 86 | cassandra_server_list=$__contrail_cassandra_server_list__ 87 | disc_server_ip=$__contrail_disc_server_ip__ 88 | disc_server_port=$__contrail_disc_server_port__ 89 | rabbit_user=$__contrail_rabbit_user__ 90 | rabbit_password=$__contrail_rabbit_password__ 91 | 92 | [SECURITY] 93 | use_certs=$__contrail_use_certs__ 94 | keyfile=$__contrail_keyfile_location__ 95 | certfile=$__contrail_certfile_location__ 96 | ca_certs=$__contrail_cacertfile_location__ 97 | 98 | [KEYSTONE] 99 | auth_host=$__contrail_openstack_ip__ 100 | admin_user=$__contrail_admin_user__ 101 | admin_password=$__contrail_admin_password__ 102 | admin_tenant_name=$__contrail_admin_tenant_name__ 103 | """) 104 | 105 | bgp_param_template = string.Template(""" 106 | IFMAP_SERVER=$__contrail_ifmap_srv_ip__ 107 | IFMAP_PORT=$__contrail_ifmap_srv_port__ 108 | IFMAP_USER=$__contrail_ifmap_usr__ 109 | IFMAP_PASWD=$__contrail_ifmap_paswd__ 110 | COLLECTOR=$__contrail_collector__ 111 | COLLECTOR_PORT=$__contrail_collector_port__ 112 | DISCOVERY=$__contrail_discovery_ip__ 113 | HOSTNAME=$__contrail_hostname__ 114 | HOSTIP=$__contrail_host_ip__ 115 | BGP_PORT=$__contrail_bgp_port__ 116 | CERT_OPTS=$__contrail_cert_ops__ 117 | CONTROL_LOGFILE=$__contrail_logfile__ 118 | LOG_LOCAL=$__contrail_log_local__ 119 | """) 120 | 121 | dns_param_template = string.Template(""" 122 | IFMAP_SERVER=$__contrail_ifmap_srv_ip__ 123 | IFMAP_PORT=$__contrail_ifmap_srv_port__ 124 | IFMAP_USER=$__contrail_ifmap_usr__ 125 | IFMAP_PASWD=$__contrail_ifmap_paswd__ 126 | COLLECTOR=$__contrail_collector__ 127 | COLLECTOR_PORT=$__contrail_collector_port__ 128 | DISCOVERY=$__contrail_discovery_ip__ 129 | HOSTIP=$__contrail_host_ip__ 130 | CERT_OPTS=$__contrail_cert_ops__ 131 | DNS_LOGFILE=$__contrail_logfile__ 132 | LOG_LOCAL=$__contrail_log_local__ 133 | """) 134 | 135 | 136 | discovery_conf_template = string.Template(""" 137 | [DEFAULTS] 138 | zk_server_ip=127.0.0.1 139 | zk_server_port=$__contrail_zk_server_port__ 140 | listen_ip_addr=$__contrail_listen_ip_addr__ 141 | listen_port=$__contrail_listen_port__ 142 | log_local=$__contrail_log_local__ 143 | log_file=$__contrail_log_file__ 144 | 145 | # minimim time to allow client to cache service information (seconds) 146 | ttl_min=300 147 | 148 | # maximum time to allow client to cache service information (seconds) 149 | ttl_max=1800 150 | 151 | # maximum hearbeats to miss before server will declare publisher out of 152 | # service. 153 | hc_max_miss=3 154 | 155 | # use short TTL for agressive rescheduling if all services are not up 156 | ttl_short=1 157 | 158 | ###################################################################### 159 | # Other service specific knobs ... 160 | 161 | # use short TTL for agressive rescheduling if all services are not up 162 | # ttl_short=1 163 | 164 | # specify policy to use when assigning services 165 | # policy = [load-balance | round-robin | fixed] 166 | ###################################################################### 167 | """) 168 | 169 | contrail_collector_conf_template = string.Template(""" 170 | CASSANDRA_SERVER_LIST=$__contrail_cassandra_server_list__ 171 | REDIS_SERVER=$__contrail_redis_server__ 172 | REDIS_SERVER_PORT=$__contrail_redis_server_port__ 173 | DISCOVERY=$__contrail_discovery_ip__ 174 | HOST_IP=$__contrail_host_ip__ 175 | LISTEN_PORT=$__contrail_listen_port__ 176 | HTTP_SERVER_PORT=$__contrail_http_server_port__ 177 | LOG_FILE=$__contrail_log_file__ 178 | LOG_LOCAL=$__contrail_log_local__ 179 | LOG_LEVEL=$__contrail_log_level__ 180 | """) 181 | 182 | contrail_query_conf_template = string.Template(""" 183 | CASSANDRA_SERVER_LIST=$__contrail_cassandra_server_list__ 184 | REDIS_SERVER=$__contrail_redis_server__ 185 | REDIS_SERVER_PORT=$__contrail_redis_server_port__ 186 | DISCOVERY=$__contrail_discovery_ip__ 187 | HOST_IP=$__contrail_host_ip__ 188 | LISTEN_PORT=$__contrail_listen_port__ 189 | HTTP_SERVER_PORT=$__contrail_http_server_port__ 190 | LOG_FILE=$__contrail_log_file__ 191 | LOG_LOCAL=$__contrail_log_local__ 192 | LOG_LEVEL=$__contrail_log_level__ 193 | """) 194 | 195 | contrail_analytics_api_template = string.Template(""" 196 | REDIS_SERVER=$__contrail_redis_server__ 197 | REDIS_SERVER_PORT=$__contrail_redis_server_port__ 198 | REDIS_QUERY_PORT=$__contrail_redis_query_port__ 199 | COLLECTOR=$__contrail_collector__ 200 | COLLECTOR_PORT=$__contrail_collector_port__ 201 | HTTP_SERVER_PORT=$__contrail_http_server_port__ 202 | REST_API_PORT=$__contrail_rest_api_port__ 203 | LOG_FILE=$__contrail_log_file__ 204 | LOG_LOCAL=$__contrail_log_local__ 205 | LOG_LEVEL=$__contrail_log_level__ 206 | DISCOVERY=$__contrail_discovery_ip__ 207 | """) 208 | 209 | vnc_api_lib_ini_template = string.Template(""" 210 | [global] 211 | ;WEB_SERVER = 127.0.0.1 212 | ;WEB_PORT = 9696 ; connection through quantum plugin 213 | 214 | WEB_SERVER = 127.0.0.1 215 | WEB_PORT = 8082 ; connection to api-server directly 216 | BASE_URL = / 217 | ;BASE_URL = /tenants/infra ; common-prefix for all URLs 218 | 219 | ; Authentication settings (optional) 220 | [auth] 221 | AUTHN_TYPE = keystone 222 | AUTHN_SERVER=$__contrail_openstack_ip__ 223 | AUTHN_PORT = 35357 224 | AUTHN_URL = /v2.0/tokens 225 | """) 226 | 227 | agent_param_template = string.Template(""" 228 | LOG=/var/log/contrail.log 229 | CONFIG=/etc/contrail/agent.conf 230 | prog=/usr/bin/vnswad 231 | kmod=vrouter/vrouter.ko 232 | pname=vnswad 233 | LIBDIR=/usr/lib64 234 | VHOST_CFG=/etc/sysconfig/network-scripts/ifcfg-vhost0 235 | VROUTER_LOGFILE=--log-file=/var/log/vrouter.log 236 | COLLECTOR=$__contrail_collector__ 237 | $__contrail_dev__ 238 | """) 239 | 240 | agent_conf_template = string.Template(""" 241 | 242 | 243 | 244 | 245 | 246 | vhost0 247 | $__contrail_box_ip__ 248 | $__contrail_gateway__ 249 | 250 | 251 | $__contrail_intf__ 252 | 253 | 254 | $__contrail_box_ip__ 255 | 256 | 257 | $__contrail_control_ip__ 258 | 259 | 260 | 261 | """) 262 | 263 | agent_vgw_conf_template = string.Template(""" 264 | 265 | 266 | 267 | 268 | 269 | vhost0 270 | $__contrail_box_ip__ 271 | $__contrail_gateway__ 272 | 273 | 274 | $__contrail_intf__ 275 | 276 | 277 | $__contrail_control_ip__ 278 | 279 | 280 | $__contrail_control_ip__ 281 | 282 | 283 | $__contrail_vgw_interface__ 284 | $__contrail_vgw_public_subnet__ 285 | 286 | 287 | 288 | """) 289 | 290 | ifconfig_vhost0_template = string.Template(""" 291 | #Contrail vhost0 292 | DEVICE=vhost0 293 | ONBOOT=yes 294 | BOOTPROTO=none 295 | IPV6INIT=no 296 | USERCTL=yes 297 | IPADDR=$__contrail_ipaddr__ 298 | NETMASK=$__contrail_netmask__ 299 | NM_CONTROLLED=no 300 | #NETWORK MANAGER BUG WORKAROUND 301 | SUBCHANNELS=1,2,3 302 | $__contrail_gateway__ 303 | $__contrail_dns__ 304 | $__contrail_domain__ 305 | $__contrail_mtu__ 306 | """) 307 | 308 | contrail_plugin_template = string.Template(""" 309 | [APISERVER] 310 | api_server_ip=$__api_server_ip__ 311 | api_server_port=$__api_server_port__ 312 | multi_tenancy=$__multitenancy__ 313 | 314 | [KEYSTONE] 315 | admin_user=$__contrail_admin_user__ 316 | admin_password=$__contrail_admin_password__ 317 | admin_tenant_name=$__contrail_admin_tenant_name__ 318 | """) 319 | 320 | openstackrc_template = string.Template(""" 321 | export OS_USERNAME=$__contrail_admin_user__ 322 | export OS_PASSWORD=$__contrail_admin_password__ 323 | export OS_TENANT_NAME=$__contrail_admin_tenant_name__ 324 | export OS_AUTH_URL=http://$__contrail_keystone_ip__:5000/v2.0/ 325 | export OS_NO_CACHE=1 326 | """) 327 | 328 | -------------------------------------------------------------------------------- /utilities/task.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################################################### 3 | # 4 | # This script can be used for auto build or CI to perform opencontrail and devstack single node installation. 5 | # Sanity Report will be generated after the installation 6 | # 7 | # Date:25-sep-2014 8 | # 9 | ############################################################################################################### 10 | 11 | CLONE_DIR=${CLONE_DIR:-`pwd`} 12 | ENABLE_BINARY=${ENABLE_BINARY:-False} 13 | LAUNCHPAD_BRANCH=${LAUNCHPAD_BRANCH:-snapshots} 14 | WITH_CONTRAIL_CLONE=${WITH_CONTRAIL_CLONE:-True} 15 | ENABLE_CI=${ENABLE_CI:-False} 16 | DEVSTACK_CLONE_URL=${DEVSTACK_CLONE_URL:-"https://github.com/openstack-dev/devstack.git"} 17 | DEVSTACK_CLONE_BRANCH=${DEVSTACK_CLONE_BRANCH:-"stable/juno"} 18 | RECLONE=${RECLONE:-False} 19 | #run_sanity=${run_sanity:-False} 20 | RUN_SANITY=${RUN_SANITY:-False} 21 | NETWORK_NAME=${NETWORK_NAME:-net} 22 | SUBNET_NAME=${SUBNET_NAME:-subnet} 23 | SUBNET_CIDR=${SUBNET_CIDR:-11.0.0.0/24} 24 | TENANT_NAME=${TENANT_NAME:-demo} 25 | 26 | # error codes 27 | _RETURN_STATUS=0 28 | CLONE_ERR_CODE=500 29 | BUILD_ERR_CODE=100 30 | INSTALL_ERR_CODE=200 31 | START_ERR_CODE=300 32 | STACK_ERR_CODE=400 33 | KEYBOARD_INTERUPT=700 34 | 35 | 36 | 37 | function set_environment() 38 | { 39 | if [[ "$WITH_CONTRAIL_CLONE" = "False" ]]; then 40 | CONTRAIL_CLONE_DIR=`pwd` 41 | CONTRAIL_DIR=$CONTRAIL_CLONE_DIR/../../contrail-installer 42 | DEVSTACK_CLONE_DIR=$CONTRAIL_DIR/.. 43 | DEVSTACK_DIR=$DEVSTACK_CLONE_DIR/devstack 44 | else 45 | CONTRAIL_CLONE_DIR=$CLONE_DIR 46 | CONTRAIL_DIR=$CLONE_DIR/contrail-installer 47 | DEVSTACK_CLONE_DIR=$CLONE_DIR 48 | DEVSTACK_DIR=$DEVSTACK_CLONE_DIR/devstack 49 | fi 50 | } 51 | 52 | function replace_localrc_bin_master() 53 | { 54 | if [[ ! -f localrc ]]; then 55 | cp samples/localrc-all ./localrc 56 | #sed -i "s/.*SERVICE_HOST=localhost.*/SERVICE_HOST=$IP/" ./localrc 57 | sed -i "s/.*# CONTRAIL_REPO_PROTO=https.*/CONTRAIL_REPO_PROTO=https/" ./localrc 58 | sed -i "s/.*CONTRAIL_DEFAULT_INSTALL=False.*/CONTRAIL_DEFAULT_INSTALL=True/" ./localrc 59 | sed -i "s/.*LAUNCHPAD_BRANCH=.*/LAUNCHPAD_BRANCH=$LAUNCHPAD_BRANCH/" ./localrc 60 | echo "USE_SCREENS=True" >> ./localrc 61 | fi 62 | } 63 | 64 | function replace_localrc_source_master() 65 | { 66 | if [[ ! -f localrc ]]; then 67 | cp samples/localrc-all ./localrc 68 | #sed -i "s/.*SERVICE_HOST=localhost.*/SERVICE_HOST=$IP/" ./localrc 69 | sed -i "s/.*# CONTRAIL_REPO_PROTO=https.*/CONTRAIL_REPO_PROTO=https/" ./localrc 70 | sed -i "s/.*CONTRAIL_DEFAULT_INSTALL=True.*/CONTRAIL_DEFAULT_INSTALL=False/" ./localrc 71 | echo "USE_SCREENS=True" >> ./localrc 72 | fi 73 | } 74 | 75 | function set_localrc() 76 | { 77 | if [[ -f localrc ]]; then 78 | rm localrc 79 | fi 80 | if [[ "$ENABLE_BINARY" = "True" ]]; then 81 | replace_localrc_bin_master 82 | else 83 | replace_localrc_source_master 84 | fi 85 | } 86 | 87 | function value_check() 88 | { 89 | value=$1 90 | if [[ $value == 0 ]]; then 91 | echo "1" 92 | fi 93 | echo "0" 94 | 95 | } 96 | function check_start_status() 97 | { 98 | source $CONTRAIL_DIR/taskrc 99 | if [[ -d $CONTRAIL_DIR/status/contrail ]] ; then 100 | enabled_services_count=$NUM_ENABLED_SERVICES 101 | pid_count=`ls $CONTRAIL_DIR/status/contrail/*.pid|wc -l` 102 | if [[ $pid_count -le $enabled_services_count ]]; then 103 | echo 1 104 | else 105 | echo 0 106 | fi 107 | else 108 | echo 1 109 | fi 110 | } 111 | 112 | function run_command() 113 | { 114 | _command=$1 115 | cd $CONTRAIL_DIR 116 | if [[ "$_command" = "start" ]]; then 117 | ./contrail.sh stop 118 | if [[ -f $DEVSTACK_DIR/unstack.sh ]] ; then 119 | dir=`pwd` 120 | cd $DEVSTACK_DIR 121 | ./unstack.sh 122 | cd $dir 123 | fi 124 | 125 | fi 126 | 127 | ./contrail.sh $_command 128 | 129 | } 130 | 131 | function get_management_ip() 132 | { 133 | interface=$1 134 | management_ip=$(ifconfig $interface|grep -e addr| awk 'BEGIN{FS=OFS="net addr"}{print $2}'|awk '{print $1}'|awk 'BEGIN{FS=OFS=":"}{print $2}') 135 | echo $management_ip 136 | 137 | } 138 | 139 | 140 | function status_return() 141 | { 142 | _status=$1 143 | _new_status=$2 144 | if [[ $_status -eq 0 ]] ; then 145 | echo $_status 146 | else 147 | echo $_new_status 148 | fi 149 | 150 | } 151 | 152 | function get_running_status() 153 | { 154 | status=$(cat $CONTRAIL_DIR/.stage.txt) 155 | echo "$status" 156 | } 157 | 158 | function ENABLE_CI_changes() 159 | { 160 | sed -i "s/\(^[' '\t]*\)\(repo_initialize.*\)/\1#\2/g" $CONTRAIL_DIR/contrail.sh 161 | sed -i "s/\(^[' '\t]*\)\(repo sync.*\)/\1#\2/g" $CONTRAIL_DIR/contrail.sh 162 | echo "CONTRAIL_SRC=$CONTRAIL_SRC" >> $CONTRAIL_DIR/localrc 163 | } 164 | 165 | function clone_contrail() 166 | { 167 | 168 | if [[ ! -d contrail-installer ]]; then 169 | if [[ -z $CONTRAIL_INSTALLER_BRANCH ]]; then 170 | git clone https://github.com/Juniper/contrail-installer 171 | else 172 | git clone -b $CONTRAIL_INSTALLER_BRANCH https://github.com/Juniper/contrail-installer 173 | fi 174 | fi 175 | _status=$? 176 | _RETURN_STATUS=$(status_return $_status $CLONE_ERR_CODE) 177 | 178 | } 179 | 180 | function add_gateway() 181 | { 182 | localrc_file=$CONTRAIL_DIR/localrc 183 | sudo grep -q ^"CONTRAIL_VGW_INTERFACE" $localrc_file 184 | value=$? 185 | if [[ $value -eq 1 ]]; then 186 | 187 | echo "CONTRAIL_VGW_INTERFACE=vgw" >> $localrc_file 188 | echo "CONTRAIL_VGW_PUBLIC_SUBNET=$SUBNET_CIDR" >> $localrc_file 189 | echo "CONTRAIL_VGW_PUBLIC_NETWORK=default-domain:$TENANT_NAME:$NETWORK_NAME:$NETWORK_NAME" >> $localrc_file 190 | else 191 | : 192 | fi 193 | } 194 | 195 | function start_contrail() 196 | { if [[ "$WITH_CONTRAIL_CLONE" = "True" ]]; then 197 | clone_contrail 198 | fi 199 | if [[ -d $CONTRAIL_DIR ]] ; then 200 | cd $CONTRAIL_DIR 201 | set_localrc 202 | 203 | if [[ "$ENABLE_CI" = "True" ]]; then 204 | ENABLE_CI_changes 205 | fi 206 | 207 | if [[ -f $CONTRAIL_DIR/.stage.txt ]]; then 208 | 209 | running_status=$(get_running_status) 210 | if [[ "$running_status" = "Build" ]]; then 211 | run_command install 212 | _status=$? 213 | _RETURN_STATUS=$(status_return $_status $INSTALL_ERR_CODE) 214 | elif [[ "$running_status" = "install" ]]; then 215 | : 216 | else 217 | run_command build 218 | _status=$? 219 | _RETURN_STATUS=$(status_return $_status $BUILD_ERR_CODE) 220 | running_status=$(get_running_status) 221 | if [[ "$running_status" = "Build" ]]; then 222 | run_command install 223 | _status=$? 224 | _RETURN_STATUS=$(status_return $_status $INSTALL_ERR_CODE) 225 | fi 226 | fi 227 | 228 | else 229 | run_command build 230 | _status=$? 231 | _RETURN_STATUS=$(status_return $_status $BUILD_ERR_CODE) 232 | 233 | sleep 5 234 | 235 | echo "sleeping for 5 seconds to start install..." 236 | running_status=$(get_running_status) 237 | if [[ "$running_status" = "Build" ]]; then 238 | run_command install 239 | _status=$? 240 | _RETURN_STATUS=$(status_return $_status $INSTALL_ERR_CODE) 241 | else 242 | echo "Contrail stoped in the build phase please check the issue" 243 | fi 244 | fi 245 | sleep 5 246 | 247 | echo "sleeping for 5 seconds to start configure..." 248 | 249 | running_status=$(get_running_status) 250 | if [[ "$running_status" = "install" ]]; then 251 | 252 | add_gateway 253 | run_command configure 254 | sleep 5 255 | 256 | echo "sleeping for 5 seconds to start contrail services..." 257 | 258 | run_command start 259 | _status=$(check_start_status) 260 | _RETURN_STATUS=$(status_return $_status $START_ERR_CODE) 261 | sleep 5 262 | fi 263 | else 264 | echo "contrail installation stoped" 265 | fi 266 | 267 | } 268 | 269 | function unset_creds() 270 | { 271 | unset https_proxy 272 | unset http_proxy 273 | unset ftp_proxy 274 | unset socks_proxy 275 | unset no_proxy 276 | } 277 | 278 | function start_script() 279 | { 280 | configuration_file=$1 281 | #cat $configuration_file 282 | 283 | ARGS_COUNT=$# 284 | #echo $ARGS_COUNT 285 | if [[ $ARGS_COUNT -le 1 ]] ; then 286 | #echo "entered" 287 | if [[ "$configuration_file" = "usage" ]] || [[ "$configuration_file" = "--help" ]] || [[ "$configuration_file" = "--h" ]]; then 288 | echo " " 289 | echo "Usage: ./task.sh [auto.conf]" 290 | echo "ex: task.sh auto.conf" 291 | echo " " 292 | echo "auto.conf parameters:" 293 | echo "----------------------" 294 | echo "CONTRAIL_INSTALLER_BRANCH : if any specfic branch is to be cloned" 295 | echo "ENABLE_BINARY : set this value to True or False" 296 | echo "LAUNCHPAD_BRANCH : set this value to PPA release if ENABLE_BINARY is True" 297 | echo "DEVSTACK_CLONE_BRANCH : devstack branch to be cloned" 298 | echo "ENABLE_CI : set this value to True or False" 299 | echo "CONTRAIL_SRC : contrail source directory" 300 | echo "NETWORK_NAME : name of the network to be created" 301 | echo "SUBNET_NAME : name of the subnet to be created" 302 | echo "SUBNET_CIDR : subnet CIDR address " 303 | echo "TENANT_NAME : name of the tenant " 304 | 305 | echo " " 306 | exit 307 | 308 | fi 309 | if [[ -f $configuration_file ]]; then 310 | #echo "entered into file" 311 | source $configuration_file 312 | set_environment 313 | #echo $WITH_CONTRAIL_CLONE 314 | start_contrail 315 | start_status=$(check_start_status) 316 | if [[ $start_status -eq 0 ]]; then 317 | start_devstack 318 | else 319 | echo "contrail services are not up and running..please check the services" 320 | fi 321 | 322 | else 323 | if [[ $ARGS_COUNT -eq 0 ]] ; then 324 | echo "continuing with the default parameters" 325 | start_contrail 326 | start_status=$(check_start_status) 327 | if [[ $start_status -eq 0 ]]; then 328 | start_devstack 329 | else 330 | echo "contrail services are not up and running..please check the services" 331 | fi 332 | else 333 | echo " " 334 | echo "SCRIPT ERROR:: Invalid option please try ./task.sh usage (or) ./task.sh --help (or) ./task.sh --h" 335 | echo " " 336 | exit 337 | fi 338 | 339 | fi 340 | 341 | 342 | 343 | else 344 | echo "Usage: ./task.sh [auto.conf]" 345 | echo "ex: task.sh auto.conf" 346 | echo " " 347 | echo "auto.conf parameters:" 348 | echo "----------------------" 349 | 350 | echo "CONTRAIL_INSTALLER_BRANCH : if any specfic branch is to be cloned" 351 | echo "ENABLE_BINARY : set this value to True or False" 352 | echo "DEVSTACK_CLONE_BRANCH : devstack branch to be cloned" 353 | echo "ENABLE_CI : set this value to True or False" 354 | echo "CONTRAIL_SRC : contrail source directory" 355 | echo "NETWORK_NAME : name of the network to be created" 356 | echo "SUBNET_NAME : name of the subnet to be created" 357 | echo "SUBNET_CIDR : subnet CIDR address " 358 | echo "TENANT_NAME : name of the tenant " 359 | 360 | echo "-----------------------" 361 | fi 362 | } 363 | 364 | function start_devstack() 365 | { 366 | cd $CONTRAIL_DIR 367 | if [[ "$RECLONE" == "True" ]]; then 368 | echo "Removing the current devstack and recloning again" 369 | sudo rm -r $DEVSTACK_DIR 370 | fi 371 | if [[ -d $DEVSTACK_DIR ]]; then 372 | echo "devstack is already cloned using that devstack to work" 373 | else 374 | if [[ $DEVSTACK_CLONE_BRANCH ]];then 375 | echo "cloning the branch $DEVSTACK_CLONE_BRANCH" 376 | CLONE_BRANCH="-b $DEVSTACK_CLONE_BRANCH" 377 | fi 378 | cd $DEVSTACK_CLONE_DIR 379 | git clone $CLONE_BRANCH $DEVSTACK_CLONE_URL 380 | _status=$? 381 | _RETURN_STATUS=$(status_return $_status $CLONE_ERR_CODE) 382 | fi 383 | cd $CONTRAIL_DIR 384 | #checks if there is devstack folder cloned or not 385 | if [[ -d $DEVSTACK_DIR ]] ; then 386 | 387 | if [[ -f $DEVSTACK_DIR/lib/neutron_thirdparty/opencontrail ]]; then 388 | echo "file already exist" 389 | else 390 | cp $CONTRAIL_DIR/devstack/lib/neutron_plugins/opencontrail $DEVSTACK_DIR/lib/neutron_plugins/ 391 | fi 392 | cd $CONTRAIL_DIR 393 | 394 | if [[ -f $DEVSTACK_DIR/localrc ]]; then 395 | echo "localrc is already new" 396 | else 397 | cp $CONTRAIL_DIR/devstack/samples/localrc-all $DEVSTACK_DIR/localrc 398 | fi 399 | cd $DEVSTACK_DIR 400 | if [[ "$ENABLE_BINARY" = "False" ]]; then 401 | sed -i "s/.*Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2.*/#Q_PLUGIN_CLASS=neutron_plugin_contrail.plugins.opencontrail.contrail_plugin_core.NeutronPluginContrailCoreV2/" ./localrc 402 | fi 403 | HOST_IP=$(get_management_ip vhost0) 404 | echo "HOST_IP=$HOST_IP" >> ./localrc 405 | echo "enable_service h-eng h-api h-api-cfn h-api-cw" >> ./localrc 406 | #./unstack.sh 407 | ./stack.sh 408 | _stack_status=$? 409 | if [[ "$WITH_CONTRAIL_CLONE" = "False" ]] ; then 410 | cd $CONTRAIL_DIR/utilities 411 | else 412 | cd $CLONE_DIR 413 | fi 414 | 415 | if [[ "$RUN_SANITY" == "True" ]]; then 416 | source sanity.sh 417 | start_sanity_script 418 | 419 | _RETURN_STATUS=$(status_return $_stack_status $STACK_ERR_CODE) 420 | fi 421 | fi 422 | } 423 | 424 | start_script $@ 425 | echo "exit code:"$_RETURN_STATUS 426 | exit $_RETURN_STATUS 427 | 428 | trap clean SIGINT 429 | clean() { 430 | 431 | local r=$KEYBOARD_INTERUPT 432 | exit $r 433 | } 434 | 435 | -------------------------------------------------------------------------------- /utilities/sanity.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # test_network_simple.sh 4 | # 5 | # Set up a couple of test VMs on two networks on a single 6 | # node setup 7 | # 8 | # uses localrc-single 9 | # 10 | 11 | 12 | CLONE_DIR=${CLONE_DIR:-`pwd`} 13 | WITH_CONTRAIL_CLONE=${WITH_CONTRAIL_CLONE:-True} 14 | NETWORK_NAME=${NETWORK_NAME:-net} 15 | SUBNET_NAME=${SUBNET_NAME:-subnet} 16 | SUBNET_CIDR=${SUBNET_CIDR:-11.0.0.0/24} 17 | TENANT_NAME=${TENANT_NAME:-demo} 18 | VM1_IP=${VM1_IP:-11.0.0.3} 19 | VM2_IP=${VM2_IP:-11.0.0.4} 20 | VM_USER=${VM_USER:-cirros} 21 | VM_PASSWORD=${VM_PASSWORD:-cubswin:)} 22 | #CLONE_DIR=`pwd` 23 | _CONTRAIL_NEUTRON_SERVICES=("apiSrv" "schema" "svc-mon") 24 | #source $DEVSTACK_DIR/openrc $TENANT_NAME $TENANT_NAME 25 | 26 | echo "$CONTRAIL_DIR" 27 | if [[ -f $DEVSTACK_DIR/openrc ]] ; then 28 | source $DEVSTACK_DIR/openrc $TENANT_NAME $TENANT_NAME 29 | else 30 | echo "Invalid devstack directory please set DEVSTACK_DIR and try again" 31 | fi 32 | #report generation variables 33 | test_cases=("ServiceStatus" "ServiceRequest" "NeutronRequest" "VmCreation" "SimpleGateway" "PingBeweenVms") 34 | 35 | status_flags=("NOTEXECUTED" "NOTEXECUTED" "NOTEXECUTED" "NOTEXECUTED" "NOTEXECUTED" "NOTEXECUTED") 36 | 37 | log_file_name=("Opencontrail_services_status" "Opencontrail_services_response" "Opencontrail_neutron_requests" "Opencontrail_vm_communication_status" "Opencontrail_simplegateway_status" "Opencontrail_vm_communication" ) 38 | 39 | function security_group_rules() 40 | { 41 | # allow ping and ssh 42 | nova secgroup-list 43 | if ! nova secgroup-list-rules default | grep tcp | grep 22; then 44 | nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 45 | fi 46 | if ! nova secgroup-list-rules default | grep icmp | grep "\-1"; then 47 | nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 48 | fi 49 | nova secgroup-list-rules default 50 | } 51 | 52 | function network_creation(){ 53 | 54 | net=$1 55 | subnet=$net-$2 56 | subnet_cidr=$3 57 | report_file=$CLONE_DIR/sanity_status/Opencontrail_neutron_requests 58 | if [[ -f $report_file ]]; then 59 | rm $report_file 60 | fi 61 | touch $report_file 62 | eval $(neutron net-create -f shell -c id net | sed -ne '/^id=/p') 63 | net_id=$id 64 | #echo "net_id=$net_id" >> $report_file 65 | if [[ $net_id ]]; then 66 | echo "--------------------------------------" >> $report_file 67 | echo "network created successfully net_id=$net_id " >> $report_file 68 | echo "---------------------------------------" >> $report_file 69 | subnet_args="$subnet $net $subnet_cidr" 70 | echo $subnet_args 71 | subnet_request=$(subnet_creation $subnet_args) 72 | echo "$subnet_request" >> $report_file 73 | 74 | fi 75 | } 76 | 77 | function subnet_creation() 78 | { 79 | subnet_args=$@ 80 | echo $subnet_args 81 | neutron subnet-create --name $subnet_args 82 | } 83 | 84 | function get_branch() 85 | { 86 | path=$1 87 | if [[ -d $path ]] ; then 88 | cd $path 89 | branch=$(git status|grep "On branch"|awk '{print $4}') 90 | echo $branch 91 | fi 92 | 93 | } 94 | 95 | function get_platform() 96 | { 97 | platform=$(lsb_release -a |grep "Description" | awk '{print $2,$3,$4}') 98 | echo $platform 99 | 100 | } 101 | 102 | function network_delete() 103 | { 104 | network=$1 105 | list=(`neutron net-list|grep "$network"|awk '{print $2}'`) 106 | for net in ${list[@]} 107 | do 108 | neutron net-delete $net 109 | done 110 | } 111 | 112 | function network_list() 113 | { 114 | network=$1 115 | neutron net-list | grep -i "$network" 116 | #status=$? 117 | network_creation_request=$? 118 | #echo $status 119 | } 120 | 121 | function check_network() 122 | { 123 | network=$1 124 | network_list $network 125 | #status=$? 126 | #echo $status 127 | } 128 | 129 | function generate_keys() 130 | { 131 | yes | ssh-keygen -N "" -f sshkey 132 | keypairs=$(nova keypair-add --pub-key sshkey.pub sshkey) 133 | echo "$keypairs" >> $report_file 134 | } 135 | 136 | function launch_vm(){ 137 | vm_name=$1 138 | report_file=$2 139 | image=cirros-0.3.4-x86_64-uec 140 | flavor=m1.nano 141 | vmargs="--image $image --flavor $flavor --key-name sshkey" 142 | 143 | nova boot $vmargs --nic net-id=$net_id $vm_name >> $report_file 144 | } 145 | 146 | function check_vm_status() 147 | { 148 | vm_name_index=3 149 | report_file=$1 150 | vm_status_index=$(($vm_name_index+1)) 151 | vm_network_index=$(($vm_network_index+1)) 152 | vm_ip=(`nova list --fields name,status,networks|awk '{print $4,$6,$8}'`) 153 | while [[ $vm_name_index -le ${#vm_ip[@]} ]] 154 | do 155 | vm_name=${vm_ip[$vm_name_index]} 156 | vm_name_index=$((vm_name_index+1)) 157 | vm_status=${vm_ip[$vm_name_index]} 158 | vm_name_index=$((vm_name_index+1)) 159 | vm_network_ip=${vm_ip[$vm_name_index]} 160 | vm_name_index=$((vm_name_index+1)) 161 | if [[ $vm_name ]] || [[ $vm_status ]] || [[ $vm_network_ip ]]; then 162 | echo "----------------------------------------" >> $report_file 163 | echo " VM DETAILS" >> $report_file 164 | echo "----------------------------------------" >> $report_file 165 | echo "vm name:$vm_name" >> $report_file 166 | echo "vm status:$vm_status" >> $report_file 167 | echo "vm network:$vm_network_ip" >> $report_file 168 | 169 | if [[ "$vm_status" = "ACTIVE" ]] ; then 170 | echo "TESTCASE : VMCREATION $vm_name -- PASSED" 171 | status_flags[3]="PASSED" 172 | else 173 | echo "TESTCASE : VMCREATION $vm_name -- FAILED" 174 | status_flags[3]="FAILED" 175 | fi 176 | fi 177 | 178 | done 179 | echo ${vm_ip[@]} 180 | } 181 | 182 | function check_service_stop() 183 | { 184 | _array="${!1}" 185 | return_status="start" 186 | report_file=$CLONE_DIR/sanity_status/Opencontrail_services_status 187 | for service in $_array[@] 188 | do 189 | status=(`grep -e "$service" $report_file |awk '{print $3}'`) 190 | 191 | if [[ "$status" = "ERROR" ]]; then 192 | return_status="stop" 193 | fi 194 | done 195 | echo "$return_status" 196 | } 197 | 198 | function start_sanity_script() 199 | { 200 | mkdir -p $CLONE_DIR/sanity_status 201 | 202 | contrail_service_running_report 203 | status=$(check_service_stop $_CONTRAIL_NEUTRON_SERVICES) 204 | echo "$status" 205 | if [[ "$status" = "start" ]]; then 206 | services_respose 207 | network_creation $NETWORK_NAME $SUBNET_NAME $SUBNET_CIDR 208 | check_network $net 209 | echo "RETURN STATUS::"$network_creation_request 210 | if [[ $network_creation_request -eq 0 ]] ; then 211 | status_flags[2]="PASSED" 212 | report_file=$CLONE_DIR/sanity_status/Opencontrail_vm_communication_status 213 | if [[ -f $report_file ]] ; then 214 | rm $report_file 215 | fi 216 | 217 | generate_keys 218 | launch_vm vm1 $report_file 219 | launch_vm vm2 $report_file 220 | sleep 30 221 | check_vm_status $report_file 222 | 223 | sudo iptables --flush 224 | sleep 15 225 | simplegateway_report_file=$CLONE_DIR/sanity_status/Opencontrail_simplegateway_status 226 | if [[ -f $simplegateway_report_file ]] ; then 227 | rm $simplegateway_report_file 228 | fi 229 | 230 | ping -c 3 $VM1_IP >> $simplegateway_report_file 231 | vm1_status=$? 232 | ping -c 3 $VM2_IP >> $simplegateway_report_file 233 | vm2_status=$? 234 | if [[ $vm1_status -eq 0 ]] && [[ $vm2_status -eq 0 ]] ; then 235 | status_flags[4]="PASSED" 236 | ping_vms $VM1_IP $VM2_IP 237 | 238 | else 239 | echo "TESTCASE : SIMPLE GATEWAY -- FAILED " 240 | status_flags[4]="FAILED" 241 | fi 242 | 243 | else 244 | echo "TESTCASE : NETWORK CREATION -- FAILED" 245 | status_flags[2]="FAILED" 246 | fi 247 | 248 | else 249 | echo "CONTRAIL SERVICE ${_CONTRAIL_NEUTRON_SERVICES[@]} are not running please check the status" >> $CLONE_DIR/sanity_status/final_sanity_report 250 | status 251 | fi 252 | final_sanity_script 253 | } 254 | 255 | function check_array_value() 256 | { 257 | _array="${!1}" 258 | #echo "$_array" 259 | _value=$2 260 | status="not found" 261 | for value in ${_array[@]} 262 | do 263 | service_name=$(echo "$value" | awk 'BEGIN {FS=OFS="."}{print $1}') 264 | 265 | if [[ "$service_name" = "$_value" ]] ; then 266 | status="found" 267 | fi 268 | done 269 | echo $status 270 | } 271 | 272 | function contrail_service_running_report() 273 | { 274 | report_file=$CLONE_DIR/sanity_status/Opencontrail_services_status 275 | report_error_file=$CLONE_DIR/sanity_status/Opencontrail_services_errors 276 | 277 | if [[ -f $report_file ]]; then 278 | rm $report_file 279 | 280 | fi 281 | touch $report_file 282 | touch $report_error_file 283 | if [[ -d $CONTRAIL_DIR/status/contrail ]]; then 284 | cd $CONTRAIL_DIR/status/contrail/ 285 | services=(`ls *.pid`) 286 | failures=(`ls *.failure`) 287 | line="----------------------------------------------------------------" 288 | space=" " 289 | 290 | for service in ${services[@]} 291 | do 292 | 293 | service_name=$(echo "$service" | awk 'BEGIN {FS=OFS="."}{print $1}') 294 | _status=$(check_array_value failures[@] $service_name) 295 | if [[ "$_status" = "found" ]] ; then 296 | echo "$line" >> $report_error_file 297 | printf '%-20s : ERROR\n' $service_name >> $report_file 298 | printf '%-20s : ERROR\n' $service_name >> $report_error_file 299 | echo "$line" >> $report_error_file 300 | echo "ERROR : `tail -n 50 $CONTRAIL_DIR/log/screens/screen-$service_name.log`" >> $report_error_file 301 | echo "$line" >> $report_error_file 302 | 303 | else 304 | printf '%-20s : ACTIVE\n' $service_name >> $report_file 305 | fi 306 | done 307 | cat $report_error_file >> $report_file 308 | rm $report_error_file 309 | #echo $errors 310 | fi 311 | status_flags[0]="PASSED" 312 | } 313 | 314 | function services_respose() 315 | { 316 | report_file=$CLONE_DIR/sanity_status/Opencontrail_services_response 317 | line="----------------------------------------------------------------" 318 | space=" " 319 | if [[ -f $report_file ]]; then 320 | rm $report_file 321 | fi 322 | touch $report_file 323 | if [[ -d $CONTRAIL_DIR/status/contrail ]]; then 324 | cd $CONTRAIL_DIR/status/contrail/ 325 | services=(`ls *.pid`) 326 | fi 327 | curl -H "GET" "http://localhost:8082/domains" 328 | #curl -H "GET" http://localhost:8082/instance-ips 329 | 330 | if [[ $? -eq 0 ]] ; then 331 | status_flags[1]="PASSED" 332 | else 333 | status_flags[1]="FAILED" 334 | fi 335 | for service in ${services[@]} 336 | do 337 | service_name=$(echo "$service" | awk 'BEGIN {FS=OFS="."}{print $1}') 338 | if [[ -f $CONTRAIL_DIR/log/screens/screen-$service_name.log ]]; then 339 | echo "$line" >> $report_file 340 | echo "service : $service_name " >> $report_file 341 | echo "$line" >> $report_file 342 | 343 | echo "Start : `tail -n 50 $CONTRAIL_DIR/log/screens/screen-$service_name.log`" >> $report_file 344 | echo "$line" >> $report_file 345 | fi 346 | done 347 | 348 | } 349 | 350 | function get_contail_installation() 351 | { 352 | grep_variable=$1 353 | filename=$2 354 | return_value="False" 355 | if [[ -f $filename ]]; then 356 | return_value=$(grep "$grep_variable" $filename |awk 'BEGIN{FS=OFS="="}{print $2}') 357 | fi 358 | if [[ "$return_value" = "True" ]] ; then 359 | echo "Binary installation" 360 | else 361 | echo "Source installation" 362 | fi 363 | } 364 | 365 | function final_sanity_script() 366 | { 367 | cd $CLONE_DIR/sanity_status 368 | final_report_file=./final_report_file 369 | if [[ -f $final_report_file ]] ; then 370 | rm $final_report_file 371 | fi 372 | file_name=$CLONE_DIR/.report.txt 373 | touch $final_report_file 374 | index=0 375 | platform=$(get_platform) 376 | devstack_branch=$(get_branch $DEVSTACK_DIR) 377 | contrail_branch=$(get_branch $CONTRAIL_DIR) 378 | report_generation_date=$(date | awk '{print $1,$3,$2,$6}') 379 | report_generation_time=$(date | awk '{print $4,$5 }') 380 | contrail_installation_type=$(get_contail_installation "CONTRAIL_DEFAULT_INSTALL=True" $CONTRAIL_DIR/localrc) 381 | echo -e "----------------------------------------------------------------" >> $final_report_file 382 | echo -e "\t\t\tSANITY REPORT" >> $final_report_file 383 | echo -e "----------------------------------------------------------------" >> $final_report_file 384 | echo -e "PLATFORM\t\t:\t$platform" >> $final_report_file 385 | echo -e "CONTRAIL-INSTALLATION\t:\t$contrail_installation_type" >> $final_report_file 386 | echo -e "CONTRAIL-BRANCH\t\t:\t$contrail_branch" >> $final_report_file 387 | echo -e "DEVSTACK-BRANCH\t\t:\t$devstack_branch" >> $final_report_file 388 | echo -e "REPORT-DATE\t\t:\t$report_generation_date" >> $final_report_file 389 | echo -e "REPORT-TIME\t\t:\t$report_generation_time" >> $final_report_file 390 | echo -e "----------------------------------------------------------------" >> $final_report_file 391 | 392 | 393 | for test_case in ${test_cases[@]} 394 | do 395 | if [[ -f $CLONE_DIR/report_generation.py ]]; then 396 | if [[ "${status_flags[$index]}" = "PASSED" ]] || [[ "${status_flags[$index]}" = "NOTEXECUTED" ]] ; then 397 | python $CLONE_DIR/report_generation.py --testcase $test_case --status ${status_flags[$index]} --FILE $file_name finalreport 398 | else 399 | python $CLONE_DIR/report_generation.py --testcase $test_case --status ${status_flags[$index]} --log_path ${log_file_name[$index]} --FILE $file_name finalreport 400 | fi 401 | index=$((index+1)) 402 | fi 403 | done 404 | if [[ -f $CLONE_DIR/report_generation.py ]]; then 405 | python $CLONE_DIR/report_generation.py --FILE $file_name display >> $final_report_file 406 | rm $file_name 407 | fi 408 | echo -e "NOTE:\tSanity log reports placed under $CLONE_DIR/sanity_status/ " >> $final_report_file 409 | cat $final_report_file 410 | } 411 | 412 | function ping_vms() { 413 | sleep 20 414 | report_file=$CLONE_DIR/sanity_status/Opencontrail_vm_communication 415 | if [[ -f $report_file ]]; then 416 | rm $report_file 417 | fi 418 | touch $report_file 419 | source_ip=$1 420 | destination_ip=$2 421 | rm ~/.ssh/known_hosts 422 | expect -c " 423 | set timeout 1 424 | spawn ssh $VM_USER@$source_ip 425 | expect yes/no { send yes\r ; exp_continue } 426 | expect password: { send $VM_PASSWORD\r } 427 | expect $ { send exit \r } 428 | " 429 | sshpass -p $VM_PASSWORD ssh -x $VM_USER@$source_ip " ping -c 3 $destination_ip;echo $? " >> $report_file 430 | status=$? 431 | if [[ $status -eq 0 ]]; then 432 | status_flags[5]="PASSED" 433 | echo "TESTCASE PING FROM $source_ip TO $destination_ip : PASSED" >> $report_file 434 | else 435 | status_flags[5]="FAILED" 436 | echo "TESTCASE PING FROM $source_ip TO $destination_ip : FAILED" >> $report_file 437 | fi 438 | } 439 | -------------------------------------------------------------------------------- /contrail_config_functions: -------------------------------------------------------------------------------- 1 | # vim: syntax=sh 2 | 3 | source functions 4 | 5 | function replace_cassandra_conf() 6 | { 7 | if [ ! -z "$CASSANDRA_IP" ] 8 | then 9 | sudo sed -i -e 's/listen_address:.*/listen_address: '$CASSANDRA_IP'/' /etc/cassandra/cassandra.yaml 10 | sudo sed -i -e 's/rpc_address:.*/rpc_address: '$CASSANDRA_IP'/' /etc/cassandra/cassandra.yaml 11 | fi 12 | 13 | cassandra_server="" 14 | for ip in ${CASSANDRA_IP_LIST[@]}; 15 | do 16 | seeds=${seeds}""$ip"," 17 | done 18 | seeds=${seeds::-1} 19 | 20 | sudo sed -i -e 's/seeds:.*/seeds: "'$seeds'"/' /etc/cassandra/cassandra.yaml 21 | } 22 | 23 | function replace_kafka_conf() 24 | { 25 | file="/usr/share/kafka/config/server.properties" 26 | 27 | sudo sed -i 's/^#port=9092/port=9092/g' $file 28 | sudo sed -i 's/^#advertised.host.name=.*/advertised.host.name=127.0.0.1/g' $file 29 | sudo sed -i 's/^listeners=\(.*\)/#listeners=\1/g' $file 30 | } 31 | 32 | 33 | function replace_api_server_conf() 34 | { 35 | file="/etc/contrail/contrail-api.conf" 36 | 37 | cassandra_server="" 38 | for ip in ${CASSANDRA_IP_LIST[@]}; 39 | do 40 | cassandra_server=${cassandra_server}""$ip":9160 " 41 | done 42 | zookeeper_server="" 43 | for ip in ${ZOOKEEPER_IP_LIST[@]}; 44 | do 45 | zookeeper_server=${zookeeper_server}""$ip"," 46 | done 47 | zookeeper_server=${zookeeper_server::-1} 48 | port=0 49 | if $USE_CERTS ; then 50 | port=8444 51 | else 52 | port=8443 53 | fi 54 | check_replace_value $file DEFAULTS ifmap_server_ip $IFMAP_IP 55 | check_replace_value $file DEFAULTS ifmap_server_port $port 56 | check_replace_value $file DEFAULTS multi_tenancy $MULTI_TENANCY 57 | check_replace_value $file DEFAULTS cassandra_server_list $cassandra_server 58 | check_replace_value $file DEFAULTS zk_server_ip $zookeeper_server 59 | check_replace_value $file DEFAULTS zk_server_port 2181 60 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 61 | check_replace_value $file DEFAULTS ifmap_username 'api-server' 62 | check_replace_value $file DEFAULTS ifmap_password 'api-server' 63 | check_replace_value $file DEFAULTS listen_ip_addr '0.0.0.0' 64 | check_replace_value $file DEFAULTS listen_port 8082 65 | check_replace_value $file DEFAULTS log_file '/var/log/contrail/api.log' 66 | check_replace_value $file DEFAULTS disc_server_port 5998 67 | # check_replace_value $file DEFAULTS auth keystone 68 | check_replace_value $file DEFAULTS redis_server_port 6379 69 | fi 70 | 71 | check_replace_value $file SECURITY use_certs $USE_CERTS 72 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 73 | check_replace_value $file SECURITY keyfile '/etc/contrail/ssl/private_keys/apiserver_key.pem' 74 | check_replace_value $file SECURITY certfile '/etc/contrail/ssl/certs/apiserver.pem' 75 | check_replace_value $file SECURITY ca_certs '/etc/contrail/ssl/certs/ca.pem' 76 | fi 77 | check_replace_value $file KEYSTONE auth_host $OPENSTACK_IP 78 | check_replace_value $file KEYSTONE admin_user $CONTRAIL_ADMIN_USERNAME 79 | check_replace_value $file KEYSTONE admin_password $ADMIN_PASSWORD 80 | check_replace_value $file KEYSTONE admin_tenant_name $CONTRAIL_ADMIN_TENANT 81 | check_replace_value $file KEYSTONE auth_port 5000 82 | check_replace_value $file KEYSTONE auth_protocol http 83 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 84 | check_replace_value $file KEYSTONE memcache_servers '127.0.0.1:11211' 85 | fi 86 | } 87 | 88 | function check_replace_value() 89 | { 90 | file=$1 91 | section=$2 92 | key=$3 93 | value=$4 94 | if [[ -n "$value" ]]; then 95 | if [[ -n "$section" ]]; then 96 | iniset $file $section $key $value 97 | else 98 | iniset $file "DEFAULTS" $key $value 99 | fi 100 | fi 101 | } 102 | 103 | function replace_contrail_plugin_conf() 104 | { 105 | 106 | file="/etc/contrail/contrail_plugin.ini" 107 | temp_location="/etc/quantum/plugins/contrail/contrail_plugin.ini" 108 | check_replace_value $file APISERVER api_server_ip $CFGM_IP 109 | check_replace_value $file APISERVER multi_tenancy $MULTI_TENANCY 110 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 111 | check_replace_value $file APISERVER api_server_port 8082 112 | fi 113 | 114 | #un-comment if keystone ip present 115 | #check_replace_value $file APISERVER auth_url http://$KEYSTONE_IP:5000/v2.0 116 | #check_replace_value $file APISERVER admin_token $CONTRAIL_ADMIN_TOKEN 117 | 118 | check_replace_value $file KEYSTONE admin_user $CONTRAIL_ADMIN_USERNAME 119 | check_replace_value $file KEYSTONE admin_password $ADMIN_PASSWORD 120 | check_replace_value $file KEYSTONE admin_tenant_name $CONTRAIL_ADMIN_TENANT 121 | check_replace_value $file KEYSTONE auth_url http://$OPENSTACK_IP:5000/v2.0 122 | cp $file $temp_location 123 | } 124 | 125 | function replace_contrail_schema_conf() 126 | { 127 | 128 | file="/etc/contrail/contrail-schema.conf" 129 | 130 | cassandra_server="" 131 | for ip in ${CASSANDRA_IP_LIST[@]}; 132 | do 133 | cassandra_server=${cassandra_server}""$ip":9160 " 134 | done 135 | zookeeper_server="" 136 | for ip in ${ZOOKEEPER_IP_LIST[@]}; 137 | do 138 | zookeeper_server=${zookeeper_server}""$ip"," 139 | done 140 | zookeeper_server=${zookeeper_server::-1} 141 | port=0 142 | if $USE_CERTS ; then 143 | port=8444 144 | else 145 | port=8443 146 | fi 147 | check_replace_value $file DEFAULTS ifmap_server_ip $CFGM_IP 148 | check_replace_value $file DEFAULTS ifmap_server_port $port 149 | check_replace_value $file DEFAULTS api_server_ip $CFGM_IP 150 | check_replace_value $file DEFAULTS cassandra_server_list $cassandra_server 151 | check_replace_value $file DEFAULTS zk_server_ip $zookeeper_server 152 | check_replace_value $file DEFAULTS zk_server_port 2181 153 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 154 | check_replace_value $file DEFAULTS ifmap_username 'schema-transformer' 155 | check_replace_value $file DEFAULTS ifmap_password 'schema-transformer' 156 | check_replace_value $file DEFAULTS api_server_port 8082 157 | check_replace_value $file DEFAULTS log_file '/var/log/contrail/schema.log' 158 | check_replace_value $file DEFAULTS disc_server_port 5998 159 | fi 160 | check_replace_value $file SECURITY use_certs $USE_CERTS 161 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 162 | check_replace_value $file SECURITY ca_certs '/etc/contrail/ssl/certs/ca.pem' 163 | check_replace_value $file SECURITY certfile '/etc/contrail/ssl/certs/schema_xfer.pem' 164 | check_replace_value $file SECURITY keyfile '/etc/contrail/ssl/private_keys/schema_xfer_key.pem' 165 | fi 166 | check_replace_value $file KEYSTONE admin_user $CONTRAIL_ADMIN_USERNAME 167 | check_replace_value $file KEYSTONE admin_password $ADMIN_PASSWORD 168 | check_replace_value $file KEYSTONE admin_tenant_name $CONTRAIL_ADMIN_TENANT 169 | 170 | } 171 | 172 | function replace_svc_monitor_conf() 173 | { 174 | 175 | file="/etc/contrail/svc-monitor.conf" 176 | 177 | cassandra_server="" 178 | for ip in ${CASSANDRA_IP_LIST[@]}; 179 | do 180 | cassandra_server=${cassandra_server}""$ip":9160 " 181 | done 182 | zookeeper_server="" 183 | for ip in ${ZOOKEEPER_IP_LIST[@]}; 184 | do 185 | zookeeper_server=${zookeeper_server}""$ip"," 186 | done 187 | zookeeper_server=${zookeeper_server::-1} 188 | port=0 189 | if $USE_CERTS ; then 190 | port=8444 191 | else 192 | port=8443 193 | fi 194 | check_replace_value $file DEFAULTS ifmap_server_ip $CFGM_IP 195 | check_replace_value $file DEFAULTS ifmap_server_port $port 196 | check_replace_value $file DEFAULTS api_server_ip $CFGM_IP 197 | check_replace_value $file DEFAULTS cassandra_server_list $cassandra_server 198 | check_replace_value $file DEFAULTS zk_server_ip $zookeeper_server 199 | check_replace_value $file DEFAULTS zk_server_port 2181 200 | check_replace_value $file DEFAULTS ifmap_username 'svc_monitor' 201 | check_replace_value $file DEFAULTS ifmap_password 'svc_monitor' 202 | check_replace_value $file DEFAULTS rabbit_user $RABBIT_USER 203 | check_replace_value $file DEFAULTS rabbit_password $RABBIT_PASSWORD 204 | check_replace_value $file SECURITY ca_certs '/etc/contrail/ssl/certs/ca.pem' 205 | check_replace_value $file SECURITY certfile '/etc/contrail/ssl/certs/svc_monitor.pem' 206 | check_replace_value $file SECURITY keyfile '/etc/contrail/ssl/private_keys/svc_monitor_key.pem' 207 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 208 | check_replace_value $file DEFAULTS ifmap_username 'svc-monitor' 209 | check_replace_value $file DEFAULTS ifmap_password 'svc-monitor' 210 | check_replace_value $file DEFAULTS api_server_port 8082 211 | check_replace_value $file DEFAULTS log_file '/var/log/contrail/svc-monitor.log' 212 | fi 213 | 214 | check_replace_value $file SECURITY use_certs $USE_CERTS 215 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 216 | check_replace_value $file SECURITY ca_certs '/etc/contrail/ssl/certs/ca.pem' 217 | check_replace_value $file SECURITY certfile '/etc/contrail/ssl/certs/svc_monitor.pem' 218 | check_replace_value $file SECURITY keyfile '/etc/contrail/ssl/private_keys/svc_monitor_key.pem' 219 | fi 220 | check_replace_value $file KEYSTONE admin_user $CONTRAIL_ADMIN_USERNAME 221 | check_replace_value $file KEYSTONE admin_password $ADMIN_PASSWORD 222 | check_replace_value $file KEYSTONE admin_tenant_name $CONTRAIL_ADMIN_TENANT 223 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 224 | check_replace_value $file KEYSTONE memcache_servers '127.0.0.1:11211' 225 | fi 226 | } 227 | 228 | 229 | function replace_discovery_conf() 230 | { 231 | 232 | file="/etc/contrail/contrail-discovery.conf" 233 | 234 | cassandra_server="" 235 | for ip in ${CASSANDRA_IP_LIST[@]}; 236 | do 237 | cassandra_server=${cassandra_server}""$ip":9160 " 238 | done 239 | 240 | zookeeper_server="" 241 | for ip in ${ZOOKEEPER_IP_LIST[@]}; 242 | do 243 | zookeeper_server=${zookeeper_server}""$ip"," 244 | done 245 | zookeeper_server=${zookeeper_server::-1} 246 | check_replace_value $file DEFAULTS zk_server_ip $zookeeper_server 247 | 248 | check_replace_value $file DEFAULTS listen_ip_addr $CFGM_IP 249 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 250 | check_replace_value $file DEFAULTS zk_server_port 2181 251 | check_replace_value $file DEFAULTS listen_port 5998 252 | check_replace_value $file DEFAULTS log_local 'True' 253 | check_replace_value $file DEFAULTS log_file '/var/log/contrail/discovery.log' 254 | fi 255 | 256 | check_replace_value $file DEFAULTS cassandra_server_list $cassandra_server 257 | 258 | # minimim time to allow client to cache service information (seconds) 259 | #check_replace_value $file DEFAULTS ttl_min 300 260 | 261 | # maximum time to allow client to cache service information (seconds) 262 | #check_replace_value $file DEFAULTS ttl_max 1800 263 | 264 | # maximum hearbeats to miss before server will declare publisher out of 265 | # service. 266 | #check_replace_value $file DEFAULTS hc_max_miss 3 267 | 268 | # use short TTL for agressive rescheduling if all services are not up 269 | #check_replace_value $file DEFAULTS ttl_short 1 270 | 271 | ###################################################################### 272 | # Other service specific knobs ... 273 | 274 | # use short TTL for agressive rescheduling if all services are not up 275 | # ttl_short=1 276 | 277 | # specify policy to use when assigning services 278 | # policy = [load-balance | round-robin | fixed] 279 | ###################################################################### 280 | 281 | } 282 | 283 | function replace_vnc_api_lib_conf() 284 | { 285 | file="/etc/contrail/vnc_api_lib.ini" 286 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 287 | check_replace_value $file global WEB_SERVER '127.0.0.1' 288 | check_replace_value $file global WEB_PORT 8082 ; connection to api-server directly 289 | check_replace_value $file global BASE_URL '/' 290 | 291 | check_replace_value $file auth AUTHN_TYPE 'keystone' 292 | check_replace_value $file auth AUTHN_PORT 5000 293 | check_replace_value $file auth AUTHN_URL '/v2.0/tokens' 294 | fi 295 | check_replace_value $file auth AUTHN_SERVER $OPENSTACK_IP 296 | 297 | } 298 | 299 | 300 | function replace_ContrailPlugin_conf() 301 | { 302 | file="/etc/contrail/ContrailPlugin.ini" 303 | check_replace_value $file APISERVER api_server_ip $CFGM_IP 304 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 305 | check_replace_value $file APISERVER api_server_port 8082 306 | check_replace_value $file APISERVER multi_tenancy False 307 | fi 308 | 309 | check_replace_value $file KEYSTONE admin_user $CONTRAIL_ADMIN_USERNAME 310 | check_replace_value $file KEYSTONE admin_password $ADMIN_PASSWORD 311 | check_replace_value $file KEYSTONE admin_tenant_name $CONTRAIL_ADMIN_TENANT 312 | check_replace_value $file KEYSTONE admin_tenant_name $CONTRAIL_ADMIN_TENANT 313 | check_replace_value $file KEYSTONE auth_host $OPENSTACK_IP 314 | check_replace_value $file KEYSTONE auth_url http://$OPENSTACK_IP:5000/v2.0 315 | } 316 | 317 | function replace_contrail_control_conf() 318 | { 319 | file="/etc/contrail/contrail-control.conf" 320 | 321 | port=0 322 | CERT_OPTS="" 323 | 324 | rabbitmq_server="" 325 | for ip in ${RABBITMQ_IP_LIST[@]}; 326 | do 327 | rabbitmq_server=${rabbitmq_server}""$ip":5672 " 328 | done 329 | 330 | if [[ -n $PUPPET_SERVER ]]; then 331 | CERTDIR='/var/lib/puppet/ssl' 332 | else 333 | CERTDIR='/etc/contrail/ssl' 334 | fi 335 | 336 | if $USE_CERTS ; then 337 | port=8444 338 | CERT_OPTS="--use-certs=$CERTDIR" 339 | else 340 | port=8443 341 | fi 342 | if [[ $CONTROL_IP = "localhost" ]]; then 343 | CONTROL_IP="127.0.0.1" 344 | fi 345 | if [[ $COLLECTOR_IP = "localhost" ]]; then 346 | COLLECTOR_IP="127.0.0.1" 347 | fi 348 | 349 | cassandra_server="" 350 | for ip in ${CASSANDRA_IP_LIST[@]}; 351 | do 352 | cassandra_server=${cassandra_server}""$ip":9042 " 353 | done 354 | 355 | check_replace_value $file CONFIGDB config_db_server_list $cassandra_server 356 | check_replace_value $file CONFIGDB rabbitmq_server_list $rabbitmq_server 357 | check_replace_value $file CONFIGDB rabbitmq_user $RABBIT_USER 358 | check_replace_value $file CONFIGDB rabbitmq_password $RABBIT_PASSWORD 359 | check_replace_value $file DEFAULT collectors $COLLECTOR_IP:8086 360 | check_replace_value $file DEFAULT hostname `hostname` 361 | check_replace_value $file DEFAULT log_file '/var/log/contrail/control.log' 362 | check_replace_value $file DEFAULT hostip $CONTROL_IP 363 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 364 | check_replace_value $file DEFAULT bgp_port 179 365 | check_replace_value $file DEFAULT CERT_OPTS $CERT_OPTS 366 | fi 367 | } 368 | 369 | function replace_contrail_collector_conf() 370 | { 371 | file="/etc/contrail/contrail-collector.conf" 372 | 373 | cassandra_server="" 374 | for ip in ${CASSANDRA_IP_LIST[@]}; 375 | do 376 | cassandra_server=${cassandra_server}""$ip":9042 " 377 | done 378 | if [[ $COLLECTOR_IP = "localhost" ]]; then 379 | COLLECTOR_IP="127.0.0.1" 380 | fi 381 | 382 | kafka_server="" 383 | for ip in ${KAFKA_IP_LIST[@]}; 384 | do 385 | kafka_server=${kafka_server}""$ip":9092 " 386 | done 387 | 388 | check_replace_value $file DEFAULT log_file '/var/log/contrail/contrail-collector.log' 389 | check_replace_value $file DEFAULT log_local 1 390 | check_replace_value $file DEFAULT cassandra_server_list $cassandra_server 391 | check_replace_value $file DEFAULT kafka_broker_list $kafka_server 392 | check_replace_value $file DEFAULT hostip $COLLECTOR_IP 393 | check_replace_value $file DEFAULT hostname `hostname` 394 | } 395 | 396 | function replace_contrail_analytics_api_conf() 397 | { 398 | file="/etc/contrail/contrail-analytics-api.conf" 399 | 400 | check_replace_value $file DEFAULTS log_file '/var/log/contrail/contrail-analytics-api.log' 401 | check_replace_value $file DEFAULTS host_ip $COLLECTOR_IP 402 | check_replace_value $file DEFAULTS aaa_mode "no-auth" 403 | 404 | cassandra_server="" 405 | for ip in ${CASSANDRA_IP_LIST[@]}; 406 | do 407 | cassandra_server=${cassandra_server}""$ip":9042 " 408 | done 409 | 410 | check_replace_value $file DEFAULTS cassandra_server_list $cassandra_server 411 | } 412 | 413 | function replace_contrail_query_engine_conf() 414 | { 415 | file="/etc/contrail/contrail-query-engine.conf" 416 | 417 | cassandra_server="" 418 | for ip in ${CASSANDRA_IP_LIST[@]}; 419 | do 420 | cassandra_server=${cassandra_server}""$ip":9042 " 421 | done 422 | 423 | check_replace_value $file DEFAULT hostip $COLLECTOR_IP 424 | check_replace_value $file DEFAULT cassandra_server_list $cassandra_server 425 | } 426 | 427 | function replace_contrail_alarm_gen_conf() 428 | { 429 | file="/etc/contrail/contrail-alarm-gen.conf" 430 | 431 | kafka_server="" 432 | for ip in ${KAFKA_IP_LIST[@]}; 433 | do 434 | kafka_server=${kafka_server}""$ip":9092 " 435 | done 436 | 437 | zookeeper_server="" 438 | for ip in ${ZOOKEEPER_IP_LIST[@]}; 439 | do 440 | zookeeper_server=${zookeeper_server}""$ip":2181," 441 | done 442 | zookeeper_server=${zookeeper_server::-1} 443 | 444 | rabbitmq_server="" 445 | for ip in ${RABBITMQ_IP_LIST[@]}; 446 | do 447 | rabbitmq_server=${rabbitmq_server}""$ip" ," 448 | done 449 | 450 | check_replace_value $file DEFAULTS host_ip $COLLECTOR_IP 451 | check_replace_value $file DEFAULTS kafka_broker_list $kafka_server 452 | check_replace_value $file DEFAULTS zk_list $zookeeper_server 453 | check_replace_value $file DEFAULTS rabbitmq_server_list $rabbitmq_server 454 | check_replace_value $file DEFAULTS rabbitmq_port 5672 455 | } 456 | 457 | function replace_contrail_dns_conf() 458 | { 459 | file="/etc/contrail/contrail-dns.conf" 460 | named_log="/var/log/contrail/contrail-named.log" 461 | rndc_secret="xvysmOR8lnUQRBcunkC6vg==" 462 | 463 | rabbitmq_server="" 464 | for ip in ${RABBITMQ_IP_LIST[@]}; 465 | do 466 | rabbitmq_server=${rabbitmq_server}""$ip":5672 " 467 | done 468 | 469 | if [[ $CONTROL_IP = "localhost" ]]; then 470 | CONTROL_IP="127.0.0.1" 471 | fi 472 | if [[ $COLLECTOR_IP = "localhost" ]]; then 473 | COLLECTOR_IP="127.0.0.1" 474 | fi 475 | 476 | cassandra_server="" 477 | for ip in ${CASSANDRA_IP_LIST[@]}; 478 | do 479 | cassandra_server=${cassandra_server}""$ip":9042 " 480 | done 481 | 482 | check_replace_value $file CONFIGDB config_db_server_list $cassandra_server 483 | check_replace_value $file CONFIGDB rabbitmq_server_list $rabbitmq_server 484 | check_replace_value $file CONFIGDB rabbitmq_user $RABBIT_USER 485 | check_replace_value $file CONFIGDB rabbitmq_password $RABBIT_PASSWORD 486 | check_replace_value $file DEFAULT collectors $COLLECTOR_IP:8086 487 | check_replace_value $file DEFAULT hostip $CONTROL_IP 488 | check_replace_value $file DEFAULT hostname `hostname` 489 | check_replace_value $file DEFAULT log_file '/var/log/contrail/contrail-dns.log' 490 | check_replace_value $file DEFAULT log_level 'SYS_NOTICE' 491 | check_replace_value $file DEFAULT log_local 1 492 | check_replace_value $file DEFAULT named_log_file $named_log 493 | check_replace_value $file DEFAULT rndc_secret $rndc_secret 494 | check_replace_value $file DEFAULT rndc_config_file 'contrail-rndc.conf' 495 | 496 | sudo cp $file /etc/contrail/contrail-dns.conf 497 | 498 | # log file must be created with correct permissions for named to start 499 | touch $named_log 500 | sudo chown $(id -u):root $named_log 501 | # https://bugs.launchpad.net/opencontrail/+bug/1479323 502 | mkdir -p ${CONTRAIL_SRC}/build/var/run/named/ 503 | sudo chown root:root ${CONTRAIL_SRC}/build/var/run/named/ 504 | } 505 | 506 | function check_dev() 507 | { 508 | interface=$1 509 | arr=$(ifconfig | awk '{print $1}') 510 | if [[ " ${arr[*]} " == *"$interface"* ]]; then 511 | echo "interface found" 512 | 513 | else 514 | echo "interface not found try another interface" 515 | 516 | fi 517 | 518 | } 519 | 520 | function remove_spaces() 521 | { 522 | file=$1 523 | section=$2 524 | sed -i "s/\[$section\]//g" $file 525 | sed -i "s/ //g" $file 526 | 527 | } 528 | 529 | function replace_contrail_compute_conf() 530 | { 531 | file="/etc/contrail/contrail-compute.conf" 532 | if [[ -f $file ]]; then 533 | rm $file 534 | fi 535 | value=$(check_dev $PHYSICAL_INTERFACE) 536 | if [[ $value = "interface found" ]];then 537 | 538 | check_replace_value $file "" LOG /var/log/contrail.log 539 | check_replace_value $file "" CONFIG /etc/contrail/agent.conf 540 | check_replace_value $file "" prog /usr/bin/vnswad 541 | check_replace_value $file "" kmod vrouter.ko 542 | check_replace_value $file "" pname vnswad 543 | check_replace_value $file "" LIBDIR /usr/lib64 544 | check_replace_value $file "" VHOST_CFG /etc/sysconfig/network-scripts/ifcfg-vhost0 545 | check_replace_value $file "" VROUTER_LOGFILE --log-file=/var/log/vrouter.log 546 | check_replace_value $file "" COLLECTOR $COLLECTOR_IP 547 | check_replace_value $file "" dev $PHYSICAL_INTERFACE 548 | remove_spaces $file DEFAULTS 549 | else 550 | echo "interface not found try another interface inside else" 551 | exit 1 552 | fi 553 | 554 | } 555 | 556 | function get_dns_servers() 557 | { 558 | dns_list=$(grep "^nameserver\\>" /etc/resolv.conf | awk '{print $2}') 559 | echo $dns_list 560 | } 561 | 562 | function get_domain_search_list() 563 | { 564 | domain_list='' 565 | domin_list=$(grep ^"search" /etc/resolv.conf | awk '{$1="";print $0}') 566 | if [[ $? -eq 1 ]]; then 567 | domin_list=grep ^"domain" /etc/resolv.conf | awk '{$1=""; print $0}' 568 | fi 569 | echo $domin_list 570 | } 571 | 572 | function get_if_mtu() 573 | { 574 | mtu='' 575 | interface=$1 576 | mtu=$(ifconfig $interface|grep MTU | awk 'BEGIN{FS=OFS="MTU"}{print $2}'|awk 'BEGIN{FS=OFS=":"}{print $2}'|awk '{print $1}') 577 | if [[ $mtu -eq 1500 ]]; then 578 | mtu='' 579 | fi 580 | echo $mtu 581 | } 582 | 583 | function find_gateway() 584 | { 585 | interface=$1 586 | gateway=$(netstat -rn | grep ^"0.0.0.0" | grep $interface | awk '{ print $2 }') 587 | echo $gateway 588 | 589 | } 590 | 591 | function get_Mask() 592 | { 593 | interface=$1 594 | if is_ubuntu; then 595 | mask=$(ifconfig $interface|grep Mask | awk 'BEGIN{FS=OFS="Mask"}{print $2}'|awk 'BEGIN{FS=OFS=":"}{print $2}') 596 | echo $mask 597 | else 598 | mask=$(ifconfig $interface|sed -ne 's/.*[[net]*]*mask[: ]*\([0-9.]*\).*/\1/i p') 599 | echo $mask 600 | fi 601 | } 602 | 603 | function get_management_ip() 604 | { 605 | interface=$1 606 | if is_ubuntu; then 607 | management_ip=$(ifconfig $interface|grep -e addr| awk 'BEGIN{FS=OFS="net addr"}{print $2}'|awk '{print $1}'|awk 'BEGIN{FS=OFS=":"}{print $2}') 608 | echo $management_ip 609 | else 610 | management_ip=$(ifconfig $interface|sed -ne 's/.*inet [[addr]*]*[: ]*\([0-9.]*\).*/\1/i p') 611 | echo $management_ip 612 | fi 613 | } 614 | function get_intf_ip() 615 | { 616 | interface=$1 617 | ip='' 618 | interface_list=$(sudo netstat -i | awk '{print $1}'|sed -n '1,2!p') 619 | for inf in ${interface_list[@]} 620 | do 621 | if [[ "$inf" == "$interface" ]]; then 622 | ip=$(get_management_ip $inf) 623 | echo $ip 624 | fi 625 | done 626 | if [[ -z $ip ]]; then 627 | echo "$interface not configured" 628 | fi 629 | 630 | } 631 | 632 | function get_device_by_ip() 633 | { 634 | ip=$1 635 | interface="" 636 | interface_list=$(sudo netstat -i | awk '{print $1}'|sed -n '1,2!p') 637 | for inf in ${interface_list[@]} 638 | do 639 | if [[ $inf == "pkt1" ]]; then 640 | interface="" 641 | else 642 | if [[ "$ip" == "$(get_management_ip $inf)" ]]; then 643 | if [[ "$interface" == "vhost0" ]]; then 644 | : 645 | fi 646 | interface=$inf 647 | echo $interface 648 | fi 649 | 650 | fi 651 | done 652 | if [[ -z $interface ]]; then 653 | echo "$ip not configured" 654 | fi 655 | 656 | } 657 | function _rewrite_ifcfg_file() 658 | { 659 | filename=$1 660 | dev=$2 661 | prsv_cfg=$3 662 | 663 | bond=false 664 | mac='' 665 | temp_dir_name="/tmp" 666 | if [[ -d "/sys/class/net/$dev/bonding" ]]; then 667 | bond=true 668 | fi 669 | mac=$(get_Mac $dev) 670 | ifcfg_file="/etc/sysconfig/network-scripts/ifcfg-$dev" 671 | if is_fedora ; then 672 | echo "#Contrail-$dev" >> $ifcfg_file 673 | echo "ONBOOT=yes" >> $ifcfg_file 674 | echo "DEVICE="$dev"" >> $ifcfg_file 675 | echo "BOOTPROTO=dhcp" >> $ifcfg_file 676 | fi 677 | if [[ ! -f $ifcfg_file ]]; then 678 | ifcfg_file=$temp_dir_name'/ifcfg-'$dev 679 | rm $ifcfg_file 680 | echo "#Contrail-$dev" >> $ifcfg_file 681 | echo "TYPE=Ethernet" >> $ifcfg_file 682 | echo "ONBOOT=yes" >> $ifcfg_file 683 | echo "DEVICE="$dev"" >> $ifcfg_file 684 | echo "USERCTL=yes" >> $ifcfg_file 685 | echo "NM_CONTROLLED=no" >> $ifcfg_file 686 | echo "HWADDR=$mac" >> $ifcfg_file 687 | fi 688 | for dcfg in ${prsv_cfg[@]} 689 | do 690 | $dcfg >> $ifcfg_file 691 | done 692 | new_f_lines=() 693 | remove_items=('IPADDR','NETMASK','PREFIX','GATEWAY','HWADDR','DNS1','DNS2','BOOTPROTO','NM_CONTROLLED','#Contrail') 694 | remove_items+=("DEVICE") 695 | new_f_lines+=("#Contrail-$dev") 696 | new_f_lines+=("DEVICE=$dev") 697 | f_lines=() 698 | while read line; do 699 | f_lines+=($line) 700 | done < $ifcfg_file 701 | for line in ${f_lines[@]} 702 | do 703 | found=false 704 | for text in ${remove_items[@]} 705 | do 706 | if echo "$line" | grep -q "$text"; then 707 | found=true 708 | fi 709 | done 710 | if [[ $found ]]; then 711 | new_f_lines+=($line) 712 | fi 713 | done 714 | if [[ $bond ]]; then 715 | new_f_lines+=("SUBCHANNELS=1,2,3") 716 | #new_f_lines+=() 717 | else 718 | new_f_lines+=("HWADDR=$mac") 719 | fi 720 | if [[ -f $filename ]]; then 721 | sudo rm $filename 722 | fi 723 | for line in ${new_f_lines[@]} 724 | do 725 | echo $line >> $filename 726 | done 727 | 728 | 729 | } 730 | 731 | function migrate_routes() 732 | { 733 | : 734 | } 735 | function get_Mac() 736 | { 737 | interface=$1 738 | if is_ubuntu; then 739 | mac=$(ifconfig $interface|grep HWaddr | awk '{print $5}') 740 | elif is_fedora; then 741 | mac=$(ifconfig $interface|grep ether | awk '{print $2}') 742 | fi 743 | echo $mac 744 | 745 | } 746 | 747 | function replace_contrail_vrouter_agent_conf() 748 | { 749 | file="/etc/contrail/contrail-vrouter-agent.conf" 750 | 751 | cidr=$(get_management_ip $PHYSICAL_INTERFACE)/24 752 | gateway=$(find_gateway $PHYSICAL_INTERFACE) 753 | 754 | if [ $USE_DISCOVERY = "False" ]; then 755 | check_replace_value $file CONTROL-NODE server $CFGM_IP 756 | else 757 | inicomment $file CONTROL-NODE server 758 | fi 759 | check_replace_value $file NETWORKS control_network_ip $CFGM_IP 760 | check_replace_value $file VIRTUAL-HOST-INTERFACE ip $cidr 761 | check_replace_value $file VIRTUAL-HOST-INTERFACE name vhost0 762 | check_replace_value $file VIRTUAL-HOST-INTERFACE gateway $gateway 763 | check_replace_value $file VIRTUAL-HOST-INTERFACE physical_interface $PHYSICAL_INTERFACE 764 | check_replace_value $file COLLECTOR port 8080 765 | if [ $USE_DISCOVERY = "False" ]; then 766 | check_replace_value $file COLLECTOR server $CFGM_IP 767 | else 768 | inicomment $file COLLECTOR server 769 | fi 770 | 771 | if [ $CONTRAIL_VGW_INTERFACE -a $CONTRAIL_VGW_PUBLIC_SUBNET -a $CONTRAIL_VGW_PUBLIC_NETWORK ]; then 772 | check_replace_value $file GATEWAY-0 interface $CONTRAIL_VGW_INTERFACE 773 | check_replace_value $file GATEWAY-0 ip_blocks $CONTRAIL_VGW_PUBLIC_SUBNET 774 | check_replace_value $file GATEWAY-0 routing_instance $CONTRAIL_VGW_PUBLIC_NETWORK 775 | fi 776 | 777 | # workaround for bug with resource backup enabled as well as VGW configured 778 | check_replace_value $file RESTART backup_enable false 779 | } 780 | 781 | function replace_irond_basic_auth_users() 782 | { 783 | if [ "$CONTRAIL_DEFAULT_INSTALL" == "True" ]; then 784 | file="/etc/ifmap-server/basicauthusers.properties" 785 | file1="/etc/ifmap-server/publisher.properties" 786 | sudo chown `whoami`:`whoami` $file 787 | sudo chown `whoami`:`whoami` $file1 788 | sudo chmod 664 $file 789 | sudo chmod 664 $file1 790 | else 791 | if is_ubuntu; then 792 | file="$CONTRAIL_SRC/build/packages/ifmap-server/basicauthusers.properties" 793 | file1="$CONTRAIL_SRC/build/packages/ifmap-server/publisher.properties" 794 | else 795 | file="/opt/stack/contrail/third_party/irond-0.3.0-bin/basicauthusers.properties" 796 | file1="/opt/stack/contrail/third_party/irond-0.3.0-bin/publisher.properties" 797 | fi 798 | sudo chown `whoami`:`whoami` $file 799 | sudo chown `whoami`:`whoami` $file1 800 | sudo chmod 664 $file 801 | sudo chmod 664 $file1 802 | fi 803 | 804 | sudo grep -q ^"# Contrail" $file 805 | value=$? 806 | if [[ $value -eq 1 ]]; then 807 | echo "$CONTROL_IP=$CFGM_IP--0000000001-1" | sudo tee -a $file1 808 | fi 809 | 810 | sudo sed -i '/^# Contrail/Q' $file 811 | 812 | echo '# Contrail users' | sudo tee -a $file 813 | echo 'api-server:api-server' | sudo tee -a $file 814 | echo 'schema-transformer:schema-transformer' | sudo tee -a $file 815 | echo 'svc_monitor:svc_monitor' | sudo tee -a $file 816 | for ip in ${CONTROL_IP_LIST[@]}; 817 | do 818 | echo "$ip:$ip" | sudo tee -a $file 819 | done 820 | for ip in ${DNS_IP_LIST[@]}; 821 | do 822 | echo "$ip.dns:$ip.dns" | sudo tee -a $file 823 | done 824 | } 825 | 826 | function write_openstackrc_file() 827 | { 828 | file="/etc/contrail/openstackrc" 829 | if [[ -f $file ]]; then 830 | rm $file 831 | fi 832 | 833 | echo "export OS_USERNAME=$CONTRAIL_ADMIN_USERNAME" >> $file 834 | echo "export OS_PASSWORD=$ADMIN_PASSWORD" >> $file 835 | echo "export OS_TENANT_NAME=$CONTRAIL_ADMIN_TENANT" >> $file 836 | echo "export OS_AUTH_URL=http://127.0.0.1:5000/v2.0/" >> $file 837 | echo "export OS_NO_CACHE=1" >> $file 838 | } 839 | 840 | function write_default_pmac() 841 | { 842 | file="/etc/contrail/default_pmac" 843 | mac=$(get_Mac) 844 | echo $mac >> $file 845 | } 846 | 847 | function write_ifcfg-vhost0() 848 | { 849 | vhost_file="/etc/contrail/ifcfg-vhost0" 850 | value=$(check_dev 'vhost0') 851 | if [[ $value = "interface found" ]];then 852 | ip=$(get_management_ip vhost0) 853 | else 854 | ip=$(get_management_ip $PHYSICAL_INTERFACE) 855 | fi 856 | if [[ -f $vhost_file ]]; then 857 | sudo rm $vhost_file 858 | fi 859 | echo "#Contrail vhost0" >> $vhost_file 860 | echo "DEVICE=vhost0" >> $vhost_file 861 | #echo "ONBOOT=yes" >> $vhost_file 862 | echo "ONBOOT=no" >> $vhost_file 863 | #echo "BOOTPROTO=static" >> $vhost_file 864 | echo "BOOTPROTO=none" >> $vhost_file 865 | echo "IPV6INIT=no" >> $vhost_file 866 | echo "USERCTL=yes" >> $vhost_file 867 | echo "HWADDR=$(get_Mac $PHYSICAL_INTERFACE)" >> $vhost_file 868 | #echo "TYPE=Ethernet" >> $vhost_file 869 | echo "IPADDR=$ip" >> $vhost_file 870 | echo "NETMASK=$(get_Mask $PHYSICAL_INTERFACE)" >> $vhost_file 871 | echo "GATEWAY=$(find_gateway $PHYSICAL_INTERFACE)" >> $vhost_file 872 | echo "NM_CONTROLLED=no" >>$vhost_file 873 | echo "#NETWORK MANAGER BUG WORKAROUND" >> $vhost_file 874 | echo "SUBCHANNELS=1,2,3" >> $vhost_file 875 | 876 | } 877 | 878 | function write_qemu_conf() 879 | { 880 | file="/etc/libvirt/qemu.conf" 881 | temp_file="qemu.conf" 882 | sudo grep -q ^"cgroup_device_acl" $file 883 | value=$? 884 | if [[ $value -eq 1 ]] ; then 885 | sudo cp $file $temp_file 886 | sudo chown `whoami` $temp_file 887 | echo "cgroup_device_acl = [" | sudo tee -a $temp_file 888 | echo ' "/dev/null", "/dev/full", "/dev/zero",' | sudo tee -a $temp_file 889 | echo ' "/dev/random", "/dev/urandom",' | sudo tee -a $temp_file 890 | echo ' "/dev/ptmx", "/dev/kvm", "/dev/kqemu",' | sudo tee -a $temp_file 891 | echo ' "/dev/rtc", "/dev/hpet","/dev/net/tun",' | sudo tee -a $temp_file 892 | echo "]" | sudo tee -a $temp_file 893 | sudo mv $temp_file $file 894 | fi 895 | 896 | } 897 | 898 | function replace_in_file() 899 | { 900 | file=$1 901 | regexp=$2 902 | replace=$3 903 | sed -i 's|^.*\b'"$regexp"'.*\b|'"$replace"'|g' $file 904 | } 905 | 906 | function contains_elements() 907 | { 908 | role=() 909 | roles+=$1 910 | search_string=$2 911 | match=$(echo "${roles[@]:0}" | grep -o $search_string) 912 | [[ ! -z $match ]] && echo "found" 913 | 914 | } 915 | 916 | function fixup_config_files() 917 | { 918 | multi_net=false 919 | #roles=${roles:-('config', 'openstack', 'control', 'compute', 'collector', 'webui')} 920 | if [[ ! -d "/etc/contrail" ]]; then 921 | sudo mkdir -p /etc/contrail 922 | sudo chown `whoami` /etc/contrail 923 | fi 924 | if [[ ! -d "/etc/quantum/plugins/contrail" ]]; then 925 | sudo mkdir -p /etc/quantum/plugins/contrail 926 | sudo chown `whoami` /etc/quantum/plugins/contrail 927 | fi 928 | COMPUTE_IP=$(get_management_ip $PHYSICAL_INTERFACE) 929 | if [[ -z $SERVICE_TOKEN ]]; then 930 | SERVICE_TOKEN=$(sudo openssl rand -hex 10) 931 | $SERVICE_TOKEN > /etc/contrail/service.token 932 | fi 933 | 934 | # Disable selinux 935 | sudo sed 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config > config.new 936 | sudo mv config.new /etc/selinux/config 937 | setenforce 0 938 | 939 | # Disable iptables 940 | if [[ "$DISTRO" != "trusty" ]]; then 941 | sudo chkconfig iptables off 942 | else 943 | sudo sysv-rc-conf iptables off 944 | fi 945 | sudo iptables --flush 946 | 947 | sudo rm /etc/contrail/ctrl-details 948 | echo 'SERVICE_TOKEN='$SERVICE_TOKEN >> "/etc/contrail/ctrl-details" 949 | echo 'ADMIN_PASSWORD='$ADMIN_PASSWORD >> "/etc/contrail/ctrl-details" 950 | echo 'CONTROLLER='$OPENSTACK_IP >> "/etc/contrail/ctrl-details" 951 | echo 'QUANTUM='$CFGM_IP >> "/etc/contrail/ctrl-details" 952 | echo 'COMPUTE='$COMPUTE_IP >> "/etc/contrail/ctrl-details" 953 | echo 'CONTROLLER_MGMT='$CFGM_IP >> "/etc/contrail/ctrl-details" 954 | if [ "$INSTALL_PROFILE" = "ALL" ]; then 955 | REDIS_WEBUI="/etc/contrail/redis-webui.conf" 956 | if [[ -f /etc/redis/redis.conf ]]; then 957 | REDIS_CONF="/etc/redis/redis.conf" 958 | else 959 | REDIS_CONF="/etc/redis.conf" 960 | fi 961 | sudo sed 's/bind 127.0.0.1.*/#bind 127.0.0.1/g' $REDIS_CONF > redis.conf.new 962 | sudo mv redis.conf.new $REDIS_CONF 963 | sudo cp $REDIS_CONF $REDIS_WEBUI 964 | replace_in_file $REDIS_WEBUI 'pidfile /var/run/redis/redis.pid' 'pidfile /var/run/redis/redis-webui.pid' 965 | replace_in_file $REDIS_WEBUI 'port 6379' 'port 6383' 966 | replace_in_file $REDIS_WEBUI 'logfile /var/log/redis/redis-server.log' 'logfile /var/log/redis/redis-webui.log' 967 | replace_in_file $REDIS_WEBUI 'dbfilename dump.rdb' 'dbfilename dump-webui.rdb' 968 | 969 | fi 970 | if [[ $NON_MGMT_IP ]]; then 971 | if [[ $NON_MGMT_IP != $COMPUTE_IP ]]; then 972 | multi_net=true 973 | vhost_ip=$NON_MGMT_IP 974 | fi 975 | fi 976 | if [[ $PHYSICAL_INTERFACE ]];then 977 | if [[ $(check_dev $PHYSICAL_INTERFACE) = "interface found" ]]; then 978 | dev=$PHYSICAL_INTERFACE 979 | else 980 | echo "PHYSICAL INTERFACE NOT CONFIGURED" 981 | fi 982 | else 983 | dev=$(get_device_by_ip $vhost_ip) 984 | if [[ $multi_net ]]; then 985 | compute_dev=$(get_device_by_ip $COMPUTE_IP) 986 | fi 987 | fi 988 | if [[ $dev ]] && [[ $dev != "vhost0" ]]; then 989 | mac=$(get_Mac $dev) 990 | netmask=$(get_Mask $dev) 991 | if [[ $multi_net ]]; then 992 | gateway=$NON_MGMT_GW 993 | else 994 | gateway=$(find_gateway $dev) 995 | fi 996 | fi 997 | i=0 998 | if [[ ! multi_net ]]; then 999 | if [[ $gateway ]]; then 1000 | echo "GATEWAY=$gateway" >> "/etc/contrail/ifcfg-vhost0" 1001 | fi 1002 | dns_list=() 1003 | dns_list+=$(get_dns_servers $dev) 1004 | for dns in ${dns_list[@]} 1005 | do 1006 | echo "DNS$i=$dev" >> "/etc/contrail/ifcfg-vhost0" 1007 | i=$((i+1)) 1008 | done 1009 | domain_list=$(get_domain_search_list) 1010 | if [[ domain_list ]]; then 1011 | echo "DOMAIN=$domin_list" >> "/etc/contrail/ifcfg-vhost0" 1012 | fi 1013 | fi 1014 | prsv_cfg=() 1015 | mtu=$(get_if_mtu $dev) 1016 | if [[ $mtu ]]; then 1017 | dcfg="MTU=$mtu" 1018 | echo "$dcfg" >> "/etc/contrail/ifcfg-vhost0" 1019 | prsv_cfg+=(dcfg) 1020 | fi 1021 | sudo mv /etc/contrail/ifcfg-vhost0 /etc/sysconfig/network-scripts/ifcfg-vhost0 1022 | if [[ -f "/etc/sysconfig/network-scripts/ifcfg-$dev.rpmsave" ]]; then 1023 | sudo cp /etc/sysconfig/network-scripts/ifcfg-$dev /etc/sysconfig/network-scripts/ifcfg-$dev.rpmsave 1024 | fi 1025 | _rewrite_ifcfg_file /etc/contrail/ifcfg-$dev $dev $prsv_cfg 1026 | if [[ multi_net ]]; then 1027 | #migrate_routes $dev 1028 | : 1029 | fi 1030 | if [[ "$DISTRO" != "trusty" ]]; then 1031 | sudo chkconfig network on 1032 | else 1033 | sudo sysv-rc-conf network on 1034 | fi 1035 | 1036 | } 1037 | -------------------------------------------------------------------------------- /setup_contrail.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import ConfigParser 3 | 4 | import platform 5 | import os 6 | import sys 7 | import time 8 | import re 9 | import string 10 | import socket 11 | import netifaces, netaddr 12 | import subprocess 13 | import fnmatch 14 | import struct 15 | import shutil 16 | import json 17 | from pprint import pformat 18 | import xml.etree.ElementTree as ET 19 | import platform 20 | import getpass 21 | import re 22 | 23 | import tempfile 24 | 25 | # Get Environment Stuff 26 | password = os.environ.get('ADMIN_PASSWORD', 'contrail123') 27 | admin_username = os.environ.get('CONTRAIL_ADMIN_USERNAME', 'admin') 28 | admin_passwd = os.environ.get('ADMIN_PASSWORD', 'contrail123') 29 | admin_tenant = os.environ.get('CONTRAIL_ADMIN_TENANT', 'admin') 30 | 31 | # TODO following keystone credentials hardcoded 32 | ks_admin_user = admin_username 33 | ks_admin_password = admin_passwd 34 | ks_admin_tenant_name = admin_tenant 35 | 36 | from contrail_config_templates import * 37 | 38 | class Setup(object): 39 | def __init__(self, args_str = None): 40 | self._args = None 41 | if not args_str: 42 | args_str = ' '.join(sys.argv[1:]) 43 | self._parse_args(args_str) 44 | 45 | self._setup_tgt_path = os.path.abspath(os.path.dirname(sys.argv[0])) 46 | 47 | self._temp_dir_name = tempfile.mkdtemp() 48 | self._fixed_qemu_conf = False 49 | #end __init__ 50 | 51 | def _parse_args(self, args_str): 52 | ''' 53 | Eg. python setup.py --cfgm_ip 127.0.0.1 --vgw_interface vgw --vgw_public_subnet 1.1.1.0/24 --vgw_public_network default-domain:default-project:public:public 54 | ''' 55 | 56 | # Source any specified config/ini file 57 | # Turn off help, so we print all options in response to -h 58 | conf_parser = argparse.ArgumentParser(add_help = False) 59 | 60 | conf_parser.add_argument("-c", "--conf_file", 61 | help="Specify config file", metavar="FILE") 62 | args, remaining_argv = conf_parser.parse_known_args(args_str.split()) 63 | 64 | global_defaults = { 65 | 'use_certs': False, 66 | 'puppet_server': None, 67 | } 68 | cfgm_defaults = { 69 | 'cfgm_ip': '127.0.0.1', 70 | 'openstack_ip': '127.0.0.1', 71 | 'service_token': '', 72 | 'multi_tenancy': False, 73 | } 74 | openstack_defaults = { 75 | 'cfgm_ip': '127.0.0.1', 76 | 'service_token': '', 77 | } 78 | control_node_defaults = { 79 | 'cfgm_ip': '127.0.0.1', 80 | 'collector_ip': '127.0.0.1', 81 | 'control_ip': '127.0.0.1', 82 | } 83 | compute_node_defaults = { 84 | 'compute_ip': '127.0.0.1', 85 | 'openstack_ip': '127.0.0.1', 86 | 'service_token': '', 87 | 'ncontrols' : 2, 88 | 'physical_interface': None, 89 | 'non_mgmt_ip': None, 90 | 'non_mgmt_gw': None, 91 | } 92 | collector_defaults = { 93 | 'cfgm_ip': '127.0.0.1', 94 | 'self_collector_ip': '127.0.0.1', 95 | } 96 | database_defaults = { 97 | 'database_dir' : '/usr/share/cassandra', 98 | 'database_listen_ip' : '127.0.0.1', 99 | } 100 | 101 | if args.conf_file: 102 | config = ConfigParser.SafeConfigParser() 103 | config.read([args.conf_file]) 104 | global_defaults.update(dict(config.items("GLOBAL"))) 105 | cfgm_defaults.update(dict(config.items("CFGM"))) 106 | openstack_defaults.update(dict(config.items("OPENSTACK"))) 107 | control_node_defaults.update(dict(config.items("CONTROL-NODE"))) 108 | compute_node_defaults.update(dict(config.items("COMPUTE-NODE"))) 109 | collector_defaults.update(dict(config.items("COLLECTOR"))) 110 | database_defaults.update(dict(config.items("DATABASE"))) 111 | 112 | # Override with CLI options 113 | # Don't surpress add_help here so it will handle -h 114 | parser = argparse.ArgumentParser( 115 | # Inherit options from config_parser 116 | parents=[conf_parser], 117 | # print script description with -h/--help 118 | description=__doc__, 119 | # Don't mess with format of description 120 | formatter_class=argparse.RawDescriptionHelpFormatter, 121 | ) 122 | 123 | all_defaults = {'global': global_defaults, 124 | 'cfgm': cfgm_defaults, 125 | 'openstack': openstack_defaults, 126 | 'control-node': control_node_defaults, 127 | 'compute-node': compute_node_defaults, 128 | 'collector': collector_defaults, 129 | 'database': database_defaults, 130 | } 131 | parser.set_defaults(**all_defaults) 132 | 133 | parser.add_argument("--role", action = 'append', 134 | help = "Role of server (config, openstack, control, compute, collector, webui, database") 135 | parser.add_argument("--cfgm_ip", help = "IP Address of Configuration Node") 136 | parser.add_argument("--openstack_ip", help = "IP Address of Openstack Node") 137 | parser.add_argument("--openstack_mgmt_ip", help = "Management IP Address of Openstack Node") 138 | parser.add_argument("--collector_ip", help = "IP Address of Collector Node") 139 | parser.add_argument("--discovery_ip", help = "IP Address of Discovery Node") 140 | parser.add_argument("--control_ip", help = "IP Address of first Control Node (for control role)") 141 | parser.add_argument("--ncontrols", help = "Number of Control Nodes in the system (for compute role)") 142 | parser.add_argument("--compute_ip", help = "IP Address of Compute Node (for compute role)") 143 | parser.add_argument("--service_token", help = "The service password to access keystone") 144 | parser.add_argument("--physical_interface", help = "Name of the physical interface to use") 145 | parser.add_argument("--non_mgmt_ip", help = "IP Address of non-management interface(fabric network) on the compute node") 146 | parser.add_argument("--non_mgmt_gw", help = "Gateway Address of the non-management interface(fabric network) on the compute node") 147 | parser.add_argument("--use_certs", help = "Use certificates for authentication", 148 | action="store_true") 149 | parser.add_argument("--puppet_server", help = "FQDN of Puppet Master") 150 | parser.add_argument("--multi_tenancy", help = "Enforce resource permissions (implies keystone token validation)", 151 | action="store_true") 152 | parser.add_argument("--cassandra_ip_list", help = "IP Addresses of Cassandra Nodes", nargs = '+', type = str) 153 | parser.add_argument("--database_listen_ip", help = "Listen IP Address of database node", default = '127.0.0.1') 154 | parser.add_argument("--database_dir", help = "Directory where database binary exists", default = '/usr/share/cassandra') 155 | parser.add_argument("--database_initial_token", help = "Initial token for database node") 156 | parser.add_argument("--database_seed_list", help = "List of seed nodes for database", nargs='+') 157 | parser.add_argument("--num_collector_nodes", help = "Number of Collector Nodes", type = int) 158 | parser.add_argument("--redis_master_ip", help = "IP Address of Redis Master Node") 159 | parser.add_argument("--redis_role", help = "Redis Role of Node") 160 | parser.add_argument("--self_collector_ip", help = "Self IP of Collector Node") 161 | 162 | #Simple gateway interface 163 | parser.add_argument("--vgw_interface", help="Simple Virtual Gateway interface") 164 | parser.add_argument("--vgw_public_subnet", help="Simple Virtual Gateway public sub-net") 165 | parser.add_argument("--vgw_public_network", help="FQDN for public network") 166 | 167 | self._args = parser.parse_args(remaining_argv) 168 | 169 | # dsetia 170 | self._args.openstack_ip = self._args.cfgm_ip 171 | self._args.collector_ip = self._args.cfgm_ip 172 | self._args.discovery_ip = self._args.cfgm_ip 173 | self._args.control_ip = self._args.cfgm_ip 174 | self._args.compute_ip = self.get_management_ip(self._args.physical_interface) 175 | self._args.openstack_mgmt_ip = self._args.cfgm_ip 176 | self._args.database_listen_ip = self._args.cfgm_ip 177 | self._args.cassandra_ip_list = ['127.0.0.1'] 178 | self._args.role = ['config', 'openstack', 'control', 'compute', 'collector'] 179 | 180 | #end _parse_args 181 | 182 | def call_cmd(self, cmd): 183 | from subprocess import call 184 | return call(cmd, shell=True) 185 | # end 186 | 187 | def run_cmd(self, cmd): 188 | """Return (status, output) of executing cmd in a shell.""" 189 | pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') 190 | text = '' 191 | while True: 192 | line = pipe.readline() 193 | if line == '': 194 | break 195 | text += line 196 | print line 197 | sts = pipe.close() 198 | if sts is None: sts = 0 199 | if text[-1:] == '\n': text = text[:-1] 200 | return sts, text 201 | # end 202 | 203 | def run_shell (self, cmd): 204 | s, o = self.run_cmd (cmd) 205 | # if s: raise RuntimeError, '+ %s[%d]\n%s' % (cmd, s, o) 206 | print '+ %s [%d]' % (cmd, s) 207 | return o 208 | 209 | def _template_substitute(self, template, vals): 210 | data = template.safe_substitute(vals) 211 | return data 212 | #end _template_substitute 213 | 214 | def _template_substitute_write(self, template, vals, filename): 215 | data = self._template_substitute(template, vals) 216 | outfile = open(filename, 'w') 217 | outfile.write(data) 218 | outfile.close() 219 | #end _template_substitute_write 220 | 221 | def _replaces_in_file(self, file, replacement_list): 222 | rs = [ (re.compile(regexp), repl) for (regexp, repl) in replacement_list] 223 | file_tmp = file + ".tmp" 224 | with open(file, 'r') as f: 225 | with open(file_tmp, 'w') as f_tmp: 226 | for line in f: 227 | for r, replace in rs: 228 | match = r.search(line) 229 | if match: 230 | line = replace + "\n" 231 | f_tmp.write(line) 232 | shutil.move(file_tmp, file) 233 | #end _replaces_in_file 234 | 235 | def replace_in_file(self, file, regexp, replace): 236 | self._replaces_in_file(file, [(regexp, replace)]) 237 | #end replace_in_file 238 | 239 | def find_gateway (self, dev): 240 | gateway = '' 241 | gateway = self.run_shell("netstat -rn | grep ^\"0.0.0.0\" | grep %s | awk '{ print $2 }'" % dev) 242 | # capture = True).strip() 243 | return gateway 244 | 245 | #end find_gateway 246 | 247 | def get_dns_servers (self, dev): 248 | dns_list = self.run_shell("grep \"^nameserver\\>\" /etc/resolv.conf | awk '{print $2}'") 249 | return dns_list.split() 250 | #end get_dns_servers 251 | 252 | def get_domain_search_list (self): 253 | domain_list = '' 254 | domain_list = self.run_shell("grep ^\"search\" /etc/resolv.conf | awk '{$1=\"\";print $0}'") 255 | if not domain_list: 256 | domain_list = self.run_shell("grep ^\"domain\" /etc/resolv.conf | awk '{$1=\"\"; print $0}'") 257 | return domain_list 258 | 259 | def get_if_mtu (self, dev): 260 | ifconfig = self.run_shell("ifconfig %s" % dev) 261 | m = re.search(r'(?i)mtu[:\s]*(\d+)\b', ifconfig) 262 | mtu = '' 263 | if m: 264 | mtu = m.group(1) 265 | if mtu == '1500': 266 | mtu = '' 267 | return mtu 268 | #end if_mtu 269 | 270 | def get_intf_ip (self, intf): 271 | if intf in netifaces.interfaces (): 272 | ip = netifaces.ifaddresses (intf)[netifaces.AF_INET][0]['addr'] 273 | return ip 274 | raise RuntimeError, '%s not configured' % intf 275 | # end 276 | 277 | def get_management_ip(self, physical_interface): 278 | if 'vhost0' in netifaces.interfaces(): 279 | ipaddr = netifaces.ifaddresses('vhost0') 280 | else: 281 | ipaddr = netifaces.ifaddresses(physical_interface) 282 | return ipaddr[netifaces.AF_INET][0]['addr'] 283 | # end get_management_ip 284 | 285 | def get_device_by_ip (self, ip): 286 | for i in netifaces.interfaces (): 287 | try: 288 | if i == 'pkt1': 289 | continue 290 | if netifaces.ifaddresses (i).has_key (netifaces.AF_INET): 291 | if ip == netifaces.ifaddresses (i)[netifaces.AF_INET][0][ 292 | 'addr']: 293 | if i == 'vhost0': 294 | print "vhost0 is already present!" 295 | # raise RuntimeError, 'vhost0 already running with %s'%ip 296 | return i 297 | except ValueError,e: 298 | print "Skipping interface %s" % i 299 | raise RuntimeError, '%s not configured, rerun w/ --physical_interface' % ip 300 | #end get_device_by_ip 301 | 302 | def _is_string_in_file(self, string, filename): 303 | f_lines=[] 304 | if os.path.isfile( filename ): 305 | fd=open(ifcfg_file) 306 | f_lines=fd.readlines() 307 | fd.close() 308 | #end if 309 | found= False 310 | for line in f_lines: 311 | if string in line: 312 | found= True 313 | return found 314 | #end _is_string_in_file 315 | 316 | def _rewrite_ifcfg_file(self, filename, dev, prsv_cfg): 317 | bond = False 318 | mac = '' 319 | temp_dir_name = self._temp_dir_name 320 | 321 | if os.path.isdir ('/sys/class/net/%s/bonding' % dev): 322 | bond = True 323 | # end if os.path.isdir... 324 | 325 | mac = netifaces.ifaddresses(dev)[netifaces.AF_LINK][0]['addr'] 326 | ifcfg_file='/etc/sysconfig/network-scripts/ifcfg-%s' %(dev) 327 | if not os.path.isfile( ifcfg_file ): 328 | ifcfg_file = temp_dir_name + 'ifcfg-' + dev 329 | with open (ifcfg_file, 'w') as f: 330 | f.write ('''#Contrail %s 331 | TYPE=Ethernet 332 | ONBOOT=yes 333 | DEVICE="%s" 334 | USERCTL=yes 335 | NM_CONTROLLED=no 336 | HWADDR=%s 337 | ''' % (dev, dev, mac)) 338 | for dcfg in prsv_cfg: 339 | f.write(dcfg+'\n') 340 | f.flush() 341 | fd=open(ifcfg_file) 342 | f_lines=fd.readlines() 343 | fd.close() 344 | new_f_lines=[] 345 | remove_items=['IPADDR', 'NETMASK', 'PREFIX', 'GATEWAY', 'HWADDR', 346 | 'DNS1', 'DNS2', 'BOOTPROTO', 'NM_CONTROLLED', '#Contrail'] 347 | 348 | remove_items.append('DEVICE') 349 | new_f_lines.append('#Contrail %s\n' % dev) 350 | new_f_lines.append('DEVICE=%s\n' % dev) 351 | 352 | 353 | for line in f_lines: 354 | found=False 355 | for text in remove_items: 356 | if text in line: 357 | found=True 358 | if not found: 359 | new_f_lines.append(line) 360 | 361 | new_f_lines.append('NM_CONTROLLED=no\n') 362 | if bond: 363 | new_f_lines.append('SUBCHANNELS=1,2,3\n') 364 | else: 365 | new_f_lines.append('HWADDR=%s\n' % mac) 366 | 367 | fdw=open(filename,'w') 368 | fdw.writelines(new_f_lines) 369 | fdw.close() 370 | 371 | def migrate_routes(self, device): 372 | ''' 373 | Sample output of /proc/net/route : 374 | Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT 375 | p4p1 00000000 FED8CC0A 0003 0 0 0 00000000 0 0 0 376 | ''' 377 | with open('/etc/sysconfig/network-scripts/route-vhost0', 'w') as route_cfg_file: 378 | for route in open('/proc/net/route', 'r').readlines(): 379 | if route.startswith(device): 380 | route_fields = route.split() 381 | destination = int(route_fields[1], 16) 382 | gateway = int(route_fields[2], 16) 383 | flags = int(route_fields[3], 16) 384 | mask = int(route_fields[7], 16) 385 | if flags & 0x2: 386 | if destination != 0: 387 | route_cfg_file.write(socket.inet_ntoa(struct.pack('I', destination))) 388 | route_cfg_file.write('/' + str(bin(mask).count('1')) + ' ') 389 | route_cfg_file.write('via ') 390 | route_cfg_file.write(socket.inet_ntoa(struct.pack('I', gateway)) + ' ') 391 | route_cfg_file.write('dev vhost0') 392 | #end if detination... 393 | #end if flags &... 394 | #end if route.startswith... 395 | #end for route... 396 | #end with open... 397 | #end def migrate_routes 398 | 399 | def _replace_discovery_server(self, agent_elem, discovery_ip, ncontrols): 400 | for srv in agent_elem.findall('discovery-server'): 401 | agent_elem.remove(srv) 402 | 403 | pri_dss_elem = ET.Element('discovery-server') 404 | pri_dss_ip = ET.SubElement(pri_dss_elem, 'ip-address') 405 | pri_dss_ip.text = '%s' %(discovery_ip) 406 | 407 | xs_instances = ET.SubElement(pri_dss_elem, 'control-instances') 408 | xs_instances.text = '%s' %(ncontrols) 409 | agent_elem.append(pri_dss_elem) 410 | 411 | #end _replace_discovery_server 412 | 413 | 414 | def fixup_config_files(self): 415 | temp_dir_name = self._temp_dir_name 416 | hostname = socket.gethostname() 417 | cfgm_ip = self._args.cfgm_ip 418 | collector_ip = self._args.collector_ip 419 | use_certs = True if self._args.use_certs else False 420 | 421 | whoami = getpass.getuser() 422 | self.run_shell("sudo mkdir -p /etc/contrail") 423 | self.run_shell("sudo chown %s /etc/contrail" % whoami) 424 | self.run_shell("sudo mkdir -p /etc/quantum/plugins/contrail") 425 | self.run_shell("sudo chown %s /etc/quantum/plugins/contrail" % whoami) 426 | # generate service token 427 | self.service_token = self._args.service_token 428 | if not self.service_token: 429 | self.run_shell("sudo openssl rand -hex 10 > /etc/contrail/service.token") 430 | tok_fd = open('/etc/contrail/service.token') 431 | self.service_token = tok_fd.read() 432 | tok_fd.close() 433 | # local("sudo chmod 400 /etc/contrail/service.token") 434 | 435 | """ dsetia 436 | # TODO till post of openstack-horizon.spec is fixed... 437 | if 'config' in self._args.role: 438 | pylibpath = local ('/usr/bin/python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"', capture = True) 439 | local('runuser -p apache -c "echo yes | django-admin collectstatic --settings=settings --pythonpath=%s/openstack_dashboard"' % pylibpath) 440 | """ 441 | 442 | # Disable selinux 443 | self.run_shell("sudo sed 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config > config.new") 444 | self.run_shell("sudo mv config.new /etc/selinux/config") 445 | self.run_shell("setenforce 0") 446 | 447 | # Disable iptables 448 | self.run_shell("sudo chkconfig iptables off") 449 | self.run_shell("sudo iptables --flush") 450 | 451 | if 'config' in self._args.role or 'compute' in self._args.role or 'openstack' in self._args.role: 452 | openstack_ip = self._args.openstack_ip 453 | compute_ip = self._args.compute_ip 454 | cfgm_ip = self._args.cfgm_ip 455 | temp_dir_name = "/tmp" 456 | 457 | self.run_shell("echo 'SERVICE_TOKEN=%s' >> %s/ctrl-details" 458 | %(self.service_token, temp_dir_name)) 459 | self.run_shell("echo 'ADMIN_PASSWORD=%s' >> %s/ctrl-details" %(ks_admin_password, temp_dir_name)) 460 | self.run_shell("echo 'CONTROLLER=%s' >> %s/ctrl-details" %(openstack_ip, temp_dir_name)) 461 | self.run_shell("echo 'QUANTUM=%s' >> %s/ctrl-details" %(cfgm_ip, temp_dir_name)) 462 | self.run_shell("echo 'COMPUTE=%s' >> %s/ctrl-details" %(compute_ip, temp_dir_name)) 463 | if 'compute' in self._args.role: 464 | self.run_shell("echo 'CONTROLLER_MGMT=%s' >> %s/ctrl-details" %(self._args.openstack_mgmt_ip, temp_dir_name)) 465 | self.run_shell("sudo cp %s/ctrl-details /etc/contrail/ctrl-details" %(temp_dir_name)) 466 | self.run_shell("rm %s/ctrl-details" %(temp_dir_name)) 467 | 468 | # database (cassandra setup in contrail.sh) 469 | 470 | # collector in Phase 2 471 | 472 | if 'config' in self._args.role: 473 | openstack_ip = self._args.openstack_ip 474 | cassandra_server_list = [(cassandra_server_ip, '9042') for cassandra_server_ip in self._args.cassandra_ip_list] 475 | template_vals = {'__contrail_ifmap_server_ip__': cfgm_ip, 476 | '__contrail_ifmap_server_port__': '8444' if use_certs else '8443', 477 | '__contrail_ifmap_username__': 'api-server', 478 | '__contrail_ifmap_password__': 'api-server', 479 | '__contrail_listen_ip_addr__': '0.0.0.0', 480 | '__contrail_listen_port__': '8082', 481 | '__contrail_use_certs__': use_certs, 482 | '__contrail_keyfile_location__': '/etc/contrail/ssl/private_keys/apiserver_key.pem', 483 | '__contrail_certfile_location__': '/etc/contrail/ssl/certs/apiserver.pem', 484 | '__contrail_cacertfile_location__': '/etc/contrail/ssl/certs/ca.pem', 485 | '__contrail_multi_tenancy__': self._args.multi_tenancy, 486 | '__contrail_openstack_ip__': openstack_ip, 487 | '__contrail_admin_user__': ks_admin_user, 488 | '__contrail_admin_password__': ks_admin_password, 489 | '__contrail_admin_tenant_name__': ks_admin_tenant_name, 490 | '__contrail_memcached_opt__': 'memcache_servers=127.0.0.1:11211' if self._args.multi_tenancy else '', 491 | '__contrail_log_file__': '/var/log/contrail/api.log', 492 | '__contrail_cassandra_server_list__' : ' '.join('%s:%s' % cassandra_server for cassandra_server in cassandra_server_list), 493 | '__contrail_disc_server_ip__': self._args.discovery_ip or '', 494 | '__contrail_disc_server_port__': '5998', 495 | } 496 | self._template_substitute_write(api_server_conf_template, 497 | template_vals, temp_dir_name + '/api_server.conf') 498 | self.run_shell("sudo mv %s/api_server.conf /etc/contrail/" %(temp_dir_name)) 499 | 500 | template_vals = {'__contrail_api_server_ip__': cfgm_ip, 501 | '__contrail_api_server_port__': '8082', 502 | '__contrail_multi_tenancy__': self._args.multi_tenancy, 503 | '__contrail_keystone_ip__': '127.0.0.1', 504 | '__contrail_admin_user__': ks_admin_user, 505 | '__contrail_admin_password__': ks_admin_password, 506 | '__contrail_admin_tenant_name__': ks_admin_tenant_name, 507 | } 508 | self._template_substitute_write(quantum_conf_template, 509 | template_vals, temp_dir_name + '/contrail_plugin.ini') 510 | 511 | self.run_shell("sudo mv %s/contrail_plugin.ini /etc/quantum/plugins/contrail/contrail_plugin.ini" %(temp_dir_name)) 512 | 513 | template_vals = {'__contrail_ifmap_server_ip__': cfgm_ip, 514 | '__contrail_ifmap_server_port__': '8444' if use_certs else '8443', 515 | '__contrail_ifmap_username__': 'schema-transformer', 516 | '__contrail_ifmap_password__': 'schema-transformer', 517 | '__contrail_api_server_ip__': cfgm_ip, 518 | '__contrail_api_server_port__': '8082', 519 | '__contrail_zookeeper_server_ip__': '127.0.0.1', 520 | '__contrail_zookeeper_server_port__': '2181', 521 | '__contrail_use_certs__': use_certs, 522 | '__contrail_keyfile_location__': '/etc/contrail/ssl/private_keys/schema_xfer_key.pem', 523 | '__contrail_certfile_location__': '/etc/contrail/ssl/certs/schema_xfer.pem', 524 | '__contrail_cacertfile_location__': '/etc/contrail/ssl/certs/ca.pem', 525 | '__contrail_admin_user__': ks_admin_user, 526 | '__contrail_admin_password__': ks_admin_password, 527 | '__contrail_admin_tenant_name__': ks_admin_tenant_name, 528 | '__contrail_log_file__' : '/var/log/contrail/schema.log', 529 | '__contrail_cassandra_server_list__' : ' '.join('%s:%s' % cassandra_server for cassandra_server in cassandra_server_list), 530 | '__contrail_disc_server_ip__': self._args.discovery_ip or '', 531 | '__contrail_disc_server_port__': '5998', 532 | } 533 | self._template_substitute_write(schema_transformer_conf_template, 534 | template_vals, temp_dir_name + '/schema_transformer.conf') 535 | self.run_shell("sudo mv %s/schema_transformer.conf /etc/contrail/schema_transformer.conf" %(temp_dir_name)) 536 | 537 | template_vals = {'__contrail_ifmap_server_ip__': cfgm_ip, 538 | '__contrail_ifmap_server_port__': '8444' if use_certs else '8443', 539 | '__contrail_ifmap_username__': 'svc-monitor', 540 | '__contrail_ifmap_password__': 'svc-monitor', 541 | '__contrail_api_server_ip__': cfgm_ip, 542 | '__contrail_api_server_port__': '8082', 543 | '__contrail_openstack_ip__': openstack_ip, 544 | '__contrail_zookeeper_server_ip__': '127.0.0.1', 545 | '__contrail_zookeeper_server_port__': '2181', 546 | '__contrail_use_certs__': use_certs, 547 | '__contrail_keyfile_location__': '/etc/contrail/ssl/private_keys/svc_monitor_key.pem', 548 | '__contrail_certfile_location__': '/etc/contrail/ssl/certs/svc_monitor.pem', 549 | '__contrail_cacertfile_location__': '/etc/contrail/ssl/certs/ca.pem', 550 | '__contrail_admin_user__': ks_admin_user, 551 | '__contrail_admin_password__': ks_admin_password, 552 | '__contrail_admin_tenant_name__': ks_admin_tenant_name, 553 | '__contrail_log_file__' : '/var/log/contrail/svc-monitor.log', 554 | '__contrail_cassandra_server_list__' : ' '.join('%s:%s' % cassandra_server for cassandra_server in cassandra_server_list), 555 | '__contrail_disc_server_ip__': self._args.discovery_ip or '', 556 | '__contrail_disc_server_port__': '5998', 557 | } 558 | self._template_substitute_write(svc_monitor_conf_template, 559 | template_vals, temp_dir_name + '/svc-monitor.conf') 560 | self.run_shell("sudo mv %s/svc-monitor.conf /etc/contrail/svc-monitor.conf" %(temp_dir_name)) 561 | 562 | template_vals = { 563 | '__contrail_zk_server_ip__': '127.0.0.1', 564 | '__contrail_zk_server_port__': '2181', 565 | '__contrail_listen_ip_addr__': cfgm_ip, 566 | '__contrail_listen_port__': '5998', 567 | '__contrail_log_local__': 'True', 568 | '__contrail_log_file__': '/var/log/contrail/discovery.log', 569 | } 570 | self._template_substitute_write(discovery_conf_template, 571 | template_vals, temp_dir_name + '/discovery.conf') 572 | self.run_shell("sudo mv %s/discovery.conf /etc/contrail/" %(temp_dir_name)) 573 | 574 | template_vals = { 575 | '__contrail_openstack_ip__': openstack_ip, 576 | } 577 | self._template_substitute_write(vnc_api_lib_ini_template, 578 | template_vals, temp_dir_name + '/vnc_api_lib.ini') 579 | self.run_shell("sudo mv %s/vnc_api_lib.ini /etc/contrail/" %(temp_dir_name)) 580 | 581 | template_vals = { 582 | '__api_server_ip__' : cfgm_ip, 583 | '__api_server_port__': '8082', 584 | '__multitenancy__' : 'False', 585 | '__contrail_admin_user__': ks_admin_user, 586 | '__contrail_admin_password__': ks_admin_password, 587 | '__contrail_admin_tenant_name__': ks_admin_tenant_name, 588 | } 589 | self._template_substitute_write(contrail_plugin_template, 590 | template_vals, temp_dir_name + '/ContrailPlugin.ini') 591 | self.run_shell("sudo cp %s/ContrailPlugin.ini /opt/stack/neutron/etc/neutron/plugins/juniper/contrail/" %(temp_dir_name)) 592 | self.run_shell("sudo mv %s/ContrailPlugin.ini /etc/contrail/" %(temp_dir_name)) 593 | 594 | template_vals = { 595 | '__contrail_keystone_ip__': cfgm_ip, 596 | '__contrail_admin_user__': ks_admin_user, 597 | '__contrail_admin_password__': ks_admin_password, 598 | '__contrail_admin_tenant_name__': ks_admin_tenant_name, 599 | } 600 | self._template_substitute_write(openstackrc_template, 601 | template_vals, temp_dir_name + '/openstackrc') 602 | self.run_shell("sudo mv %s/openstackrc /etc/contrail/openstackrc" %(temp_dir_name)) 603 | 604 | if 'control' in self._args.role: 605 | control_ip = self._args.control_ip 606 | certdir = '/var/lib/puppet/ssl' if self._args.puppet_server else '/etc/contrail/ssl' 607 | template_vals = {'__contrail_ifmap_srv_ip__': cfgm_ip, 608 | '__contrail_ifmap_srv_port__': '8444' if use_certs else '8443', 609 | '__contrail_ifmap_usr__': '%s' %(control_ip), 610 | '__contrail_ifmap_paswd__': '%s' %(control_ip), 611 | '__contrail_collector__': collector_ip, 612 | '__contrail_collector_port__': '8086', 613 | '__contrail_discovery_ip__': self._args.discovery_ip, 614 | '__contrail_hostname__': hostname, 615 | '__contrail_host_ip__': control_ip, 616 | '__contrail_bgp_port__': '179', 617 | '__contrail_cert_ops__': '"--use-certs=%s"' %(certdir) if use_certs else '', 618 | '__contrail_log_local__': '', 619 | '__contrail_logfile__': '--log-file=/var/log/contrail/control.log', 620 | } 621 | self._template_substitute_write(bgp_param_template, 622 | template_vals, temp_dir_name + '/control_param') 623 | self.run_shell("sudo mv %s/control_param /etc/contrail/control_param" %(temp_dir_name)) 624 | 625 | dns_template_vals = {'__contrail_ifmap_srv_ip__': cfgm_ip, 626 | '__contrail_ifmap_srv_port__': '8444' if use_certs else '8443', 627 | '__contrail_ifmap_usr__': '%s.dns' %(control_ip), 628 | '__contrail_ifmap_paswd__': '%s.dns' %(control_ip), 629 | '__contrail_collector__': collector_ip, 630 | '__contrail_collector_port__': '8086', 631 | '__contrail_discovery_ip__': self._args.discovery_ip, 632 | '__contrail_host_ip__': control_ip, 633 | '__contrail_cert_ops__': '"--use-certs=%s"' %(certdir) if use_certs else '', 634 | '__contrail_log_local__': '', 635 | '__contrail_logfile__': '--log-file=/var/log/contrail/dns.log', 636 | } 637 | self._template_substitute_write(dns_param_template, 638 | dns_template_vals, temp_dir_name + '/dns_param') 639 | self.run_shell("sudo mv %s/dns_param /etc/contrail/dns_param" %(temp_dir_name)) 640 | 641 | dir = "/opt/stack/contrail/third_party/irond-0.3.0-bin" 642 | self.run_shell("echo >> %s/basicauthusers.properties" % dir) 643 | self.run_shell("echo '# Contrail users' >> %s/basicauthusers.properties" % dir) 644 | self.run_shell("echo 'api-server:api-server' >> %s/basicauthusers.properties" % dir) 645 | self.run_shell("echo 'schema-transformer:schema-transformer' >> %s/basicauthusers.properties" % dir) 646 | self.run_shell("echo 'svc-monitor:svc-monitor' >> %s/basicauthusers.properties" % dir) 647 | self.run_shell("sudo sed -e '/%s:/d' -e '/%s.dns:/d' %s/%s > %s/%s.new" \ 648 | %(control_ip, control_ip, dir, 'basicauthusers.properties', 649 | dir, 'basicauthusers.properties')) 650 | self.run_shell("echo '%s:%s' >> %s/%s.new" \ 651 | %(control_ip, control_ip, dir, 'basicauthusers.properties')) 652 | self.run_shell("echo '%s.dns:%s.dns' >> %s/%s.new" \ 653 | %(control_ip, control_ip, dir, 'basicauthusers.properties')) 654 | self.run_shell("sudo mv %s/%s.new %s/%s" \ 655 | % (dir, 'basicauthusers.properties', dir, 'basicauthusers.properties')) 656 | self.run_shell("echo '%s=%s--0000000001-1' >> %s/%s" \ 657 | %(control_ip, control_ip, dir, 'publisher.properties')) 658 | if self._args.puppet_server: 659 | self.run_shell("echo ' server = %s' >> /etc/puppet/puppet.conf" \ 660 | %(self._args.puppet_server)) 661 | 662 | if 'compute' in self._args.role: 663 | dist = platform.dist()[0] 664 | # add /dev/net/tun in cgroup_device_acl needed for type=ethernet interfaces 665 | ret = self.call_cmd("sudo grep -q '^cgroup_device_acl' /etc/libvirt/qemu.conf") 666 | if ret == 1: 667 | self.run_shell('sudo cp /etc/libvirt/qemu.conf qemu.conf') 668 | self.run_shell('sudo chown %s qemu.conf' % whoami) 669 | if dist == 'centos': 670 | self.run_shell('sudo echo "clear_emulator_capabilities = 1" >> qemu.conf') 671 | self.run_shell('sudo echo \'user = "root"\' >> qemu.conf') 672 | self.run_shell('sudo echo \'group = "root"\' >> qemu.conf') 673 | self.run_shell('sudo echo \'cgroup_device_acl = [\' >> qemu.conf') 674 | self.run_shell('sudo echo \' "/dev/null", "/dev/full", "/dev/zero",\' >> qemu.conf') 675 | self.run_shell('sudo echo \' "/dev/random", "/dev/urandom",\' >> qemu.conf') 676 | self.run_shell('sudo echo \' "/dev/ptmx", "/dev/kvm", "/dev/kqemu",\' >> qemu.conf') 677 | self.run_shell('sudo echo \' "/dev/rtc", "/dev/hpet","/dev/net/tun",\' >> qemu.conf') 678 | self.run_shell('sudo echo \']\' >> qemu.conf') 679 | self.run_shell('sudo cp qemu.conf /etc/libvirt/qemu.conf') 680 | self._fixed_qemu_conf = True 681 | # add "alias bridge off" in /etc/modprobe.conf for Centos 682 | if dist == 'centos': 683 | self.run_shell('sudo echo "alias bridge off" > /etc/modprobe.conf') 684 | 685 | if 'compute' in self._args.role : 686 | openstack_ip = self._args.openstack_ip 687 | compute_ip = self._args.compute_ip 688 | discovery_ip = self._args.discovery_ip 689 | ncontrols = self._args.ncontrols 690 | physical_interface = self._args.physical_interface 691 | non_mgmt_ip = self._args.non_mgmt_ip 692 | non_mgmt_gw = self._args.non_mgmt_gw 693 | vhost_ip = compute_ip 694 | vgw_interface = self._args.vgw_interface 695 | vgw_public_subnet = self._args.vgw_public_subnet 696 | vgw_public_network = self._args.vgw_public_network 697 | multi_net= False 698 | if non_mgmt_ip : 699 | if non_mgmt_ip != compute_ip: 700 | multi_net= True 701 | vhost_ip= non_mgmt_ip 702 | 703 | dev = None 704 | compute_dev = None 705 | if physical_interface: 706 | if physical_interface in netifaces.interfaces (): 707 | dev = physical_interface 708 | else: 709 | raise KeyError, 'Interface %s in present' % ( 710 | physical_interface) 711 | else: 712 | # deduce the phy interface from ip, if configured 713 | dev = self.get_device_by_ip (vhost_ip) 714 | if multi_net: 715 | compute_dev = self.get_device_by_ip (compute_ip) 716 | 717 | mac = None 718 | if dev and dev != 'vhost0' : 719 | mac = netifaces.ifaddresses (dev)[netifaces.AF_LINK][0][ 720 | 'addr'] 721 | if mac: 722 | with open ('%s/default_pmac' % temp_dir_name, 'w') as f: 723 | f.write (mac) 724 | self.run_shell("sudo mv %s/default_pmac /etc/contrail/default_pmac" % (temp_dir_name)) 725 | else: 726 | raise KeyError, 'Interface %s Mac %s' % (str (dev), str (mac)) 727 | netmask = netifaces.ifaddresses (dev)[netifaces.AF_INET][0][ 728 | 'netmask'] 729 | if multi_net: 730 | gateway= non_mgmt_gw 731 | else: 732 | gateway = self.find_gateway (dev) 733 | cidr = str (netaddr.IPNetwork('%s/%s' % (vhost_ip, netmask))) 734 | 735 | template_vals = { 736 | '__contrail_dev__' : 'dev=%s' % dev, 737 | '__contrail_collector__' : collector_ip 738 | } 739 | self._template_substitute_write(agent_param_template, 740 | template_vals, "agent_param") 741 | self.run_shell("sudo mv agent_param /etc/contrail/agent_param") 742 | 743 | if vgw_interface is None or vgw_public_subnet is None or vgw_public_network is None: 744 | template_vals = { 745 | '__contrail_box_ip__' : cidr, 746 | '__contrail_gateway__' : gateway, 747 | '__contrail_intf__' : dev, 748 | '__contrail_disc_ip__' : discovery_ip, 749 | '__contrail_instances__' : ncontrols, 750 | '__contrail_control_ip__' : cfgm_ip, 751 | } 752 | self._template_substitute_write(agent_conf_template, 753 | template_vals, "agent.conf") 754 | else: 755 | template_vals = { 756 | '__contrail_box_ip__' : cidr, 757 | '__contrail_gateway__' : gateway, 758 | '__contrail_intf__' : dev, 759 | '__contrail_disc_ip__' : discovery_ip, 760 | '__contrail_instances__' : ncontrols, 761 | '__contrail_control_ip__' : cfgm_ip, 762 | '__contrail_vgw_interface__' : vgw_interface, 763 | '__contrail_vgw_public_subnet__' : vgw_public_subnet, 764 | '__contrail_vgw_public_network__' : vgw_public_network, 765 | } 766 | self._template_substitute_write(agent_vgw_conf_template, 767 | template_vals, "agent.conf") 768 | 769 | self.run_shell("sudo mv agent.conf /etc/contrail/agent.conf") 770 | 771 | ## make ifcfg-vhost0 772 | with open ('%s/ifcfg-vhost0' % temp_dir_name, 'w') as f: 773 | f.write ('''#Contrail vhost0 774 | DEVICE=vhost0 775 | ONBOOT=yes 776 | BOOTPROTO=none 777 | IPV6INIT=no 778 | USERCTL=yes 779 | IPADDR=%s 780 | NETMASK=%s 781 | NM_CONTROLLED=no 782 | #NETWORK MANAGER BUG WORKAROUND 783 | SUBCHANNELS=1,2,3 784 | ''' % (vhost_ip, netmask )) 785 | # Don't set gateway and DNS on vhost0 if on non-mgmt network 786 | if not multi_net: 787 | if gateway: 788 | f.write('GATEWAY=%s\n' %( gateway ) ) 789 | dns_list = self.get_dns_servers(dev) 790 | for i, dns in enumerate(dns_list): 791 | f.write('DNS%d=%s\n' % (i+1, dns)) 792 | domain_list = self.get_domain_search_list() 793 | if domain_list: 794 | f.write('DOMAIN="%s"\n'% domain_list) 795 | 796 | prsv_cfg = [] 797 | mtu = self.get_if_mtu (dev) 798 | if mtu: 799 | dcfg = 'MTU=%s' % str(mtu) 800 | f.write(dcfg+'\n') 801 | prsv_cfg.append (dcfg) 802 | f.flush () 803 | # if dev != 'vhost0': 804 | self.run_shell("sudo mv %s/ifcfg-vhost0 /etc/sysconfig/network-scripts/ifcfg-vhost0" % (temp_dir_name)) 805 | ## make ifcfg-$dev 806 | if not os.path.isfile ( 807 | '/etc/sysconfig/network-scripts/ifcfg-%s.rpmsave' % dev): 808 | self.run_shell("sudo cp /etc/sysconfig/network-scripts/ifcfg-%s /etc/sysconfig/network-scripts/ifcfg-%s.rpmsave" % (dev, dev)) 809 | self._rewrite_ifcfg_file('%s/ifcfg-%s' % (temp_dir_name, dev), dev, prsv_cfg) 810 | 811 | if multi_net : 812 | self.migrate_routes(dev) 813 | 814 | self.run_shell("sudo mv %s/ifcfg-%s /etc/contrail/" % (temp_dir_name, dev)) 815 | 816 | self.run_shell("sudo chkconfig network on") 817 | #end if dev and dev != 'vhost0' : 818 | 819 | # role == compute && !cfgm 820 | 821 | if 'webui' in self._args.role: 822 | openstack_ip = self._args.openstack_ip 823 | self.run_shell("sudo sed \"s/config.cnfg.server_ip.*/config.cnfg.server_ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(cfgm_ip)) 824 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 825 | self.run_shell("sudo sed \"s/config.networkManager.ip.*/config.networkManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(cfgm_ip)) 826 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 827 | self.run_shell("sudo sed \"s/config.imageManager.ip.*/config.imageManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(openstack_ip)) 828 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 829 | self.run_shell("sudo sed \"s/config.computeManager.ip.*/config.computeManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(openstack_ip)) 830 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 831 | self.run_shell("sudo sed \"s/config.identityManager.ip.*/config.identityManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(openstack_ip)) 832 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 833 | self.run_shell("sudo sed \"s/config.storageManager.ip.*/config.storageManager.ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(openstack_ip)) 834 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 835 | if collector_ip: 836 | self.run_shell("sudo sed \"s/config.analytics.server_ip.*/config.analytics.server_ip = '%s';/g\" /etc/contrail/config.global.js > config.global.js.new" %(collector_ip)) 837 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 838 | if self._args.cassandra_ip_list: 839 | self.run_shell("sudo sed \"s/config.cassandra.server_ips.*/config.cassandra.server_ips = %s;/g\" /etc/contrail/config.global.js > config.global.js.new" %(str(self._args.cassandra_ip_list))) 840 | self.run_shell("sudo mv config.global.js.new /etc/contrail/config.global.js") 841 | 842 | """ 843 | if 'config' in self._args.role and self._args.use_certs: 844 | local("sudo ./contrail_setup_utils/setup-pki.sh /etc/contrail/ssl") 845 | """ 846 | 847 | #end fixup_config_files 848 | 849 | def add_vnc_config(self): 850 | if 'compute' in self._args.role: 851 | cfgm_ip = self._args.cfgm_ip 852 | compute_ip = self._args.compute_ip 853 | compute_hostname = socket.gethostname() 854 | with settings(host_string = 'root@%s' %(cfgm_ip), password = env.password): 855 | prov_args = "--host_name %s --host_ip %s --api_server_ip %s --oper add " \ 856 | "--admin_user %s --admin_password %s --admin_tenant_name %s" \ 857 | %(compute_hostname, compute_ip, cfgm_ip, ks_admin_user, ks_admin_password, ks_admin_tenant_name) 858 | run("source /opt/contrail/api-venv/bin/activate && python /opt/contrail/utils/provision_vrouter.py %s" %(prov_args)) 859 | #end add_vnc_config 860 | 861 | def cleanup(self): 862 | os.removedirs(self._temp_dir_name) 863 | #end cleanup 864 | 865 | def do_setup(self): 866 | # local configuration 867 | self.fixup_config_files() 868 | 869 | # global vnc configuration 870 | # self.add_vnc_config() dsetia disabled temporarily 871 | 872 | self.cleanup() 873 | #end do_setup 874 | 875 | #end class Setup 876 | 877 | def main(args_str = None): 878 | setup_obj = Setup(args_str) 879 | setup_obj.do_setup() 880 | #end main 881 | 882 | if __name__ == "__main__": 883 | main() 884 | --------------------------------------------------------------------------------