Example #1
0
    def _validate(body):
        """Validate that the request has all the required parameters"""
        InstanceController._validate_body_not_empty(body)

        try:
            body['instance']
            body['instance']['flavorRef']
            vol_enabled = utils.bool_from_string(
                config.Config.get('reddwarf_volume_support', 'True'))
            must_have_vol = utils.bool_from_string(
                config.Config.get('reddwarf_must_use_volume', 'False'))
            if vol_enabled:
                if body['instance'].get('volume', None):
                    if body['instance']['volume'].get('size', None):
                        volume_size = body['instance']['volume']['size']
                        InstanceController._validate_volume_size(volume_size)
                    elif must_have_vol:
                        raise exception.MissingKey(key="size")
                elif must_have_vol:
                    raise exception.MissingKey(key="volume")

        except KeyError as e:
            LOG.error(_("Create Instance Required field(s) - %s") % e)
            raise exception.ReddwarfError("Required element/key - %s "
                                          "was not specified" % e)
Example #2
0
 def validate(cls, body):
     """Validate that the request has all the required parameters"""
     if not body:
         raise exception.BadRequest("The request contains an empty body")
     if not body.get('databases', ''):
         raise exception.MissingKey(key='databases')
     for database in body.get('databases'):
         if not database.get('name', ''):
             raise exception.MissingKey(key='name')
Example #3
0
 def validate(cls, body):
     """Validate that the request has all the required parameters"""
     if not body:
         raise exception.BadRequest("The request contains an empty body")
     if body.get('users') is None:
         raise exception.MissingKey(key='users')
     for user in body.get('users'):
         if not user.get('name'):
             raise exception.MissingKey(key='name')
         if not user.get('password'):
             raise exception.MissingKey(key='password')
Example #4
0
 def validate(cls, body):
     """Validate that the request has all the required parameters"""
     if not body:
         raise exception.BadRequest("The request contains an empty body")
     if not body.get('databases', []):
         raise exception.MissingKey(key='databases')
     if type(body['databases']) is not list:
         raise exception.BadRequest("Databases must be provided as a list.")
     for database in body.get('databases'):
         if not database.get('name', ''):
             raise exception.MissingKey(key='name')
Example #5
0
    def _validate(body):
        """Validate that the request has all the required parameters"""
        InstanceController._validate_body_not_empty(body)

        try:
            body['instance']
            body['instance']['flavorRef']
            name = body['instance'].get('name', '').strip()
            if not name:
                raise exception.MissingKey(key='name')
            if CONF.reddwarf_volume_support:
                if body['instance'].get('volume', None):
                    if body['instance']['volume'].get('size', None):
                        volume_size = body['instance']['volume']['size']
                        InstanceController._validate_volume_size(volume_size)
                    else:
                        raise exception.MissingKey(key="size")
                else:
                    raise exception.MissingKey(key="volume")

        except KeyError as e:
            LOG.error(_("Create Instance Required field(s) - %s") % e)
            raise exception.ReddwarfError("Required element/key - %s "
                                          "was not specified" % e)