Merge "Added apis to scenario manager"
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 0000000..8e42e85
--- /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 86df83a..85a6488 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -1173,6 +1173,32 @@
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