cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
s100_create_vm_clean.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 
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 # 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 actions.append(wait_vm_is_running("TestVM"))
50 
51 actions.append(list_user_vms)
52 
53 # Send ping to VM
54 actions.append({'type': 'ping',
55  'host': MACRO_GET_USER_VM_IP("TestVM", 0),
56  'count': 1,
57  'wait_response': 0,
58  'wait_max': 1})
59 
60 actions.append(list_admin_vms)
61 actions.append(list_nodes)
62 actions.append(get_admin_vm_details("TestVM"))
63 
64 
65 actions.append({'type': 'libvirt',
66  'connection': {'driver': 'qemu',
67  'transport': 'ssh',
68  'user': 'root',
69  'address': MACRO_GET_VM_NODE_IP("TestVM"),
70  'suffix': 'system'
71  },
72  'fname': 'lookupByID',
73  'args': [MACRO_GET_ADMIN_LIBVIRT_ID("TestVM")],
74  'estatus': 'r != None'
75  })
76 
77 actions.append({'type': 'exec',
78  'command': '/usr/bin/ssh',
79  'args': [MACRO_GET_VM_NODE_IP("TestVM"), '-l', 'root', 'cd', '/images', ';', 'ls', '-l', MACRO_GET_USER_VM_ID_STR("TestVM")],
80  })
81 
82 actions.append({'type': 'exec',
83  'command': '/usr/bin/ssh',
84  'args': [MACRO_GET_VM_NODE_IP("TestVM"), '-l', 'root', 'brctl', 'show', '|', 'grep', MACRO_GET_USER_VM_ID_STR("TestVM")],
85  })
86 
87 # Destroy VM and wait when VM is closed
88 actions.append({'u': u_new,
89  'fname': 'vm.user.destroy',
90  'args': [[MACRO_GET_USER_VM_ID("TestVM")]]})
91 
92 actions.append(wait_vm_in_state_by_id(MACRO_GET_USER_VM_ID("TestVM"), 3))
93 
94 actions.append({'type': 'exec',
95  'command': '/usr/bin/ssh',
96  'args': [MACRO_GET_VM_NODE_IP("TestVM"), '-l', 'root', 'cd', '/', '/images', ';', 'ls', '-l', MACRO_GET_USER_VM_ID_STR("TestVM")],
97  'estatus': 2
98  })
99 
100 actions.append({'type': 'exec',
101  'command': '/usr/bin/ssh',
102  'args': [MACRO_GET_VM_NODE_IP("TestVM"), '-l', 'root', 'brctl', 'show', '|', 'grep', MACRO_GET_USER_VM_ID_STR("TestVM")],
103  'estatus': 1
104  })
105