Esempio n. 1
0
def update(context, id, name, description, is_public=None):
    """Update share type by id."""
    values = {}
    if name:
        values.update({'name': name})
    if description == "":
        values.update({'description': None})
    elif description:
        values.update({'description': description})
    if is_public is not None:
        values.update({'is_public': is_public})
    try:
        db.share_type_update(context, id, values)
    except db_exception.DBError:
        LOG.exception('DB error.')
        raise exception.ShareTypeUpdateFailed(id=id)
Esempio n. 2
0
def return_share_type_update(context,
                             id=4,
                             name=None,
                             description=None,
                             is_public=None):
    if id == 888:
        raise exception.ShareTypeUpdateFailed(id=id)
    if id == 999:
        raise exception.ShareTypeNotFound(share_type_id=id)
    pre_share_type = stub_share_type(int(id))
    new_name = name
    new_description = description
    return pre_share_type.update({
        "name": new_name,
        "description": new_description,
        "is_public": is_public
    })
Esempio n. 3
0
def return_share_type_update(context, id, values):
    name = values.get('name')
    description = values.get('description')
    is_public = values.get('is_public')
    if id == '444':
        raise exception.ShareTypeUpdateFailed(id=id)
    else:
        st_update = {
            'created_at': datetime.datetime(2019, 9, 9, 14, 40, 31),
            'deleted': '0',
            'deleted_at': None,
            'extra_specs': {u'gold': u'True'},
            'required_extra_specs': {},
            'id': id,
            'name': name,
            'is_public': is_public,
            'description': description,
            'updated_at': None
        }
        return st_update