summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-07-03 19:34:14 +0000
committerGerrit Code Review <review@openstack.org>2012-07-03 19:34:14 +0000
commit511e24a7a37665bff36cf41cd9c30701f7946203 (patch)
treed9be05d8936aa878f2a5eebd0a0727fdb81d1a70
parent2f62b72e521b135a16fb023b5da8443e0fef664d (diff)
parent0038e3818393415fc9628aef2747136a626682ee (diff)
Merge "Modifies ec2/cloud to be able to use Cinder"
-rw-r--r--nova/api/ec2/cloud.py42
-rw-r--r--nova/db/sqlalchemy/api.py2
-rw-r--r--nova/tests/api/ec2/test_cloud.py1
3 files changed, 25 insertions, 20 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index c632d7ac2..94302383c 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -315,11 +315,13 @@ class CloudController(object):
context=context)
volume_id = ec2utils.ec2_vol_id_to_uuid(volume_id)
volume = self.volume_api.get(context, volume_id)
- snapshot = self.volume_api.create_snapshot(
- context,
- volume,
- None,
- kwargs.get('description'))
+ args = (context, volume, kwargs.get('name'), kwargs.get('description'))
+ if kwargs.get('force', False):
+ snapshot = self.volume_api.create_snapshot_force(*args)
+ else:
+ snapshot = self.volume_api.create_snapshot(*args)
+
+ db.ec2_snapshot_create(context, snapshot['id'])
return self._format_snapshot(context, snapshot)
def delete_snapshot(self, context, snapshot_id, **kwargs):
@@ -723,24 +725,28 @@ class CloudController(object):
return v
def create_volume(self, context, **kwargs):
- size = kwargs.get('size')
- if kwargs.get('snapshot_id') is not None:
+ snapshot_ec2id = kwargs.get('snapshot_id', None)
+ if snapshot_ec2id is not None:
snapshot_id = ec2utils.ec2_snap_id_to_uuid(kwargs['snapshot_id'])
snapshot = self.volume_api.get_snapshot(context, snapshot_id)
- LOG.audit(_("Create volume from snapshot %s"), snapshot_id,
+ LOG.audit(_("Create volume from snapshot %s"), snapshot_ec2id,
context=context)
else:
snapshot = None
- LOG.audit(_("Create volume of %s GB"), size, context=context)
-
- availability_zone = kwargs.get('availability_zone', None)
+ LOG.audit(_("Create volume of %s GB"),
+ kwargs.get('size'),
+ context=context)
volume = self.volume_api.create(context,
- size,
- None,
- None,
+ kwargs.get('size'),
+ kwargs.get('name'),
+ kwargs.get('description'),
snapshot,
- availability_zone=availability_zone)
+ kwargs.get('volume_type'),
+ kwargs.get('metadata'),
+ kwargs.get('availability_zone'))
+
+ db.ec2_volume_create(context, volume['id'])
# TODO(vish): Instance should be None at db layer instead of
# trying to lazy load, but for now we turn it into
# a dict to avoid an error.
@@ -749,7 +755,6 @@ class CloudController(object):
def delete_volume(self, context, volume_id, **kwargs):
validate_ec2_id(volume_id)
volume_id = ec2utils.ec2_vol_id_to_uuid(volume_id)
-
try:
volume = self.volume_api.get(context, volume_id)
self.volume_api.delete(context, volume)
@@ -758,7 +763,10 @@ class CloudController(object):
return True
- def attach_volume(self, context, volume_id, instance_id, device, **kwargs):
+ def attach_volume(self, context,
+ volume_id,
+ instance_id,
+ device, **kwargs):
validate_ec2_id(instance_id)
validate_ec2_id(volume_id)
volume_id = ec2utils.ec2_vol_id_to_uuid(volume_id)
diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py
index f9f9e2228..bc82765fb 100644
--- a/nova/db/sqlalchemy/api.py
+++ b/nova/db/sqlalchemy/api.py
@@ -2900,7 +2900,6 @@ def volume_create(context, values):
with session.begin():
volume_ref.save(session=session)
- ec2_volume_create(context, volume_ref['id'])
return volume_ref
@@ -3205,7 +3204,6 @@ def snapshot_create(context, values):
session = get_session()
with session.begin():
snapshot_ref.save(session=session)
- ec2_snapshot_create(context, snapshot_ref['id'])
return snapshot_ref
diff --git a/nova/tests/api/ec2/test_cloud.py b/nova/tests/api/ec2/test_cloud.py
index 6128811f1..7ac9cd862 100644
--- a/nova/tests/api/ec2/test_cloud.py
+++ b/nova/tests/api/ec2/test_cloud.py
@@ -1018,7 +1018,6 @@ class CloudTestCase(test.TestCase):
db.instance_destroy(self.context, inst2['uuid'])
db.instance_destroy(self.context, inst1['uuid'])
- # NOTE(jdg) Modified expected volume_id's to string
_expected_instance_bdm1 = {
'instanceId': 'i-00000001',
'rootDeviceName': '/dev/sdb1',