Fix snapshot tests
diff --git a/ec2stack/providers/cloudstack/snapshots.py b/ec2stack/providers/cloudstack/snapshots.py
index a75a5fb..69e53ea 100644
--- a/ec2stack/providers/cloudstack/snapshots.py
+++ b/ec2stack/providers/cloudstack/snapshots.py
@@ -4,14 +4,10 @@
"""This module contains functions for handling requests in relation to snapshots.
"""
-import uuid
-
-from flask import current_app
-
from ec2stack import errors
from ec2stack import helpers
from ec2stack.providers import cloudstack
-from ec2stack.providers.cloudstack import requester, zones
+from ec2stack.providers.cloudstack import requester
@helpers.authentication_required
@@ -46,7 +42,7 @@
@return: Response.
"""
- response = response['snapshot']
+ response = response['vmsnapshot']
return {
'template_name_or_list': 'create_snapshot.xml',
'response_type': 'CreateSnapshotResponse',
@@ -101,7 +97,7 @@
"""
args = {'command': 'listSnapshots'}
response = cloudstack.describe_item(
- args, 'snapshot', errors.invalid_snapshot_id, 'SnapshotId'
+ args, 'vmsnapshot', errors.invalid_snapshot_id, 'SnapshotId'
)
return _describe_snapshot_response(
diff --git a/ec2stack/templates/create_snapshot.xml b/ec2stack/templates/create_snapshot.xml
index b7f6ce0..91ca1cb 100644
--- a/ec2stack/templates/create_snapshot.xml
+++ b/ec2stack/templates/create_snapshot.xml
@@ -2,7 +2,7 @@
{% block response_content %}
<snapshot>
<snapshotId>{{ response.id }}</snapshotId>
- <volumeId>{{ snapshot.volumeid }}</volumeId>
+ <volumeId>{{ response.volumeid }}</volumeId>
<status>{{ response.state }}</status>
</snapshot>
{% endblock %}
\ No newline at end of file
diff --git a/ec2stack/templates/snapshots.xml b/ec2stack/templates/snapshots.xml
index d4a3cee..1560683 100644
--- a/ec2stack/templates/snapshots.xml
+++ b/ec2stack/templates/snapshots.xml
@@ -1,7 +1,7 @@
{% extends "response.xml" %}
{% block response_content %}
<snapshotSet>
- {% for snapshot in response.snapshot %}
+ {% for snapshot in response.vmsnapshot %}
<item>
<snapshotId>{{ snapshot.id }}</snapshotId>
<volumeId>{{ snapshot.volumeid }}</volumeId>
diff --git a/tests/snapshot_tests.py b/tests/snapshot_tests.py
index a100252..ec9a842 100644
--- a/tests/snapshot_tests.py
+++ b/tests/snapshot_tests.py
@@ -55,7 +55,7 @@
def test_describe_snapshot_by_name(self):
data = self.get_example_data()
- data['Action'] = 'DescribeVpcs'
+ data['Action'] = 'DescribeSnapshots'
data['SnapshotId'] = 'examplesnapshot'
data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')
@@ -71,13 +71,14 @@
data=data
)
+ print response.data
self.assert_ok(response)
assert 'DescribeSnapshotsResponse' in response.data
assert 'examplesnapshot' in response.data
def test_describe_snapshot_by_name_invalid_name(self):
data = self.get_example_data()
- data['Action'] = 'DescribeVpcs'
+ data['Action'] = 'DescribeSnapshots'
data['SnapshotId'] = 'invalidsnapshot'
data['Signature'] = generate_signature(data, 'POST', 'localhost', '/')
@@ -94,7 +95,7 @@
)
self.assert_bad_request(response)
- assert 'InvalidSnapshotID.NotFound' in response.data
+ assert 'InvalidSnapshot.NotFound' in response.data
def test_delete_snapshot(self):
data = self.get_example_data()