| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 1 | # Neutron Cisco plugin | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 2 | # --------------------------- | 
 | 3 |  | 
 | 4 | # Save trace setting | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 5 | CISCO_XTRACE=$(set +o | grep xtrace) | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 6 | set +o xtrace | 
 | 7 |  | 
 | 8 | # Scecify the VSM parameters | 
 | 9 | Q_CISCO_PLUGIN_VSM_IP=${Q_CISCO_PLUGIN_VSM_IP:-} | 
 | 10 | # Specify the VSM username | 
 | 11 | Q_CISCO_PLUGIN_VSM_USERNAME=${Q_CISCO_PLUGIN_VSM_USERNAME:-admin} | 
 | 12 | # Specify the VSM passward for above username | 
 | 13 | Q_CISCO_PLUGIN_VSM_PASSWORD=${Q_CISCO_PLUGIN_VSM_PASSWORD:-} | 
 | 14 | # Specify the uVEM integration bridge name | 
 | 15 | Q_CISCO_PLUGIN_INTEGRATION_BRIDGE=${Q_CISCO_PLUGIN_INTEGRATION_BRIDGE:-br-int} | 
 | 16 | # Specify if tunneling is enabled | 
 | 17 | Q_CISCO_PLUGIN_ENABLE_TUNNELING=${Q_CISCO_PLUGIN_ENABLE_TUNNELING:-True} | 
 | 18 | # Specify the VXLAN range | 
 | 19 | Q_CISCO_PLUGIN_VXLAN_ID_RANGES=${Q_CISCO_PLUGIN_VXLAN_ID_RANGES:-5000:10000} | 
 | 20 | # Specify the VLAN range | 
 | 21 | Q_CISCO_PLUGIN_VLAN_RANGES=${Q_CISCO_PLUGIN_VLAN_RANGES:-vlan:1:4094} | 
 | 22 |  | 
 | 23 | # Specify ncclient package information | 
 | 24 | NCCLIENT_DIR=$DEST/ncclient | 
 | 25 | NCCLIENT_VERSION=${NCCLIENT_VERSION:-0.3.1} | 
| Shweta P | de3b820 | 2014-03-03 13:38:37 -0500 | [diff] [blame] | 26 | NCCLIENT_REPO=${NCCLIENT_REPO:-git://github.com/CiscoSystems/ncclient.git} | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 27 | NCCLIENT_BRANCH=${NCCLIENT_BRANCH:-master} | 
 | 28 |  | 
 | 29 | # This routine put a prefix on an existing function name | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 30 | function _prefix_function { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 31 |     declare -F $1 > /dev/null || die "$1 doesn't exist" | 
 | 32 |     eval "$(echo "${2}_${1}()"; declare -f ${1} | tail -n +2)" | 
 | 33 | } | 
 | 34 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 35 | function _has_ovs_subplugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 36 |     local subplugin | 
 | 37 |     for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do | 
 | 38 |         if [[ "$subplugin" == "openvswitch" ]]; then | 
 | 39 |             return 0 | 
 | 40 |         fi | 
 | 41 |     done | 
 | 42 |     return 1 | 
 | 43 | } | 
 | 44 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 45 | function _has_nexus_subplugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 46 |     local subplugin | 
 | 47 |     for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do | 
 | 48 |         if [[ "$subplugin" == "nexus" ]]; then | 
 | 49 |             return 0 | 
 | 50 |         fi | 
 | 51 |     done | 
 | 52 |     return 1 | 
 | 53 | } | 
 | 54 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 55 | function _has_n1kv_subplugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 56 |     local subplugin | 
 | 57 |     for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do | 
 | 58 |         if [[ "$subplugin" == "n1kv" ]]; then | 
 | 59 |             return 0 | 
 | 60 |         fi | 
 | 61 |     done | 
 | 62 |     return 1 | 
 | 63 | } | 
 | 64 |  | 
 | 65 | # This routine populates the cisco config file with the information for | 
 | 66 | # a particular nexus switch | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 67 | function _config_switch { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 68 |     local cisco_cfg_file=$1 | 
 | 69 |     local switch_ip=$2 | 
 | 70 |     local username=$3 | 
 | 71 |     local password=$4 | 
 | 72 |     local ssh_port=$5 | 
 | 73 |     shift 5 | 
 | 74 |  | 
 | 75 |     local section="NEXUS_SWITCH:$switch_ip" | 
 | 76 |     iniset $cisco_cfg_file $section username $username | 
 | 77 |     iniset $cisco_cfg_file $section password $password | 
 | 78 |     iniset $cisco_cfg_file $section ssh_port $ssh_port | 
 | 79 |  | 
 | 80 |     while [[ ${#@} != 0 ]]; do | 
 | 81 |         iniset  $cisco_cfg_file $section $1 $2 | 
 | 82 |         shift 2 | 
 | 83 |     done | 
 | 84 | } | 
 | 85 |  | 
 | 86 | # Prefix openvswitch plugin routines with "ovs" in order to differentiate from | 
 | 87 | # cisco plugin routines. This means, ovs plugin routines will coexist with cisco | 
 | 88 | # plugin routines in this script. | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 89 | source $TOP_DIR/lib/neutron_plugins/openvswitch | 
 | 90 | _prefix_function neutron_plugin_create_nova_conf ovs | 
 | 91 | _prefix_function neutron_plugin_install_agent_packages ovs | 
 | 92 | _prefix_function neutron_plugin_configure_common ovs | 
 | 93 | _prefix_function neutron_plugin_configure_debug_command ovs | 
 | 94 | _prefix_function neutron_plugin_configure_dhcp_agent ovs | 
 | 95 | _prefix_function neutron_plugin_configure_l3_agent ovs | 
 | 96 | _prefix_function neutron_plugin_configure_plugin_agent ovs | 
 | 97 | _prefix_function neutron_plugin_configure_service ovs | 
 | 98 | _prefix_function neutron_plugin_setup_interface_driver ovs | 
 | 99 | _prefix_function has_neutron_plugin_security_group ovs | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 100 |  | 
 | 101 | # Check the version of the installed ncclient package | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 102 | function check_ncclient_version { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 103 | python << EOF | 
 | 104 | version = '$NCCLIENT_VERSION' | 
 | 105 | import sys | 
 | 106 | try: | 
 | 107 |     import pkg_resources | 
 | 108 |     import ncclient | 
 | 109 |     module_version = pkg_resources.get_distribution('ncclient').version | 
 | 110 |     if version != module_version: | 
 | 111 |         sys.exit(1) | 
 | 112 | except: | 
 | 113 |     sys.exit(1) | 
 | 114 | EOF | 
 | 115 | } | 
 | 116 |  | 
 | 117 | # Install the ncclient package | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 118 | function install_ncclient { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 119 |     git_clone $NCCLIENT_REPO $NCCLIENT_DIR $NCCLIENT_BRANCH | 
 | 120 |     (cd $NCCLIENT_DIR; sudo python setup.py install) | 
 | 121 | } | 
 | 122 |  | 
 | 123 | # Check if the required version of ncclient has been installed | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 124 | function is_ncclient_installed { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 125 |     # Check if the Cisco ncclient repository exists | 
 | 126 |     if [[ -d $NCCLIENT_DIR ]]; then | 
 | 127 |         remotes=$(cd $NCCLIENT_DIR; git remote -v | grep fetch | awk '{ print $2}') | 
 | 128 |         for remote in $remotes; do | 
 | 129 |             if [[ $remote == $NCCLIENT_REPO ]]; then | 
 | 130 |                 break; | 
 | 131 |             fi | 
 | 132 |         done | 
 | 133 |         if [[ $remote != $NCCLIENT_REPO ]]; then | 
 | 134 |             return 1 | 
 | 135 |         fi | 
 | 136 |     else | 
 | 137 |         return 1 | 
 | 138 |     fi | 
 | 139 |  | 
 | 140 |     # Check if the ncclient is installed with the right version | 
 | 141 |     if ! check_ncclient_version; then | 
 | 142 |         return 1 | 
 | 143 |     fi | 
 | 144 |     return 0 | 
 | 145 | } | 
 | 146 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 147 | function has_neutron_plugin_security_group { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 148 |     if _has_ovs_subplugin; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 149 |         ovs_has_neutron_plugin_security_group | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 150 |     else | 
 | 151 |         return 1 | 
 | 152 |     fi | 
 | 153 | } | 
 | 154 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 155 | function is_neutron_ovs_base_plugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 156 |     # Cisco uses OVS if openvswitch subplugin is deployed | 
 | 157 |     _has_ovs_subplugin | 
 | 158 |     return | 
 | 159 | } | 
 | 160 |  | 
 | 161 | # populate required nova configuration parameters | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 162 | function neutron_plugin_create_nova_conf { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 163 |     if _has_ovs_subplugin; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 164 |         ovs_neutron_plugin_create_nova_conf | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 165 |     else | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 166 |         _neutron_ovs_base_configure_nova_vif_driver | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 167 |     fi | 
 | 168 | } | 
 | 169 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 170 | function neutron_plugin_install_agent_packages { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 171 |     # Cisco plugin uses openvswitch to operate in one of its configurations | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 172 |     ovs_neutron_plugin_install_agent_packages | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 173 | } | 
 | 174 |  | 
 | 175 | # Configure common parameters | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 176 | function neutron_plugin_configure_common { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 177 |     # setup default subplugins | 
 | 178 |     if [ ! -v Q_CISCO_PLUGIN_SUBPLUGINS ]; then | 
 | 179 |         declare -ga Q_CISCO_PLUGIN_SUBPLUGINS | 
 | 180 |         Q_CISCO_PLUGIN_SUBPLUGINS=(openvswitch nexus) | 
 | 181 |     fi | 
 | 182 |     if _has_ovs_subplugin; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 183 |         ovs_neutron_plugin_configure_common | 
 | 184 |         Q_PLUGIN_EXTRA_CONF_PATH=etc/neutron/plugins/cisco | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 185 |         Q_PLUGIN_EXTRA_CONF_FILES=(cisco_plugins.ini) | 
| Dane LeBlanc | c68a8f6 | 2014-03-20 19:10:08 -0400 | [diff] [blame] | 186 |         # Copy extra config files to /etc so that they can be modified | 
 | 187 |         # later according to Cisco-specific localrc settings. | 
 | 188 |         mkdir -p /$Q_PLUGIN_EXTRA_CONF_PATH | 
 | 189 |         local f | 
 | 190 |         local extra_conf_file | 
 | 191 |         for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do | 
 | 192 |             extra_conf_file=$Q_PLUGIN_EXTRA_CONF_PATH/${Q_PLUGIN_EXTRA_CONF_FILES[$f]} | 
 | 193 |             cp $NEUTRON_DIR/$extra_conf_file /$extra_conf_file | 
 | 194 |         done | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 195 |     else | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 196 |         Q_PLUGIN_CONF_PATH=etc/neutron/plugins/cisco | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 197 |         Q_PLUGIN_CONF_FILENAME=cisco_plugins.ini | 
 | 198 |     fi | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 199 |     Q_PLUGIN_CLASS="neutron.plugins.cisco.network_plugin.PluginV2" | 
 | 200 |     Q_DB_NAME=cisco_neutron | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 201 | } | 
 | 202 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 203 | function neutron_plugin_configure_debug_command { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 204 |     if _has_ovs_subplugin; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 205 |         ovs_neutron_plugin_configure_debug_command | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 206 |     fi | 
 | 207 | } | 
 | 208 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 209 | function neutron_plugin_configure_dhcp_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 210 |     iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 211 | } | 
 | 212 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 213 | function neutron_plugin_configure_l3_agent { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 214 |     if _has_ovs_subplugin; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 215 |         ovs_neutron_plugin_configure_l3_agent | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 216 |     fi | 
 | 217 | } | 
 | 218 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 219 | function _configure_nexus_subplugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 220 |     local cisco_cfg_file=$1 | 
 | 221 |  | 
 | 222 |     # Install a known compatible ncclient from the Cisco repository if necessary | 
 | 223 |     if ! is_ncclient_installed; then | 
 | 224 |         # Preserve the two global variables | 
 | 225 |         local offline=$OFFLINE | 
 | 226 |         local reclone=$RECLONE | 
 | 227 |         # Change their values to allow installation | 
 | 228 |         OFFLINE=False | 
 | 229 |         RECLONE=yes | 
 | 230 |         install_ncclient | 
 | 231 |         # Restore their values | 
 | 232 |         OFFLINE=$offline | 
 | 233 |         RECLONE=$reclone | 
 | 234 |     fi | 
 | 235 |  | 
 | 236 |     # Setup default nexus switch information | 
 | 237 |     if [ ! -v Q_CISCO_PLUGIN_SWITCH_INFO ]; then | 
 | 238 |         declare -A Q_CISCO_PLUGIN_SWITCH_INFO | 
 | 239 |         HOST_NAME=$(hostname) | 
 | 240 |         Q_CISCO_PLUGIN_SWITCH_INFO=([1.1.1.1]=stack:stack:22:${HOST_NAME}:1/10) | 
 | 241 |     else | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 242 |         iniset $cisco_cfg_file CISCO nexus_driver neutron.plugins.cisco.nexus.cisco_nexus_network_driver_v2.CiscoNEXUSDriver | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 243 |     fi | 
 | 244 |  | 
 | 245 |     # Setup the switch configurations | 
 | 246 |     local nswitch | 
 | 247 |     local sw_info | 
 | 248 |     local segment | 
 | 249 |     local sw_info_array | 
 | 250 |     declare -i count=0 | 
 | 251 |     for nswitch in ${!Q_CISCO_PLUGIN_SWITCH_INFO[@]}; do | 
 | 252 |         sw_info=${Q_CISCO_PLUGIN_SWITCH_INFO[$nswitch]} | 
 | 253 |         sw_info_array=${sw_info//:/ } | 
 | 254 |         sw_info_array=( $sw_info_array ) | 
 | 255 |         count=${#sw_info_array[@]} | 
 | 256 |         if [[ $count < 5 || $(( ($count-3) % 2 )) != 0 ]]; then | 
 | 257 |             die $LINENO "Incorrect switch configuration: ${Q_CISCO_PLUGIN_SWITCH_INFO[$nswitch]}" | 
 | 258 |         fi | 
 | 259 |         _config_switch $cisco_cfg_file $nswitch ${sw_info_array[@]} | 
 | 260 |     done | 
 | 261 | } | 
 | 262 |  | 
 | 263 | # Configure n1kv plugin | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 264 | function _configure_n1kv_subplugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 265 |     local cisco_cfg_file=$1 | 
 | 266 |  | 
 | 267 |     # populate the cisco plugin cfg file with the VSM information | 
 | 268 |     echo "Configuring n1kv in $cisco_cfg_file-- $Q_CISCO_PLUGIN_VSM_IP $Q_CISCO_PLUGIN_VSM_USERNAME $Q_CISCO_PLUGIN_VSM_PASSWORD" | 
 | 269 |     iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP username $Q_CISCO_PLUGIN_VSM_USERNAME | 
 | 270 |     iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP password $Q_CISCO_PLUGIN_VSM_PASSWORD | 
 | 271 |  | 
 | 272 |     iniset $cisco_cfg_file CISCO_N1K integration_bridge $Q_CISCO_PLUGIN_INTEGRATION_BRIDGE | 
 | 273 |     iniset $cisco_cfg_file CISCO_N1K enable_tunneling $Q_CISCO_PLUGIN_ENABLE_TUNNELING | 
 | 274 |     iniset $cisco_cfg_file CISCO_N1K vxlan_id_ranges $Q_CISCO_PLUGIN_VXLAN_ID_RANGES | 
 | 275 |     iniset $cisco_cfg_file CISCO_N1K network_vlan_ranges $Q_CISCO_PLUGIN_VLAN_RANGES | 
 | 276 |  | 
 | 277 |     # Setup the integration bridge by calling the ovs_base | 
 | 278 |     OVS_BRIDGE=$Q_CISCO_PLUGIN_INTEGRATION_BRIDGE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 279 |     _neutron_ovs_base_setup_bridge $OVS_BRIDGE | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 280 | } | 
 | 281 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 282 | function neutron_plugin_configure_plugin_agent { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 283 |     if _has_ovs_subplugin; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 284 |         ovs_neutron_plugin_configure_plugin_agent | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 285 |     fi | 
 | 286 | } | 
 | 287 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 288 | function neutron_plugin_configure_service { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 289 |     local subplugin | 
 | 290 |     local cisco_cfg_file | 
 | 291 |  | 
 | 292 |     if _has_ovs_subplugin; then | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 293 |         ovs_neutron_plugin_configure_service | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 294 |         cisco_cfg_file=/${Q_PLUGIN_EXTRA_CONF_FILES[0]} | 
 | 295 |     else | 
 | 296 |         cisco_cfg_file=/$Q_PLUGIN_CONF_FILE | 
 | 297 |     fi | 
 | 298 |  | 
 | 299 |     # Setup the [CISCO_PLUGINS] section | 
 | 300 |     if [[ ${#Q_CISCO_PLUGIN_SUBPLUGINS[@]} > 2 ]]; then | 
 | 301 |         die $LINENO "At most two subplugins are supported." | 
 | 302 |     fi | 
 | 303 |  | 
 | 304 |     if _has_ovs_subplugin && _has_n1kv_subplugin; then | 
 | 305 |         die $LINENO "OVS subplugin and n1kv subplugin cannot coexist" | 
 | 306 |     fi | 
 | 307 |  | 
 | 308 |     # Setup the subplugins | 
 | 309 |     inicomment $cisco_cfg_file CISCO_PLUGINS nexus_plugin | 
 | 310 |     inicomment $cisco_cfg_file CISCO_PLUGINS vswitch_plugin | 
 | 311 |     inicomment $cisco_cfg_file CISCO_TEST host | 
 | 312 |     for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do | 
 | 313 |         case $subplugin in | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 314 |             nexus) iniset $cisco_cfg_file CISCO_PLUGINS nexus_plugin neutron.plugins.cisco.nexus.cisco_nexus_plugin_v2.NexusPlugin;; | 
 | 315 |             openvswitch) iniset $cisco_cfg_file CISCO_PLUGINS vswitch_plugin neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2;; | 
 | 316 |             n1kv) iniset $cisco_cfg_file CISCO_PLUGINS vswitch_plugin neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2;; | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 317 |             *) die $LINENO "Unsupported cisco subplugin: $subplugin";; | 
 | 318 |         esac | 
 | 319 |     done | 
 | 320 |  | 
 | 321 |     if _has_nexus_subplugin; then | 
 | 322 |         _configure_nexus_subplugin $cisco_cfg_file | 
 | 323 |     fi | 
 | 324 |  | 
 | 325 |     if _has_n1kv_subplugin; then | 
 | 326 |         _configure_n1kv_subplugin $cisco_cfg_file | 
 | 327 |     fi | 
 | 328 | } | 
 | 329 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 330 | function neutron_plugin_setup_interface_driver { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 331 |     local conf_file=$1 | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 332 |     iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 333 | } | 
 | 334 |  | 
 | 335 | # Restore xtrace | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 336 | $CISCO_XTRACE |