cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
public_ip.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.vm
22 # @alldecoratedby{src.clm.utils.decorators.admin_cm_log}
23 # @author Maciej Nabo┼╝ny <mn@mnabozny.pl>
24 #
25 
26 from clm.utils.decorators import admin_cm_log, cm_request
27 from clm.models.user import User
28 from clm.utils.cm import CM
29 from clm.utils.exception import CLMException
30 
31 
32 @admin_cm_log(log=False, pack=False)
33 @cm_request
34 ##
35 #
36 # @clmview_admin_cm
37 # @cm_request_transparent{public_ip.get_list()}
38 #
39 def get_list(cm_response, **data):
40  names = {}
41 
42  for ip in cm_response['data']:
43  if ip['user_id'] == '':
44  ip['owner'] = ''
45  elif str(ip['user_id']) not in names:
46  try:
47  user = User.objects.get(pk=ip['user_id'])
48  names[str(ip['user_id'])] = user.first + " " + user.last
49  except:
50  raise CLMException('user_get')
51  ip['owner'] = names[str(ip['user_id'])]
52 
53  return cm_response
54 
55 
56 @admin_cm_log(log=True, pack=False)
57 @cm_request
58 ##
59 #
60 # @clmview_admin_cm
61 # @cm_request_transparent{public_ip.add()}
62 #
63 def add(cm_response, **data):
64  return cm_response
65 
66 
67 @admin_cm_log(log=True, pack=False)
68 @cm_request
69 ##
70 #
71 # @clmview_admin_cm
72 # @cm_request_transparent{public_ip.delete()}
73 #
74 def delete(cm_response, **data):
75  return cm_response
76 
77 
78 @admin_cm_log(log=True, pack=False)
79 @cm_request
80 ##
81 #
82 # @clmview_admin_cm
83 # @cm_request_transparent{public_ip.unassign()}
84 #
85 def unassign(cm_response, **data):
86  return cm_response
87 
88 
89 @admin_cm_log(log=True, pack=False)
90 @cm_request
91 ##
92 #
93 # @clmview_admin_cm
94 # @cm_request_transparent{public_ip.release()}
95 #
96 def release(cm_response, **data):
97  return cm_response
98 
99 
100 @admin_cm_log(log=True, pack=False)
101 @cm_request
102 ##
103 #
104 # @clmview_admin_cm
105 # @cm_request_transparent{public_ip.revoke()}
106 #
107 def revoke(cm_response, **data):
108  return cm_response
109