-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First resources for openstack client: Port NuageL2bridge Subnet Network Router Floating IP (the extension) Nuage Floating IP (the resource) Security group Depends-On: Ic26b6c6f5fc1c7da6698954d3c9b052239fba0b3 Change-Id: I952fc4a0ac28aeb67e8b459bcc4a7bd0ddc0503a
- Loading branch information
Glenn Van de Water
authored and
Glenn Van de Water
committed
Jun 21, 2019
1 parent
51ff3ee
commit 5a2c51c
Showing
36 changed files
with
3,102 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[DEFAULT] | ||
test_path=${OS_TEST_PATH:-./nuage_neutronclient/osc/tests/functional} | ||
top_dir=./ | ||
group_regex=([^\.]+\.)+ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
# Note the actual url here is somewhat irrelevant because it | ||
# caches in nodepool, however make it a valid url for | ||
# documentation purposes. | ||
export DEVSTACK_LOCAL_CONFIG="enable_plugin nuage-openstack-neutron git://git.openstack.org/openstack/nuage-openstack-neutron" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"enable_plugin nuage-openstack-neutronclient git://git.openstack.org/openstack/nuage-openstack-neutronclient" | ||
|
||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NUAGE_FIP_UNDERLAY=True" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"OVS_BRIDGE=alubr0" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_USE_PROVIDERNET_FOR_PUBLIC=False" | ||
|
||
# VSP related config | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NUAGE_VSD_SERVERS=$VSD_SERVER" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NUAGE_VSD_SERVER_AUTH=csproot:csproot" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NUAGE_VSD_ORGANIZATION=csp" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NUAGE_VSD_SERVER_SSL=True" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NUAGE_VSD_AUTH_RESOURCE=/me" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"NUAGE_VSD_DEF_NETPART_NAME=DevstackCI-${ZUUL_CHANGE}-os-neutronclient-${RANDOM}" | ||
|
||
# Keep localrc to be able to set some vars in pre_test_hook | ||
export KEEP_LOCALRC=1 | ||
|
||
# Neutron Plugin related config | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_PLUGIN=ml2" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ML2_PLUGIN_EXT_DRIVERS=nuage_subnet,nuage_port,port_security,nuage_network" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ML2_TENANT_NETWORK_TYPE=vxlan,vlan" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"ENABLE_TENANT_TUNNELS=True" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"ML2_VLAN_RANGES=physnet1:1:4000,physnet2:1:4000" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"PHYSICAL_NETWORK=physnet1,physnet2" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ML2_PLUGIN_MECHANISM_DRIVERS=nuage,nuage_sriov,nuage_baremetal" | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"Q_ML2_PLUGIN_TYPE_DRIVERS=vxlan,vlan" | ||
|
||
# disable neutron advanced services for nuage ci | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"disable_service q-lbaas q-fwaas q-vpn" | ||
|
||
# We are only interested on Neutron and Heat, so very few services are needed | ||
# to deploy devstack and run the tests | ||
s="" | ||
s+="mysql,rabbit" | ||
s+=",key" | ||
s+=",n-api,n-cond,n-cpu,n-crt,n-sch,placement-api" | ||
s+=",g-api,g-reg" | ||
s+=",q-svc,quantum" | ||
s+=",dstat" | ||
|
||
export OVERRIDE_ENABLED_SERVICES="$s" | ||
|
||
export DEVSTACK_GATE_CONFIGDRIVE=1 | ||
export DEVSTACK_GATE_LIBVIRT_TYPE=kvm | ||
|
||
# Explicitly set LOGDIR to align with the SCREEN_LOGDIR setting | ||
# from devstack-gate. Otherwise, devstack infers it from LOGFILE, | ||
# which is not appropriate for our gate jobs. | ||
export DEVSTACK_LOCAL_CONFIG+=$'\n'"LOGDIR=$BASE/new/screen-logs" | ||
|
||
$BASE/new/devstack-gate/devstack-vm-gate.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash -xe | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
# This script is executed inside post_test_hook function in devstack gate. | ||
|
||
SCRIPTS_DIR="/usr/os-testr-env/bin/" | ||
function generate_test_logs { | ||
local path="$1" | ||
# Compress all $path/*.txt files and move the directories holding those | ||
# files to /opt/stack/logs. Files with .log suffix have their | ||
# suffix changed to .txt (so browsers will know to open the compressed | ||
# files and not download them). | ||
if [ -d "$path" ] | ||
then | ||
sudo find $path -iname "*.log" -type f -exec mv {} {}.txt \; -exec gzip -9 {}.txt \; | ||
sudo mv $path/* /opt/stack/logs/ | ||
fi | ||
} | ||
|
||
function generate_testr_results { | ||
# Give job user rights to access tox logs | ||
sudo -H -u $USER chmod o+rw . | ||
sudo -H -u $USER chmod o+rw -R .stestr | ||
if [ -f ".stestr/0" ] ; then | ||
.tox/$VENV/bin/subunit-1to2 < .stestr/0 > ./stestr.subunit | ||
$SCRIPTS_DIR/subunit2html ./stestr.subunit testr_results.html | ||
gzip -9 ./stestr.subunit | ||
gzip -9 ./testr_results.html | ||
sudo mv ./*.gz /opt/stack/logs/ | ||
fi | ||
|
||
if [ "$venv" == "functional" ] | ||
then | ||
generate_test_logs "/tmp/${venv}-logs" | ||
fi | ||
} | ||
|
||
export NUAGECLIENT_DIR="$BASE/new/nuage-openstack-neutronclient" | ||
|
||
sudo chown -R $USER:stack $NUAGECLIENT_DIR | ||
|
||
# Go to the openstaclient dir | ||
cd $NUAGECLIENT_DIR | ||
|
||
# Run tests | ||
VENV=${1:-"functional"} | ||
echo "Running openstackclientclient functional test suite" | ||
set +e | ||
# Preserve env for OS_ credentials | ||
sudo -E -H -u $USER tox -e $VENV | ||
EXIT_CODE=$? | ||
set -e | ||
|
||
# Collect and parse result | ||
generate_testr_results | ||
exit $EXIT_CODE | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Copyright 2018 NOKIA | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""OpenStackClient plugin for Nuage service.""" | ||
|
||
import logging | ||
|
||
# from nuage_neutronclient.api.v2 import octavia | ||
from osc_lib import utils | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
DEFAULT_API_VERSION = '2.0' | ||
API_VERSION_OPTION = 'os_nuageclient_api_version' | ||
API_NAME = 'nuageclient' | ||
API_TYPE = 'nuageclient' | ||
API_VERSIONS = { | ||
'2.0': 'nuage_neutronclient.osc.v2.client.Client', | ||
'2': 'nuage_neutronclient.osc.v2.client.Client', | ||
} | ||
|
||
|
||
def make_client(instance): | ||
"""Returns a nuage service client""" | ||
nuage_client = utils.get_client_class( | ||
API_NAME, | ||
instance._api_version[API_NAME], | ||
API_VERSIONS) | ||
LOG.debug('Instantiating nuage client: %s', nuage_client) | ||
|
||
client = nuage_client(session=instance.session, | ||
region_name=instance.region_name, | ||
endpoint_type=instance.interface, | ||
insecure=not instance.verify, | ||
ca_cert=instance.cacert) | ||
return client | ||
|
||
|
||
def build_option_parser(parser): | ||
"""Hook to add global options | ||
Called from openstackclient.shell.OpenStackShell.__init__() | ||
after the builtin parser has been initialized. This is | ||
where a plugin can add global options such as an API version. | ||
:param argparse.ArgumentParser parser: The parser object that | ||
has been initialized by OpenStackShell. | ||
""" | ||
parser.add_argument( | ||
'--os-nuageclient-api-version', | ||
metavar='<nuageclient-api-version>', | ||
default=utils.env( | ||
'OS_NUAGECLIENT_API_VERSION', | ||
default=DEFAULT_API_VERSION), | ||
help='OSC Plugin API version, default=' + | ||
DEFAULT_API_VERSION + | ||
' (Env: OS_NUAGECLIENT_API_VERSION)') | ||
return parser |
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions
16
nuage_neutronclient/osc/tests/functional/run_stestr_with_os_env.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# This is a script that runs ostestr with the openrc OS_ variables sourced. | ||
# Do not run this script unless you know what you're doing. | ||
# For more information refer to: | ||
# https://docs.openstack.org/python-openstackclient/latest/ | ||
|
||
# Source environment variables to kick things off | ||
if [ -f ~stack/devstack/openrc ] ; then | ||
source ~stack/devstack/openrc admin admin | ||
fi | ||
|
||
echo 'Running tests with:' | ||
env | grep OS | ||
|
||
stestr run $* |
120 changes: 120 additions & 0 deletions
120
nuage_neutronclient/osc/tests/functional/test_floating_ip.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Copyright 2015 Alcatel-Lucent USA Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
# | ||
import json | ||
|
||
import testtools | ||
|
||
import nuage_neutronclient.osc.tests.utils as utils | ||
from openstackclient.tests.functional.network.v2.test_floating_ip \ | ||
import FloatingIpTests | ||
|
||
|
||
class NuageFloatingIPExtensionTests(FloatingIpTests): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
super(NuageFloatingIPExtensionTests, cls).setUpClass() | ||
|
||
cls.random_name = utils.get_random_name() | ||
|
||
# Private network | ||
cls.openstack('network create {}'.format(cls.random_name)) | ||
|
||
cls.openstack(('subnet create --subnet-range 99.168.0.1/24 ' | ||
'--network {} {}'.format(cls.random_name, | ||
cls.random_name))) | ||
|
||
cls.openstack('port create --network {} {}'.format(cls.random_name, | ||
cls.random_name)) | ||
|
||
# Public network | ||
cls.openstack('network create --external public-{}' | ||
.format(cls.random_name)) | ||
cls.openstack((('subnet create --subnet-range 98.0.2.1/24 ' | ||
'--network public-{} public-{}' | ||
.format(cls.random_name, cls.random_name)))) | ||
|
||
# Router | ||
cls.openstack('router create {}'.format(cls.random_name)) | ||
cls.openstack(('router set --external-gateway {} {}' | ||
.format('public-{}'.format(cls.random_name), | ||
cls.random_name))) | ||
cls.openstack(('router add subnet {} {}' | ||
.format(cls.random_name, cls.random_name))) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
super(NuageFloatingIPExtensionTests, cls).tearDownClass() | ||
|
||
# Router | ||
cls.openstack('router remove subnet {} {}'.format(cls.random_name, | ||
cls.random_name)) | ||
cls.openstack(('router remove subnet {} public-{}' | ||
.format(cls.random_name, cls.random_name))) | ||
|
||
cls.openstack('router delete {}'.format(cls.random_name)) | ||
|
||
# Public network | ||
cls.openstack('subnet delete public-{}'.format(cls.random_name)) | ||
cls.openstack('network delete public-{}'.format(cls.random_name)) | ||
|
||
# Private network | ||
cls.openstack('port delete {}'.format(cls.random_name)) | ||
cls.openstack('subnet delete {}'.format(cls.random_name)) | ||
cls.openstack('network delete {}'.format(cls.random_name)) | ||
|
||
def test_crud(self): | ||
# create with nuage attributes, expect no output | ||
cmd_output = json.loads(self.openstack(( | ||
'floating ip create -f json --port {} ' | ||
'--nuage-ingress-fip-rate-kbps 100 ' | ||
'--nuage-egress-fip-rate-kbps 200 ' | ||
'public-{}'.format(self.random_name, self.random_name)))) | ||
fip_id = cmd_output['id'] | ||
|
||
self.addCleanup(self.openstack, ('floating ip delete {}' | ||
.format(fip_id))) | ||
self.assertEqual(observed=cmd_output['nuage_ingress_fip_rate_kbps'], | ||
expected=100) | ||
self.assertEqual(observed=cmd_output['nuage_egress_fip_rate_kbps'], | ||
expected=200) | ||
|
||
# verify show | ||
cmd_output = json.loads(self.openstack(('floating ip show -f json {}' | ||
.format(fip_id)))) | ||
self.assertEqual(observed=cmd_output['nuage_ingress_fip_rate_kbps'], | ||
expected=100) | ||
self.assertEqual(observed=cmd_output['nuage_egress_fip_rate_kbps'], | ||
expected=200) | ||
|
||
# update nuage attributes | ||
cmd_output = self.openstack(('floating ip set ' | ||
'--nuage-ingress-fip-rate-kbps 200 ' | ||
'--nuage-egress-fip-rate-kbps 100 {}' | ||
.format(fip_id))) | ||
self.assertEqual(expected='', observed=cmd_output) | ||
|
||
# verify show | ||
cmd_output = json.loads(self.openstack(('floating ip show -f json {}' | ||
.format(fip_id)))) | ||
self.assertEqual(observed=cmd_output['nuage_ingress_fip_rate_kbps'], | ||
expected=200) | ||
self.assertEqual(observed=cmd_output['nuage_egress_fip_rate_kbps'], | ||
expected=100) | ||
|
||
@testtools.skip("OPENSTACK-2591") | ||
def test_floating_ip_set_and_unset_port(self): | ||
return super(NuageFloatingIPExtensionTests, self)\ | ||
.test_floating_ip_set_and_unset_port() |
Oops, something went wrong.