Drop common code and add kuryr_lib as requirement

1. Drop the common(COE agnostic) code such as binding, exceptions
2. Renamed kuryr-libnetwork/kuryr to kuryr-libnetwork/kuryr_libnetwork
3. change default kuryr port from 2377 to 23750
4. Add Kuryr-lib(Kuryr) to requirements.txt:
      Kuryr-lib(Kuryr) has also been cleaned to remove libnetwork specific
code(which is active in this repo such as libnetwork api handlers and
test cases). This patch is under review, [1]_. Meanwhile kuryr-lib
dependency is being resolved from external repo [2]. Exacltly same
changes, as present in under review kuryr-lib patch [1], are there on
external repo, [2]

[1] https://review.openstack.org/#/c/336784/
[2] https://github.com/vikaschoudhary16/kuryr/tree/drop_libnet_specific_code
Implements blueprint common-code-drop

Change-Id: If0823791463011dc395cd3390a7f4c187c9c2653
This commit is contained in:
vikaschoudhary16 2016-07-04 23:47:30 +05:30
parent 8953d58edc
commit 9c94d3ccc5
55 changed files with 107 additions and 816 deletions

View File

@ -1,4 +1,4 @@
[DEFAULT]
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_LOG_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./kuryr/tests/unit} $LISTOPT $IDOPTION | cat
test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 OS_LOG_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./kuryr_libnetwork/tests/unit} $LISTOPT $IDOPTION | cat
test_id_option=--load-list $IDFILE
test_list_option=--list

View File

@ -1,5 +1,5 @@
===============================
kuryr
kuryr-libnetwork
===============================
.. image:: https://raw.githubusercontent.com/openstack/kuryr/master/doc/images/kuryr_logo.png
@ -9,9 +9,14 @@ kuryr
Docker for OpenStack Neutron
Kuryr is a Docker network plugin that uses Neutron to provide networking
services to Docker containers. It provides containerised images for the
common Neutron plugins.
Kuryr-libnetwork is `Kuryr's <https://github.com/openstack/kuryr>`_ Docker
libnetwork driver that uses Neutron to provide networking services. It provides
containerised images for the common Neutron plugins.
This repo provides libnetwork specific functionalities such as handler methods
for libnetwork apis. All the logic/utilities that can be shared among
different container networking frameworks such as Docker's libnetwork,
K8s's cni and so on, is maintained in seperate Kuryr repo as a common library.
* Free software: Apache license
@ -69,8 +74,8 @@ Edit keystone section in `/etc/kuryr/kuryr.conf`, replace ADMIN_PASSWORD:
admin_password = ADMIN_PASSWORD
In the same file uncomment the `bindir` parameter with the path for the Kuryr vif binding
executables:
In the same file uncomment the `bindir` parameter with the path for the Kuryr
vif binding executables:
::

View File

@ -1,4 +1,4 @@
{
"Name": "kuryr",
"Addr": "http://127.0.0.1:2377"
"Addr": "http://127.0.0.1:23750"
}

View File

@ -1 +1 @@
http://127.0.0.1:2377
http://127.0.0.1:23750

View File

@ -1,42 +0,0 @@
# All Rights Reserved.
#
# 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 oslo_i18n
DOMAIN = "kuryr"
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
# The primary translation function using the well-known name "_"
_ = _translators.primary
# The contextual translation function using the name "_C"
_C = _translators.contextual_form
# The plural translation function using the name "_P"
_P = _translators.plural_form
# Translators for log levels.
#
# The abbreviated names are meant to reflect the usual use of a short
# name like '_'. The "L" is for "log" and the other letter comes from
# the level.
_LI = _translators.log_info
_LW = _translators.log_warning
_LE = _translators.log_error
_LC = _translators.log_critical
def get_available_languages():
return oslo_i18n.get_available_languages(DOMAIN)

View File

@ -1,195 +0,0 @@
# 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 os
import netaddr
from oslo_concurrency import processutils
from oslo_utils import excutils
import pyroute2
from kuryr.common import config
from kuryr.common import exceptions
from kuryr import utils
BINDING_SUBCOMMAND = 'bind'
DOWN = 'DOWN'
FALLBACK_VIF_TYPE = 'unbound'
FIXED_IP_KEY = 'fixed_ips'
IFF_UP = 0x1 # The last bit represents if the interface is up
IP_ADDRESS_KEY = 'ip_address'
KIND_VETH = 'veth'
MAC_ADDRESS_KEY = 'mac_address'
SUBNET_ID_KEY = 'subnet_id'
UNBINDING_SUBCOMMAND = 'unbind'
VIF_TYPE_KEY = 'binding:vif_type'
VIF_DETAILS_KEY = 'binding:vif_details'
_IPDB_CACHE = None
_IPROUTE_CACHE = None
def get_ipdb():
"""Returns the already cached or a newly created IPDB instance.
IPDB reads the Linux specific file when it's instantiated. This behaviour
prevents Mac OSX users from running unit tests. This function makes the
loading IPDB lazyily and therefore it can be mocked after the import of
modules that import this module.
:returns: The already cached or newly created ``pyroute2.IPDB`` instance
"""
global _IPDB_CACHE
if not _IPDB_CACHE:
_IPDB_CACHE = pyroute2.IPDB()
return _IPDB_CACHE
def get_iproute():
"""Returns the already cached or a newly created IPRoute instance.
IPRoute reads the Linux specific file when it's instantiated. This
behaviour prevents Mac OSX users from running unit tests. This function
makes the loading IPDB lazyily and therefore it can be mocked after the
import of modules that import this module.
:returns: The already cached or newly created ``pyroute2.IPRoute`` instance
"""
global _IPROUTE_CACHE
if not _IPROUTE_CACHE:
_IPROUTE_CACHE = pyroute2.IPRoute()
return _IPROUTE_CACHE
def _is_up(interface):
flags = interface['flags']
if not flags:
return False
return (flags & IFF_UP) == 1
def cleanup_veth(ifname):
"""Cleans the veth passed as an argument up.
:param ifname: the name of the veth endpoint
:returns: the index of the interface which name is the given ifname if it
exists, otherwise None
:raises: pyroute2.NetlinkError
"""
ipr = get_iproute()
veths = ipr.link_lookup(ifname=ifname)
if veths:
host_veth_index = veths[0]
ipr.link_remove(host_veth_index)
return host_veth_index
else:
return None
def port_bind(endpoint_id, neutron_port, neutron_subnets):
"""Binds the Neutron port to the network interface on the host.
:param endpoint_id: the ID of the endpoint as string
:param neutron_port: a port dictionary returned from
python-neutronclient
:param neutron_subnets: a list of all subnets under network to which this
endpoint is trying to join
:returns: the tuple of the names of the veth pair and the tuple of stdout
and stderr returned by processutils.execute invoked with the
executable script for binding
:raises: kuryr.common.exceptions.VethCreationFailure,
processutils.ProcessExecutionError
"""
ip = get_ipdb()
port_id = neutron_port['id']
ifname, peer_name = utils.get_veth_pair_names(port_id)
subnets_dict = {subnet['id']: subnet for subnet in neutron_subnets}
try:
with ip.create(ifname=ifname, kind=KIND_VETH,
reuse=True, peer=peer_name) as host_veth:
if not _is_up(host_veth):
host_veth.up()
with ip.interfaces[peer_name] as peer_veth:
fixed_ips = neutron_port.get(FIXED_IP_KEY, [])
if not fixed_ips and (IP_ADDRESS_KEY in neutron_port):
peer_veth.add_ip(neutron_port[IP_ADDRESS_KEY])
for fixed_ip in fixed_ips:
if IP_ADDRESS_KEY in fixed_ip and (SUBNET_ID_KEY in fixed_ip):
subnet_id = fixed_ip[SUBNET_ID_KEY]
subnet = subnets_dict[subnet_id]
cidr = netaddr.IPNetwork(subnet['cidr'])
peer_veth.add_ip(fixed_ip[IP_ADDRESS_KEY], cidr.prefixlen)
peer_veth.address = neutron_port[MAC_ADDRESS_KEY].lower()
if not _is_up(peer_veth):
peer_veth.up()
except pyroute2.CreateException:
raise exceptions.VethCreationFailure(
'Creating the veth pair was failed.')
except pyroute2.CommitException:
raise exceptions.VethCreationFailure(
'Could not configure the veth endpoint for the container.')
vif_type = neutron_port.get(VIF_TYPE_KEY, FALLBACK_VIF_TYPE)
vif_details = utils.string_mappings(neutron_port.get(VIF_DETAILS_KEY))
binding_exec_path = os.path.join(config.CONF.bindir, vif_type)
if not os.path.exists(binding_exec_path):
cleanup_veth(ifname)
raise exceptions.BindingNotSupportedFailure(
"vif_type({0}) is not supported. A binding script for "
"this type can't be found.".format(vif_type))
port_id = neutron_port['id']
network_id = neutron_port['network_id']
tenant_id = neutron_port['tenant_id']
mac_address = neutron_port['mac_address']
try:
stdout, stderr = processutils.execute(
binding_exec_path, BINDING_SUBCOMMAND, port_id, ifname,
endpoint_id, mac_address, network_id, tenant_id, vif_details,
run_as_root=True)
except processutils.ProcessExecutionError:
with excutils.save_and_reraise_exception():
cleanup_veth(ifname)
return (ifname, peer_name, (stdout, stderr))
def port_unbind(endpoint_id, neutron_port):
"""Unbinds the Neutron port from the network interface on the host.
:param endpoint_id: the ID of the Docker container as string
:param neutron_port: a port dictionary returned from python-neutronclient
:returns: the tuple of stdout and stderr returned by processutils.execute
invoked with the executable script for unbinding
:raises: processutils.ProcessExecutionError, pyroute2.NetlinkError
"""
vif_type = neutron_port.get(VIF_TYPE_KEY, FALLBACK_VIF_TYPE)
vif_details = utils.string_mappings(neutron_port.get(VIF_DETAILS_KEY))
unbinding_exec_path = os.path.join(config.CONF.bindir, vif_type)
port_id = neutron_port['id']
ifname, _ = utils.get_veth_pair_names(port_id)
mac_address = neutron_port['mac_address']
stdout, stderr = processutils.execute(
unbinding_exec_path, UNBINDING_SUBCOMMAND, port_id, ifname,
endpoint_id, mac_address, vif_details, run_as_root=True)
try:
cleanup_veth(ifname)
except pyroute2.NetlinkError:
raise exceptions.VethDeleteionFailure(
'Deleting the veth pair failed.')
return (stdout, stderr)

View File

@ -1,88 +0,0 @@
# 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.
class KuryrException(Exception):
"""Default Kuryr exception"""
class BindingFailure(KuryrException):
"""Exception represents the binding is failed.
This exception is thrown when the executable script for the binding is
failed and Kuryr can't proceed further.
"""
class BindingNotSupportedFailure(KuryrException):
"""Exception represents the vif type binding not support.
This exception is thrown when the executable script for the binding does
not exist and Kuryr can't proceed further.
"""
class DuplicatedResourceException(KuryrException):
"""Exception represents there're multiple resources for the ID.
For example, this exception is thrown when you query the Neutron resource
associated with the ID and you get multiple resources.
"""
class GatewayConflictFailure(KuryrException):
"""Exception represents gateway ip is conflict.
This exception is thrown when request gateway ip is conflict with the
gateway ip in existed network.
"""
class MandatoryApiMissing(KuryrException):
"""Exception represents that mandatory api is not found.
For example, this exception is thrown when expected neutron
extension(subnetpools) APIs are not found.
"""
class NoResourceException(KuryrException):
"""Exception represents there's no resource for the given query.
This exception is thrown when you query the Neutron resource associated
with the given query and you get none of them actually.
"""
class InactiveResourceException(KuryrException):
"""Exception represents the resource for the given query is not active.
This exception is thrown when you query the Neutron resource associated
with the given query and you get the status of the resource as something
other than ACTIVE.
"""
class VethCreationFailure(KuryrException):
"""Exception represents the veth pair creation is failed.
This exception is thrown when the veth pair is not created appropriately
and Kuryr can't proceed the binding further.
"""
class VethDeletionFailure(KuryrException):
"""Exception represents the veth pair deletion is failed.
This exception is thrown when the veth pair is not deleted appropriately
and Kuryr can't proceed the unbinding further.
"""

View File

@ -1,55 +0,0 @@
# 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.
__all__ = [
'list_kuryr_opts',
]
import copy
import itertools
from oslo_log import _options
from kuryr.common import config
_core_opts_with_logging = config.core_opts
_core_opts_with_logging += _options.common_cli_opts
_core_opts_with_logging += _options.logging_cli_opts
_core_opts_with_logging += _options.generic_log_opts
_kuryr_opts = [
(None, list(itertools.chain(_core_opts_with_logging))),
('neutron_client', config.neutron_opts),
('keystone_client', config.keystone_opts),
('binding', config.binding_opts),
]
def list_kuryr_opts():
"""Return a list of oslo_config options available in Kuryr service.
Each element of the list is a tuple. The first element is the name of the
group under which the list of elements in the second element will be
registered. A group name of None corresponds to the [DEFAULT] group in
config files.
This function is also discoverable via the 'kuryr' entry point under
the 'oslo_config.opts' namespace.
The purpose of this is to allow tools like the Oslo sample config file
generator to discover the options exposed to users by Kuryr.
:returns: a list of (group_name, opts) tuples
"""
return [(k, copy.deepcopy(o)) for k, o in _kuryr_opts]

View File

@ -1,17 +0,0 @@
# Copyright 2015 OpenStack Foundation
#
# 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 pbr.version
version_info = pbr.version.VersionInfo('kuryr')

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr import utils
from kuryr_libnetwork import utils
app = utils.make_json_app(__name__)

View File

@ -19,8 +19,8 @@ import os
from oslo_config import cfg
from oslo_log import log
from kuryr._i18n import _
from kuryr import version
from kuryr.lib._i18n import _
from kuryr.lib import version
core_opts = [
@ -32,7 +32,7 @@ core_opts = [
default='$pybasedir/usr/libexec/kuryr',
help=_('Directory for Kuryr vif binding executables.')),
cfg.StrOpt('kuryr_uri',
default='http://127.0.0.1:2377',
default='http://127.0.0.1:23750',
help=_('Kuryr URL for accessing Kuryr through json rpc.')),
cfg.StrOpt('capability_scope',
default=os.environ.get('CAPABILITY_SCOPE', 'local'),

View File

@ -24,14 +24,14 @@ from oslo_config import cfg
from oslo_log import log
from oslo_utils import excutils
from kuryr import app
from kuryr import binding
from kuryr.common import config
from kuryr.common import constants as const
from kuryr.common import exceptions
from kuryr._i18n import _LE, _LI, _LW
from kuryr import schemata
from kuryr import utils
from kuryr.lib import binding
from kuryr.lib import exceptions
from kuryr.lib._i18n import _LE, _LI, _LW
from kuryr_libnetwork import app
from kuryr_libnetwork.common import config
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork import schemata
from kuryr_libnetwork import utils
LOG = log.getLogger(__name__)
@ -85,8 +85,8 @@ def get_neutron_client():
return neutron_client
except Exception:
pass
cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
cfg.CONF.import_group('keystone_client', 'kuryr.common.config')
cfg.CONF.import_group('neutron_client', 'kuryr_libnetwork.common.config')
cfg.CONF.import_group('keystone_client', 'kuryr_libnetwork.common.config')
keystone_conf = cfg.CONF.keystone_client
username = keystone_conf.admin_user

View File

@ -10,16 +10,16 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import endpoint_create
from kuryr.schemata import endpoint_delete
from kuryr.schemata import join
from kuryr.schemata import leave
from kuryr.schemata import network_create
from kuryr.schemata import network_delete
from kuryr.schemata import release_address
from kuryr.schemata import release_pool
from kuryr.schemata import request_address
from kuryr.schemata import request_pool
from kuryr_libnetwork.schemata import endpoint_create
from kuryr_libnetwork.schemata import endpoint_delete
from kuryr_libnetwork.schemata import join
from kuryr_libnetwork.schemata import leave
from kuryr_libnetwork.schemata import network_create
from kuryr_libnetwork.schemata import network_delete
from kuryr_libnetwork.schemata import release_address
from kuryr_libnetwork.schemata import release_pool
from kuryr_libnetwork.schemata import request_address
from kuryr_libnetwork.schemata import request_pool
# Aliases for schemata in each module

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
ENDPOINT_CREATE_SCHEMA = {
u'links': [{

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
ENDPOINT_DELETE_SCHEMA = {
u'links': [{

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata.commons import COMMONS
from kuryr_libnetwork.schemata.commons import COMMONS
JOIN_SCHEMA = {

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import endpoint_delete
from kuryr_libnetwork.schemata import endpoint_delete
LEAVE_SCHEMA = endpoint_delete.ENDPOINT_DELETE_SCHEMA

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
NETWORK_CREATE_SCHEMA = {
u'links': [{

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
NETWORK_DELETE_SCHEMA = {
u'links': [{

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
RELEASE_ADDRESS_SCHEMA = {
u'links': [{

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
RELEASE_POOL_SCHEMA = {
u'links': [{

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
REQUEST_ADDRESS_SCHEMA = {
u'links': [{

View File

@ -10,7 +10,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr.schemata import commons
from kuryr_libnetwork.schemata import commons
REQUEST_POOL_SCHEMA = {
u'links': [{

View File

@ -14,9 +14,9 @@ import sys
from oslo_log import log
from kuryr import app
from kuryr.common import config
from kuryr import controllers
from kuryr_libnetwork import app
from kuryr_libnetwork.common import config
from kuryr_libnetwork import controllers
config.init(sys.argv[1:])

View File

@ -12,11 +12,11 @@
from neutronclient.tests.unit import test_cli20
from kuryr import app
from kuryr import binding
from kuryr.common import constants as const
from kuryr import controllers
from kuryr import utils
from kuryr.lib import binding
from kuryr_libnetwork import app
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork import controllers
from kuryr_libnetwork import utils
class TestCase(test_cli20.CLITestV20Base):

View File

@ -15,10 +15,10 @@ import os
from neutronclient.common import exceptions as n_exceptions
from kuryr.common import config
from kuryr.common import exceptions
from kuryr import controllers
from kuryr.tests.unit import base
from kuryr.lib import exceptions
from kuryr_libnetwork.common import config
from kuryr_libnetwork import controllers
from kuryr_libnetwork.tests.unit import base
class ConfigurationTest(base.TestKuryrBase):
@ -30,7 +30,7 @@ class ConfigurationTest(base.TestKuryrBase):
config.CONF.pybasedir)
self.assertEqual(basepath + '/usr/libexec/kuryr',
config.CONF.bindir)
self.assertEqual('http://127.0.0.1:2377',
self.assertEqual('http://127.0.0.1:23750',
config.CONF.kuryr_uri)
self.assertEqual('http://127.0.0.1:9696',

View File

@ -14,9 +14,9 @@ import ddt
from neutronclient.common import exceptions
from oslo_serialization import jsonutils
from kuryr import app
from kuryr.tests.unit import base
from kuryr import utils
from kuryr_libnetwork import app
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
@ddt.ddt

View File

@ -17,12 +17,12 @@ from oslo_concurrency import processutils
from oslo_serialization import jsonutils
from werkzeug import exceptions as w_exceptions
from kuryr import app
from kuryr import binding
from kuryr.common import constants as const
from kuryr.common import exceptions
from kuryr.tests.unit import base
from kuryr import utils
from kuryr.lib import binding
from kuryr.lib import exceptions
from kuryr_libnetwork import app
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
@ddt.ddt

View File

@ -15,11 +15,11 @@ import uuid
import ddt
from oslo_serialization import jsonutils
from kuryr import app
from kuryr.common import config
from kuryr.common import constants
from kuryr.tests.unit import base
from kuryr import utils
from kuryr_libnetwork import app
from kuryr_libnetwork.common import config
from kuryr_libnetwork.common import constants
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
@ddt.ddt

View File

@ -16,10 +16,10 @@ import ddt
from neutronclient.common import exceptions
from oslo_serialization import jsonutils
from kuryr import app
from kuryr.common import constants
from kuryr.tests.unit import base
from kuryr import utils
from kuryr_libnetwork import app
from kuryr_libnetwork.common import constants
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
class TestKuryrEndpointFailures(base.TestKuryrFailures):

View File

@ -15,10 +15,10 @@ import uuid
import ddt
from oslo_serialization import jsonutils
from kuryr import app
from kuryr.common import constants as const
from kuryr.tests.unit import base
from kuryr import utils
from kuryr_libnetwork import app
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
@ddt.ddt

View File

@ -14,11 +14,11 @@ import ddt
from oslo_serialization import jsonutils
import uuid
from kuryr.common import config
from kuryr.common import constants as const
from kuryr.controllers import app
from kuryr.tests.unit import base
from kuryr import utils
from kuryr_libnetwork.common import config
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork.controllers import app
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
FAKE_IP4_CIDR = '10.0.0.0/16'

View File

@ -15,10 +15,10 @@ from ddt import ddt
from neutronclient.common import exceptions
from oslo_serialization import jsonutils
from kuryr import app
from kuryr.common import constants as const
from kuryr.tests.unit import base
from kuryr import utils
from kuryr_libnetwork import app
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
class TestKuryrNetworkCreateFailures(base.TestKuryrFailures):

View File

@ -17,12 +17,12 @@ from oslo_concurrency import processutils
from oslo_serialization import jsonutils
from werkzeug import exceptions as w_exceptions
from kuryr import app
from kuryr import binding
from kuryr.common import constants as const
from kuryr.common import exceptions
from kuryr.tests.unit import base
from kuryr import utils
from kuryr.lib import binding
from kuryr.lib import exceptions
from kuryr_libnetwork import app
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
@ddt.ddt

View File

@ -15,9 +15,9 @@ import uuid
import ddt
from oslo_config import cfg
from kuryr.common import constants as const
from kuryr.tests.unit import base
from kuryr import utils
from kuryr_libnetwork.common import constants as const
from kuryr_libnetwork.tests.unit import base
from kuryr_libnetwork import utils
@ddt.ddt

View File

@ -9,7 +9,7 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
import hashlib
import os
import random
@ -27,9 +27,9 @@ from oslo_concurrency import processutils
from oslo_config import cfg
from werkzeug import exceptions as w_exceptions
from kuryr._i18n import _LE
from kuryr.common import constants as const
from kuryr.common import exceptions
from kuryr.lib._i18n import _LE
from kuryr.lib import exceptions
from kuryr_libnetwork.common import constants as const
DOCKER_NETNS_BASE = '/var/run/docker/netns'
PORT_POSTFIX = 'port'

View File

@ -15,3 +15,4 @@ python-neutronclient>=4.2.0 # Apache-2.0
pyroute2>=0.4.3 # Apache-2.0 (+ dual licensed GPL2)
os-client-config>=1.13.1 # Apache-2.0
neutron-lib>=0.2.0 # Apache-2.0
-e git+https://github.com/vikaschoudhary16/kuryr.git@drop_libnet_specific_code#egg=kuryr

View File

@ -12,6 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from kuryr import server
from kuryr_libnetwork import server
server.start()

View File

@ -1,59 +0,0 @@
#!/bin/bash
# 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.
bind_port() {
echo "plugging veth $2 (Neutron port $1)..."
# create a linux bridge
br_name="br"${4:0:12}
ip link show $br_name
if [ $? -ne 0 ]; then
echo "Bridge $br_name does not exist, create it"
ip link add name $br_name type bridge
echo 0 > /sys/devices/virtual/net/$br_name/bridge/forward_delay
echo 0 > /sys/devices/virtual/net/$br_name/bridge/stp_state
ip link set $br_name up
else
echo "Bridge $br_name exists"
fi
# connect the veth outside to linux bridge
ip link set dev $2 master $br_name
ip link set $2 up
}
unbind_port() {
echo "unplugging veth $1..."
br_name="br"${3:0:12}
ip link set dev $2 nomaster
ip link set $br_name down
ip link delete $br_name type bridge
}
case $1 in
"bind")
shift
bind_port "$@"
exit 0
;;
"unbind")
shift
unbind_port "$@"
exit 0
;;
*)
echo >&2 "$0: Invalid command $1."
exit 1
;;
esac

View File

@ -1,42 +0,0 @@
#!/bin/bash
# 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.
bind_port() {
echo "plugging veth $2 (Neutron port $1)..."
/opt/pg/bin/ifc_ctl gateway add_port $2
/opt/pg/bin/ifc_ctl gateway ifup $2 access_vm $1 $4 pgtag2=$5 pgtag1=$6
}
unbind_port() {
echo "unplugging veth $1..."
/opt/pg/bin/ifc_ctl gateway ifdown $2 access_vm $1 $4
/opt/pg/bin/ifc_ctl gateway del_port $2
}
case $1 in
"bind")
shift
bind_port "$@"
exit 0
;;
"unbind")
shift
unbind_port "$@"
exit 0
;;
*)
echo >&2 "$0: Invalid command $1."
exit 1
;;
esac

View File

@ -1,39 +0,0 @@
#!/bin/bash
# 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.
bind_port() {
echo "Binding Neutron port $1 to the veth $2..."
mm-ctl --bind-port $1 $2
}
unbind_port() {
echo "Unbinding Neutron port $1..."
mm-ctl --unbind-port $1
}
case $1 in
"bind")
shift
bind_port "$@"
exit 0
;;
"unbind")
shift
unbind_port "$@"
exit 0
;;
*)
echo >&2 "$0: Invalid command $1."
exit 1
;;
esac

View File

@ -1,115 +0,0 @@
#!/bin/bash
# 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.
INT_BRIDGE="br-int"
HYBRID_PLUG="'ovs_hybrid_plug': True"
OPERATION=$1
PORT=$2
VETH=$3
CONTAINER_UUID=$4
MAC_ADDRESS=$5
ovs_bind_port() {
echo "plugging veth $VETH (Neutron port $PORT)..."
ovs-vsctl -- --may-exist add-port $INT_BRIDGE $VETH -- \
set interface $VETH external_ids:attached-mac=$MAC_ADDRESS \
external_ids:iface-id=$PORT external_ids:vm-uuid=$CONTAINER_UUID \
external_ids:iface-status=active external_ids:owner=kuryr
}
ovs_unbind_port() {
echo "unplugging port $PORT..."
MYPORT=`ovs-vsctl --data=bare --no-heading --columns=name \
find interface external_ids:iface-id=$PORT \
external_ids:owner=kuryr`
if [ -z "$MYPORT" ]; then
echo >&2 "Failed to find port $PORT."
exit 1
fi
ovs-vsctl del-port $INT_BRIDGE $MYPORT
}
ovs_hybrid_bind_port() {
echo "... plugging veth $VETH (Neutron port $PORT) ..."
# create a linux bridge
br_name="qbr"${PORT:0:11}
ip link add name $br_name type bridge
# Using brctl allows containerized usage not to need privileged mode
# as sysfs is mounted read-only when running with just CAP_NET_ADMIN
brctl setfd $br_name 0
brctl stp $br_name off
# connect the veth outside to linux bridge
ip link set $VETH up
ip link set dev $VETH master $br_name
# create a veth pair to connect linux bridge and the integration bridge
veth_lb="qvb"${PORT:0:11}
veth_ovs="qvo"${PORT:0:11}
ip link add $veth_lb type veth peer name $veth_ovs
# connect one end to the linux bridge
ip link set dev $veth_lb master $br_name
ip link set $br_name up
# connect one end to the ovs integration bridge
ovs-vsctl add-port $INT_BRIDGE $veth_ovs -- \
set interface $veth_ovs external_ids:attached-mac=$MAC_ADDRESS \
external_ids:iface-id=$PORT external_ids:vm-id=$CONTAINER_UUID \
external_ids:iface-status=active external_ids:owner=kuryr
ip link set $veth_lb up
ip link set $veth_ovs up
}
ovs_hybrid_unbind_port() {
echo "unplugging port $PORT ..."
br_name="qbr"${PORT:0:11}
veth_lb="qvb"${PORT:0:11}
veth_ovs="qvo"${PORT:0:11}
ip link set dev $veth_lb nomaster
ovs-vsctl del-port $veth_ovs
ip link delete $veth_lb type veth
ip link set $br_name down
ip link delete $br_name type bridge
}
case $OPERATION in
"bind")
shift
if [ "${7/$HYBRID_PLUG}" = "$7" ]
then
ovs_bind_port
else
ovs_hybrid_bind_port
fi
exit 0
;;
"unbind")
shift
if [ "${5/$HYBRID_PLUG}" = "$5" ]
then
ovs_unbind_port
else
ovs_hybrid_unbind_port
fi
exit 0
;;
*)
echo >&2 "$0: Invalid command $OPERATION."
exit 1
;;
esac

View File

@ -1,47 +0,0 @@
#!/bin/bash
# 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.
bind_port() {
echo "Binding VIF_TYPE_TAP Neutron port $1 / veth $2..."
#
# No real code is needed here, because VIF_TYPE_TAP means that the
# host-side TAP or veth device should be left unbridged. The core Kuryr
# code has already created the Linux TAP/veth device on the host side, so
# there is nothing further for this script to do.
}
unbind_port() {
echo "Unbinding VIF_TYPE_TAP Neutron port $1..."
#
# As with bind_port(), there is actually nothing to do here. The core
# Kuryr code will delete the Linux TAP/veth device on the host side after
# this script returns, and for VIF_TYPE_TAP we don't need to do anything to
# 'unbind' before that happens.
}
case $1 in
"bind")
shift
bind_port "$@"
exit 0
;;
"unbind")
shift
unbind_port "$@"
exit 0
;;
*)
echo >&2 "$0: Invalid command $1."
exit 1
;;
esac

View File

@ -1,16 +0,0 @@
#!/bin/bash
# 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.
echo "binding:vif_type is invalid."
exit 1