Commit Graph

309 Commits

Author SHA1 Message Date
Michał Dulko 66d31e7d65 Fix unit tests
pyroute2 changed structure of the modules a bit and the unit tests were
assuming it. This commit makes sure tests work with new pyroute2.

Change-Id: I013f2750ca1371d3b4d5e2f618067cd9b70e76e4
2021-09-15 12:32:40 +02:00
Andrew Bonney cdb9fe351d Remove run_as_root which fails without root_helper
It appears that this library is typically run as the root user
which shouldn't require 'run_as_root'. When running as an
unprivileged user the required permissions can be granted by
specifying 'AmbientCapabilities = CAP_NET_ADMIN' in the service,
rather than 'CapabilityBoundingSet'.

An alternative approach would be to specify a 'root_helper' or to
switch to oslo.privsep, but these don't fully solve the problem
as the 'pyroute2' library also requires 'CAP_NET_ADMIN'.

Closes-Bug: #1852105
Change-Id: I9d0942f1cfc06cc3a7585683a030516096297767
2020-12-01 08:32:18 +00:00
xuanyandong e1edbc4661 Remove six
Change-Id: I9f6f057fde95f378071c25dba7f27ed3f3a4c27b
2020-09-30 17:01:51 +08:00
Michał Dulko 2559722a72 Fix pep8 and lower-constraints gates
PEP8 needs upgrade of hacking version and lower-constraints require us
to start having stuff supporting Python 3.8 in lower-constraints.txt.
Both are fixed by this commit.

Change-Id: I1d0b244f98dbe2228edfcc0caae70b43013a18ad
2020-09-11 16:10:34 +02:00
gugug d3a2fae486 Remove all usage of six library
Convert all code to not require six library and instead
use python 3.x logic.

Change-Id: I273fee5b36e9bb57e3120597314176e0eac17a78
2020-08-27 23:10:32 +08:00
Sean McGinnis 0f47555b38
Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: Ibe31e2d17b8baf88c40e00e3beaa019b13594c7c
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-18 11:53:47 -05:00
Maysa Macedo 027247329d Fix default region name definition
This commit sets the default value of the region_name to 'None' in the
config, this way its avoided the use of a region name
that might not exists on the OpenStack cloud.

Closes-Bug: 1843194
Change-Id: Ic9deca9cb073b5458f5aa063f669b30ae2568f30
2019-09-09 11:32:51 +00:00
zhangchi 50da6c1b30 add region_name in get neutron client to support multi-region scene
kuryr should support neutron client in multi-region scene as follows:

https://bugs.launchpad.net/kuryr/+bug/1831684

Closes-Bug: 1831684

Change-Id: I91315885a56c5cfb313b73b1eddc3935bc200c6c
2019-08-29 07:28:41 +00:00
Zuul b10acd57ea Merge "Use keystone v3 instead of v2" 2019-08-14 13:35:40 +00:00
Andreas Jaeger d16ed92685 Update api-ref location
The api documentation is now published on docs.openstack.org instead
of developer.openstack.org. Update all links that are changed to the
new location.

Note that redirects will be set up as well but let's point now to the
new location.

For details, see:
http://lists.openstack.org/pipermail/openstack-discuss/2019-July/007828.html

Change-Id: Iff96760f90ea1bf71070577ed26ec6767860ea83
2019-07-25 18:06:17 +02:00
Takashi Kajinami 3c640ebf12 Use keystone v3 instead of v2
This patch replaces parameters for keystone v2 in README and
test codes by the ones for keystone v3, as currently keystone
v2 should not be used anymore.

Change-Id: I6b063dd980e414bfb7c7a94612076690daa85b2d
2019-06-19 14:48:15 +09:00
whoami-rajat d75eaff065 Add kuryr-status upgrade check command framework
This adds basic framework for kuryr-status upgrade
check commands. For now it has only "check_placeholder"
check implemented.
Real checks can be added to this tool in the future.

Change-Id: I8af38f087672a390ec8b2b78916315b5a646fcbb
Story: 2003657
Task: 26137
2018-10-23 16:51:51 +05:30
Hongbin Lu 2f38e07a38 Add logging for the original message
On port binding/unbinding, Kuryr catches exception raised from
pyroute2 and re-raise a new exception. As a result, the detailed
information contained in the original exception loses. This patch
adds a logging to record the original exception message and trace.

Related-Bug: #1776035
Change-Id: I4b13724a460d84a2b953f750b8b88c0f60cee97d
2018-06-09 22:07:34 +00:00
wanghui 7b2c13592a fix Neutron misspelling
Change-Id: I01e02b1e00fbbd7833f645804e15d25446dadcdf
2018-01-16 13:46:47 +08:00
Kien Nguyen d8e39cd8a6 Add ConflictConfigOption Exception
Change-Id: I448cf979fb87de7fe57325cca579b47b43c37f36
2017-11-15 08:36:35 +07:00
Hongbin Lu da736d115b Allow multiple binding drivers
In before, only one binding driver is allowed. This patch introduces
a new config to support multiple binding drivers. The first use case
is to allow SR-IOV binding to be co-existed with other binding.

* Rename the config 'driver' to 'default_driver' in 'binding' group.
  This is for making it clear that it is allowed to have more than
  one type of bindings.
* Introduce a new config called 'enabled_drivers'.
* Allow client to pass a driver name to port_bind and port_unbind.
  If this parameter is None, kuryr will load the default driver.

Partial-Implements: blueprint sriov-binding
Change-Id: I14b23379de9f2459ba97d5d82dfdb51553370cb1
2017-10-17 12:06:57 -04:00
Hongbin Lu 48e3f4f91d Introduce a SR-IOV binding driver
The driver is for binding/unbinding SR-IOV port. Basically,
what it does is setting the vlan id for the VF interface.

Change-Id: Ife43b57a11c9aac9c0bece84adf719e62f708fda
Partial-Implements: blueprint sriov-binding
2017-10-16 13:45:16 +00:00
Kien Nguyen df421a9b2e Add compatibility for pyroute2>=0.4.15
Pyroute2 was updated, its change make some testcases failed.
This patch fix the problem with pyroute2 update.

Change-Id: I300f9830927a8babf9112f9aff265ef4b2e5e03e
Closes-Bug: #1700469
2017-06-26 15:00:31 +07:00
shihanzhang 41a6cc6e13 Remove log translations
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: I525013db086e2eed874c5cc9bb8fc409d5a527cc
2017-03-21 13:53:50 +08:00
Dongcan Ye d4e71a3794 Add unit tests for nested binding driver
Add unit test for binding drivers: IPVLAN, MACVLAN,
and VLAN.

Change-Id: I8d25630b1543f9760cc34f331711804c7a1dde0f
Closes-Bug: #1644403
2017-03-06 13:27:03 +08:00
Dongcan Ye e6ed953784 Add unit test for veth binding driver
This patch adds unit test for veth binding driver,
this change is mostly based on the previously test_package.

Change-Id: I2ba8dafbe31243608bf0c4ae68e8324ec7e27157
Partial-Bug: #1644403
2017-03-01 17:05:31 +08:00
Jenkins 9583a26274 Merge "E128 ignore statement make code unclearly" 2017-02-13 14:30:43 +00:00
xhzhf cecb593a3f E128 ignore statement make code unclearly
E128 ignore statement make code unclearly.
we can fix E128 issue.
Closes-Bug: #1651297

Change-Id: I0f38febecffb0dc5f5419b959be5758739d9cde0
2017-02-13 19:40:18 +08:00
Luis Tomas Bolivar 07d62f1e95 Change DEVICE_OWNER to make it more Neutron compliant
Change-Id: Id7a2973928c6df9e134e7b91000e90f244066703
2017-02-08 17:37:37 +00:00
Jenkins 4224ccce3b Merge "Add randomness to the returned vlan_ids" 2017-02-01 11:06:04 +00:00
Luis Tomas Bolivar af9d0eb0d6 Add randomness to the returned vlan_ids
This patch modifies allocate_segmentation_id so that the vlan_id
returned is randomly selected between the available ids.
The main rationale behind is to avoid vlan_id collisions, for
instance in active-active deployments, among different calls.
Note this will minimize the collision if nested containers are
created by using both kubernetes and docker in the same VM.

Partially Implements blueprint containers-in-instances

Change-Id: Iba2c94707c4932d59483c793452da88c43d4215c
2017-02-01 09:34:21 +00:00
Luis Tomas Bolivar 2ddf65f2b4 Make segmentation driver testable
This allows import vlan segmentation driver for unit testing

Change-Id: Ic69b1481d5815b900608a8ad99a99b686724246c
2017-02-01 07:20:17 +00:00
Jenkins 161274b27e Merge "Add the missing AddressInUseException" 2017-01-09 18:58:17 +00:00
Hongbin Lu 0439d7b820 Refactor out keystoneauth code from neutron
* Split get_neutron_client into three methods: get_neutron_client,
  get_auth_plugin, and get_keystone_session.
* Split register_neutron_opts into two methods:
  register_neutron_opts and register_keystoneauth_opts
* Split list_neutron_opts into two methods: list_neutron_opts
  and get_keystoneauth_conf_options

This allows Fuxi to reuse the keystone code to get a cinder
client and generate sample config.

Change-Id: I9053b6d1a669d471a4c6b447fb72591a421a8caa
2016-12-27 22:32:00 -06:00
Hongbin Lu 0f118fee78 Avoid hard-coding of 'neutron' config group
The name of neutron config group is specified in file
kuryr/lib/config.py. If we want to retrieve the name of this config
group, we should read it from that file instead of hard-coding it.

Change-Id: Id6ebc4fc8433a802edc04b941a591e03d23c489e
2016-12-27 18:13:21 -06:00
Hong Hui Xiao 3f88afa5a9 Add the missing AddressInUseException
Commit fd904a6a656e338ece36f5353273bcb7220066ee uses an exception from
kuryr lib. However, it missed to add the exception.

Change-Id: I52507a547a5f20254e86a0b5cda9eb0b70617ead
Closes-Bug: #1651062
2016-12-19 04:02:32 -05:00
Jenkins c02ff1aa3a Merge "Passing port's project_id in port_bind" 2016-12-12 11:40:53 +00:00
Dongcan Ye 0cd6cfa02f Passing port's project_id in port_bind
Only get port's tenant_id if we're in Keystone v2.

Closes-Bug: #1649218
Change-Id: I7cf64183785f9eb04d9f831ec3cc65c2f9ee01f8
2016-12-12 08:48:51 +00:00
Dongcan Ye efe0078d36 Fix mock order
As per [1], the order of the created mocks passed into test function must
matches the decorators apply order(from the bottom upwards).

[1] http://www.voidspace.org.uk/python/mock/patch.html#nesting-patch-decorators

Change-Id: I139f78f25c32cf82c9d4b4d4d3a2852a23fab89c
2016-12-12 13:36:45 +08:00
Liping Mao 94544eef29 mac and mtu is not configured in macvlan and ipvlan driver
Change-Id: I4e2ab38e32830f58e638c8acf0494b0807d72691
Closes-bug: #1648018
2016-12-07 22:38:40 +08:00
Jenkins 051b7dcc53 Merge "Nested-Containers: vlan driver" 2016-11-29 08:49:10 +00:00
vikaschoudhary16 116052f9db Nested-Containers: vlan driver
Add support to enable isolation of container's traffic within
host(nova instances) using vlan segmentations.

Partially Implements blueprint containers-in-instances
Change-Id: If4800594adfac27a8f30dedac4787d79c8634b65
2016-11-28 14:52:10 +00:00
Jenkins 0fd045d743 Merge "Fix wrong exception catch in port_unbind" 2016-11-24 08:27:20 +00:00
Dongcan Ye 1164fbffc7 Fix wrong exception catch in port_unbind
Change-Id: I902c466c09a9b524af745a159136d647e23ca166
Closes-Bug: #1644136
2016-11-24 10:15:14 +08:00
Jenkins c5dc85057c Merge "Fix container port ipaddress setting in ipvlan/macvlan drivers" 2016-11-23 10:45:53 +00:00
vikaschoudhary16 1939273877 Fix container port ipaddress setting in ipvlan/macvlan drivers
Currently ipaddress is being set from nova instance port and thus
making vm ip and container ip same. Fix this by using container port
dict for getting container IP.

Another change is renaming 'nested_port', which is actually Nova
instance port, to 'vm_port', for the sake of avoiding ambiguity.

Change-Id: I9ea93c88c2889c5a6b7eff230ffdfb87b96b0e25
Closes-bug: #1641537
2016-11-22 10:21:54 +00:00
bailinzhang 0b311c8507 Replaces uuid.uuid4 with uuidutils.generate_uuid()
Change-Id: Idf397282e60a2d1a5e0b092d7d61d7e5532afa7b
Closes-Bug: #1082248
2016-11-21 01:50:03 +00:00
Jenkins 421ce166f1 Merge "Update message as per i18n" 2016-11-07 11:50:22 +00:00
Liping Mao d241bbbb2f kuryr bind port error with neutron linux bridge driver
When neutron configured with linux bridge driver, kuryr will bind
port error. The linux bridge name should be "brq"+network_id[0,11].

Change-Id: I07be68bbfe7b1384f4e946664aed41546ff9ddce
Closes-bug: #1638041
2016-11-01 14:57:05 +08:00
Jenkins 31325bd85a Merge "return key error when start container with kuryr binding veth driver" 2016-10-17 14:32:00 +00:00
Janonymous cf337db2ea Update message as per i18n
Change-Id: Iffd22fb6c634047a52a38b3ab78205255fe46047
2016-10-13 03:17:10 +00:00
Liping Mao 2f5fcc9926 'IPDB' object has no attribute 'interface' in utils.remove_device
Change-Id: I7068651572f4781ebf7f8cd954730f6a4c30dab3
Closes-bug: #1631819
2016-10-13 08:39:52 +08:00
Liping Mao 2740f78b9c return key error when start container with kuryr binding veth driver
the veth should be created before we call ip.interfaces[container_ifname].

Change-Id: Ifc56317433f3691841411be63e5e5f5ab56aeacf
Closes-bug: #1631817
2016-10-12 22:20:55 +00:00
Jenkins f2073f6dfb Merge "binding: use cached interface info" 2016-10-03 18:10:48 +00:00
Jenkins f0b53161b5 Merge "Replace link_remove with link delete" 2016-10-03 18:10:37 +00:00