cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
s020_add_vm_image.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 predefined.users import *
21 from predefined.actions import *
22 from predefined.macros import *
23 import settings
24 
25 actions = []
26 actions.append(list_clusters)
27 
28 actions.append(list_video_devices)
29 actions.append(list_network_devices)
30 actions.append(list_disk_controllers)
31 
32 # Add public image
33 actions.append({'u': u_new,
34  'fname': 'image.user.download',
35  'args': [{'name': settings.PUBLIC_IMAGE,
36  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
37  'access': 0,
38  'platform': 1,
39  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
40  'path': settings.VM_IMAGE_LINK,
41  'type': 2,
42  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
43  'description': 'Test image - public'}]})
44 actions.append(wait_image_is_downloaded(settings.PUBLIC_IMAGE, access=0, type=2))
45 
46 actions.append(list_private_vm_images)
47 actions.append({'u': u_admin_cm,
48  'as_cmadmin': True,
49  'fname': 'image.admin_cm.set_public',
50  'args': [MACRO_GET_PRIVATE_VM_IMAGE_ID(settings.PUBLIC_IMAGE)]
51  })
52 
53 # Add private image
54 actions.append({'u': u_new,
55  'fname': 'image.user.download',
56  'args': [{'name': settings.PRIVATE_IMAGE,
57  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
58  'access': 0,
59  'platform': 1,
60  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
61  'path': settings.VM_IMAGE_LINK,
62  'type': 2,
63  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
64  'description': 'Test image - private'}]})
65 
66 actions.append(wait_image_is_downloaded(settings.PRIVATE_IMAGE, access=0, type=2))
67 
68 # Edit images
69 actions.append(list_public_vm_images)
70 actions.append(list_private_vm_images)
71 
72 # First try to edit with some fake values
73 actions.append({'u': u_new,
74  'fname': 'image.user.edit',
75  'args': [MACRO_GET_PRIVATE_VM_IMAGE_ID(settings.PRIVATE_IMAGE),
76  {'name': settings.PRIVATE_IMAGE,
77  'video_device': 9999,
78  'platform': 1,
79  'network_device': 9999,
80  'disk_controller': 9999,
81  'description': 'Test image - private'}],
82  'estatus': 'bla_bla_bla'
83  })
84 actions.append({'u': u_new,
85  'fname': 'image.user.edit',
86  'args': [MACRO_GET_PUBLIC_VM_IMAGE_ID(settings.PUBLIC_IMAGE),
87  {'name': settings.PUBLIC_IMAGE,
88  'video_device': 9999,
89  'platform': 1,
90  'network_device': 9999,
91  'disk_controller': 9999,
92  'description': 'Test image - private'}],
93  'estatus': 'image_get'
94  })
95 # Set to valid values
96 actions.append({'u': u_new,
97  'fname': 'image.user.edit',
98  'args': [MACRO_GET_PRIVATE_VM_IMAGE_ID(settings.PRIVATE_IMAGE),
99  {'name': settings.PRIVATE_IMAGE,
100  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
101  'platform': 1,
102  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
103  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
104  'description': 'Test image - private'}]
105  })
106 
107 ##################
108 # Try to fake up #
109 ##################
110 
111 # Download non-existing image (404)
112 actions.append({'u': u_new,
113  'fname': 'image.user.download',
114  'args': [{'name': settings.PRIVATE_IMAGE,
115  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
116  'access': 0,
117  'platform': 1,
118  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
119  'path': 'http://onet.pl/houston_we_have_a_problem',
120  'type': 2,
121  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
122  'description': 'Test image - private'}]})
123 # Download non-existing image (server not found)
124 actions.append({'u': u_new,
125  'fname': 'image.user.download',
126  'args': [{'name': settings.PRIVATE_IMAGE,
127  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
128  'access': 0,
129  'platform': 1,
130  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
131  'path': 'http://houston_we_have_a_problem',
132  'type': 2,
133  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
134  'description': 'Test image - private'}]})
135 # Add strange type
136 actions.append({'u': u_new,
137  'fname': 'image.user.download',
138  'args': [{'name': settings.PRIVATE_IMAGE,
139  'video_device': 99999,
140  'access': 0,
141  'platform': 1,
142  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
143  'path': settings.VM_IMAGE_LINK,
144  'type': 2,
145  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
146  'description': 'Test image - private'}]})
147 actions.append({'u': u_new,
148  'fname': 'image.user.download',
149  'args': [{'name': settings.PRIVATE_IMAGE,
150  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
151  'access': 0,
152  'platform': 1,
153  'network_device': 99999,
154  'path': settings.VM_IMAGE_LINK,
155  'type': 2,
156  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
157  'description': 'Test image - private'}]})
158 actions.append({'u': u_new,
159  'fname': 'image.user.download',
160  'args': [{'name': settings.PRIVATE_IMAGE,
161  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
162  'access': 0,
163  'platform': 1,
164  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
165  'path': settings.VM_IMAGE_LINK,
166  'type': 2,
167  'disk_controller': 99999,
168  'description': 'Test image - private'}]})
169 actions.append({'u': u_new,
170  'fname': 'image.user.download',
171  'args': [{'name': settings.PRIVATE_IMAGE,
172  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
173  'access': 0,
174  'platform': 1,
175  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
176  'path': settings.VM_IMAGE_LINK,
177  'type': 99999,
178  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
179  'description': 'Test image - private'}],
180  'estatus': 'image_unsupported'})
181 actions.append({'u': u_new,
182  'fname': 'image.user.download',
183  'args': [{'name': settings.PRIVATE_IMAGE,
184  'video_device': MACRO_GET_VIDEO_DEVICE_ID("cirrus"),
185  'access': 99999,
186  'platform': 1,
187  'network_device': MACRO_GET_NETWORK_DEVICE_ID("virtio"),
188  'path': settings.VM_IMAGE_LINK,
189  'type': 2,
190  'disk_controller': MACRO_GET_DISK_CONTROLLER_ID("virtio"),
191  'description': 'Test image - private'}]})
192