Skip to content
Permalink
Browse files
Complete volume attachment / detachment
  • Loading branch information
brogand93 committed Mar 3, 2014
1 parent 4953565 commit 96b7c33ac55067c55474c9b61e35a54e44b75809
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
@@ -44,6 +44,22 @@ def invalid_volume_id():
)


def volume_attached():
raise Ec2stackError(
'400',
'InvalidVolume.Attached',
'The specified Volume is already attached.'
)


def volume_detached():
raise Ec2stackError(
'400',
'InvalidVolume.Detached',
'The specified Volume isn\'t attached.'
)


def invalid_disk_offering_name():
raise Ec2stackError(
'400',
@@ -11,7 +11,11 @@

volume_error_to_aws = {
'unable to find a snapshot': errors.invalid_snapshot_id,
'Unable to aquire volume with ID': errors.invalid_volume_id
'Unable to aquire volume with ID': errors.invalid_volume_id,
'Please specify a volume that is not attached': errors.volume_attached,
'The specified volume is not attached': errors.volume_detached,
'Invalid parameter virtualmachineid': errors.invalid_instance_id,
'Invalid parameter id': errors.invalid_volume_id
}


@@ -76,6 +80,7 @@ def _create_volume_response(response):
'response': response
}


@helpers.authentication_required
def attach_volume():
helpers.require_parameters(['VolumeId', 'InstanceId', 'Device'])
@@ -88,11 +93,12 @@ def _attach_volume_request():

volume_id = helpers.get('VolumeId')
instance_id = helpers.get('InstanceId')

device = helpers.get('Device')

args['id'] = volume_id
args['command'] = 'attachVolume'
args['virtualmachineid'] = instance_id
args['device'] = device

response = requester.make_request_async(args)

@@ -124,10 +130,8 @@ def _detach_volume_request():
volume_id = helpers.get('VolumeId')

if helpers.contains_parameter('InstanceId'):
print('hello world instance')
args['virtualmachineid'] = helpers.get('InstanceId')
if helpers.contains_parameter('Device'):
print('hello world device')
args['deviceid'] = helpers.get('Device')

args['id'] = volume_id
@@ -3,9 +3,11 @@
<volumeId>
{{ response.id }}
</volumeId>
{% if response.virtualmachineid %}
<instanceId>
{{ response.virtualmachineid }}
</instanceId>
<status>{{ response.status }}</status>
<attachTime>{{ response.attached }}</attachTime>
{% endif %}
<status>{{ response.state }}</status>
<attachTime>{{ response.created }}</attachTime>
{% endblock %}

0 comments on commit 96b7c33

Please sign in to comment.