cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
user.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 ##
21 # @package src.clm.views.admin_cm.user
22 # @alldecoratedby{src.clm.utils.decorators.user_log}
23 #
24 
25 from clm.models.user import User
26 from clm.utils.decorators import admin_cm_log, cm_request
27 
28 
29 @admin_cm_log(log=True, pack=False)
30 @cm_request
31 ##
32 #
33 # @clmview_admin_cm
34 # @cm_request_transparent{user.add()}
35 #
36 def add(cm_response, **data):
37  return cm_response
38 
39 
40 @admin_cm_log(log=False, pack=True)
41 ##
42 #
43 # @clmview_admin_cm
44 # @param_post{user_id,int}
45 # @response{dict} dict property of the requested User
46 #
47 def get_by_id(cm_id, caller_id, cm_password, user_id):
48  user = User.get(user_id)
49  return user.dict
50 
51 
52 @admin_cm_log(log=True, pack=True)
53 @cm_request
54 ##
55 #
56 # Method returns list of Users of the managed cluster
57 #
58 # @cm_request{storage_image.get_list()}
59 # @clmview_admin_cm
60 # @param_post{short,bool} caller's CM admin password
61 #
62 # @response{list(dict)} dicts property for each requested cluster's User
63 #
64 def get_list(cm_response, **data):
65  # build dictionary 'id':'dict from cm'
66  d = {}
67  ret = {}
68  for i in cm_response['data']:
69  d[i['user_id']] = i
70  for user in User.objects.filter(id__in=d.keys()):
71  ret[user.id] = d[user.id]
72  ret[user.id].update(user.short_dict if data.get('short', False) else user.dict)
73 
74  return ret.values()
75 
76 
77 @admin_cm_log(log=True, pack=False)
78 @cm_request
79 ##
80 #
81 # Method returns state of user's quota.
82 #
83 # @clmview_admin_cm
84 # @cm_request_transparent{user.get_quota()}
85 #
86 def get_quota(cm_response, **data):
87  return cm_response
88 
89 
90 @admin_cm_log(log=True, pack=False)
91 @cm_request
92 ##
93 #
94 # Changes quota (CPU, storage, public IPs count and points)
95 # as described by \c data.
96 #
97 # @clmview_admin_cm
98 # @cm_request{user.change_quota()}
99 #
100 def change_quota(cm_response, **data):
101  return cm_response
102 
103 
104 @admin_cm_log(log=True, pack=False)
105 @cm_request
106 ##
107 #
108 # Method changes quota as described by \c data.
109 #
110 # @clmview_admin_cm
111 # @cm_request_transparent{user.multiple_change_quota()}
112 #
113 def multiple_change_quota(cm_response, **data):
114  return cm_response
115