summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Beierl <mark.beierl@emc.com>2016-05-10 10:48:53 -0600
committerMark Beierl <mark.beierl@emc.com>2016-05-10 10:49:00 -0600
commitc999a6716e412d36b7c91e15eaaca3ab3cd2bc93 (patch)
tree810127f3f06600bad93bb1d4c783e667ddaace9f
parentedbced4cda35e63c9ddc4e40a67807cbfd6d6c20 (diff)
Auth timeout fix and VM image selection
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>
-rw-r--r--docker/requirements.pip1
-rw-r--r--rest_server.py6
-rw-r--r--storperf/resources/hot/agent-group.yaml4
-rw-r--r--storperf/storperf_master.py35
4 files changed, 44 insertions, 2 deletions
diff --git a/docker/requirements.pip b/docker/requirements.pip
index 4c9aaae..8efaf24 100644
--- a/docker/requirements.pip
+++ b/docker/requirements.pip
@@ -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
diff --git a/rest_server.py b/rest_server.py
index 72f849a..7fba94a 100644
--- a/rest_server.py
+++ b/rest_server.py
@@ -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})
diff --git a/storperf/resources/hot/agent-group.yaml b/storperf/resources/hot/agent-group.yaml
index 4a1df8e..4566f7a 100644
--- a/storperf/resources/hot/agent-group.yaml
+++ b/storperf/resources/hot/agent-group.yaml
@@ -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}
diff --git a/storperf/storperf_master.py b/storperf/storperf_master.py
index c7739da..b678bc8 100644
--- a/storperf/storperf_master.py
+++ b/storperf/storperf_master.py
@@ -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):
@@ -101,6 +103,28 @@ class StorPerfMaster(object):
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(
'stack',
@@ -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,