Auth timeout fix and VM image selection 63/13863/1
authorMark Beierl <mark.beierl@emc.com>
Tue, 10 May 2016 16:48:53 +0000 (10:48 -0600)
committerMark Beierl <mark.beierl@emc.com>
Tue, 10 May 2016 16:49:00 +0000 (10:49 -0600)
Fix the OpenStack client authentication timeout bug where we never
reauthenticate after authentication expires
Add the ability to specify what OS image from the Glance catalog
should be used for the Agent VM

Change-Id: I2ff8f5598b8d58ee2bf654b3572e9841b24cc9de
JIRA: STORPERF-42
Signed-off-by: Mark Beierl <mark.beierl@emc.com>
docker/requirements.pip
rest_server.py
storperf/resources/hot/agent-group.yaml
storperf/storperf_master.py

index 4c9aaae..8efaf24 100644 (file)
@@ -5,6 +5,7 @@ python-novaclient==2.28.1
 python-glanceclient==1.1.0
 python-cinderclient==1.6.0
 python-keystoneclient==1.6.0
+matplotlib==1.3.1
 flask==0.10
 flask-restful==0.3.5
 flask-restful-swagger==0.19
index 72f849a..7fba94a 100644 (file)
@@ -113,6 +113,7 @@ def results_page(job_id):
 class ConfigurationRequestModel:
     resource_fields = {
         'agent_count': fields.Integer,
+        'agent_image': fields.String,
         'public_network': fields.String,
         'volume_size': fields.Integer
     }
@@ -122,6 +123,7 @@ class ConfigurationRequestModel:
 class ConfigurationResponseModel:
     resource_fields = {
         'agent_count': fields.Integer,
+        'agent_image': fields.String,
         'public_network': fields.String,
         'stack_created': fields.Boolean,
         'stack_id': fields.String,
@@ -142,6 +144,7 @@ class Configure(Resource):
     )
     def get(self):
         return jsonify({'agent_count': storperf.agent_count,
+                        'agent_image': storperf.agent_image,
                         'public_network': storperf.public_network,
                         'volume_size': storperf.volume_size,
                         'stack_created': storperf.is_stack_created,
@@ -171,6 +174,8 @@ class Configure(Resource):
         try:
             if ('agent_count' in request.json):
                 storperf.agent_count = request.json['agent_count']
+            if ('agent_image' in request.json):
+                storperf.agent_image = request.json['agent_image']
             if ('public_network' in request.json):
                 storperf.public_network = request.json['public_network']
             if ('volume_size' in request.json):
@@ -180,6 +185,7 @@ class Configure(Resource):
             storperf.create_stack()
 
             return jsonify({'agent_count': storperf.agent_count,
+                            'agent_image': storperf.agent_image,
                             'public_network': storperf.public_network,
                             'volume_size': storperf.volume_size,
                             'stack_id': storperf.stack_id})
index 4a1df8e..4566f7a 100644 (file)
@@ -17,6 +17,9 @@ parameters:
   flavor:
     type: string
     default: "m1.small"
+  agent_image:
+    type: string
+    default: 'StorPerf Ubuntu 14.04'
   key_name:
     type: string
     default: StorPerf
@@ -47,6 +50,7 @@ resources:
           public_network: {get_param: public_network},
           agent_network: {get_resource: storperf_network},
           flavor: {get_param: flavor},
+          image: {get_param: agent_image},
           storperf_open_security_group: {get_resource: storperf_open_security_group},
           key_name: {get_param: key_name},
           volume_size: {get_param: volume_size}
index c7739da..b678bc8 100644 (file)
@@ -7,6 +7,7 @@
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
 
+from datetime import datetime
 from storperf.db.graphite_db import GraphiteDB
 from threading import Thread
 from time import sleep
@@ -56,6 +57,7 @@ class StorPerfMaster(object):
         self._cinder_client = None
         self._heat_client = None
         self._test_executor = TestExecutor()
+        self._last_openstack_auth = datetime.now()
 
     @property
     def volume_size(self):
@@ -100,6 +102,28 @@ class StorPerfMaster(object):
             'agent_count',
             value)
 
+    @property
+    def agent_image(self):
+        value = self.configuration_db.get_configuration_value(
+            'stack',
+            'agent_image')
+
+        if (value is None):
+            value = 'Ubuntu 14.04'
+            self.agent_image = value
+            return value
+
+    @agent_image.setter
+    def agent_image(self, value):
+        if (self.stack_id is not None):
+            raise ParameterError(
+                "ERROR: Cannot change agent image after stack is created")
+
+        self.configuration_db.set_configuration_value(
+            'stack',
+            'agent_image',
+            value)
+
     @property
     def public_network(self):
         return self.configuration_db.get_configuration_value(
@@ -357,17 +381,24 @@ class StorPerfMaster(object):
         heat_parameters['public_network'] = self.public_network
         heat_parameters['agent_count'] = self.agent_count
         heat_parameters['volume_size'] = self.volume_size
+        heat_parameters['agent_image'] = self.agent_image
         return heat_parameters
 
     def _attach_to_openstack(self):
 
-        if (self._cinder_client is None):
+        time_since_last_auth = datetime.now() - self._last_openstack_auth
+        print time_since_last_auth.total_seconds()
+        if (self._cinder_client is None or
+                time_since_last_auth.total_seconds() > 600):
+            self._last_openstack_auth = datetime.now()
+
+            self.logger.debug("Authenticating with OpenStack")
+
             self._cinder_client = cinderclient.Client(
                 self._username, self._password, self._project_name,
                 self._auth_url, service_type='volumev2')
             self._cinder_client.authenticate()
 
-        if (self._heat_client is None):
             self._keystone_client = ksclient.Client(
                 auth_url=self._auth_url,
                 username=self._username,