Example #1
0
def volume_update():
    username = current_user.username
    usertype = current_user.usertype
    _volume = request.json['volume']
    print 'volume_update:', locals()
    
    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    volume = Volume.query.get(_volume['id'])
    _volume['updated'] = datetime.utcnow()
    update_object_with_dict(volume, _volume)
    db.session.commit()
    _volume = object_to_dict(volume)
    
    # insert host_name
    # insert mount_point_name
    host = Host.query.get(_volume['host_id'])
    assert host is not None
    
    mount_point = MountPoint.query.get(_volume['mount_point_id'])
    assert mount_point is not None
    
    _volume['host_name'] = host.name
    _volume['mount_point_name'] = mount_point.name
    
    data = {
        'volume': _volume,
    }
    
    return jsonify(data)
Example #2
0
def volume_update():
    username = current_user.username
    usertype = current_user.usertype
    _volume = request.json['volume']
    print 'volume_update:', locals()

    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)

    volume = Volume.query.get(_volume['id'])
    _volume['updated'] = datetime.utcnow()
    update_object_with_dict(volume, _volume)
    db.session.commit()
    _volume = object_to_dict(volume)

    # insert host_name
    # insert mount_point_name
    host = Host.query.get(_volume['host_id'])
    assert host is not None

    mount_point = MountPoint.query.get(_volume['mount_point_id'])
    assert mount_point is not None

    _volume['host_name'] = host.name
    _volume['mount_point_name'] = mount_point.name

    data = {
        'volume': _volume,
    }

    return jsonify(data)
Example #3
0
def mount_update():
    username = current_user.username
    usertype = current_user.usertype
    _mount = request.json['mount']
    print 'mount_update:', locals()
    
    # FIXME:
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    mount = MountPoint.query.get(_mount['id'])
    _mount['updated'] = datetime.utcnow()
    update_object_with_dict(mount, _mount)
    db.session.commit()
    
    _mount = object_to_dict(mount)
    
    # insert host_name
    host = Host.query.get(_mount['host_id'])
    assert host is not None
    _mount['host_name'] = host.name
    
    data = {
        'mount': _mount,
    }
    
    return jsonify(data)
Example #4
0
def account_quota_update():
    username = current_user.username
    usertype = current_user.usertype
    _user_quota = request.json['user_quota']
    print 'account_quota_update locals:', dict(locals())
    
    # update user quota
    user_quota = UserQuota.query.filter_by(username=_user_quota['username']).one()
    _user_quota['updated'] = datetime.utcnow()
    update_object_with_dict(user_quota, _user_quota)
    db.session.commit()
    
    _user_quota = object_to_dict(user_quota)
    
    data = {
        'user_quota': _user_quota,
    }
    
    return jsonify(data)
Example #5
0
def account_user_update():
    username = current_user.username
    _user_account = request.json['user_account']
    print 'account_user_update locals:', dict(locals())
    
    # update user account
    username_ = _user_account['username']
    user_account = UserAccount.query.filter_by(username=username_).one()
    _user_account['updated'] = datetime.utcnow()
    update_object_with_dict(user_account, _user_account)
    db.session.commit()
    
    _user_account = object_to_dict(user_account)
    
    data = {
        'user_account': _user_account,
    }
    
    return jsonify(data)
Example #6
0
def network_domain_update():
    username = current_user.username
    usertype = current_user.usertype
    _domain = request.json['domain']
    print 'network_domain_update:', locals()
    
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    domain = Domain.query.get(_domain['id'])
    _domain['updated'] = datetime.utcnow()
    update_object_with_dict(domain, _domain)
    db.session.commit()
    
    _domain = object_to_dict(domain)
    
    data = {
        'domain': _domain,
    }
    
    return jsonify(data)
Example #7
0
def network_route_update():
    username = current_user.username
    usertype = current_user.usertype
    _route = request.json['route']
    print 'network_route_update:', locals()
    
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    route = Route.query.get(_route['id'])
    _route['updated'] = datetime.utcnow()
    update_object_with_dict(route, _route)
    db.session.commit()
    
    _route = object_to_dict(route)
    
    # insert domain, host, container name
    domain = Domain.query.get(_route['domain_id'])
    assert domain is not None
    
    host = Host.query.get(_route['host_id'])
    assert host is not None
    
    container = Container.query.get(_route['container_id'])
    assert container is not None
    
    _route['domain_domain'] = domain.domain
    _route['host_name'] = host.name
    _route['container_name'] = container.name
    _route['container_container_id'] = container.container_id
    
    data = {
        'route': _route,
    }
    
    return jsonify(data)
Example #8
0
def host_update():
    username = current_user.username
    usertype = current_user.usertype
    _host = request.json['host']
    print 'host_update:', locals()
    
    if usertype != 'super':
        data = {}
        return jsonify(data)
        
    host = Host.query.get(_host['id'])
    assert host is not None
    
    _host['updated'] = datetime.utcnow()
    update_object_with_dict(host, _host)
    db.session.commit()
    
    _host = object_to_dict(host)
    
    data = {
        'host': _host,
    }
    
    return jsonify(data)
Example #9
0
def host_update():
    username = current_user.username
    usertype = current_user.usertype
    _host = request.json['host']
    print 'host_update:', locals()

    if usertype != 'super':
        data = {}
        return jsonify(data)

    host = Host.query.get(_host['id'])
    assert host is not None

    _host['updated'] = datetime.utcnow()
    update_object_with_dict(host, _host)
    db.session.commit()

    _host = object_to_dict(host)

    data = {
        'host': _host,
    }

    return jsonify(data)