cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
s104_create_vm_with_image_adding.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 # Try to create VM with image, which is in adding state.
23 #
24 from predefined.actions import *
25 from predefined.users import *
26 from predefined.macros import *
27 import settings
28 
29 actions = []
30 actions.append(list_clusters)
31 
32 actions.append(list_filesystems)
33 actions.append(list_video_devices)
34 actions.append(list_network_devices)
35 actions.append(list_disk_controllers)
36 actions.append(list_templates)
37 
38 # Add public image
39 actions.append({'u': u_new,
40  'fname': 'image.user.download',
41  'args': [{'name': 'DownloadedImage',
42  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
43  'access': 0,
44  'platform': 1,
45  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
46  'path': settings.VM_IMAGE_LINK,
47  'type': 2,
48  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
49  'description': 'Test image - download'}]})
50 
51 actions.append(list_private_vm_images)
52 
53 actions.append({'u': u_new,
54  'fname': 'vm.user.create',
55  'args': [{'vnc': True,
56  'name': 'TestVMDownload',
57  'iso_list': [],
58  'image_id': MACRO_GET_PRIVATE_VM_IMAGE_ID("DownloadedImage"),
59  'disk_list': [],
60  'template_id': MACRO_GET_TEMPLATE_ID("Small"),
61  'description': 'asd'}],
62  'estatus': 'image_unavailable',
63  })
64 
65 actions.append(wait_image_is_downloaded("DownloadedImage", access=0, type=2))
66 
67 # Create vm from downloaded image
68 actions.append({'u': u_new,
69  'fname': 'vm.user.create',
70  'args': [{'vnc': True,
71  'name': 'TestVMDownload',
72  'iso_list': [],
73  'image_id': MACRO_GET_PRIVATE_VM_IMAGE_ID("DownloadedImage"),
74  'disk_list': [],
75  'template_id': MACRO_GET_TEMPLATE_ID("Small"),
76  'description': 'asd'}],
77  'estatus': 'image_unavailable',
78  })
79 
80 # Destroy this vm
81 actions.append(list_user_vms)
82 actions.append({'u': u_new,
83  'fname': 'vm.user.destroy',
84  'args': [[MACRO_GET_USER_VM_ID("TestVM")]]})
85 actions.append(wait_vm_in_state_by_id(MACRO_GET_USER_VM_ID("TestVM"), 3))
86 
87 # Remove image
88 actions.append({'u': u_new,
89  'fname': 'image.user.delete',
90  'args': [MACRO_GET_PRIVATE_VM_IMAGE_ID('DownloadedImage')]})
91