blob: 39b00401aecec6a560e8da682065eef71ac9e927 [file] [log] [blame]
Mohammad Banikazemi729236c2014-02-05 14:45:04 -05001# Neutron IBM SDN-VE plugin
2# ---------------------------
3
4# Save trace setting
Dean Troyere3a91602014-03-28 12:40:56 -05005IBM_XTRACE=$(set +o | grep xtrace)
Mohammad Banikazemi729236c2014-02-05 14:45:04 -05006set +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
Mohammad Banikazemi729236c2014-02-05 14:45:04 -050063 Q_PLUGIN_CLASS="neutron.plugins.ibm.sdnve_neutron_plugin.SdnvePluginV2"
64}
65
66function neutron_plugin_configure_service {
67 # Define extra "SDNVE" configuration options when q-svc is configured
68
69 iniset /$Q_PLUGIN_CONF_FILE securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver
70
71 if [[ "$SDNVE_CONTROLLER_IPS" != "" ]]; then
72 iniset /$Q_PLUGIN_CONF_FILE sdnve controller_ips $SDNVE_CONTROLLER_IPS
73 fi
74
75 if [[ "$SDNVE_INTEGRATION_BRIDGE" != "" ]]; then
76 iniset /$Q_PLUGIN_CONF_FILE sdnve integration_bridge $SDNVE_INTEGRATION_BRIDGE
77 fi
78
79 if [[ "$SDNVE_RESET_BRIDGE" != "" ]]; then
80 iniset /$Q_PLUGIN_CONF_FILE sdnve reset_bridge $SDNVE_RESET_BRIDGE
81 fi
82
83 if [[ "$SDNVE_OUT_OF_BAND" != "" ]]; then
84 iniset /$Q_PLUGIN_CONF_FILE sdnve out_of_band $SDNVE_OUT_OF_BAND
85 fi
86
87 if [[ "$SDNVE_INTERFACE_MAPPINGS" != "" ]]; then
88 iniset /$Q_PLUGIN_CONF_FILE sdnve interface_mappings $SDNVE_INTERFACE_MAPPINGS
89 fi
90
91 if [[ "$SDNVE_FAKE_CONTROLLER" != "" ]]; then
92 iniset /$Q_PLUGIN_CONF_FILE sdnve use_fake_controller $SDNVE_FAKE_CONTROLLER
93 fi
94
95
96 iniset $NEUTRON_CONF DEFAULT notification_driver neutron.openstack.common.notifier.no_op_notifier
97
98}
99
100function neutron_plugin_configure_plugin_agent {
101 AGENT_BINARY="$NEUTRON_BIN_DIR/neutron-ibm-agent"
102}
103
104function neutron_plugin_configure_debug_command {
105 :
106}
107
108function neutron_plugin_setup_interface_driver {
109 return 0
110}
111
112function has_neutron_plugin_security_group {
113 # Does not support Security Groups
114 return 1
115}
116
117function neutron_ovs_base_cleanup {
118 if [[ "$SDNVE_RESET_BRIDGE" != False ]]; then
119 # remove all OVS ports that look like Neutron created ports
120 for port in $(sudo ovs-vsctl list port | grep -o -e tap[0-9a-f\-]* -e q[rg]-[0-9a-f\-]*); do
121 sudo ovs-vsctl del-port ${port}
122 done
123
124 # remove integration bridge created by Neutron
125 for bridge in $(sudo ovs-vsctl list-br | grep -o -e ${SDNVE_INTEGRATION_BRIDGE}); do
126 sudo ovs-vsctl del-br ${bridge}
127 done
128 fi
129}
130
131# Restore xtrace
Dean Troyere3a91602014-03-28 12:40:56 -0500132$IBM_XTRACE