Update: assign static IP to VM for standalone 65/64165/3
authorStepan Andrushko <stepanx.andrushko@intel.com>
Mon, 29 Oct 2018 19:32:44 +0000 (21:32 +0200)
committerStepan Andrushko <stepanx.andrushko@intel.com>
Tue, 30 Oct 2018 19:31:11 +0000 (21:31 +0200)
Updated cloud-init network file to be used on Ubuntu 16.04 and
Ubuntu 18.04. Fields 'macaddress' and 'prefix' modified in
network-config file.

JIRA: YARDSTICK-1402

Change-Id: Ibe7fb9dbf23326a0a6106f98d3b2b9fedf81f79a
Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
yardstick/benchmark/contexts/standalone/model.py
yardstick/tests/unit/benchmark/contexts/standalone/test_model.py

index 1004c62..ab5fec0 100644 (file)
@@ -107,7 +107,7 @@ version: 2
 ethernets:
   ens3:
     match:
-      mac_address: {mac_address}
+      macaddress: {mac_address}
     addresses:
       - {ip_address}
 EOF
@@ -570,6 +570,8 @@ class StandaloneContextHelper(object):
         # Update image with public key
         key_filename = node.get('key_filename')
         ip_netmask = "{0}/{1}".format(node.get('ip'), node.get('netmask'))
+        ip_netmask = "{0}/{1}".format(node.get('ip'),
+                                      IPNetwork(ip_netmask).prefixlen)
         Libvirt.gen_cdrom_image(connection, cdrom_img, vm_name, user_name, key_filename, mac,
                                 ip_netmask)
         return node
index 98d2b18..10e1e3b 100644 (file)
@@ -17,6 +17,7 @@ import os
 import uuid
 
 import mock
+import netaddr
 import unittest
 from xml.etree import ElementTree
 
@@ -292,6 +293,7 @@ class ModelLibvirtTestCase(unittest.TestCase):
         hostname = root.find('name').text
         mac = "00:11:22:33:44:55"
         ip = "{0}/{1}".format(node.get('ip'), node.get('netmask'))
+        ip = "{0}/{1}".format(node.get('ip'), netaddr.IPNetwork(ip).prefixlen)
         model.StandaloneContextHelper.check_update_key(self.mock_ssh, node, hostname, id_name,
                                                        cdrom_img, mac)
         mock_gen_cdrom_image.assert_called_once_with(self.mock_ssh, cdrom_img, hostname,