From 4d350dc82ecfe1d272bfbd43445a78c69a32fc90 Mon Sep 17 00:00:00 2001 From: Michael Still Date: Sat, 11 Aug 2012 20:51:27 +1000 Subject: Simple checks for instance user data. Check that instance user data wont be truncated, and that it is valid base64 data. This partially resolves bug 1035055. I don't love the hard coded maximum length, but I haven't worked out how to get sqlalchemy to tell me the maximum size of the data type. Change-Id: I045d6b4481563d01cae371cf61a91781cfed6f4b --- nova/exception.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'nova/exception.py') diff --git a/nova/exception.py b/nova/exception.py index 315147764..de8982488 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -1155,6 +1155,16 @@ class ConfigDriveUnknownFormat(NovaException): "iso9660 or vfat.") +class InstanceUserDataTooLarge(NovaException): + message = _("User data too large. User data must be no larger than " + "%(maxsize)s bytes once base64 encoded. Your data is " + "%(length)d bytes") + + +class InstanceUserDataMalformed(NovaException): + message = _("User data needs to be valid base 64.") + + def get_context_from_function_and_args(function, args, kwargs): """Find an arg of type RequestContext and return it. -- cgit