Exemplo n.º 1
0
def sfa_update_user(request, user_hrn, user_params):
    # user_params: keys [public_key] 
    if 'email' in user_params:
        user_params['user_email'] = user_params['email']
    query = Query.update('user').filter_by('user_hrn', '==', user_hrn).set(user_params).select('user_hrn')
    results = execute_query(request,query)
    return results
Exemplo n.º 2
0
def manifold_update_user(request, email, user_params):
    # user_params: password, config e.g., 
    query = Query.update('local:user').filter_by('email', '==', email).set(user_params).select('email')
    results = execute_admin_query(request,query)
    # NOTE: results remains empty and goes to Exception. However, it updates the manifold DB.
    # That's why I commented the exception part. -- Yasin 
    #if not results:
    #    raise Exception, "Failed updating manifold user: %s" % user_params['email']
    #result, = results
    return results
Exemplo n.º 3
0
def sfa_add_user_to_slice(request, user_hrn, slice_params):
# UPDATE myslice:slice SET researcher=['ple.upmc.jordan_auge','ple.inria.thierry_parmentelat','ple.upmc.loic_baron','ple.upmc.ciro_scognamiglio','ple.upmc.mohammed-yasin_rahman','ple.upmc.azerty'] where slice_hrn=='ple.upmc.myslicedemo'
    query_current_users = Query.get('slice').select('user').filter_by('slice_hrn','==',slice_params['hrn'])
    results_current_users = execute_query(request, query_current_users)
    slice_params['researcher'] = slice_params['researcher'] | results_current_users
    query = Query.update('slice').filter_by('user_hrn', '==', user_hrn).set(slice_params).select('slice_hrn')
    results = execute_query(request, query)
# Also possible but not supported yet
# UPDATE myslice:user SET slice=['ple.upmc.agent','ple.upmc.myslicedemo','ple.upmc.tophat'] where user_hrn=='ple.upmc.azerty'
    if not results:
        raise Exception, "Could not create %s. Already exists ?" % slice_params['hrn']
    return results
Exemplo n.º 4
0
def dispatch(request, action):

    if (action == 'clear'):
        query = Query.update('myslice:user').filter_by('user_hrn', '==',
                                                       '$user_hrn').set({
                                                           'user_email':
                                                           str(request.user)
                                                       }).select('user_hrn')
        try:
            res = execute_query(request, query)
        except Exception, e:
            ret = {"ret": -1, "error": "error clearing cache: %s" % e}
            return HttpResponse(json.dumps(ret),
                                content_type="application/json")

        ret = {"ret": 1}
Exemplo n.º 5
0
    def update(self):
        query = Query.update(self.type)
        query = self.applyFilters(query, True)

        if self.params :
            for p in self.params :
                for k,v in p.iteritems() :
                    logger.debug("param: {} : {}".format(k, v))
                    query.set({k : v})
            logger.debug("query = {}".format(query))
        else:
            raise Exception, "Params are required for update"

        if self.id is not None:
           query.select(self.id)
       
        return execute_query(self.request, query)
Exemplo n.º 6
0
def dispatch(request, action):

    results = []
    error = None
    try:
        if request.method == 'POST':
            req_items = request.POST
        elif request.method == 'GET':
            req_items = request.GET

        for el in req_items.items():
            if el[0].startswith('slice_hrn'):
                slice_hrn = el[1]
            elif el[0].startswith('initscript_code'):
                initscript_code = el[1]

        if (action == 'get'):
            # select initscript_code from initscript where slice_hrn=='onelab.upmc.express'
            query = Query.get('initscript').filter_by(
                'slice_hrn', '==', slice_hrn).select('initscript_code')
            results = execute_admin_query(request, query)

        if (action == 'update'):
            # UPDATE initscript SET initscript_code='test3' where slice_hrn=='onelab.upmc.express'
            params = {'initscript_code': initscript_code}
            query = Query.update('initscript').filter_by(
                'slice_hrn', '==', slice_hrn).set(params)
            results = execute_admin_query(request, query)

            if results[0]['initscript_code'] == 1:
                results[0]['initscript_code'] = initscript_code
            else:
                error = "Error in update return value"

        if (action == 'delete'):
            # delete from initscript where slice_hrn=='onelab.upmc.express'
            query = Query.delete('initscript').filter_by(
                'slice_hrn', '==', slice_hrn)
            results = execute_admin_query(request, query)

            if results[0]['initscript_code'] == 1:
                results[0]['initscript_code'] = ""
            else:
                error = "Error in delete return value"
    except Exception, e:
        error = str(e)
Exemplo n.º 7
0
def manifold_update_account(request,user_id,account_params):
    # account_params: config
    query = Query.update('local:account').filter_by('platform', '==', 'myslice').filter_by('user_id', '==', user_id).set(account_params).select('user_id')
    results = execute_admin_query(request,query)
    return results