cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
s107_create_many_vms.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
23 #
24 from predefined.users import *
25 from predefined.actions import *
26 from predefined.macros import *
27 import settings
28 import random
29 
30 actions = []
31 actions.append(list_clusters)
32 actions.append(list_private_vm_images)
33 actions.append(list_public_vm_images)
34 actions.append(list_private_storage_images)
35 actions.append(list_templates)
36 actions.append(list_user_public_ip)
37 
38 name = str(random.random())
39 num = 2
40 
41 # Create normal VM with storage
42 for i in range(num):
43  actions.append({'u': u_new,
44  'fname': 'vm.user.create',
45  'args': [{'vnc': True,
46  'name': 'TestVM%d-%s' % (i, name),
47  'iso_list': [],
48  'image_id': MACRO_GET_PRIVATE_VM_IMAGE_ID("PrivateImage"),
49  'disk_list': [],
50  'template_id': MACRO_GET_TEMPLATE_ID("Small"),
51  'description': 'asd'}],
52  })
53 for i in range(num):
54  actions.append(wait_vm_is_running("TestVM%d-%s" % (i, name)))
55 
56 for i in range(num):
57  actions.append(list_user_vms)
58 
59 for i in range(num):
60  # Send ping to VM
61  actions.append({'type': 'ping',
62  'host': MACRO_GET_USER_VM_IP("TestVM%d-%s" % (i, name), 0),
63  'count': 1,
64  'wait_response': 0,
65  'wait_max': 1})
66 
67  #actions.append({'type': 'exec',
68  # 'command': 'ssh',
69  # 'args': [MACRO_GET_VM_NODE_IP("TestVM%d-%s" % (i, name)),
70  # '-u', 'root']})
71 
72 for i in range(num):
73  actions.append({'u': u_new,
74  'fname': 'vm.user.destroy',
75  'args': [[MACRO_GET_USER_VM_ID("TestVM%d-%s" % (i, name))]]})
76 
77