blob: 1406e3790c479722b7490d0bd3b12140c16a2b48 [file] [log] [blame]
Mark McClainb05c8762013-07-06 23:29:39 -04001# Neutron Cisco plugin
Baodong (Robert) Li901419d2013-06-10 08:39:26 -07002# ---------------------------
3
4# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05005CISCO_XTRACE=$(set +o | grep xtrace)
Baodong (Robert) Li901419d2013-06-10 08:39:26 -07006set +o xtrace
7
8# Scecify the VSM parameters
9Q_CISCO_PLUGIN_VSM_IP=${Q_CISCO_PLUGIN_VSM_IP:-}
10# Specify the VSM username
11Q_CISCO_PLUGIN_VSM_USERNAME=${Q_CISCO_PLUGIN_VSM_USERNAME:-admin}
12# Specify the VSM passward for above username
13Q_CISCO_PLUGIN_VSM_PASSWORD=${Q_CISCO_PLUGIN_VSM_PASSWORD:-}
14# Specify the uVEM integration bridge name
15Q_CISCO_PLUGIN_INTEGRATION_BRIDGE=${Q_CISCO_PLUGIN_INTEGRATION_BRIDGE:-br-int}
16# Specify if tunneling is enabled
17Q_CISCO_PLUGIN_ENABLE_TUNNELING=${Q_CISCO_PLUGIN_ENABLE_TUNNELING:-True}
18# Specify the VXLAN range
19Q_CISCO_PLUGIN_VXLAN_ID_RANGES=${Q_CISCO_PLUGIN_VXLAN_ID_RANGES:-5000:10000}
20# Specify the VLAN range
21Q_CISCO_PLUGIN_VLAN_RANGES=${Q_CISCO_PLUGIN_VLAN_RANGES:-vlan:1:4094}
22
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070023# This routine put a prefix on an existing function name
Ian Wienandaee18c72014-02-21 15:35:08 +110024function _prefix_function {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070025 declare -F $1 > /dev/null || die "$1 doesn't exist"
26 eval "$(echo "${2}_${1}()"; declare -f ${1} | tail -n +2)"
27}
28
Ian Wienandaee18c72014-02-21 15:35:08 +110029function _has_n1kv_subplugin {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070030 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) Li901419d2013-06-10 08:39:26 -070039# 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 McClainb05c8762013-07-06 23:29:39 -040042source $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) Li901419d2013-06-10 08:39:26 -070053
Ian Wienandaee18c72014-02-21 15:35:08 +110054function has_neutron_plugin_security_group {
Pritesh Kothari107278f2014-09-15 09:29:55 -070055 return 1
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070056}
57
Ian Wienandaee18c72014-02-21 15:35:08 +110058function is_neutron_ovs_base_plugin {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070059 return
60}
61
62# populate required nova configuration parameters
Ian Wienandaee18c72014-02-21 15:35:08 +110063function neutron_plugin_create_nova_conf {
Pritesh Kothari107278f2014-09-15 09:29:55 -070064 _neutron_ovs_base_configure_nova_vif_driver
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070065}
66
Ian Wienandaee18c72014-02-21 15:35:08 +110067function neutron_plugin_install_agent_packages {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070068 # Cisco plugin uses openvswitch to operate in one of its configurations
Mark McClainb05c8762013-07-06 23:29:39 -040069 ovs_neutron_plugin_install_agent_packages
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070070}
71
72# Configure common parameters
Ian Wienandaee18c72014-02-21 15:35:08 +110073function neutron_plugin_configure_common {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070074 # setup default subplugins
75 if [ ! -v Q_CISCO_PLUGIN_SUBPLUGINS ]; then
76 declare -ga Q_CISCO_PLUGIN_SUBPLUGINS
Pritesh Kothari107278f2014-09-15 09:29:55 -070077 Q_CISCO_PLUGIN_SUBPLUGINS=(n1kv)
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070078 fi
Pritesh Kothari107278f2014-09-15 09:29:55 -070079 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/cisco
80 Q_PLUGIN_CONF_FILENAME=cisco_plugins.ini
Mark McClainb05c8762013-07-06 23:29:39 -040081 Q_PLUGIN_CLASS="neutron.plugins.cisco.network_plugin.PluginV2"
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070082}
83
Ian Wienandaee18c72014-02-21 15:35:08 +110084function neutron_plugin_configure_debug_command {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070085}
86
Ian Wienandaee18c72014-02-21 15:35:08 +110087function neutron_plugin_configure_dhcp_agent {
Mark McClainb05c8762013-07-06 23:29:39 -040088 iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070089}
90
Ian Wienandaee18c72014-02-21 15:35:08 +110091function neutron_plugin_configure_l3_agent {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070092}
93
94# Configure n1kv plugin
Ian Wienandaee18c72014-02-21 15:35:08 +110095function _configure_n1kv_subplugin {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -070096 local cisco_cfg_file=$1
97
98 # populate the cisco plugin cfg file with the VSM information
99 echo "Configuring n1kv in $cisco_cfg_file-- $Q_CISCO_PLUGIN_VSM_IP $Q_CISCO_PLUGIN_VSM_USERNAME $Q_CISCO_PLUGIN_VSM_PASSWORD"
100 iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP username $Q_CISCO_PLUGIN_VSM_USERNAME
101 iniset $cisco_cfg_file N1KV:$Q_CISCO_PLUGIN_VSM_IP password $Q_CISCO_PLUGIN_VSM_PASSWORD
102
103 iniset $cisco_cfg_file CISCO_N1K integration_bridge $Q_CISCO_PLUGIN_INTEGRATION_BRIDGE
104 iniset $cisco_cfg_file CISCO_N1K enable_tunneling $Q_CISCO_PLUGIN_ENABLE_TUNNELING
105 iniset $cisco_cfg_file CISCO_N1K vxlan_id_ranges $Q_CISCO_PLUGIN_VXLAN_ID_RANGES
106 iniset $cisco_cfg_file CISCO_N1K network_vlan_ranges $Q_CISCO_PLUGIN_VLAN_RANGES
107
108 # Setup the integration bridge by calling the ovs_base
109 OVS_BRIDGE=$Q_CISCO_PLUGIN_INTEGRATION_BRIDGE
Mark McClainb05c8762013-07-06 23:29:39 -0400110 _neutron_ovs_base_setup_bridge $OVS_BRIDGE
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700111}
112
Ian Wienandaee18c72014-02-21 15:35:08 +1100113function neutron_plugin_configure_plugin_agent {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700114}
115
Ian Wienandaee18c72014-02-21 15:35:08 +1100116function neutron_plugin_configure_service {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700117 local subplugin
118 local cisco_cfg_file
119
Pritesh Kothari107278f2014-09-15 09:29:55 -0700120 cisco_cfg_file=/$Q_PLUGIN_CONF_FILE
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700121
122 # Setup the [CISCO_PLUGINS] section
123 if [[ ${#Q_CISCO_PLUGIN_SUBPLUGINS[@]} > 2 ]]; then
124 die $LINENO "At most two subplugins are supported."
125 fi
126
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700127 # Setup the subplugins
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700128 inicomment $cisco_cfg_file CISCO_PLUGINS vswitch_plugin
129 inicomment $cisco_cfg_file CISCO_TEST host
130 for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do
131 case $subplugin in
Mark McClainb05c8762013-07-06 23:29:39 -0400132 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 -0700133 *) die $LINENO "Unsupported cisco subplugin: $subplugin";;
134 esac
135 done
136
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700137 if _has_n1kv_subplugin; then
138 _configure_n1kv_subplugin $cisco_cfg_file
139 fi
140}
141
Ian Wienandaee18c72014-02-21 15:35:08 +1100142function neutron_plugin_setup_interface_driver {
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700143 local conf_file=$1
Mark McClainb05c8762013-07-06 23:29:39 -0400144 iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
Baodong (Robert) Li901419d2013-06-10 08:39:26 -0700145}
146
147# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500148$CISCO_XTRACE