summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormbeierl <mark.beierl@dell.com>2017-06-21 16:02:57 -0400
committermbeierl <mark.beierl@dell.com>2017-06-26 13:00:01 -0400
commit45130c365c235bc4a5a53fd0ddb15f84a1460199 (patch)
tree0b4ea45f11d21d999256a50d081cb1ae9197a634
parentf8b67cf03ecbd4d6ab1fd115ef155d4334df266a (diff)
Allow User to Specify Flavor
Adds flavor as parameter to ReST /configurations API and passes it through to the heat template creation. Change-Id: Id3632fb571da9da51b4d75db58c7a7c0a91e0ccf JIRA: STORPERF-92 Signed-off-by: mbeierl <mark.beierl@dell.com>
-rwxr-xr-xci/start_job.sh2
-rw-r--r--rest_server.py27
-rw-r--r--storperf/resources/hot/agent-group.yaml4
-rw-r--r--storperf/storperf_master.py18
-rw-r--r--tests/db_tests/configuration_db_test.py9
-rw-r--r--tests/storperf_master_test.py18
6 files changed, 52 insertions, 26 deletions
diff --git a/ci/start_job.sh b/ci/start_job.sh
index 0a149fd..487e0c6 100755
--- a/ci/start_job.sh
+++ b/ci/start_job.sh
@@ -15,7 +15,7 @@ cat << EOF > body.json
"steady_state_samples": ${STEADY_STATE_SAMPLES},
"queue_depths": "${QUEUE_DEPTH}",
"workload": "${WORKLOAD}",
- "metadata": {
+ "metadata": {
"disk_type": "${DISK_TYPE}",
"pod_name": "${POD_NAME}",
"scenario_name": "${SCENARIO_NAME}",
diff --git a/rest_server.py b/rest_server.py
index 67d71a5..5bff09c 100644
--- a/rest_server.py
+++ b/rest_server.py
@@ -12,7 +12,7 @@ import logging.config
import os
import sys
-from flask import abort, Flask, request, jsonify, send_from_directory
+from flask import abort, Flask, request, jsonify
from flask_restful import Resource, Api, fields
from flask_restful_swagger import swagger
@@ -41,6 +41,7 @@ class ConfigurationRequestModel:
class ConfigurationResponseModel:
resource_fields = {
'agent_count': fields.Integer,
+ 'agent_flavor': fields.String,
'agent_image': fields.String,
'public_network': fields.String,
'stack_created': fields.Boolean,
@@ -62,6 +63,7 @@ class Configure(Resource):
)
def get(self):
return jsonify({'agent_count': storperf.agent_count,
+ 'agent_flavor': storperf.agent_flavor,
'agent_image': storperf.agent_image,
'public_network': storperf.public_network,
'volume_size': storperf.volume_size,
@@ -92,6 +94,8 @@ class Configure(Resource):
try:
if ('agent_count' in request.json):
storperf.agent_count = request.json['agent_count']
+ if ('agent_flavor' in request.json):
+ storperf.agent_flavor = request.json['agent_flavor']
if ('agent_image' in request.json):
storperf.agent_image = request.json['agent_image']
if ('public_network' in request.json):
@@ -102,6 +106,7 @@ class Configure(Resource):
storperf.create_stack()
return jsonify({'agent_count': storperf.agent_count,
+ 'agent_flavor': storperf.agent_flavor,
'agent_image': storperf.agent_image,
'public_network': storperf.public_network,
'volume_size': storperf.volume_size,
@@ -154,16 +159,16 @@ class Job(Resource):
"description": "The UUID of the workload in the format "
"NNNNNNNN-NNNN-NNNN-NNNN-NNNNNNNNNNNN",
"required": True,
- "type": "string",
+ "metrics_type": "string",
"allowMultiple": False,
"paramType": "query"
},
{
- "name": "type",
- "description": "The type of metrics to report. May be "
+ "name": "metrics_type",
+ "description": "The metrics_type of metrics to report. May be "
"metrics (default), or metadata",
"required": False,
- "type": "string",
+ "metrics_type": "string",
"allowMultiple": False,
"paramType": "query"
}
@@ -181,19 +186,19 @@ class Job(Resource):
)
def get(self):
- type = "metrics"
- if request.args.get('type'):
- type = request.args.get('type')
+ metrics_type = "metrics"
+ if request.args.get('metrics_type'):
+ metrics_type = request.args.get('metrics_type')
workload_id = request.args.get('id')
- if type == "metrics":
+ if metrics_type == "metrics":
return jsonify(storperf.fetch_results(workload_id))
- if type == "metadata":
+ if metrics_type == "metadata":
return jsonify(storperf.fetch_metadata(workload_id))
- if type == "status":
+ if metrics_type == "status":
return jsonify(storperf.fetch_job_status(workload_id))
@swagger.operation(
diff --git a/storperf/resources/hot/agent-group.yaml b/storperf/resources/hot/agent-group.yaml
index a06c847..c758ecd 100644
--- a/storperf/resources/hot/agent-group.yaml
+++ b/storperf/resources/hot/agent-group.yaml
@@ -14,7 +14,7 @@ parameters:
type: string
constraints:
- custom_constraint: neutron.network
- flavor:
+ agent_flavor:
type: string
default: "storperf"
agent_image:
@@ -47,7 +47,7 @@ resources:
properties: {
public_network: {get_param: public_network},
agent_network: {get_resource: storperf_network},
- flavor: {get_param: flavor},
+ flavor: {get_param: agent_flavor},
image: {get_param: agent_image},
storperf_open_security_group: {get_resource: storperf_open_security_group},
key_name: {get_resource: storperf_key_pair},
diff --git a/storperf/storperf_master.py b/storperf/storperf_master.py
index 5432ece..fb3e269 100644
--- a/storperf/storperf_master.py
+++ b/storperf/storperf_master.py
@@ -138,6 +138,23 @@ class StorPerfMaster(object):
value)
@property
+ def agent_flavor(self):
+ return self.configuration_db.get_configuration_value(
+ 'stack',
+ 'agent_flavor')
+
+ @agent_flavor.setter
+ def agent_flavor(self, value):
+ if (self.stack_id is not None):
+ raise ParameterError(
+ "ERROR: Cannot change flavor after stack is created")
+
+ self.configuration_db.set_configuration_value(
+ 'stack',
+ 'agent_flavor',
+ value)
+
+ @property
def stack_id(self):
return self.configuration_db.get_configuration_value(
'stack',
@@ -380,6 +397,7 @@ class StorPerfMaster(object):
heat_parameters['agent_count'] = self.agent_count
heat_parameters['volume_size'] = self.volume_size
heat_parameters['agent_image'] = self.agent_image
+ heat_parameters['agent_flavor'] = self.agent_flavor
return heat_parameters
def _attach_to_openstack(self):
diff --git a/tests/db_tests/configuration_db_test.py b/tests/db_tests/configuration_db_test.py
index e8b7188..dda616b 100644
--- a/tests/db_tests/configuration_db_test.py
+++ b/tests/db_tests/configuration_db_test.py
@@ -10,17 +10,14 @@
from storperf.db.configuration_db import ConfigurationDB
import os
import unittest
+import sqlite3
class ConfigurationDBTest(unittest.TestCase):
def setUp(self):
- ConfigurationDB.db_name = __name__ + ".db"
- try:
- os.remove(ConfigurationDB.db_name)
- except OSError:
- pass
-
+ ConfigurationDB.db_name = "file::memory:?cache=shared"
+ db = sqlite3.connect(ConfigurationDB.db_name)
self.config_db = ConfigurationDB()
def test_create_key(self):
diff --git a/tests/storperf_master_test.py b/tests/storperf_master_test.py
index 2dc810d..c67e3c4 100644
--- a/tests/storperf_master_test.py
+++ b/tests/storperf_master_test.py
@@ -9,18 +9,15 @@
from storperf.db.configuration_db import ConfigurationDB
from storperf.storperf_master import StorPerfMaster
-import os
import unittest
+import sqlite3
class StorPerfMasterTest(unittest.TestCase):
def setUp(self):
- ConfigurationDB.db_name = __name__ + ".db"
- try:
- os.remove(ConfigurationDB.db_name)
- except OSError:
- pass
+ ConfigurationDB.db_name = "file::memory:?cache=shared"
+ db = sqlite3.connect(ConfigurationDB.db_name)
self.storperf = StorPerfMaster()
def test_agent_count(self):
@@ -67,3 +64,12 @@ class StorPerfMasterTest(unittest.TestCase):
self.assertEqual(
expected, actual, "Did not expect: " + str(actual))
+
+ def test_agent_flavor(self):
+ expected = "m1.small"
+
+ self.storperf.agent_flavor = expected
+ actual = self.storperf.agent_flavor
+
+ self.assertEqual(
+ expected, actual, "Did not expect: " + str(actual))