summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorJesse Andrews <jesse@gigantor.local>2010-10-25 21:44:02 +0000
committerTarmac <>2010-10-25 21:44:02 +0000
commitebffd9cb35af4257a085f85abf64e0c2baf31ff0 (patch)
treeb07684feee68ef722bc01c0922c98758c7eb8435 /nova/api
parent954c91e315ba2745602336918a455ef3de047a8a (diff)
parent02e0b75e85f753043fc71ac2e0714ec4d4b0cca8 (diff)
validates device parameter for attach-volume
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 784697b01..07229dd73 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -25,6 +25,7 @@ datastore.
import base64
import datetime
import logging
+import re
import os
import time
@@ -519,6 +520,9 @@ class CloudController(object):
def attach_volume(self, context, volume_id, instance_id, device, **kwargs):
volume_ref = db.volume_get_by_ec2_id(context, volume_id)
+ if not re.match("^/dev/[a-z]d[a-z]+$", device):
+ raise exception.ApiError("Invalid device specified: %s. "
+ "Example device: /dev/vdb" % device)
# TODO(vish): abstract status checking?
if volume_ref['status'] != "available":
raise exception.ApiError("Volume status must be available")