os-ken: Initial packaging

Needed for Neutron (replacement for ryu)

Change-Id: I0b91b342f3b10caac9bf6badf31fd78ee10b5d2a
This commit is contained in:
Thomas Bechtold 2019-03-20 10:07:43 +01:00
parent bf93ed50b9
commit 3971977c6c
3 changed files with 301 additions and 0 deletions

View File

@ -0,0 +1,83 @@
From 6287e1b531341c44ea6d4fd2187f2ab4a4fbf030 Mon Sep 17 00:00:00 2001
From: Thomas Bechtold <tbechtold@suse.com>
Date: Wed, 20 Mar 2019 10:35:28 +0100
Subject: [PATCH] Fix import for oskenbgp
Running the tests in distro build env fails currently with:
Failed to import test module: os_ken.tests.integrated.bgp.test_ip6_basic
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/unittest2/loader.py", line 456, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python2.7/site-packages/unittest2/loader.py", line 395, in _get_module_from_name
__import__(name)
File "os_ken/tests/integrated/bgp/test_ip6_basic.py", line 22, in <module>
from . import base_ip6 as base
File "os_ken/tests/integrated/bgp/base_ip6.py", line 24, in <module>
from os_ken.tests.integrated.common import os_kenbgp
ImportError: cannot import name os_kenbgp
The filename is os_ken/tests/integrated/common/oskenbgp.py so import
the correct module.
Change-Id: Ie10da6df1a13e19d0ba20b4fa2c4c61125152f58
---
os_ken/tests/integrated/bgp/base.py | 8 ++++----
os_ken/tests/integrated/bgp/base_ip6.py | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/os_ken/tests/integrated/bgp/base.py b/os_ken/tests/integrated/bgp/base.py
index 1ab2c398..73e0bda5 100644
--- a/os_ken/tests/integrated/bgp/base.py
+++ b/os_ken/tests/integrated/bgp/base.py
@@ -21,7 +21,7 @@ import sys
import unittest
from os_ken.tests.integrated.common import docker_base as ctn_base
-from os_ken.tests.integrated.common import os_kenbgp
+from os_ken.tests.integrated.common import oskenbgp
from os_ken.tests.integrated.common import quagga
@@ -48,9 +48,9 @@ class BgpSpeakerTestBase(unittest.TestCase):
cls.q_img = 'osrg/quagga'
cls.images.append(cls.q_img)
- cls.r1 = os_kenbgp.OSKenBGPContainer(name='r1', asn=64512,
- router_id='192.168.0.1',
- ctn_image_name=cls.r_img)
+ cls.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
+ router_id='192.168.0.1',
+ ctn_image_name=cls.r_img)
cls.containers.append(cls.r1)
cls.r1.add_route('10.10.0.0/28')
cls.r1.run(wait=True)
diff --git a/os_ken/tests/integrated/bgp/base_ip6.py b/os_ken/tests/integrated/bgp/base_ip6.py
index 0038d1ae..668a3acb 100644
--- a/os_ken/tests/integrated/bgp/base_ip6.py
+++ b/os_ken/tests/integrated/bgp/base_ip6.py
@@ -21,7 +21,7 @@ import sys
import unittest
from os_ken.tests.integrated.common import docker_base as ctn_base
-from os_ken.tests.integrated.common import os_kenbgp
+from os_ken.tests.integrated.common import oskenbgp
from os_ken.tests.integrated.common import quagga
@@ -48,9 +48,9 @@ class BgpSpeakerTestBase(unittest.TestCase):
cls.q_img = 'osrg/quagga'
cls.images.append(cls.q_img)
- cls.r1 = os_kenbgp.OSKenBGPContainer(name='r1', asn=64512,
- router_id='192.168.0.1',
- ctn_image_name=cls.r_img)
+ cls.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
+ router_id='192.168.0.1',
+ ctn_image_name=cls.r_img)
cls.containers.append(cls.r1)
cls.r1.add_route('fc00:10::/64', route_info={'rf': 'ipv6'})
cls.r1.run(wait=True)
--
2.21.0

View File

@ -0,0 +1,110 @@
From f57d8b3b7199c1c2b48e98aaa85112f071751bdb Mon Sep 17 00:00:00 2001
From: Slawek Kaplonski <skaplons@redhat.com>
Date: Wed, 12 Dec 2018 16:14:27 +0100
Subject: [PATCH] Remove requirements unit tests module
Module os_ken.tests.unit.test_requirements was checking
in ryu if ryu's requirements are fine with OpenStack
requirements.
Now this module is not needed in os-ken as we are using
global-requirements for OpenStack projects already.
Change-Id: Ia3cdb9f156c3b3856cf39dc895669bd51a430bc7
---
os_ken/tests/unit/test_requirements.py | 84 --------------------------
1 file changed, 84 deletions(-)
delete mode 100644 os_ken/tests/unit/test_requirements.py
diff --git a/os_ken/tests/unit/test_requirements.py b/os_ken/tests/unit/test_requirements.py
deleted file mode 100644
index a15cb66e..00000000
--- a/os_ken/tests/unit/test_requirements.py
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
-#
-# 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 logging
-import os
-import sys
-import unittest
-
-import pkg_resources
-from six.moves import urllib
-
-from nose.tools import ok_
-
-
-LOG = logging.getLogger(__name__)
-
-MOD_DIR = os.path.dirname('file://' + sys.modules[__name__].__file__)
-_OSKEN_REQUIREMENTS_FILES = [
- '../../../requirements.txt',
-]
-OSKEN_REQUIREMENTS_FILES = [
- os.path.join(MOD_DIR, f) for f in _OSKEN_REQUIREMENTS_FILES]
-
-OPENSTACK_REQUIREMENTS_REPO = 'https://github.com/openstack/requirements'
-OPENSTACK_REQUIREMENTS_URL = (
- 'https://github.com/openstack/requirements/raw/master/')
-_OPENSTACK_REQUIREMENTS_FILES = [
- 'requirements.txt',
- 'global-requirements.txt',
-]
-OPENSTACK_REQUIREMENTS_FILES = [
- urllib.parse.urljoin(OPENSTACK_REQUIREMENTS_URL, f)
- for f in _OPENSTACK_REQUIREMENTS_FILES]
-
-
-def _get_requirements(files):
- requirements = {}
- for f in files:
- response = urllib.request.urlopen(f)
- contents = response.read().decode('utf-8')
- for r in pkg_resources.parse_requirements(contents):
- requirements[r.name] = str(r)
-
- return requirements
-
-
-OPENSTACK_REQUIREMENTS = _get_requirements(OPENSTACK_REQUIREMENTS_FILES)
-OSKEN_REQUIREMENTS = _get_requirements(OSKEN_REQUIREMENTS_FILES)
-
-
-class TestRequirements(unittest.TestCase):
- """
- Test whether the requirements of OSKen has no conflict with that
- of other projects.
- """
-
- def setUp(self):
- pass
-
- def tearDown(self):
- pass
-
- def test_with_openstack_requirements(self):
- try:
- for name, req in OPENSTACK_REQUIREMENTS.items():
- if name in OSKEN_REQUIREMENTS:
- ok_(pkg_resources.require(req))
- except pkg_resources.VersionConflict as e:
- LOG.exception(
- 'Some requirements of OSKen are conflicting with that of '
- 'OpenStack project: %s', OPENSTACK_REQUIREMENTS_REPO)
- raise e
--
2.21.0

View File

@ -0,0 +1,108 @@
{% set pypi_name = 'os-ken' %}
{% set upstream_version = upstream_version('0.3.1') %}
{% set rpm_release = '0' %}
{% set source = url_pypi() %}
Name: {{ py2name('os-ken') }}
Epoch: {{ epoch('os-ken') }}
Version: {{ py2rpmversion() }}
Release: {{ py2rpmrelease() }}
Summary: A component-based software defined networking framework in OpenStack
License: {{ license('Apache-2.0') }}
Group: Development/Languages/Python
URL: https://launchpad.net/{{ pypi_name }}
Source0: {{ source }}
# https://review.openstack.org/644801
Patch0: 0001-Fix-import-for-oskenbgp.patch
# https://git.openstack.org/cgit/openstack/os-ken/commit/?id=f57d8b3b7199c1c2b48e98aaa85112f071751bdb
Patch1: 0001-Remove-requirements-unit-tests-module.patch
BuildRequires: openstack-macros
BuildRequires: {{ py2pkg('devel', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('Routes', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('WebOb', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('eventlet', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('lxml', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('mock', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('msgpack', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('ncclient', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('netaddr', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('nose', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('oslo.config', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('oslotest', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('ovs', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('pbr', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('six', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('stestr', py_versions=['py2', 'py3']) }}
BuildRequires: {{ py2pkg('tinyrpc', py_versions=['py2', 'py3']) }}
Requires: {{ py2pkg('Routes') }}
Requires: {{ py2pkg('WebOb') }}
Requires: {{ py2pkg('eventlet') }}
Requires: {{ py2pkg('msgpack') }}
Requires: {{ py2pkg('netaddr') }}
Requires: {{ py2pkg('oslo.config') }}
Requires: {{ py2pkg('ovs') }}
Requires: {{ py2pkg('pbr') }}
Requires: {{ py2pkg('six') }}
Requires: {{ py2pkg('tinyrpc') }}
BuildArch: noarch
%if 0%{?suse_version}
Requires(post): update-alternatives
Requires(postun): update-alternatives
%else
# on RDO, update-alternatives is in chkconfig
Requires(post): chkconfig
Requires(postun): chkconfig
%endif
%python_subpackages
%description
A component-based software defined networking framework in OpenStack.
This is a fork of the Ryu library tailored for OpenStack Neutron.
%package -n python-osken-doc
Summary: A component-based software defined networking framework in OpenStack - Documentation
Group: Documentation/HTML
BuildRequires: {{ py2pkg('Sphinx') }}
BuildRequires: {{ py2pkg('openstackdocstheme') }}
%description -n python-osken-doc
A component-based software defined networking framework in OpenStack.
This is a fork of the Ryu library tailored for OpenStack Neutron.
This package contains the documentation.
%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup
%build
%{python_build}
PBR_VERSION=%{version} sphinx-build -b html doc/source doc/build/html
rm -rf doc/build/html/.{doctrees,buildinfo}
%install
%{python_install}
%python_clone -a %{buildroot}%{_bindir}/osken
%python_clone -a %{buildroot}%{_bindir}/osken-manager
%post
%{python_install_alternative osken osken-manager}
%postun
%python_uninstall_alternative osken
%check
%python_expand PYTHON=python%{$python_version} ./run_tests.sh -N -P
%files %{python_files}
%doc README.rst ChangeLog
%license LICENSE
%{python_sitelib}/os_ken*
%{python_sitelib}/*.egg-info
%python_alternative %{_bindir}/osken
%python_alternative %{_bindir}/osken-manager
%files -n python-osken-doc
%doc doc/build/html
%license LICENSE
%changelog