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
class ConfigurationResponseModel:
resource_fields = {
'agent_count': fields.Integer,
+ 'agent_flavor': fields.String,
'agent_image': fields.String,
'public_network': fields.String,
'stack_created': fields.Boolean,
)
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,
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):
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,
"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"
}
)
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(
'public_network',
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(
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):
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):
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))