Skip to content

Commit 22eeb1f

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Remove the Cisco Nexus monolithic plugin support"
2 parents 32ec835 + 107278f commit 22eeb1f

1 file changed

Lines changed: 6 additions & 193 deletions

File tree

lib/neutron_plugins/cisco

Lines changed: 6 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,12 @@ Q_CISCO_PLUGIN_VXLAN_ID_RANGES=${Q_CISCO_PLUGIN_VXLAN_ID_RANGES:-5000:10000}
2020
# Specify the VLAN range
2121
Q_CISCO_PLUGIN_VLAN_RANGES=${Q_CISCO_PLUGIN_VLAN_RANGES:-vlan:1:4094}
2222

23-
# Specify ncclient package information
24-
NCCLIENT_DIR=$DEST/ncclient
25-
NCCLIENT_VERSION=${NCCLIENT_VERSION:-0.3.1}
26-
NCCLIENT_REPO=${NCCLIENT_REPO:-git://github.com/CiscoSystems/ncclient.git}
27-
NCCLIENT_BRANCH=${NCCLIENT_BRANCH:-master}
28-
2923
# This routine put a prefix on an existing function name
3024
function _prefix_function {
3125
declare -F $1 > /dev/null || die "$1 doesn't exist"
3226
eval "$(echo "${2}_${1}()"; declare -f ${1} | tail -n +2)"
3327
}
3428

35-
function _has_ovs_subplugin {
36-
local subplugin
37-
for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do
38-
if [[ "$subplugin" == "openvswitch" ]]; then
39-
return 0
40-
fi
41-
done
42-
return 1
43-
}
44-
45-
function _has_nexus_subplugin {
46-
local subplugin
47-
for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do
48-
if [[ "$subplugin" == "nexus" ]]; then
49-
return 0
50-
fi
51-
done
52-
return 1
53-
}
54-
5529
function _has_n1kv_subplugin {
5630
local subplugin
5731
for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do
@@ -62,27 +36,6 @@ function _has_n1kv_subplugin {
6236
return 1
6337
}
6438

65-
# This routine populates the cisco config file with the information for
66-
# a particular nexus switch
67-
function _config_switch {
68-
local cisco_cfg_file=$1
69-
local switch_ip=$2
70-
local username=$3
71-
local password=$4
72-
local ssh_port=$5
73-
shift 5
74-
75-
local section="NEXUS_SWITCH:$switch_ip"
76-
iniset $cisco_cfg_file $section username $username
77-
iniset $cisco_cfg_file $section password $password
78-
iniset $cisco_cfg_file $section ssh_port $ssh_port
79-
80-
while [[ ${#@} != 0 ]]; do
81-
iniset $cisco_cfg_file $section $1 $2
82-
shift 2
83-
done
84-
}
85-
8639
# Prefix openvswitch plugin routines with "ovs" in order to differentiate from
8740
# cisco plugin routines. This means, ovs plugin routines will coexist with cisco
8841
# plugin routines in this script.
@@ -98,73 +51,17 @@ _prefix_function neutron_plugin_configure_service ovs
9851
_prefix_function neutron_plugin_setup_interface_driver ovs
9952
_prefix_function has_neutron_plugin_security_group ovs
10053

101-
# Check the version of the installed ncclient package
102-
function check_ncclient_version {
103-
python << EOF
104-
version = '$NCCLIENT_VERSION'
105-
import sys
106-
try:
107-
import pkg_resources
108-
import ncclient
109-
module_version = pkg_resources.get_distribution('ncclient').version
110-
if version != module_version:
111-
sys.exit(1)
112-
except:
113-
sys.exit(1)
114-
EOF
115-
}
116-
117-
# Install the ncclient package
118-
function install_ncclient {
119-
git_clone $NCCLIENT_REPO $NCCLIENT_DIR $NCCLIENT_BRANCH
120-
(cd $NCCLIENT_DIR; sudo python setup.py install)
121-
}
122-
123-
# Check if the required version of ncclient has been installed
124-
function is_ncclient_installed {
125-
# Check if the Cisco ncclient repository exists
126-
if [[ -d $NCCLIENT_DIR ]]; then
127-
remotes=$(cd $NCCLIENT_DIR; git remote -v | grep fetch | awk '{ print $2}')
128-
for remote in $remotes; do
129-
if [[ $remote == $NCCLIENT_REPO ]]; then
130-
break;
131-
fi
132-
done
133-
if [[ $remote != $NCCLIENT_REPO ]]; then
134-
return 1
135-
fi
136-
else
137-
return 1
138-
fi
139-
140-
# Check if the ncclient is installed with the right version
141-
if ! check_ncclient_version; then
142-
return 1
143-
fi
144-
return 0
145-
}
146-
14754
function has_neutron_plugin_security_group {
148-
if _has_ovs_subplugin; then
149-
ovs_has_neutron_plugin_security_group
150-
else
151-
return 1
152-
fi
55+
return 1
15356
}
15457

15558
function is_neutron_ovs_base_plugin {
156-
# Cisco uses OVS if openvswitch subplugin is deployed
157-
_has_ovs_subplugin
15859
return
15960
}
16061

16162
# populate required nova configuration parameters
16263
function neutron_plugin_create_nova_conf {
163-
if _has_ovs_subplugin; then
164-
ovs_neutron_plugin_create_nova_conf
165-
else
166-
_neutron_ovs_base_configure_nova_vif_driver
167-
fi
64+
_neutron_ovs_base_configure_nova_vif_driver
16865
}
16966

17067
function neutron_plugin_install_agent_packages {
@@ -177,86 +74,21 @@ function neutron_plugin_configure_common {
17774
# setup default subplugins
17875
if [ ! -v Q_CISCO_PLUGIN_SUBPLUGINS ]; then
17976
declare -ga Q_CISCO_PLUGIN_SUBPLUGINS
180-
Q_CISCO_PLUGIN_SUBPLUGINS=(openvswitch nexus)
181-
fi
182-
if _has_ovs_subplugin; then
183-
ovs_neutron_plugin_configure_common
184-
Q_PLUGIN_EXTRA_CONF_PATH=etc/neutron/plugins/cisco
185-
Q_PLUGIN_EXTRA_CONF_FILES=(cisco_plugins.ini)
186-
# Copy extra config files to /etc so that they can be modified
187-
# later according to Cisco-specific localrc settings.
188-
mkdir -p /$Q_PLUGIN_EXTRA_CONF_PATH
189-
local f
190-
local extra_conf_file
191-
for (( f=0; $f < ${#Q_PLUGIN_EXTRA_CONF_FILES[@]}; f+=1 )); do
192-
extra_conf_file=$Q_PLUGIN_EXTRA_CONF_PATH/${Q_PLUGIN_EXTRA_CONF_FILES[$f]}
193-
cp $NEUTRON_DIR/$extra_conf_file /$extra_conf_file
194-
done
195-
else
196-
Q_PLUGIN_CONF_PATH=etc/neutron/plugins/cisco
197-
Q_PLUGIN_CONF_FILENAME=cisco_plugins.ini
77+
Q_CISCO_PLUGIN_SUBPLUGINS=(n1kv)
19878
fi
79+
Q_PLUGIN_CONF_PATH=etc/neutron/plugins/cisco
80+
Q_PLUGIN_CONF_FILENAME=cisco_plugins.ini
19981
Q_PLUGIN_CLASS="neutron.plugins.cisco.network_plugin.PluginV2"
20082
}
20183

20284
function neutron_plugin_configure_debug_command {
203-
if _has_ovs_subplugin; then
204-
ovs_neutron_plugin_configure_debug_command
205-
fi
20685
}
20786

20887
function neutron_plugin_configure_dhcp_agent {
20988
iniset $Q_DHCP_CONF_FILE DEFAULT dhcp_agent_manager neutron.agent.dhcp_agent.DhcpAgentWithStateReport
21089
}
21190

21291
function neutron_plugin_configure_l3_agent {
213-
if _has_ovs_subplugin; then
214-
ovs_neutron_plugin_configure_l3_agent
215-
fi
216-
}
217-
218-
function _configure_nexus_subplugin {
219-
local cisco_cfg_file=$1
220-
221-
# Install a known compatible ncclient from the Cisco repository if necessary
222-
if ! is_ncclient_installed; then
223-
# Preserve the two global variables
224-
local offline=$OFFLINE
225-
local reclone=$RECLONE
226-
# Change their values to allow installation
227-
OFFLINE=False
228-
RECLONE=yes
229-
install_ncclient
230-
# Restore their values
231-
OFFLINE=$offline
232-
RECLONE=$reclone
233-
fi
234-
235-
# Setup default nexus switch information
236-
if [ ! -v Q_CISCO_PLUGIN_SWITCH_INFO ]; then
237-
declare -A Q_CISCO_PLUGIN_SWITCH_INFO
238-
HOST_NAME=$(hostname)
239-
Q_CISCO_PLUGIN_SWITCH_INFO=([1.1.1.1]=stack:stack:22:${HOST_NAME}:1/10)
240-
else
241-
iniset $cisco_cfg_file CISCO nexus_driver neutron.plugins.cisco.nexus.cisco_nexus_network_driver_v2.CiscoNEXUSDriver
242-
fi
243-
244-
# Setup the switch configurations
245-
local nswitch
246-
local sw_info
247-
local segment
248-
local sw_info_array
249-
declare -i count=0
250-
for nswitch in ${!Q_CISCO_PLUGIN_SWITCH_INFO[@]}; do
251-
sw_info=${Q_CISCO_PLUGIN_SWITCH_INFO[$nswitch]}
252-
sw_info_array=${sw_info//:/ }
253-
sw_info_array=( $sw_info_array )
254-
count=${#sw_info_array[@]}
255-
if [[ $count < 5 || $(( ($count-3) % 2 )) != 0 ]]; then
256-
die $LINENO "Incorrect switch configuration: ${Q_CISCO_PLUGIN_SWITCH_INFO[$nswitch]}"
257-
fi
258-
_config_switch $cisco_cfg_file $nswitch ${sw_info_array[@]}
259-
done
26092
}
26193

26294
# Configure n1kv plugin
@@ -279,48 +111,29 @@ function _configure_n1kv_subplugin {
279111
}
280112

281113
function neutron_plugin_configure_plugin_agent {
282-
if _has_ovs_subplugin; then
283-
ovs_neutron_plugin_configure_plugin_agent
284-
fi
285114
}
286115

287116
function neutron_plugin_configure_service {
288117
local subplugin
289118
local cisco_cfg_file
290119

291-
if _has_ovs_subplugin; then
292-
ovs_neutron_plugin_configure_service
293-
cisco_cfg_file=/${Q_PLUGIN_EXTRA_CONF_FILES[0]}
294-
else
295-
cisco_cfg_file=/$Q_PLUGIN_CONF_FILE
296-
fi
120+
cisco_cfg_file=/$Q_PLUGIN_CONF_FILE
297121

298122
# Setup the [CISCO_PLUGINS] section
299123
if [[ ${#Q_CISCO_PLUGIN_SUBPLUGINS[@]} > 2 ]]; then
300124
die $LINENO "At most two subplugins are supported."
301125
fi
302126

303-
if _has_ovs_subplugin && _has_n1kv_subplugin; then
304-
die $LINENO "OVS subplugin and n1kv subplugin cannot coexist"
305-
fi
306-
307127
# Setup the subplugins
308-
inicomment $cisco_cfg_file CISCO_PLUGINS nexus_plugin
309128
inicomment $cisco_cfg_file CISCO_PLUGINS vswitch_plugin
310129
inicomment $cisco_cfg_file CISCO_TEST host
311130
for subplugin in ${Q_CISCO_PLUGIN_SUBPLUGINS[@]}; do
312131
case $subplugin in
313-
nexus) iniset $cisco_cfg_file CISCO_PLUGINS nexus_plugin neutron.plugins.cisco.nexus.cisco_nexus_plugin_v2.NexusPlugin;;
314-
openvswitch) iniset $cisco_cfg_file CISCO_PLUGINS vswitch_plugin neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2;;
315132
n1kv) iniset $cisco_cfg_file CISCO_PLUGINS vswitch_plugin neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2;;
316133
*) die $LINENO "Unsupported cisco subplugin: $subplugin";;
317134
esac
318135
done
319136

320-
if _has_nexus_subplugin; then
321-
_configure_nexus_subplugin $cisco_cfg_file
322-
fi
323-
324137
if _has_n1kv_subplugin; then
325138
_configure_n1kv_subplugin $cisco_cfg_file
326139
fi

0 commit comments

Comments
 (0)