Add availability zone option to launch agent. 21/38221/3
authorTaseer Ahmed <taseer94@gmail.com>
Wed, 26 Jul 2017 19:46:28 +0000 (00:46 +0500)
committerTaseer Ahmed <taseer94@gmail.com>
Thu, 27 Jul 2017 04:38:11 +0000 (09:38 +0500)
JIRA: STORPERF-178

Change-Id: I1a5c1a0d1c3b700a0858f644b01553bf0b5675de
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
docker/storperf-master/rest_server.py
docker/storperf-master/storperf/resources/hot/storperf-agent.yaml
docker/storperf-master/storperf/storperf_master.py
docs/testing/user/test-usage.rst

index d551b57..7452898 100644 (file)
@@ -33,7 +33,8 @@ class ConfigurationRequestModel:
         'agent_flavor': fields.String,
         'agent_image': fields.String,
         'public_network': fields.String,
-        'volume_size': fields.Integer
+        'volume_size': fields.Integer,
+        'availability_zone': fields.String
     }
 
 
@@ -46,7 +47,8 @@ class ConfigurationResponseModel:
         'public_network': fields.String,
         'stack_created': fields.Boolean,
         'stack_id': fields.String,
-        'volume_size': fields.Integer
+        'volume_size': fields.Integer,
+        'availability_zone': fields.String
     }
 
 
@@ -68,6 +70,7 @@ class Configure(Resource):
                         'public_network': storperf.public_network,
                         'volume_size': storperf.volume_size,
                         'stack_created': storperf.is_stack_created,
+                        'availability_zone': storperf.availability_zone,
                         'stack_id': storperf.stack_id})
 
     @swagger.operation(
@@ -102,6 +105,8 @@ class Configure(Resource):
                 storperf.public_network = request.json['public_network']
             if ('volume_size' in request.json):
                 storperf.volume_size = request.json['volume_size']
+            if ('availability_zone' in request.json):
+                storperf.availabilty_zone = request.json['availability_zone']
 
             storperf.create_stack()
             if storperf.stack_id is None:
@@ -112,6 +117,7 @@ class Configure(Resource):
                             'agent_image': storperf.agent_image,
                             'public_network': storperf.public_network,
                             'volume_size': storperf.volume_size,
+                            'availability_zone': storperf.availability_zone,
                             'stack_id': storperf.stack_id})
 
         except Exception as e:
index 7bf8b4d..9f0481e 100644 (file)
@@ -39,6 +39,9 @@ parameters:
     type: string
     constraints:
         - custom_constraint: neutron.network
+  agent_zone:
+    type: string
+    default: nova
 resources:
 
   storperf_agent:
@@ -52,6 +55,7 @@ resources:
         - port: { get_resource: storperf_agent_port }
       user_data: { get_resource: storperf_agent_config }
       user_data_format: RAW
+      availability_zone: { get_param: agent_zone}
 
   storperf_agent_config:
     type: "OS::Heat::CloudConfig"
index 866a98e..8c2a7b4 100644 (file)
@@ -167,6 +167,19 @@ class StorPerfMaster(object):
             'stack_id',
             value)
 
+    @property
+    def availability_zone(self):
+        return self.configuration_db.get_configuration_value(
+            'stack',
+            'availability_zone')
+
+    @availability_zone.setter
+    def availability_zone(self, value):
+        self.configuration_db.set_configuration_value(
+            'stack',
+            'availability_zone',
+            value)
+
     @property
     def volume_quota(self):
         self._attach_to_openstack()
index 586ba7a..b13d815 100644 (file)
@@ -42,6 +42,7 @@ The following pieces of information are required to prepare the environment:
 - The OpenStack flavor to use when creating the VMs
 - The name of the public network that agents will use
 - The size, in gigabytes, of the Cinder volumes to create
+- The availability zone (optional) in which the VM is to be launched. Defaults to **nova**.
 
 The ReST API is a POST to http://StorPerf:5000/api/v1.0/configurations and
 takes a JSON payload as follows.
@@ -53,7 +54,8 @@ takes a JSON payload as follows.
      "agent_flavor": string
      "agent_image": string,
      "public_network": string,
-     "volume_size": int
+     "volume_size": int,
+     "availability_zone": string
    }
 
 This call will block until the stack is created, at which point it will return