cc1
v2.1
CC1 source code docs
Main Page
Related Pages
Packages
Classes
Files
File List
All
Classes
Namespaces
Files
Functions
Variables
Pages
s050_network_logic.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
# Start conditions:
21
# - configured CLM and CM
22
# - Active email configmation
23
# - Added at lease one public image
24
# - Added at least one vm template
25
# - Added at least one node
26
27
from
datetime
import
datetime
28
import
hashlib
29
from
scripts.s010_registration_logic
import
u_admin, u_new
30
31
actions = []
32
33
now = str(datetime.now())
34
35
#######################
36
# Prepare data for VM #
37
#######################
38
actions.append({
'
u': u_new,
39
'fname'
:
'image.user.list'
,
40
'args'
: [{
'access'
: 1,
'type'
: 2}],
41
'store_as'
:
'public_images'
})
42
actions.append({
'
u': u_new,
43
'fname'
:
'template.user.list'
,
44
'args'
: [],
45
'store_as'
:
'templates'
})
46
actions.append({
'
u': u_new,
47
'fname'
:
'network.user.list_user_networks'
,
48
'args'
: [],
49
'store_as'
:
'user_networks'
})
50
51
#actions.append({'u': u_new, 'fname': 'elasticip.user.list', 'args': [], 'store_as': 'elastic_ips'})
52
53
54
######################################################
55
# Start vm in selected network in various situations #
56
######################################################
57
58
# Lock available pool and try to start vm in this pool
59
actions.append({
'
u': u_admin,
60
'fname'
:
'network.admin_cm.lock'
,
61
'args'
: [hashlib.sha1(u_admin[
'cm_p'
]).hexdigest(),
'@r["available_networks"][0]["id"]'
]})
62
actions.append({
'
u': u_new,
63
'fname'
:
'vm.user.create'
,
64
'args'
: [{
'vnc'
:
True
,
65
'name'
:
'Test VM'
,
66
'iso_list'
: [],
67
'image_id'
:
'@r["public_images"][0]["id"]'
,
68
'ip_id'
: -1,
69
'disk_list'
: [],
70
'template_id'
:
'@r["templates"][0]["id"]'
,
71
'description'
:
'Vm Description'
}],
72
'estatus'
:
'network_unavailable'
})
73
# Unlock available pool and then create VM, in this pool
74
actions.append({
'
u': u_admin,
75
'fname'
:
'network.admin_cm.unlock'
,
76
'args'
: [hashlib.sha1(u_admin[
'cm_p'
]).hexdigest(),
'@r["available_networks"][0]["id"]'
]})
77
actions.append({
'
u': u_new,
78
'fname'
:
'vm.user.create'
,
79
'args'
: [{
'vnc'
:
True
,
80
'name'
:
'Test VM'
,
81
'iso_list'
: [],
82
'image_id'
:
'@r["public_images"][0]["id"]'
,
83
'ip_id'
: -1,
'disk_list'
: [],
84
'template_id'
:
'@r["templates"][0]["id"]'
,
85
'description'
:
'Vm Description'
}]})
86
87
# Try to delete available and user network in use
88
actions.append({
'
u': u_admin,
89
'fname'
:
'network.admin_cm.delete'
,
90
'args'
: [hashlib.sha1(u_admin[
'cm_p'
]).hexdigest(),
'@r["available_networks"][0]["id"]'
],
91
'estatus'
:
'network_in_use'
})
92
actions.append({
'
u': u_new,
93
'fname'
:
'network.user.release'
,
94
'args'
: [
'@r["user_networks"][0]["id"]'
],
95
'estatus'
:
'lease_attached'
})
96
97
# Wait to machine is running
98
actions.append({
'
u': u_new,
99
'fname'
:
'vm.user.list'
,
100
'args'
: [],
101
'store_as'
:
'vm_list'
,
102
'wait_response'
:
'True in [vm["state"] == 1 for vm in r]'
,
103
'wait_max'
: 20})
104
105
#######################
106
# Clean up everything #
107
#######################
108
# Remove vm, user and available pool
109
actions.append({
'
u': u_new,
110
'fname'
:
'vm.user.destroy'
,
111
'args'
: [[
"@r['vm_list'][0]['id']"
]]})
112
# Wait to vm is closed
113
actions.append({
'
u': u_new,
114
'fname'
:
'vm.user.list'
,
115
'args'
: [],
116
'store_as'
:
'vm_list'
,
117
'wait_response'
:
'len(r) == 0'
,
118
'wait_max'
: 20})
119
actions.append({
'
u': u_new,
120
'fname'
:
'network.user.release'
,
121
'args'
: [
'@r["user_networks"][0]["id"]'
]})
122
123
# Delete available network
124
actions.append({
'
u': u_admin,
125
'fname'
:
'network.admin_cm.delete'
,
126
'args'
: [hashlib.sha1(u_admin[
'cm_p'
]).hexdigest(),
'@r["available_networks"][0]["id"]'
]})
127
# Try o delete non-existent available network
128
actions.append({
'
u': u_admin,
129
'fname'
:
'network.admin_cm.delete'
,
130
'args'
: [hashlib.sha1(u_admin[
'cm_p'
]).hexdigest(),
'@r["available_networks"][0]["id"]'
],
131
'estatus'
:
'network_not_found'
})
132
133
clm
old-tests
scripts
s050_network_logic.py
Generated on Wed Jun 18 2014 13:32:55 for cc1 by
1.8.1.2