blob: 7d0cf1af39ba552e90d3b7af1fec4bd1c783e844 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Mark McClainb05c8762013-07-06 23:29:39 -04003# Neutron Cisco plugin
Baodong (Robert) Li901419d2013-06-10 08:39:26 -07004# ---------------------------
5
6# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05007CISCO_XTRACE=$(set +o | grep xtrace)
Baodong (Robert) Li901419d2013-06-10 08:39:26 -07008set +o xtrace
9
10# Scecify the VSM parameters
11Q_CISCO_PLUGIN_VSM_IP=${Q_CISCO_PLUGIN_VSM_IP:-}
12# Specify the VSM username
13Q_CISCO_PLUGIN_VSM_USERNAME=${Q_CISCO_PLUGIN_VSM_USERNAME:-admin}
14# Specify the VSM passward for above username
15Q_CISCO_PLUGIN_VSM_PASSWORD=${Q_CISCO_PLUGIN_VSM_PASSWORD:-}
16# Specify the uVEM integration bridge name
17Q_CISCO_PLUGIN_INTEGRATION_BRIDGE=${Q_CISCO_PLUGIN_INTEGRATION_BRIDGE:-br-int}
18# Specify if tunneling is enabled
19Q_CISCO_PLUGIN_ENABLE_TUNNELING=${Q_CISCO_PLUGIN_ENABLE_TUNNELING:-True}
20# Specify the VXLAN range
21Q_CISCO_PLUGIN_VXLAN_ID_RANGES=${Q_CISCO_PLUGIN_VXLAN_ID_RANGES:-5000:10000}
22# Specify the VLAN range
23Q_CISCO_PLUGIN_VLAN_RANGES=${Q_CISCO_PLUGIN_VLAN_RANGES:-vlan:1:4094}
24
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070025# This routine put a prefix on an existing function name
Ian Wienandaee18c72014-02-21 15:35:08 +110026function _prefix_function {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070027 declare -F $1 > /dev/null || die "$1 doesn't exist"
28 eval "$(echo "${2}_${1}()"; declare -f ${1} | tail -n +2)"
29}
30
Ian Wienandaee18c72014-02-21 15:35:08 +110031function _has_n1kv_subplugin {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070032 local subplugin
33 for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do
34 if [[ "$subplugin" == "n1kv" ]]; then
35 return 0
36 fi
37 done
38 return 1
39}
40
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070041# Prefix openvswitch plugin routines with "ovs" in order to differentiate from
42# cisco plugin routines. This means, ovs plugin routines will coexist with cisco
43# plugin routines in this script.
Mark McClainb05c8762013-07-06 23:29:39 -040044source $TOP_DIR/lib/neutron_plugins/openvswitch
45_prefix_function neutron_plugin_create_nova_conf ovs
46_prefix_function neutron_plugin_install_agent_packages ovs
47_prefix_function neutron_plugin_configure_common ovs
48_prefix_function neutron_plugin_configure_debug_command ovs
49_prefix_function neutron_plugin_configure_dhcp_agent ovs
50_prefix_function neutron_plugin_configure_l3_agent ovs
51_prefix_function neutron_plugin_configure_plugin_agent ovs
52_prefix_function neutron_plugin_configure_service ovs
53_prefix_function neutron_plugin_setup_interface_driver ovs
54_prefix_function has_neutron_plugin_security_group ovs
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070055
Ian Wienandaee18c72014-02-21 15:35:08 +110056function has_neutron_plugin_security_group {
Pritesh Kothari107278f2014-09-15 09:29:55 -070057 return 1
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070058}
59
Ian Wienandaee18c72014-02-21 15:35:08 +110060function is_neutron_ovs_base_plugin {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070061 return
62}
63
64# populate required nova configuration parameters
Ian Wienandaee18c72014-02-21 15:35:08 +110065function neutron_plugin_create_nova_conf {
Pritesh Kothari107278f2014-09-15 09:29:55 -070066 _neutron_ovs_base_configure_nova_vif_driver
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070067}
68
Ian Wienandaee18c72014-02-21 15:35:08 +110069function neutron_plugin_install_agent_packages {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070070 # Cisco plugin uses openvswitch to operate in one of its configurations
Mark McClainb05c8762013-07-06 23:29:39 -040071 ovs_neutron_plugin_install_agent_packages
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070072}
73
74# Configure common parameters
Ian Wienandaee18c72014-02-21 15:35:08 +110075function neutron_plugin_configure_common {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070076 # setup default subplugins
77 if [ ! -v Q_CISCO_PLUGIN_SUBPLUGINS ]; then
78 declare -ga Q_CISCO_PLUGIN_SUBPLUGINS
Pritesh Kothari107278f2014-09-15 09:29:55 -070079 Q_CISCO_PLUGIN_SUBPLUGINS=(n1kv)
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070080 fi
Pritesh Kothari107278f2014-09-15 09:29:55 -070081 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/cisco
82 Q_PLUGIN_CONF_FILENAME=cisco_plugins.ini
Mark McClainb05c8762013-07-06 23:29:39 -040083 Q_PLUGIN_CLASS="neutron.plugins.cisco.network_plugin.PluginV2"
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070084}
85
Ian Wienandaee18c72014-02-21 15:35:08 +110086function neutron_plugin_configure_debug_command {
Rob2a6215d2014-10-20 13:28:47 +010087 :
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070088}
89
Ian Wienandaee18c72014-02-21 15:35:08 +110090function neutron_plugin_configure_dhcp_agent {
Mark McClainb05c8762013-07-06 23:29:39 -040091 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070092}
93
Ian Wienandaee18c72014-02-21 15:35:08 +110094function neutron_plugin_configure_l3_agent {
Rob2a6215d2014-10-20 13:28:47 +010095 :
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070096}
97
98# Configure n1kv plugin
Ian Wienandaee18c72014-02-21 15:35:08 +110099function _configure_n1kv_subplugin {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700100 local cisco_cfg_file=$1
101
102 # populate the cisco plugin cfg file with the VSM information
103 echo "Configuring n1kv in $cisco_cfg_file-- $Q_CISCO_PLUGIN_VSM_IP $Q_CISCO_PLUGIN_VSM_USERNAME $Q_CISCO_PLUGIN_VSM_PASSWORD"
104 iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP username $Q_CISCO_PLUGIN_VSM_USERNAME
105 iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP password $Q_CISCO_PLUGIN_VSM_PASSWORD
106
107 iniset $cisco_cfg_file CISCO_N1K integration_bridge $Q_CISCO_PLUGIN_INTEGRATION_BRIDGE
108 iniset $cisco_cfg_file CISCO_N1K enable_tunneling $Q_CISCO_PLUGIN_ENABLE_TUNNELING
109 iniset $cisco_cfg_file CISCO_N1K vxlan_id_ranges $Q_CISCO_PLUGIN_VXLAN_ID_RANGES
110 iniset $cisco_cfg_file CISCO_N1K network_vlan_ranges $Q_CISCO_PLUGIN_VLAN_RANGES
111
112 # Setup the integration bridge by calling the ovs_base
113 OVS_BRIDGE=$Q_CISCO_PLUGIN_INTEGRATION_BRIDGE
Mark McClainb05c8762013-07-06 23:29:39 -0400114 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700115}
116
Ian Wienandaee18c72014-02-21 15:35:08 +1100117function neutron_plugin_configure_plugin_agent {
Rob2a6215d2014-10-20 13:28:47 +0100118 :
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700119}
120
Ian Wienandaee18c72014-02-21 15:35:08 +1100121function neutron_plugin_configure_service {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700122 local subplugin
123 local cisco_cfg_file
124
Pritesh Kothari107278f2014-09-15 09:29:55 -0700125 cisco_cfg_file=/$Q_PLUGIN_CONF_FILE
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700126
127 # Setup the [CISCO_PLUGINS] section
128 if [[ ${#Q_CISCO_PLUGIN_SUBPLUGINS[@]} > 2 ]]; then
129 die $LINENO "At most two subplugins are supported."
130 fi
131
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700132 # Setup the subplugins
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700133 inicomment $cisco_cfg_file CISCO_PLUGINS vswitch_plugin
134 inicomment $cisco_cfg_file CISCO_TEST host
135 for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do
136 case $subplugin in
Mark McClainb05c8762013-07-06 23:29:39 -0400137 n1kv) iniset $cisco_cfg_file CISCO_PLUGINS vswitch_plugin neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2;;
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700138 *) die $LINENO "Unsupported cisco subplugin: $subplugin";;
139 esac
140 done
141
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700142 if _has_n1kv_subplugin; then
143 _configure_n1kv_subplugin $cisco_cfg_file
144 fi
145}
146
Robd06a6d92014-12-04 20:32:22 +0000147function neutron_plugin_create_initial_network_profile {
148 neutron cisco-network-profile-create default_network_profile vlan --segment_range 1-3000 --physical_network "$1"
149}
150
Ian Wienandaee18c72014-02-21 15:35:08 +1100151function neutron_plugin_setup_interface_driver {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700152 local conf_file=$1
Martin Hickeydca49de2015-10-20 12:13:19 +0100153 iniset $conf_file DEFAULT interface_driver openvswitch
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700154}
155
156# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500157$CISCO_XTRACE