Commit d3df28b2 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Validate length of metadata

parent 7b95fba8
......@@ -408,8 +408,10 @@ class VirtualMachine(models.Model):
class VirtualMachineMetadata(models.Model):
meta_key = models.CharField(max_length=50)
meta_value = models.CharField(max_length=500)
KEY_LENGTH = 50
VALUE_LENGTH = 500
meta_key = models.CharField(max_length=KEY_LENGTH)
meta_value = models.CharField(max_length=VALUE_LENGTH)
vm = models.ForeignKey(VirtualMachine, related_name='metadata',
on_delete=models.CASCADE)
......
......@@ -205,6 +205,10 @@ def create(userid, name, password, flavor, image, metadata={},
port.save()
for key, val in metadata.items():
utils.check_name_length(key, VirtualMachineMetadata.KEY_LENGTH,
"Metadata key is too long")
utils.check_name_length(val, VirtualMachineMetadata.VALUE_LENGTH,
"Metadata value is too long")
VirtualMachineMetadata.objects.create(
meta_key=key,
meta_value=val,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment