| Sean Dague | e263c82 | 2014-12-05 14:25:28 -0500 | [diff] [blame] | 1 | #!/bin/bash | 
|  | 2 | # | 
| Mohammad Banikazemi | 729236c | 2014-02-05 14:45:04 -0500 | [diff] [blame] | 3 | # Neutron IBM SDN-VE plugin | 
|  | 4 | # --------------------------- | 
|  | 5 |  | 
|  | 6 | # Save trace setting | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 7 | IBM_XTRACE=$(set +o | grep xtrace) | 
| Mohammad Banikazemi | 729236c | 2014-02-05 14:45:04 -0500 | [diff] [blame] | 8 | set +o xtrace | 
|  | 9 |  | 
|  | 10 | source $TOP_DIR/lib/neutron_plugins/ovs_base | 
|  | 11 |  | 
|  | 12 | function neutron_plugin_install_agent_packages { | 
|  | 13 | _neutron_ovs_base_install_agent_packages | 
|  | 14 | } | 
|  | 15 |  | 
|  | 16 | function _neutron_interface_setup { | 
|  | 17 | # Setup one interface on the integration bridge if needed | 
|  | 18 | # The plugin agent to be used if more than one interface is used | 
|  | 19 | local bridge=$1 | 
|  | 20 | local interface=$2 | 
|  | 21 | sudo ovs-vsctl --no-wait -- --may-exist add-port $bridge $interface | 
|  | 22 | } | 
|  | 23 |  | 
|  | 24 | function neutron_setup_integration_bridge { | 
|  | 25 | # Setup integration bridge if needed | 
|  | 26 | if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then | 
|  | 27 | neutron_ovs_base_cleanup | 
|  | 28 | _neutron_ovs_base_setup_bridge $SDNVE_INTEGRATION_BRIDGE | 
|  | 29 | if [[ "$SDNVE_INTERFACE_MAPPINGS" != "" ]]; then | 
|  | 30 | interfaces=(${SDNVE_INTERFACE_MAPPINGS//[,:]/ }) | 
|  | 31 | _neutron_interface_setup $SDNVE_INTEGRATION_BRIDGE ${interfaces[1]} | 
|  | 32 | fi | 
|  | 33 | fi | 
|  | 34 |  | 
|  | 35 | # Set controller to SDNVE controller (1st of list) if exists | 
|  | 36 | if [[ "$SDNVE_CONTROLLER_IPS" != "" ]]; then | 
|  | 37 | # Get the first controller | 
|  | 38 | controllers=(${SDNVE_CONTROLLER_IPS//[\[,\]]/ }) | 
|  | 39 | SDNVE_IP=${controllers[0]} | 
|  | 40 | sudo ovs-vsctl set-controller $SDNVE_INTEGRATION_BRIDGE tcp:$SDNVE_IP | 
|  | 41 | fi | 
|  | 42 | } | 
|  | 43 |  | 
|  | 44 | function neutron_plugin_create_nova_conf { | 
| Mohammad Banikazemi | 729236c | 2014-02-05 14:45:04 -0500 | [diff] [blame] | 45 | # if n-cpu is enabled, then setup integration bridge | 
|  | 46 | if is_service_enabled n-cpu; then | 
|  | 47 | neutron_setup_integration_bridge | 
|  | 48 | fi | 
|  | 49 | } | 
|  | 50 |  | 
|  | 51 | function is_neutron_ovs_base_plugin { | 
|  | 52 | if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then | 
|  | 53 | # Yes, we use OVS. | 
|  | 54 | return 0 | 
|  | 55 | else | 
|  | 56 | # No, we do not use OVS. | 
|  | 57 | return 1 | 
|  | 58 | fi | 
|  | 59 | } | 
|  | 60 |  | 
|  | 61 | function neutron_plugin_configure_common { | 
|  | 62 | Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ibm | 
|  | 63 | Q_PLUGIN_CONF_FILENAME=sdnve_neutron_plugin.ini | 
| Mohammad Banikazemi | 729236c | 2014-02-05 14:45:04 -0500 | [diff] [blame] | 64 | Q_PLUGIN_CLASS="neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2" | 
|  | 65 | } | 
|  | 66 |  | 
|  | 67 | function neutron_plugin_configure_service { | 
|  | 68 | # Define extra "SDNVE" configuration options when q-svc is configured | 
|  | 69 |  | 
|  | 70 | iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver | 
|  | 71 |  | 
|  | 72 | if [[ "$SDNVE_CONTROLLER_IPS" != "" ]]; then | 
|  | 73 | iniset /$Q_PLUGIN_CONF_FILE sdnve controller_ips $SDNVE_CONTROLLER_IPS | 
|  | 74 | fi | 
|  | 75 |  | 
|  | 76 | if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then | 
|  | 77 | iniset /$Q_PLUGIN_CONF_FILE sdnve integration_bridge $SDNVE_INTEGRATION_BRIDGE | 
|  | 78 | fi | 
|  | 79 |  | 
|  | 80 | if [[ "$SDNVE_RESET_BRIDGE" != "" ]]; then | 
|  | 81 | iniset /$Q_PLUGIN_CONF_FILE sdnve reset_bridge $SDNVE_RESET_BRIDGE | 
|  | 82 | fi | 
|  | 83 |  | 
|  | 84 | if [[ "$SDNVE_OUT_OF_BAND" != "" ]]; then | 
|  | 85 | iniset /$Q_PLUGIN_CONF_FILE sdnve out_of_band $SDNVE_OUT_OF_BAND | 
|  | 86 | fi | 
|  | 87 |  | 
|  | 88 | if [[ "$SDNVE_INTERFACE_MAPPINGS" != "" ]]; then | 
|  | 89 | iniset /$Q_PLUGIN_CONF_FILE sdnve interface_mappings $SDNVE_INTERFACE_MAPPINGS | 
|  | 90 | fi | 
|  | 91 |  | 
|  | 92 | if [[ "$SDNVE_FAKE_CONTROLLER" != "" ]]; then | 
|  | 93 | iniset /$Q_PLUGIN_CONF_FILE sdnve use_fake_controller $SDNVE_FAKE_CONTROLLER | 
|  | 94 | fi | 
|  | 95 |  | 
|  | 96 |  | 
|  | 97 | iniset $NEUTRON_CONF DEFAULT notification_driver neutron.openstack.common.notifier.no_op_notifier | 
|  | 98 |  | 
|  | 99 | } | 
|  | 100 |  | 
|  | 101 | function neutron_plugin_configure_plugin_agent { | 
|  | 102 | AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ibm-agent" | 
|  | 103 | } | 
|  | 104 |  | 
|  | 105 | function neutron_plugin_configure_debug_command { | 
|  | 106 | : | 
|  | 107 | } | 
|  | 108 |  | 
|  | 109 | function neutron_plugin_setup_interface_driver { | 
|  | 110 | return 0 | 
|  | 111 | } | 
|  | 112 |  | 
|  | 113 | function has_neutron_plugin_security_group { | 
|  | 114 | # Does not support Security Groups | 
|  | 115 | return 1 | 
|  | 116 | } | 
|  | 117 |  | 
|  | 118 | function neutron_ovs_base_cleanup { | 
|  | 119 | if [[ "$SDNVE_RESET_BRIDGE" != False ]]; then | 
|  | 120 | # remove all OVS ports that look like Neutron created ports | 
|  | 121 | for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do | 
|  | 122 | sudo ovs-vsctl del-port ${port} | 
|  | 123 | done | 
|  | 124 |  | 
|  | 125 | # remove integration bridge created by Neutron | 
|  | 126 | for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${SDNVE_INTEGRATION_BRIDGE}); do | 
|  | 127 | sudo ovs-vsctl del-br ${bridge} | 
|  | 128 | done | 
|  | 129 | fi | 
|  | 130 | } | 
|  | 131 |  | 
|  | 132 | # Restore xtrace | 
| Dean Troyer | e3a9160 | 2014-03-28 12:40:56 -0500 | [diff] [blame] | 133 | $IBM_XTRACE |