summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--trove/cluster/service.py4
-rw-r--r--trove/instance/models.py8
-rw-r--r--trove/instance/service.py8
-rw-r--r--trove/taskmanager/api.py5
-rw-r--r--trove/taskmanager/manager.py12
-rwxr-xr-xtrove/taskmanager/models.py29
-rw-r--r--trove/tests/unittests/cluster/test_cluster_controller.py1
-rw-r--r--trove/tests/unittests/cluster/test_cluster_pxc_controller.py1
-rw-r--r--trove/tests/unittests/cluster/test_cluster_redis_controller.py3
-rw-r--r--trove/tests/unittests/cluster/test_cluster_vertica_controller.py1
-rw-r--r--trove/tests/unittests/taskmanager/test_manager.py12
-rw-r--r--trove/tests/unittests/taskmanager/test_models.py10
12 files changed, 61 insertions, 33 deletions
diff --git a/trove/cluster/service.py b/trove/cluster/service.py
index ae0fb413..60c81f71 100644
--- a/trove/cluster/service.py
+++ b/trove/cluster/service.py
@@ -161,9 +161,10 @@ class ClusterController(wsgi.Controller):
instances = []
for node in nodes:
flavor_id = utils.get_id_from_href(node['flavorRef'])
- volume_size = nics = availability_zone = None
+ volume_size = volume_type = nics = availability_zone = None
if 'volume' in node:
volume_size = int(node['volume']['size'])
+ volume_type = node['volume'].get('volume_type')
if 'nics' in node:
nics = node['nics']
if 'availability_zone' in node:
@@ -171,6 +172,7 @@ class ClusterController(wsgi.Controller):
instances.append({"flavor_id": flavor_id,
"volume_size": volume_size,
+ "volume_type": volume_type,
"nics": nics,
"availability_zone": availability_zone})
diff --git a/trove/instance/models.py b/trove/instance/models.py
index ee63583d..50fee79f 100644
--- a/trove/instance/models.py
+++ b/trove/instance/models.py
@@ -668,8 +668,9 @@ class Instance(BuiltInstance):
@classmethod
def create(cls, context, name, flavor_id, image_id, databases, users,
datastore, datastore_version, volume_size, backup_id,
- availability_zone=None, nics=None, configuration_id=None,
- slave_of_id=None, cluster_config=None, replica_count=None):
+ availability_zone=None, nics=None,
+ configuration_id=None, slave_of_id=None, cluster_config=None,
+ replica_count=None, volume_type=None):
# All nova flavors are permitted for a datastore-version unless one
# or more entries are found in datastore_version_metadata,
@@ -843,7 +844,8 @@ class Instance(BuiltInstance):
instance_id, instance_name, flavor, image_id, databases, users,
datastore_version.manager, datastore_version.packages,
volume_size, backup_id, availability_zone, root_password,
- nics, overrides, slave_of_id, cluster_config)
+ nics, overrides, slave_of_id, cluster_config,
+ volume_type=volume_type)
return SimpleInstance(context, db_info, service_status,
root_password)
diff --git a/trove/instance/service.py b/trove/instance/service.py
index 7a62ef06..3cb65dee 100644
--- a/trove/instance/service.py
+++ b/trove/instance/service.py
@@ -219,9 +219,12 @@ class InstanceController(wsgi.Controller):
raise exception.BadRequest(msg=ve)
if 'volume' in body['instance']:
- volume_size = int(body['instance']['volume']['size'])
+ volume_info = body['instance']['volume']
+ volume_size = int(volume_info['size'])
+ volume_type = volume_info.get('type')
else:
volume_size = None
+ volume_type = None
if 'restorePoint' in body['instance']:
backupRef = body['instance']['restorePoint']['backupRef']
@@ -242,7 +245,8 @@ class InstanceController(wsgi.Controller):
volume_size, backup_id,
availability_zone, nics,
configuration, slave_of_id,
- replica_count=replica_count)
+ replica_count=replica_count,
+ volume_type=volume_type)
view = views.InstanceDetailView(instance, req=req)
return wsgi.Result(view.data(), 200)
diff --git a/trove/taskmanager/api.py b/trove/taskmanager/api.py
index 3323ac33..dc6e5e18 100644
--- a/trove/taskmanager/api.py
+++ b/trove/taskmanager/api.py
@@ -152,7 +152,7 @@ class API(object):
packages, volume_size, backup_id=None,
availability_zone=None, root_password=None,
nics=None, overrides=None, slave_of_id=None,
- cluster_config=None):
+ cluster_config=None, volume_type=None):
LOG.debug("Making async call to create instance %s " % instance_id)
@@ -172,7 +172,8 @@ class API(object):
nics=nics,
overrides=overrides,
slave_of_id=slave_of_id,
- cluster_config=cluster_config)
+ cluster_config=cluster_config,
+ volume_type=volume_type)
def create_cluster(self, cluster_id):
LOG.debug("Making async call to create cluster %s " % cluster_id)
diff --git a/trove/taskmanager/manager.py b/trove/taskmanager/manager.py
index a35de744..2f9aa329 100644
--- a/trove/taskmanager/manager.py
+++ b/trove/taskmanager/manager.py
@@ -254,7 +254,8 @@ class Manager(periodic_task.PeriodicTasks):
image_id, databases, users,
datastore_manager, packages, volume_size,
availability_zone, root_password, nics,
- overrides, slave_of_id, backup_id):
+ overrides, slave_of_id, backup_id,
+ volume_type):
if type(instance_id) in [list]:
ids = instance_id
@@ -284,7 +285,7 @@ class Manager(periodic_task.PeriodicTasks):
flavor, image_id, databases, users, datastore_manager,
packages, volume_size, replica_backup_id,
availability_zone, root_passwords[replica_index],
- nics, overrides, None, snapshot)
+ nics, overrides, None, snapshot, volume_type)
replicas.append(instance_tasks)
except Exception:
# if it's the first replica, then we shouldn't continue
@@ -305,7 +306,7 @@ class Manager(periodic_task.PeriodicTasks):
image_id, databases, users, datastore_manager,
packages, volume_size, backup_id, availability_zone,
root_password, nics, overrides, slave_of_id,
- cluster_config):
+ cluster_config, volume_type):
if slave_of_id:
self._create_replication_slave(context, instance_id, name,
flavor, image_id, databases, users,
@@ -313,7 +314,7 @@ class Manager(periodic_task.PeriodicTasks):
volume_size,
availability_zone, root_password,
nics, overrides, slave_of_id,
- backup_id)
+ backup_id, volume_type)
else:
if type(instance_id) in [list]:
raise AttributeError(_(
@@ -323,7 +324,8 @@ class Manager(periodic_task.PeriodicTasks):
datastore_manager, packages,
volume_size, backup_id,
availability_zone, root_password,
- nics, overrides, cluster_config)
+ nics, overrides, cluster_config,
+ None, volume_type)
timeout = (CONF.restore_usage_timeout if backup_id
else CONF.usage_timeout)
instance_tasks.wait_for_instance(timeout, flavor)
diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py
index 4fbe94ca..1af3d548 100755
--- a/trove/taskmanager/models.py
+++ b/trove/taskmanager/models.py
@@ -333,7 +333,7 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
def create_instance(self, flavor, image_id, databases, users,
datastore_manager, packages, volume_size,
backup_id, availability_zone, root_password, nics,
- overrides, cluster_config, snapshot=None):
+ overrides, cluster_config, snapshot, volume_type):
# It is the caller's responsibility to ensure that
# FreshInstanceTasks.wait_for_instance is called after
# create_instance to ensure that the proper usage event gets sent
@@ -359,7 +359,7 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
"instance: %s" % self.id)
files = self._get_injected_files(datastore_manager)
-
+ cinder_volume_type = volume_type or CONF.cinder_volume_type
if use_heat:
volume_info = self._create_server_volume_heat(
flavor,
@@ -368,7 +368,8 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
volume_size,
availability_zone,
nics,
- files)
+ files,
+ cinder_volume_type)
elif use_nova_server_volume:
volume_info = self._create_server_volume(
flavor['id'],
@@ -388,7 +389,8 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
volume_size,
availability_zone,
nics,
- files)
+ files,
+ cinder_volume_type)
config = self._render_config(flavor)
@@ -643,7 +645,8 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
def _create_server_volume_heat(self, flavor, image_id,
datastore_manager, volume_size,
- availability_zone, nics, files):
+ availability_zone, nics, files,
+ volume_type):
LOG.debug("Begin _create_server_volume_heat for id: %s" % self.id)
try:
client = create_heat_client(self.context)
@@ -668,6 +671,7 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
parameters = {"Flavor": flavor["name"],
"VolumeSize": volume_size,
+ "VolumeType": volume_type,
"InstanceId": self.id,
"ImageId": image_id,
"DatastoreManager": datastore_manager,
@@ -739,12 +743,13 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
def _create_server_volume_individually(self, flavor_id, image_id,
security_groups, datastore_manager,
volume_size, availability_zone,
- nics, files):
+ nics, files, volume_type):
LOG.debug("Begin _create_server_volume_individually for id: %s" %
self.id)
server = None
volume_info = self._build_volume_info(datastore_manager,
- volume_size=volume_size)
+ volume_size=volume_size,
+ volume_type=volume_type)
block_device_mapping = volume_info['block_device']
try:
server = self._create_server(flavor_id, image_id, security_groups,
@@ -762,7 +767,8 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
self.id)
return volume_info
- def _build_volume_info(self, datastore_manager, volume_size=None):
+ def _build_volume_info(self, datastore_manager, volume_size=None,
+ volume_type=None):
volume_info = None
volume_support = self.volume_support
device_path = self.device_path
@@ -771,7 +777,7 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
if volume_support:
try:
volume_info = self._create_volume(
- volume_size, datastore_manager)
+ volume_size, volume_type, datastore_manager)
except Exception as e:
msg = _("Failed to create volume for instance %s") % self.id
err = inst_models.InstanceTasks.BUILDING_ERROR_VOLUME
@@ -794,13 +800,14 @@ class FreshInstanceTasks(FreshInstance, NotifyMixin, ConfigurationMixin):
self.update_db(task_status=task_status)
raise TroveError(message=message)
- def _create_volume(self, volume_size, datastore_manager):
+ def _create_volume(self, volume_size, volume_type, datastore_manager):
LOG.debug("Begin _create_volume for id: %s" % self.id)
volume_client = create_cinder_client(self.context)
volume_desc = ("datastore volume for %s" % self.id)
volume_ref = volume_client.volumes.create(
volume_size, name="datastore-%s" % self.id,
- description=volume_desc, volume_type=CONF.cinder_volume_type)
+ description=volume_desc,
+ volume_type=volume_type)
# Record the volume ID in case something goes wrong.
self.update_db(volume_id=volume_ref.id)
diff --git a/trove/tests/unittests/cluster/test_cluster_controller.py b/trove/tests/unittests/cluster/test_cluster_controller.py
index 66ea9388..fe20921a 100644
--- a/trove/tests/unittests/cluster/test_cluster_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_controller.py
@@ -155,6 +155,7 @@ class TestClusterController(TestCase):
instances = [
{
'volume_size': 1,
+ 'volume_type': None,
'flavor_id': '1234',
'availability_zone': 'az',
'nics': [
diff --git a/trove/tests/unittests/cluster/test_cluster_pxc_controller.py b/trove/tests/unittests/cluster/test_cluster_pxc_controller.py
index 38a470a4..e8032c6a 100644
--- a/trove/tests/unittests/cluster/test_cluster_pxc_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_pxc_controller.py
@@ -139,6 +139,7 @@ class TestClusterController(trove_testtools.TestCase):
instances = [
{
'volume_size': 1,
+ 'volume_type': None,
'flavor_id': '1234',
'availability_zone': 'az',
'nics': [
diff --git a/trove/tests/unittests/cluster/test_cluster_redis_controller.py b/trove/tests/unittests/cluster/test_cluster_redis_controller.py
index 2a10b696..5f59e79f 100644
--- a/trove/tests/unittests/cluster/test_cluster_redis_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_redis_controller.py
@@ -154,6 +154,7 @@ class TestClusterController(trove_testtools.TestCase):
instances = [
{
"volume_size": None,
+ 'volume_type': None,
"flavor_id": "1234",
"availability_zone": "az",
"nics": [
@@ -162,6 +163,7 @@ class TestClusterController(trove_testtools.TestCase):
},
{
"volume_size": None,
+ 'volume_type': None,
"flavor_id": "1234",
"availability_zone": "az",
"nics": [
@@ -170,6 +172,7 @@ class TestClusterController(trove_testtools.TestCase):
},
{
"volume_size": None,
+ 'volume_type': None,
"flavor_id": "1234",
"availability_zone": "az",
"nics": [
diff --git a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py
index 2e4f8cbc..208885c5 100644
--- a/trove/tests/unittests/cluster/test_cluster_vertica_controller.py
+++ b/trove/tests/unittests/cluster/test_cluster_vertica_controller.py
@@ -139,6 +139,7 @@ class TestClusterController(trove_testtools.TestCase):
instances = [
{
'volume_size': 1,
+ 'volume_type': None,
'flavor_id': '1234',
'availability_zone': 'az',
'nics': [
diff --git a/trove/tests/unittests/taskmanager/test_manager.py b/trove/tests/unittests/taskmanager/test_manager.py
index 3a496461..ade09a58 100644
--- a/trove/tests/unittests/taskmanager/test_manager.py
+++ b/trove/tests/unittests/taskmanager/test_manager.py
@@ -203,7 +203,7 @@ class TestManager(trove_testtools.TestCase):
'mysql', 'mysql-server', 2,
'temp-backup-id', None,
'some_password', None, Mock(),
- 'some-master-id', None)
+ 'some-master-id', None, None)
mock_tasks.get_replication_master_snapshot.assert_called_with(
self.context, 'some-master-id', mock_flavor, 'temp-backup-id',
replica_number=1)
@@ -219,14 +219,15 @@ class TestManager(trove_testtools.TestCase):
self.context, ['id1', 'id2'], Mock(), Mock(),
Mock(), None, None, 'mysql', 'mysql-server', 2,
'temp-backup-id', None, 'some_password', None,
- Mock(), 'some-master-id', None)
+ Mock(), 'some-master-id', None, None)
def test_AttributeError_create_instance(self):
self.assertRaisesRegexp(
AttributeError, 'Cannot create multiple non-replica instances.',
self.manager.create_instance, self.context, ['id1', 'id2'],
Mock(), Mock(), Mock(), None, None, 'mysql', 'mysql-server', 2,
- 'temp-backup-id', None, 'some_password', None, Mock(), None, None)
+ 'temp-backup-id', None, 'some_password', None, Mock(), None, None,
+ None)
def test_create_instance(self):
mock_tasks = Mock()
@@ -238,14 +239,15 @@ class TestManager(trove_testtools.TestCase):
mock_flavor, 'mysql-image-id', None,
None, 'mysql', 'mysql-server', 2,
'temp-backup-id', None, 'password',
- None, mock_override, None, None)
+ None, mock_override, None, None, None)
mock_tasks.create_instance.assert_called_with(mock_flavor,
'mysql-image-id', None,
None, 'mysql',
'mysql-server', 2,
'temp-backup-id', None,
'password', None,
- mock_override, None)
+ mock_override,
+ None, None, None)
mock_tasks.wait_for_instance.assert_called_with(36000, mock_flavor)
def test_create_cluster(self):
diff --git a/trove/tests/unittests/taskmanager/test_models.py b/trove/tests/unittests/taskmanager/test_models.py
index 09309e49..7ce443a5 100644
--- a/trove/tests/unittests/taskmanager/test_models.py
+++ b/trove/tests/unittests/taskmanager/test_models.py
@@ -377,7 +377,7 @@ class FreshInstanceTasksTest(trove_testtools.TestCase):
'Error creating security group for instance',
self.freshinstancetasks.create_instance, mock_flavor,
'mysql-image-id', None, None, 'mysql', 'mysql-server', 2,
- None, None, None, None, Mock(), None)
+ None, None, None, None, Mock(), None, None, None)
@patch.object(BaseInstance, 'update_db')
@patch.object(backup_models.Backup, 'get_by_id')
@@ -399,7 +399,7 @@ class FreshInstanceTasksTest(trove_testtools.TestCase):
'Error creating DNS entry for instance',
self.freshinstancetasks.create_instance, mock_flavor,
'mysql-image-id', None, None, 'mysql', 'mysql-server',
- 2, Mock(), None, 'root_password', None, Mock(), None)
+ 2, Mock(), None, 'root_password', None, Mock(), None, None, None)
@patch.object(BaseInstance, 'update_db')
@patch.object(taskmanager_models.FreshInstanceTasks, '_create_dns_entry')
@@ -424,9 +424,11 @@ class FreshInstanceTasksTest(trove_testtools.TestCase):
None, None, 'mysql',
'mysql-server', 2,
None, None, None, None,
- overrides, None)
+ overrides, None, None,
+ 'volume_type')
mock_create_secgroup.assert_called_with('mysql')
- mock_build_volume_info.assert_called_with('mysql', volume_size=2)
+ mock_build_volume_info.assert_called_with('mysql', volume_size=2,
+ volume_type='volume_type')
mock_guest_prepare.assert_called_with(
768, mock_build_volume_info(), 'mysql-server', None, None, None,
config_content, None, overrides, None, None)