Rename server resources aligning with task file 17/917/2
authorHans Feldt <hans.feldt@ericsson.com>
Mon, 29 Jun 2015 13:39:34 +0000 (15:39 +0200)
committerHans Feldt <hans.feldt@ericsson.com>
Wed, 1 Jul 2015 12:03:38 +0000 (12:03 +0000)
In the task file we have cross referencing between servers (VMs).
This is done with DNS style naming. However servers created in the
cloud does not get the same type of name.

This patch aligns the cloud resource name with the one in the task file.
This prepares for running external scripts that takes server names as
input (see YARDSTICK-46)

The "instances" support in model.Server is not really working and
should be removed or fixed. No sample task file is using this
feature for now.

Change-Id: If2f752a82d224f07e4b5ee2361c1ff2454f39462
JIRA: -
Signed-off-by: Hans Feldt <hans.feldt@ericsson.com>
yardstick/benchmark/context/model.py

index 0877859..6e754d4 100644 (file)
@@ -119,7 +119,7 @@ class Server(Object):
 
     def __init__(self, name, context, attrs):
         super(Server, self).__init__(name, context)
-        self.stack_name = context.name + "-" + self.name
+        self.stack_name = self.name + "." + context.name
         self.keypair_name = context.keypair_name
         self.secgroup_name = context.secgroup_name
         self.context = context
@@ -211,12 +211,13 @@ class Server(Object):
     def add_to_template(self, template, networks, scheduler_hints=None):
         '''adds to the template one or more servers (instances)'''
         if self.instances == 1:
-            server_name = "%s-%s" % (template.name, self.name)
+            server_name = self.stack_name
             self._add_instance(template, server_name, networks,
                                scheduler_hints=scheduler_hints)
         else:
+            # TODO(hafe) fix or remove, no test/sample for this
             for i in range(self.instances):
-                server_name = "%s-%s-%d" % (template.name, self.name, i)
+                server_name = "%s-%d" % (self.stack_name, i)
                 self._add_instance(template, server_name, networks,
                                    scheduler_hints=scheduler_hints)