cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
s101_create_vm_over_quota.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 #
22 # Create pure VM with exceeted (przekroczona) quota
23 #
24 from predefined.users import *
25 from predefined.actions import *
26 from predefined.macros import *
27 import settings
28 
29 actions = []
30 actions.append(list_clusters)
31 actions.append(list_private_vm_images)
32 actions.append(list_public_vm_images)
33 actions.append(list_private_storage_images)
34 actions.append(list_templates)
35 actions.append(list_user_public_ip)
36 actions.append(list_users)
37 
38 # Create normal VM with storage
39 actions.append({'u': u_new,
40  'fname': 'vm.user.create',
41  'args': [{'vnc': True,
42  'name': 'TestVM',
43  'iso_list': [],
44  'image_id': MACRO_GET_PRIVATE_VM_IMAGE_ID(settings.PRIVATE_IMAGE),
45  'disk_list': [],
46  'template_id': MACRO_GET_TEMPLATE_ID("Small"),
47  'description': 'asd'}],
48  })
49 
50 # Next should be over cpu quota
51 actions.append({'u': u_admin_cm,
52  'as_cmadmin': True,
53  'fname': 'user.admin_cm.change_quota',
54  'args': [MACRO_GET_USER_ID(u_new['l']), {'public_ip': 1, 'points': 2000, 'storage': 40000, 'cpu': 1, 'memory': 40000}],
55  })
56 actions.append({'u': u_new,
57  'fname': 'vm.user.create',
58  'args': [{'vnc': True,
59  'name': 'TestVMQ',
60  'iso_list': [],
61  'image_id': MACRO_GET_PRIVATE_VM_IMAGE_ID(settings.PRIVATE_IMAGE),
62  'disk_list': [],
63  'template_id': MACRO_GET_TEMPLATE_ID("Small"),
64  'description': 'asd'}],
65  'estatus': 'user_cpu_limit',
66  })
67 
68 # This should be over memory quota
69 actions.append({'u': u_admin_cm,
70  'as_cmadmin': True,
71  'fname': 'user.admin_cm.change_quota',
72  'args': [MACRO_GET_USER_ID(u_new['l']), {'public_ip': 1, 'points': 2000, 'storage': 40000, 'cpu': 12, 'memory': 1}],
73  })
74 actions.append({'u': u_new,
75  'fname': 'vm.user.create',
76  'args': [{'vnc': True,
77  'name': 'TestVMQ',
78  'iso_list': [],
79  'image_id': MACRO_GET_PRIVATE_VM_IMAGE_ID(settings.PRIVATE_IMAGE),
80  'disk_list': [],
81  'template_id': MACRO_GET_TEMPLATE_ID("Small"),
82  'description': 'asd'}],
83  'estatus': 'user_memory_limit',
84  })
85 
86 
87 # Restore big quota
88 actions.append({'u': u_admin_cm,
89  'as_cmadmin': True,
90  'fname': 'user.admin_cm.change_quota',
91  'args': [MACRO_GET_USER_ID(u_new['l']), {'public_ip': 1, 'points': 2000, 'storage': 40000, 'cpu': 24, 'memory': 40000}],
92  })
93 
94 actions.append(wait_vm_is_running("TestVM"))
95 actions.append(list_user_vms)
96 actions.append({'u': u_new,
97  'fname': 'vm.user.destroy',
98  'args': [[MACRO_GET_USER_VM_ID("TestVM")]]
99  })
100