blob: 3660a9f2b92bca9ebdfabf0beb2df7b57ca96837 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
Mohammad Banikazemi729236c2014-02-05 14:45:04 -05003# Neutron IBM SDN-VE plugin
4# ---------------------------
5
6# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05007IBM_XTRACE=$(set +o | grep xtrace)
Mohammad Banikazemi729236c2014-02-05 14:45:04 -05008set +o xtrace
9
10source $TOP_DIR/lib/neutron_plugins/ovs_base
11
12function neutron_plugin_install_agent_packages {
13 _neutron_ovs_base_install_agent_packages
14}
15
16function _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
24function 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
44function neutron_plugin_create_nova_conf {
45 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
46 # if n-cpu is enabled, then setup integration bridge
47 if is_service_enabled n-cpu; then
48 neutron_setup_integration_bridge
49 fi
50}
51
52function is_neutron_ovs_base_plugin {
53 if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then
54 # Yes, we use OVS.
55 return 0
56 else
57 # No, we do not use OVS.
58 return 1
59 fi
60}
61
62function neutron_plugin_configure_common {
63 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ibm
64 Q_PLUGIN_CONF_FILENAME=sdnve_neutron_plugin.ini
Mohammad Banikazemi729236c2014-02-05 14:45:04 -050065 Q_PLUGIN_CLASS="neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2"
66}
67
68function neutron_plugin_configure_service {
69 # Define extra "SDNVE" configuration options when q-svc is configured
70
71 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
72
73 if [[ "$SDNVE_CONTROLLER_IPS" != "" ]]; then
74 iniset /$Q_PLUGIN_CONF_FILE sdnve controller_ips $SDNVE_CONTROLLER_IPS
75 fi
76
77 if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then
78 iniset /$Q_PLUGIN_CONF_FILE sdnve integration_bridge $SDNVE_INTEGRATION_BRIDGE
79 fi
80
81 if [[ "$SDNVE_RESET_BRIDGE" != "" ]]; then
82 iniset /$Q_PLUGIN_CONF_FILE sdnve reset_bridge $SDNVE_RESET_BRIDGE
83 fi
84
85 if [[ "$SDNVE_OUT_OF_BAND" != "" ]]; then
86 iniset /$Q_PLUGIN_CONF_FILE sdnve out_of_band $SDNVE_OUT_OF_BAND
87 fi
88
89 if [[ "$SDNVE_INTERFACE_MAPPINGS" != "" ]]; then
90 iniset /$Q_PLUGIN_CONF_FILE sdnve interface_mappings $SDNVE_INTERFACE_MAPPINGS
91 fi
92
93 if [[ "$SDNVE_FAKE_CONTROLLER" != "" ]]; then
94 iniset /$Q_PLUGIN_CONF_FILE sdnve use_fake_controller $SDNVE_FAKE_CONTROLLER
95 fi
96
97
98 iniset $NEUTRON_CONF DEFAULT notification_driver neutron.openstack.common.notifier.no_op_notifier
99
100}
101
102function neutron_plugin_configure_plugin_agent {
103 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ibm-agent"
104}
105
106function neutron_plugin_configure_debug_command {
107 :
108}
109
110function neutron_plugin_setup_interface_driver {
111 return 0
112}
113
114function has_neutron_plugin_security_group {
115 # Does not support Security Groups
116 return 1
117}
118
119function neutron_ovs_base_cleanup {
120 if [[ "$SDNVE_RESET_BRIDGE" != False ]]; then
121 # remove all OVS ports that look like Neutron created ports
122 for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
123 sudo ovs-vsctl del-port ${port}
124 done
125
126 # remove integration bridge created by Neutron
127 for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${SDNVE_INTEGRATION_BRIDGE}); do
128 sudo ovs-vsctl del-br ${bridge}
129 done
130 fi
131}
132
133# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500134$IBM_XTRACE