| 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 |  | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 23 | # This routine put a prefix on an existing function name | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 24 | function _prefix_function { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 25 |     declare -F $1 > /dev/null || die "$1 doesn't exist" | 
 | 26 |     eval "$(echo "${2}_${1}()"; declare -f ${1} | tail -n +2)" | 
 | 27 | } | 
 | 28 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 29 | function _has_n1kv_subplugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 30 |     local subplugin | 
 | 31 |     for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do | 
 | 32 |         if [[ "$subplugin" == "n1kv" ]]; then | 
 | 33 |             return 0 | 
 | 34 |         fi | 
 | 35 |     done | 
 | 36 |     return 1 | 
 | 37 | } | 
 | 38 |  | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 39 | # Prefix openvswitch plugin routines with "ovs" in order to differentiate from | 
 | 40 | # cisco plugin routines. This means, ovs plugin routines will coexist with cisco | 
 | 41 | # plugin routines in this script. | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 42 | source $TOP_DIR/lib/neutron_plugins/openvswitch | 
 | 43 | _prefix_function neutron_plugin_create_nova_conf ovs | 
 | 44 | _prefix_function neutron_plugin_install_agent_packages ovs | 
 | 45 | _prefix_function neutron_plugin_configure_common ovs | 
 | 46 | _prefix_function neutron_plugin_configure_debug_command ovs | 
 | 47 | _prefix_function neutron_plugin_configure_dhcp_agent ovs | 
 | 48 | _prefix_function neutron_plugin_configure_l3_agent ovs | 
 | 49 | _prefix_function neutron_plugin_configure_plugin_agent ovs | 
 | 50 | _prefix_function neutron_plugin_configure_service ovs | 
 | 51 | _prefix_function neutron_plugin_setup_interface_driver ovs | 
 | 52 | _prefix_function has_neutron_plugin_security_group ovs | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 53 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 54 | function has_neutron_plugin_security_group { | 
| Pritesh Kothari | 107278f | 2014-09-15 09:29:55 -0700 | [diff] [blame] | 55 |     return 1 | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 56 | } | 
 | 57 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 58 | function is_neutron_ovs_base_plugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 59 |     return | 
 | 60 | } | 
 | 61 |  | 
 | 62 | # populate required nova configuration parameters | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 63 | function neutron_plugin_create_nova_conf { | 
| Pritesh Kothari | 107278f | 2014-09-15 09:29:55 -0700 | [diff] [blame] | 64 |     _neutron_ovs_base_configure_nova_vif_driver | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 65 | } | 
 | 66 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 67 | function neutron_plugin_install_agent_packages { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 68 |     # Cisco plugin uses openvswitch to operate in one of its configurations | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 69 |     ovs_neutron_plugin_install_agent_packages | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 70 | } | 
 | 71 |  | 
 | 72 | # Configure common parameters | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 73 | function neutron_plugin_configure_common { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 74 |     # setup default subplugins | 
 | 75 |     if [ ! -v Q_CISCO_PLUGIN_SUBPLUGINS ]; then | 
 | 76 |         declare -ga Q_CISCO_PLUGIN_SUBPLUGINS | 
| Pritesh Kothari | 107278f | 2014-09-15 09:29:55 -0700 | [diff] [blame] | 77 |         Q_CISCO_PLUGIN_SUBPLUGINS=(n1kv) | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 78 |     fi | 
| Pritesh Kothari | 107278f | 2014-09-15 09:29:55 -0700 | [diff] [blame] | 79 |     Q_PLUGIN_CONF_PATH=etc/neutron/plugins/cisco | 
 | 80 |     Q_PLUGIN_CONF_FILENAME=cisco_plugins.ini | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 81 |     Q_PLUGIN_CLASS="neutron.plugins.cisco.network_plugin.PluginV2" | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 82 | } | 
 | 83 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 84 | function neutron_plugin_configure_debug_command { | 
| Rob | 2a6215d | 2014-10-20 13:28:47 +0100 | [diff] [blame^] | 85 |     : | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 86 | } | 
 | 87 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 88 | function neutron_plugin_configure_dhcp_agent { | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 89 |     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] | 90 | } | 
 | 91 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 92 | function neutron_plugin_configure_l3_agent { | 
| Rob | 2a6215d | 2014-10-20 13:28:47 +0100 | [diff] [blame^] | 93 |     : | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 94 | } | 
 | 95 |  | 
 | 96 | # Configure n1kv plugin | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 97 | function _configure_n1kv_subplugin { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 98 |     local cisco_cfg_file=$1 | 
 | 99 |  | 
 | 100 |     # populate the cisco plugin cfg file with the VSM information | 
 | 101 |     echo "Configuring n1kv in $cisco_cfg_file-- $Q_CISCO_PLUGIN_VSM_IP $Q_CISCO_PLUGIN_VSM_USERNAME $Q_CISCO_PLUGIN_VSM_PASSWORD" | 
 | 102 |     iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP username $Q_CISCO_PLUGIN_VSM_USERNAME | 
 | 103 |     iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP password $Q_CISCO_PLUGIN_VSM_PASSWORD | 
 | 104 |  | 
 | 105 |     iniset $cisco_cfg_file CISCO_N1K integration_bridge $Q_CISCO_PLUGIN_INTEGRATION_BRIDGE | 
 | 106 |     iniset $cisco_cfg_file CISCO_N1K enable_tunneling $Q_CISCO_PLUGIN_ENABLE_TUNNELING | 
 | 107 |     iniset $cisco_cfg_file CISCO_N1K vxlan_id_ranges $Q_CISCO_PLUGIN_VXLAN_ID_RANGES | 
 | 108 |     iniset $cisco_cfg_file CISCO_N1K network_vlan_ranges $Q_CISCO_PLUGIN_VLAN_RANGES | 
 | 109 |  | 
 | 110 |     # Setup the integration bridge by calling the ovs_base | 
 | 111 |     OVS_BRIDGE=$Q_CISCO_PLUGIN_INTEGRATION_BRIDGE | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 112 |     _neutron_ovs_base_setup_bridge $OVS_BRIDGE | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 113 | } | 
 | 114 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 115 | function neutron_plugin_configure_plugin_agent { | 
| Rob | 2a6215d | 2014-10-20 13:28:47 +0100 | [diff] [blame^] | 116 |     : | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 117 | } | 
 | 118 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 119 | function neutron_plugin_configure_service { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 120 |     local subplugin | 
 | 121 |     local cisco_cfg_file | 
 | 122 |  | 
| Pritesh Kothari | 107278f | 2014-09-15 09:29:55 -0700 | [diff] [blame] | 123 |     cisco_cfg_file=/$Q_PLUGIN_CONF_FILE | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 124 |  | 
 | 125 |     # Setup the [CISCO_PLUGINS] section | 
 | 126 |     if [[ ${#Q_CISCO_PLUGIN_SUBPLUGINS[@]} > 2 ]]; then | 
 | 127 |         die $LINENO "At most two subplugins are supported." | 
 | 128 |     fi | 
 | 129 |  | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 130 |     # Setup the subplugins | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 131 |     inicomment $cisco_cfg_file CISCO_PLUGINS vswitch_plugin | 
 | 132 |     inicomment $cisco_cfg_file CISCO_TEST host | 
 | 133 |     for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do | 
 | 134 |         case $subplugin in | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 135 |             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] | 136 |             *) die $LINENO "Unsupported cisco subplugin: $subplugin";; | 
 | 137 |         esac | 
 | 138 |     done | 
 | 139 |  | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 140 |     if _has_n1kv_subplugin; then | 
 | 141 |         _configure_n1kv_subplugin $cisco_cfg_file | 
 | 142 |     fi | 
 | 143 | } | 
 | 144 |  | 
| Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 145 | function neutron_plugin_setup_interface_driver { | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 146 |     local conf_file=$1 | 
| Mark McClain | b05c876 | 2013-07-06 23:29:39 -0400 | [diff] [blame] | 147 |     iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver | 
| Baodong (Robert) Li | 901419d | 2013-06-10 08:39:26 -0700 | [diff] [blame] | 148 | } | 
 | 149 |  | 
 | 150 | # Restore xtrace | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 151 | $CISCO_XTRACE |