commit 60a80953201aae84bc0fafe0350e33d67a100311
Author: Ilias Tsitsimpis <iliastsi@grnet.gr>
Date:   Tue Nov 26 12:48:30 2013 +0200

    burnin: Implement the new Network API

diff --git a/snf-tools/synnefo_tools/burnin/network_tests.py b/snf-tools/synnefo_tools/burnin/network_tests.py
index c5c1e64..69387cb 100644
--- a/snf-tools/synnefo_tools/burnin/network_tests.py
+++ b/snf-tools/synnefo_tools/burnin/network_tests.py
@@ -79,7 +79,7 @@ class NetworkTestSuite(CycladesTests):
         """Submit create server request for server A"""
         use_image = random.choice(self.avail_images)
         use_flavor = random.choice(self.avail_flavors)
-        server = self._create_server(use_image, use_flavor)
+        server = self._create_server(use_image, use_flavor, network=True)
 
         self.server_a = {}
         self.server_a['server'] = server
@@ -92,7 +92,7 @@ class NetworkTestSuite(CycladesTests):
         """Submit create server request for server B"""
         use_image = random.choice(self.avail_images)
         use_flavor = random.choice(self.avail_flavors)
-        server = self._create_server(use_image, use_flavor)
+        server = self._create_server(use_image, use_flavor, network=True)
 
         self.server_b = {}
         self.server_b['server'] = server
@@ -113,23 +113,15 @@ class NetworkTestSuite(CycladesTests):
 
     def test_006_create_network(self):
         """Submit a create network request"""
-        name = self.run_id
-        self.network = self._create_network(name)
+        self.network = self._create_network()
 
         self._insist_on_network_transition(
             self.network, ["BUILD"], "ACTIVE")
 
     def test_007_connect_to_network(self):
         """Connect the two VMs to the newly created network"""
-        self.clients.cyclades.connect_server(
-            self.server_a['server']['id'], self.network['id'])
-        self.clients.cyclades.connect_server(
-            self.server_b['server']['id'], self.network['id'])
-
-        self._insist_on_network_connection(
-            self.server_a['server'], self.network)
-        self._insist_on_network_connection(
-            self.server_b['server'], self.network)
+        self._create_port(self.network['id'], self.server_a['server']['id'])
+        self._create_port(self.network['id'], self.server_b['server']['id'])
 
         # Update servers
         self.server_a['server'] = self._get_server_details(
@@ -138,10 +130,12 @@ class NetworkTestSuite(CycladesTests):
             self.server_b['server'])
 
         # Check that servers got private IPs
-        self.server_a['pr_ipv4'] = self._get_ip(
-            self.server_a['server'], network=self.network)
-        self.server_b['pr_ipv4'] = self._get_ip(
-            self.server_b['server'], network=self.network)
+        ipv4 = self._get_ips(self.server_a['server'], network=self.network)
+        self.assertEqual(len(ipv4), 1)
+        self.server_a['pr_ipv4'] = ipv4[0]
+        ipv4 = self._get_ips(self.server_b['server'], network=self.network)
+        self.assertEqual(len(ipv4), 1)
+        self.server_b['pr_ipv4'] = ipv4
 
     def test_008_reboot_server_a(self):
         """Rebooting server A"""
@@ -155,7 +149,7 @@ class NetworkTestSuite(CycladesTests):
 
     def test_009_ping_server_a(self):
         """Test if server A responds to IPv4 pings"""
-        self._insist_on_ping(self._get_ip(self.server_a['server']))
+        self._insist_on_ping(self._get_ips(self.server_a['server'])[0])
 
     def test_010_reboot_server_b(self):
         """Rebooting server B"""
@@ -169,7 +163,7 @@ class NetworkTestSuite(CycladesTests):
 
     def test_011_ping_server_b(self):
         """Test that server B responds to IPv4 pings"""
-        self._insist_on_ping(self._get_ip(self.server_b['server']))
+        self._insist_on_ping(self._get_ips(self.server_b['server'])[0])
 
     def test_012_test_connection_exists(self):
         """Ping server B from server A to test if connection exists"""
@@ -178,9 +172,9 @@ class NetworkTestSuite(CycladesTests):
         self._skip_if(not self._image_is(self.server_b['image'], "linux"),
                       "only valid for Linux servers")
 
-        server_a_public_ip = self._get_ip(self.server_a['server'])
-        server_b_private_ip = self._get_ip(
-            self.server_b['server'], network=self.network)
+        server_a_public_ip = self._get_ips(self.server_a['server'])[0]
+        server_b_private_ip = self._get_ips(
+            self.server_b['server'], network=self.network)[0]
         msg = "Will try to connect to server A (%s) and ping to server B (%s)"
         self.info(msg, server_a_public_ip, server_b_private_ip)
 
@@ -198,33 +192,11 @@ class NetworkTestSuite(CycladesTests):
         self._disconnect_from_network(self.server_a['server'], self.network)
         self._disconnect_from_network(self.server_b['server'], self.network)
 
-        self._insist_on_network_connection(
-            self.server_a['server'], self.network, disconnect=True)
-        self._insist_on_network_connection(
-            self.server_b['server'], self.network, disconnect=True)
-
     def test_014_destroy_network(self):
         """Submit delete network request"""
-        self.clients.cyclades.delete_network(self.network['id'])
-        self._insist_on_network_transition(
-            self.network, ["ACTIVE"], "DELETED")
-
-        networks = [net['id'] for net in self._get_list_of_networks()]
-        self.assertNotIn(self.network['id'], networks)
-
-        # Verify quotas
-        self._check_quotas(network=-1)
+        self._delete_networks([self.network])
 
     def test_015_cleanup_servers(self):
         """Cleanup servers created for this test"""
-        self.clients.cyclades.delete_server(self.server_a['server']['id'])
-        self.clients.cyclades.delete_server(self.server_b['server']['id'])
-
-        self._insist_on_server_transition(
-            self.server_a['server'], ["ACTIVE"], "DELETED")
-        self._insist_on_server_transition(
-            self.server_b['server'], ["ACTIVE"], "DELETED")
-
-        # Verify quotas
-        self._verify_quotas_deleted([self.server_a['flavor'],
-                                     self.server_b['flavor']])
+        self._delete_servers([self.server_a['server'],
+                              self.server_b['server']])
