From ed66447aae26d03de1c92563619068b44d56b27b Mon Sep 17 00:00:00 2001 From: Soniya Vyas Date: Wed, 23 Sep 2020 18:40:25 +0530 Subject: [PATCH] Added apis to scenario manager Tempest plugins do use associate_floating_ip() and disassociate_floating_ip() api but scenario- manager doesn't implement it. The plugins using these apis are manila-tempest- plugin, tap, vmware-nsx and neutron-tempest-plugin. Hence, added it to the scenario manager Implements: blueprint tempest-scenario-manager-stable Signed-off by: Soniya Vyas Change-Id: I41792bdc3478f5f290a6b3b7172ef3f6b4c62c19 --- ...ssociate-floating_ip-0b6cfebeef1304b0.yaml | 5 ++++ tempest/scenario/manager.py | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 releasenotes/notes/associate-disassociate-floating_ip-0b6cfebeef1304b0.yaml diff --git a/releasenotes/notes/associate-disassociate-floating_ip-0b6cfebeef1304b0.yaml b/releasenotes/notes/associate-disassociate-floating_ip-0b6cfebeef1304b0.yaml new file mode 100644 index 0000000000..8e42e851aa --- /dev/null +++ b/releasenotes/notes/associate-disassociate-floating_ip-0b6cfebeef1304b0.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added associate_floating_ip() and dissociate_floating_ip() methods + to the scenario manager. diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py index ff860d5b90..2f2dea577d 100644 --- a/tempest/scenario/manager.py +++ b/tempest/scenario/manager.py @@ -1137,6 +1137,32 @@ class NetworkScenarioTest(ScenarioTest): floating_ip['id']) return floating_ip + def associate_floating_ip(self, floating_ip, server): + """Associate floating ip + + This wrapper utility attaches the floating_ip for + the respective port_id of server + """ + port_id, _ = self._get_server_port_id_and_ip4(server) + kwargs = dict(port_id=port_id) + floating_ip = self.floating_ips_client.update_floatingip( + floating_ip['id'], **kwargs)['floatingip'] + self.assertEqual(port_id, floating_ip['port_id']) + return floating_ip + + def disassociate_floating_ip(self, floating_ip): + """Disassociates floating ip + + This wrapper utility disassociates given floating ip. + :param floating_ip: a dict which is a return value of + floating_ips_client.create_floatingip method + """ + kwargs = dict(port_id=None) + floating_ip = self.floating_ips_client.update_floatingip( + floating_ip['id'], **kwargs)['floatingip'] + self.assertIsNone(floating_ip['port_id']) + return floating_ip + def check_floating_ip_status(self, floating_ip, status): """Verifies floatingip reaches the given status