cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
ctx.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 from clm.utils.decorators import user_log, cm_request
21 from clm.models.key import Key
22 from clm.utils.exception import CLMException
23 from clm.utils.cm import CM
24 
25 
26 @user_log(log=True, pack=False)
27 @cm_request
28 ##
29 #
30 # @clmview_user
31 # @cm_request_transparent{user.ctx.shutdown()}
32 #
33 def shutdown(cm_response, **data):
34  return cm_response
35 
36 
37 @user_log(log=True, pack=False)
38 @cm_request
39 ##
40 #
41 # @clmview_user
42 # @cm_request_transparent{user.ctx.reboot()}
43 #
44 def reboot(cm_response, **data):
45  return cm_response
46 
47 
48 @user_log(log=True, pack=False)
49 @cm_request
50 ##
51 #
52 # @clmview_user
53 # @cm_request{user.ctx.reset_password()}
54 #
55 def reset_password(cm_response, **data):
56  return cm_response
57 
58 
59 @user_log(log=True, pack=False)
60 ##
61 #
62 # @clmview_user
63 # @param_post{vm_key,string}
64 # @param_post{vm_username,string}
65 # @param_post{vm_ids,list(int)}
66 #
67 def add_ssh_key(cm_id, caller_id, vm_key, vm_username, vm_ids):
68  try:
69  k = Key.objects.filter(user_id__exact=caller_id).filter(id__exact=vm_key)[0]
70  except:
71  raise CLMException('ssh_key_get')
72 
73  return CM(cm_id).send_request("user/ctx/add_ssh_key/", caller_id=caller_id, vm_username=vm_username, vm_ids=vm_ids, vm_key=k.dict['data'])
74