diff options
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/instance_types.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/nova/compute/instance_types.py b/nova/compute/instance_types.py index 2bc470a41..c4a6f66f9 100644 --- a/nova/compute/instance_types.py +++ b/nova/compute/instance_types.py @@ -20,6 +20,8 @@ """Built-in instance properties.""" +import re + from nova import context from nova import db from nova import exception @@ -29,6 +31,8 @@ from nova import log as logging FLAGS = flags.FLAGS LOG = logging.getLogger(__name__) +INVALID_NAME_REGEX = re.compile("[^\w\.\- ]") + def create(name, memory, vcpus, root_gb, ephemeral_gb, flavorid, swap=None, rxtx_factor=None): @@ -48,6 +52,12 @@ def create(name, memory, vcpus, root_gb, ephemeral_gb, flavorid, swap=None, 'rxtx_factor': rxtx_factor, } + # ensure name does not contain any special characters + invalid_name = INVALID_NAME_REGEX.search(name) + if invalid_name: + msg = _("names can only contain [a-zA-Z0-9_.- ]") + raise exception.InvalidInput(reason=msg) + # ensure some attributes are integers and greater than or equal to 0 for option in kwargs: try: |
