Browse code

vmware-nsx: Vendor code split

Devstack support is added using Devstack's external plugins:
https://review.openstack.org/#/c/156526

Asside to the environment variables, the following should be added to
local.conf file:

enable_plugin vmware-nsx https://git.openstack.org/stackforge/vmware-nsx

for the nsx plugin:
Q_PLUGIN=vmware_nsx
enable_service vmware_nsx

for the nsx_v plugin:
Q_PLUGIN=vmware_nsx_v

Partially-Implements: blueprint vmware-nsx-v

Change-Id: I4e03d4953bf9b5112ff75a252b61c27fadd04bf1
Signed-off-by: Roey Chen <roeyc@vmware.com>

Roey Chen authored on 2014/12/22 21:57:22
Showing 3 changed files
... ...
@@ -1,147 +1,10 @@
1 1
 #!/bin/bash
2
-#
3
-# Neutron VMware NSX plugin
4
-# -------------------------
5 2
 
6
-# Save trace setting
7
-NSX_XTRACE=$(set +o | grep xtrace)
8
-set +o xtrace
9
-
10
-source $TOP_DIR/lib/neutron_plugins/ovs_base
11
-
12
-function setup_integration_bridge {
13
-    _neutron_ovs_base_setup_bridge $OVS_BRIDGE
14
-    # Set manager to NSX controller (1st of list)
15
-    if [[ "$NSX_CONTROLLERS" != "" ]]; then
16
-        # Get the first controller
17
-        controllers=(${NSX_CONTROLLERS//,/ })
18
-        OVS_MGR_IP=${controllers[0]}
19
-    else
20
-        die $LINENO "Error - No controller specified. Unable to set a manager for OVS"
21
-    fi
22
-    sudo ovs-vsctl set-manager ssl:$OVS_MGR_IP
23
-}
24
-
25
-function is_neutron_ovs_base_plugin {
26
-    # NSX uses OVS, but not the l3-agent
27
-    return 0
28
-}
29
-
30
-function neutron_plugin_create_nova_conf {
31
-    # if n-cpu is enabled, then setup integration bridge
32
-    if is_service_enabled n-cpu; then
33
-        setup_integration_bridge
34
-    fi
35
-}
36
-
37
-function neutron_plugin_install_agent_packages {
38
-    # VMware NSX Plugin does not run q-agt, but it currently needs dhcp and metadata agents
39
-    _neutron_ovs_base_install_agent_packages
40
-}
41
-
42
-function neutron_plugin_configure_common {
43
-    Q_PLUGIN_CONF_PATH=etc/neutron/plugins/vmware
44
-    Q_PLUGIN_CONF_FILENAME=nsx.ini
45
-    Q_PLUGIN_CLASS="neutron.plugins.vmware.plugin.NsxPlugin"
46
-}
47
-
48
-function neutron_plugin_configure_debug_command {
49
-    sudo ovs-vsctl --no-wait -- --may-exist add-br $PUBLIC_BRIDGE
50
-    iniset $NEUTRON_TEST_CONFIG_FILE DEFAULT external_network_bridge "$PUBLIC_BRIDGE"
51
-}
52
-
53
-function neutron_plugin_configure_dhcp_agent {
54
-    setup_integration_bridge
55
-    iniset $Q_DHCP_CONF_FILE DEFAULT enable_isolated_metadata True
56
-    iniset $Q_DHCP_CONF_FILE DEFAULT enable_metadata_network True
57
-    iniset $Q_DHCP_CONF_FILE DEFAULT ovs_use_veth True
58
-}
59
-
60
-function neutron_plugin_configure_l3_agent {
61
-    # VMware NSX plugin does not run L3 agent
62
-    die $LINENO "q-l3 should not be executed with VMware NSX plugin!"
63
-}
64
-
65
-function neutron_plugin_configure_plugin_agent {
66
-    # VMware NSX plugin does not run L2 agent
67
-    die $LINENO "q-agt must not be executed with VMware NSX plugin!"
68
-}
69
-
70
-function neutron_plugin_configure_service {
71
-    if [[ "$MAX_LP_PER_BRIDGED_LS" != "" ]]; then
72
-        iniset /$Q_PLUGIN_CONF_FILE nsx max_lp_per_bridged_ls $MAX_LP_PER_BRIDGED_LS
73
-    fi
74
-    if [[ "$MAX_LP_PER_OVERLAY_LS" != "" ]]; then
75
-        iniset /$Q_PLUGIN_CONF_FILE nsx max_lp_per_overlay_ls $MAX_LP_PER_OVERLAY_LS
76
-    fi
77
-    if [[ "$FAILOVER_TIME" != "" ]]; then
78
-        iniset /$Q_PLUGIN_CONF_FILE nsx failover_time $FAILOVER_TIME
79
-    fi
80
-    if [[ "$CONCURRENT_CONNECTIONS" != "" ]]; then
81
-        iniset /$Q_PLUGIN_CONF_FILE nsx concurrent_connections $CONCURRENT_CONNECTIONS
82
-    fi
83
-
84
-    if [[ "$DEFAULT_TZ_UUID" != "" ]]; then
85
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_tz_uuid $DEFAULT_TZ_UUID
86
-    else
87
-        die $LINENO "The VMware NSX plugin won't work without a default transport zone."
88
-    fi
89
-    if [[ "$DEFAULT_L3_GW_SVC_UUID" != "" ]]; then
90
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l3_gw_service_uuid $DEFAULT_L3_GW_SVC_UUID
91
-        Q_L3_ENABLED=True
92
-        Q_L3_ROUTER_PER_TENANT=True
93
-        iniset /$Q_PLUGIN_CONF_FILE nsx metadata_mode access_network
94
-    fi
95
-    if [[ "$DEFAULT_L2_GW_SVC_UUID" != "" ]]; then
96
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_l2_gw_service_uuid $DEFAULT_L2_GW_SVC_UUID
97
-    fi
98
-    # NSX_CONTROLLERS must be a comma separated string
99
-    if [[ "$NSX_CONTROLLERS" != "" ]]; then
100
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_controllers $NSX_CONTROLLERS
101
-    else
102
-        die $LINENO "The VMware NSX plugin needs at least an NSX controller."
103
-    fi
104
-    if [[ "$NSX_USER" != "" ]]; then
105
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_user $NSX_USER
106
-    fi
107
-    if [[ "$NSX_PASSWORD" != "" ]]; then
108
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT nsx_password $NSX_PASSWORD
109
-    fi
110
-    if [[ "$NSX_HTTP_TIMEOUT" != "" ]]; then
111
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT http_timeout $NSX_HTTP_TIMEOUT
112
-    fi
113
-    if [[ "$NSX_RETRIES" != "" ]]; then
114
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT retries $NSX_RETRIES
115
-    fi
116
-    if [[ "$NSX_REDIRECTS" != "" ]]; then
117
-        iniset /$Q_PLUGIN_CONF_FILE DEFAULT redirects $NSX_REDIRECTS
118
-    fi
119
-    if [[ "$AGENT_MODE" != "" ]]; then
120
-        iniset /$Q_PLUGIN_CONF_FILE nsx agent_mode $AGENT_MODE
121
-        if [[ "$AGENT_MODE" == "agentless" ]]; then
122
-            if [[ "$DEFAULT_SERVICE_CLUSTER_UUID" != "" ]]; then
123
-                iniset /$Q_PLUGIN_CONF_FILE DEFAULT default_service_cluster_uuid $DEFAULT_SERVICE_CLUSTER_UUID
124
-            else
125
-                die $LINENO "Agentless mode requires a service cluster."
126
-            fi
127
-            iniset /$Q_PLUGIN_CONF_FILE nsx_metadata metadata_server_address $Q_META_DATA_IP
128
-        fi
129
-    fi
130
-}
131
-
132
-function neutron_plugin_setup_interface_driver {
133
-    local conf_file=$1
134
-    iniset $conf_file DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver
135
-}
3
+# This file is needed so Q_PLUGIN=vmware_nsx will work.
136 4
 
5
+# FIXME(salv-orlando): This function should not be here, but unfortunately
6
+# devstack calls it before the external plugins are fetched
137 7
 function has_neutron_plugin_security_group {
138 8
     # 0 means True here
139 9
     return 0
140 10
 }
141
-
142
-function neutron_plugin_check_adv_test_requirements {
143
-    is_service_enabled q-dhcp && return 0
144
-}
145
-
146
-# Restore xtrace
147
-$NSX_XTRACE
148 11
new file mode 100644
... ...
@@ -0,0 +1,10 @@
0
+#!/bin/bash
1
+#
2
+# This file is needed so Q_PLUGIN=vmware_nsx_v will work.
3
+
4
+# FIXME(salv-orlando): This function should not be here, but unfortunately
5
+# devstack calls it before the external plugins are fetched
6
+function has_neutron_plugin_security_group {
7
+    # 0 means True here
8
+    return 0
9
+}
... ...
@@ -1,89 +1,2 @@
1
-#!/bin/bash
2
-#
3
-# VMware NSX
4
-# ----------
5
-
6
-# This third-party addition can be used to configure connectivity between a DevStack instance
7
-# and an NSX Gateway in dev/test environments. In order to use this correctly, the following
8
-# env variables need to be set (e.g. in your localrc file):
9
-#
10
-# * enable_service vmware_nsx        --> to execute this third-party addition
11
-# * PUBLIC_BRIDGE                    --> bridge used for external connectivity, typically br-ex
12
-# * NSX_GATEWAY_NETWORK_INTERFACE    --> interface used to communicate with the NSX Gateway
13
-# * NSX_GATEWAY_NETWORK_CIDR         --> CIDR to configure $PUBLIC_BRIDGE, e.g. 172.24.4.211/24
14
-
15
-# Save trace setting
16
-NSX3_XTRACE=$(set +o | grep xtrace)
17
-set +o xtrace
18
-
19
-# This is the interface that connects the Devstack instance
20
-# to an network that allows it to talk to the gateway for
21
-# testing purposes
22
-NSX_GATEWAY_NETWORK_INTERFACE=${NSX_GATEWAY_NETWORK_INTERFACE:-eth2}
23
-# Re-declare floating range as it's needed also in stop_vmware_nsx, which
24
-# is invoked by unstack.sh
25
-FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.0/24}
26
-
27
-function configure_vmware_nsx {
28
-    :
29
-}
30
-
31
-function init_vmware_nsx {
32
-    if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
33
-        NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
34
-        echo "The IP address to set on $PUBLIC_BRIDGE was not specified. "
35
-        echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
36
-    fi
37
-    # Make sure the interface is up, but not configured
38
-    sudo ip link set $NSX_GATEWAY_NETWORK_INTERFACE up
39
-    # Save and then flush the IP addresses on the interface
40
-    addresses=$(ip addr show dev $NSX_GATEWAY_NETWORK_INTERFACE | grep inet | awk {'print $2'})
41
-    sudo ip addr flush $NSX_GATEWAY_NETWORK_INTERFACE
42
-    # Use the PUBLIC Bridge to route traffic to the NSX gateway
43
-    # NOTE(armando-migliaccio): if running in a nested environment this will work
44
-    # only with mac learning enabled, portsecurity and security profiles disabled
45
-    # The public bridge might not exist for the NSX plugin if Q_USE_DEBUG_COMMAND is off
46
-    # Try to create it anyway
47
-    sudo ovs-vsctl --may-exist add-br $PUBLIC_BRIDGE
48
-    sudo ovs-vsctl --may-exist add-port $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_INTERFACE
49
-    nsx_gw_net_if_mac=$(ip link show $NSX_GATEWAY_NETWORK_INTERFACE | awk '/ether/ {print $2}')
50
-    sudo ip link set address $nsx_gw_net_if_mac dev $PUBLIC_BRIDGE
51
-    for address in $addresses; do
52
-        sudo ip addr add dev $PUBLIC_BRIDGE $address
53
-    done
54
-    sudo ip addr add dev $PUBLIC_BRIDGE $NSX_GATEWAY_NETWORK_CIDR
55
-    sudo ip link set $PUBLIC_BRIDGE up
56
-}
57
-
58
-function install_vmware_nsx {
59
-    :
60
-}
61
-
62
-function start_vmware_nsx {
63
-    :
64
-}
65
-
66
-function stop_vmware_nsx {
67
-    if ! is_set NSX_GATEWAY_NETWORK_CIDR; then
68
-        NSX_GATEWAY_NETWORK_CIDR=$PUBLIC_NETWORK_GATEWAY/${FLOATING_RANGE#*/}
69
-        echo "The IP address expected on $PUBLIC_BRIDGE was not specified. "
70
-        echo "Defaulting to "$NSX_GATEWAY_NETWORK_CIDR
71
-    fi
72
-    sudo ip addr del $NSX_GATEWAY_NETWORK_CIDR dev $PUBLIC_BRIDGE
73
-    # Save and then flush remaining addresses on the interface
74
-    addresses=$(ip addr show dev $PUBLIC_BRIDGE | grep inet | awk {'print $2'})
75
-    sudo ip addr flush $PUBLIC_BRIDGE
76
-    # Try to detach physical interface from PUBLIC_BRIDGE
77
-    sudo ovs-vsctl del-port $NSX_GATEWAY_NETWORK_INTERFACE
78
-    # Restore addresses on NSX_GATEWAY_NETWORK_INTERFACE
79
-    for address in $addresses; do
80
-        sudo ip addr add dev $NSX_GATEWAY_NETWORK_INTERFACE $address
81
-    done
82
-}
83
-
84
-function check_vmware_nsx {
85
-    neutron-check-nsx-config $NEUTRON_CONF_DIR/plugins/vmware/nsx.ini
86
-}
87
-
88
-# Restore xtrace
89
-$NSX3_XTRACE
1
+# REVISIT(roeyc): this file left empty so that 'enable_service vmware_nsx'
2
+# continues to work.