Merge "api_crud: migrate ensure_hm_port_mtu to opentackSDK"
This commit is contained in:
@@ -7,3 +7,4 @@
|
|||||||
git+https://github.com/juju/charm-tools.git
|
git+https://github.com/juju/charm-tools.git
|
||||||
|
|
||||||
simplejson
|
simplejson
|
||||||
|
openstacksdk==3.0.0
|
||||||
|
@@ -33,6 +33,7 @@ from keystoneauth1 import session as keystone_session
|
|||||||
from keystoneauth1 import exceptions as keystone_exceptions
|
from keystoneauth1 import exceptions as keystone_exceptions
|
||||||
from neutronclient.v2_0 import client as neutron_client
|
from neutronclient.v2_0 import client as neutron_client
|
||||||
from novaclient import client as nova_client
|
from novaclient import client as nova_client
|
||||||
|
from openstack import connection
|
||||||
|
|
||||||
import neutron_lib.services.trunk.constants
|
import neutron_lib.services.trunk.constants
|
||||||
|
|
||||||
@@ -503,10 +504,12 @@ def ensure_hm_port_mtu(identity_service):
|
|||||||
reflected here as well.
|
reflected here as well.
|
||||||
"""
|
"""
|
||||||
session = session_from_identity_service(identity_service)
|
session = session_from_identity_service(identity_service)
|
||||||
nc = init_neutron_client(session)
|
conn = connection.Connection(session=session,
|
||||||
resp = nc.list_networks(tags='charm-octavia')
|
compute_api_version='2',
|
||||||
if len(resp['networks']) > 0:
|
identity_interface='internal')
|
||||||
network = resp['networks'][0]
|
net_resp = list(conn.network.networks(tags='charm-octavia'))
|
||||||
|
if len(net_resp) > 0:
|
||||||
|
network = net_resp[0]
|
||||||
ch_core.hookenv.log('ensuring mgmt network {} mtu={}'.
|
ch_core.hookenv.log('ensuring mgmt network {} mtu={}'.
|
||||||
format(network['id'], network['mtu']),
|
format(network['id'], network['mtu']),
|
||||||
level=ch_core.hookenv.DEBUG)
|
level=ch_core.hookenv.DEBUG)
|
||||||
|
5
tox.ini
5
tox.ini
@@ -36,7 +36,7 @@ allowlist_externals =
|
|||||||
{toxinidir}/rename.sh
|
{toxinidir}/rename.sh
|
||||||
deps =
|
deps =
|
||||||
-r{toxinidir}/requirements.txt
|
-r{toxinidir}/requirements.txt
|
||||||
|
-r{toxinidir}/test-requirements.txt
|
||||||
[testenv:build]
|
[testenv:build]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
# charmcraft clean is done to ensure that
|
# charmcraft clean is done to ensure that
|
||||||
@@ -61,17 +61,14 @@ commands =
|
|||||||
|
|
||||||
[testenv:py3]
|
[testenv:py3]
|
||||||
basepython = python3
|
basepython = python3
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = stestr run --slowest {posargs}
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
[testenv:py312]
|
[testenv:py312]
|
||||||
basepython = python3.12
|
basepython = python3.12
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = stestr run --slowest {posargs}
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
[testenv:py310]
|
[testenv:py310]
|
||||||
basepython = python3.10
|
basepython = python3.10
|
||||||
deps = -r{toxinidir}/test-requirements.txt
|
|
||||||
commands = stestr run --slowest {posargs}
|
commands = stestr run --slowest {posargs}
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
|
@@ -77,3 +77,4 @@ sys.modules['neutron_lib.services.trunk.constants'] = (
|
|||||||
neutronclient = mock.MagicMock()
|
neutronclient = mock.MagicMock()
|
||||||
sys.modules['neutronclient'] = neutronclient
|
sys.modules['neutronclient'] = neutronclient
|
||||||
sys.modules['neutronclient.v2_0'] = neutronclient.v2_0
|
sys.modules['neutronclient.v2_0'] = neutronclient.v2_0
|
||||||
|
sys.modules['openstack'] = mock.MagicMock()
|
||||||
|
@@ -21,6 +21,8 @@ import charms_openstack.test_utils as test_utils
|
|||||||
import charm.openstack.octavia as octavia # for constants
|
import charm.openstack.octavia as octavia # for constants
|
||||||
import charm.openstack.api_crud as api_crud
|
import charm.openstack.api_crud as api_crud
|
||||||
|
|
||||||
|
from openstack import connection
|
||||||
|
|
||||||
|
|
||||||
class FakeNeutronConflictException(Exception):
|
class FakeNeutronConflictException(Exception):
|
||||||
pass
|
pass
|
||||||
@@ -298,12 +300,12 @@ class TestAPICrud(test_utils.PatchHelper):
|
|||||||
def test_setup_hm_port(self):
|
def test_setup_hm_port(self):
|
||||||
self.patch_object(api_crud, 'session_from_identity_service')
|
self.patch_object(api_crud, 'session_from_identity_service')
|
||||||
self.patch_object(api_crud, 'init_neutron_client')
|
self.patch_object(api_crud, 'init_neutron_client')
|
||||||
nc = mock.MagicMock()
|
self.patch_object(connection, 'Connection')
|
||||||
self.init_neutron_client.return_value = nc
|
conn = mock.MagicMock()
|
||||||
|
self.Connection.return_value = conn
|
||||||
network_uuid = 'fake-network-uuid'
|
network_uuid = 'fake-network-uuid'
|
||||||
nc.list_networks.return_value = {'networks': [{'id': network_uuid,
|
conn.network.networks.return_value = [{'id': network_uuid,
|
||||||
'mtu': 9000}]}
|
'mtu': 9000}]
|
||||||
|
|
||||||
self.patch_object(octavia.ch_net_ip, 'get_iface_addr')
|
self.patch_object(octavia.ch_net_ip, 'get_iface_addr')
|
||||||
self.get_iface_addr.return_value = [
|
self.get_iface_addr.return_value = [
|
||||||
'fe80:db8:42%eth0', '2001:db8:42::42', '127.0.0.1'
|
'fe80:db8:42%eth0', '2001:db8:42::42', '127.0.0.1'
|
||||||
|
Reference in New Issue
Block a user