blob: 22c8578e647f18819a35fd22f4593ddbb056a089 [file] [log] [blame]
Mohammad Banikazemi729236c2014-02-05 14:45:04 -05001# Neutron IBM SDN-VE plugin
2# ---------------------------
3
4# Save trace setting
5MY_XTRACE=$(set +o | grep xtrace)
6set +o xtrace
7
8source $TOP_DIR/lib/neutron_plugins/ovs_base
9
10function neutron_plugin_install_agent_packages {
11 _neutron_ovs_base_install_agent_packages
12}
13
14function _neutron_interface_setup {
15 # Setup one interface on the integration bridge if needed
16 # The plugin agent to be used if more than one interface is used
17 local bridge=$1
18 local interface=$2
19 sudo ovs-vsctl --no-wait -- --may-exist add-port $bridge $interface
20}
21
22function neutron_setup_integration_bridge {
23 # Setup integration bridge if needed
24 if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then
25 neutron_ovs_base_cleanup
26 _neutron_ovs_base_setup_bridge $SDNVE_INTEGRATION_BRIDGE
27 if [[ "$SDNVE_INTERFACE_MAPPINGS" != "" ]]; then
28 interfaces=(${SDNVE_INTERFACE_MAPPINGS//[,:]/ })
29 _neutron_interface_setup $SDNVE_INTEGRATION_BRIDGE ${interfaces[1]}
30 fi
31 fi
32
33 # Set controller to SDNVE controller (1st of list) if exists
34 if [[ "$SDNVE_CONTROLLER_IPS" != "" ]]; then
35 # Get the first controller
36 controllers=(${SDNVE_CONTROLLER_IPS//[\[,\]]/ })
37 SDNVE_IP=${controllers[0]}
38 sudo ovs-vsctl set-controller $SDNVE_INTEGRATION_BRIDGE tcp:$SDNVE_IP
39 fi
40}
41
42function neutron_plugin_create_nova_conf {
43 NOVA_VIF_DRIVER=${NOVA_VIF_DRIVER:-"nova.virt.libvirt.vif.LibvirtGenericVIFDriver"}
44 # if n-cpu is enabled, then setup integration bridge
45 if is_service_enabled n-cpu; then
46 neutron_setup_integration_bridge
47 fi
48}
49
50function is_neutron_ovs_base_plugin {
51 if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then
52 # Yes, we use OVS.
53 return 0
54 else
55 # No, we do not use OVS.
56 return 1
57 fi
58}
59
60function neutron_plugin_configure_common {
61 Q_PLUGIN_CONF_PATH=etc/neutron/plugins/ibm
62 Q_PLUGIN_CONF_FILENAME=sdnve_neutron_plugin.ini
63 Q_DB_NAME="sdnve_neutron"
64 Q_PLUGIN_CLASS="neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2"
65}
66
67function 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
101function neutron_plugin_configure_plugin_agent {
102 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ibm-agent"
103}
104
105function neutron_plugin_configure_debug_command {
106 :
107}
108
109function neutron_plugin_setup_interface_driver {
110 return 0
111}
112
113function has_neutron_plugin_security_group {
114 # Does not support Security Groups
115 return 1
116}
117
118function 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
133$MY_XTRACE