'Creates a new volume type.'

@wsgi.action('create')
def _create(self, req, body):

    context = req.environ['cinder.context']
    authorize(context)
    self.assert_valid_body(body, 'volume_type')
    vol_type = body['volume_type']
    name = vol_type.get('name', None)
    description = vol_type.get('description')
    specs = vol_type.get('extra_specs', {})
    utils.validate_dictionary_string_length(specs)
    is_public = utils.get_bool_param('os-volume-type-access:is_public', vol_type, True)
    if ((name is None) or (len(name.strip()) == 0)):
        msg = _('Volume    type    name    can    not    be    empty.')
        raise webob.exc.HTTPBadRequest(explanation=msg)
    utils.check_string_length(name, 'Type    name', min_length=1, max_length=255)
    if (description is not None):
        utils.check_string_length(description, 'Type    description', min_length=0, max_length=255)
    try:
        volume_types.create(context, name, specs, is_public, description=description)
        vol_type = volume_types.get_volume_type_by_name(context, name)
        req.cache_resource(vol_type, name='types')
        self._notify_volume_type_info(context, 'volume_type.create', vol_type)
    except exception.VolumeTypeExists as err:
        self._notify_volume_type_error(context, 'volume_type.create', err, volume_type=vol_type)
        raise webob.exc.HTTPConflict(explanation=six.text_type(err))
    except exception.VolumeTypeNotFoundByName as err:
        self._notify_volume_type_error(context, 'volume_type.create', err, name=name)
        raise
    return self._view_builder.show(req, vol_type)
