Statistics
| Branch: | Tag: | Revision:

one / share / doc / xsd / test.sh @ f66e022b

History | View | Annotate | Download (7.39 KB)

1
#!/bin/bash
2

    
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems                #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# 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

    
19
mkdir -p samples/cluster    samples/cluster_pool
20
mkdir -p samples/datastore  samples/datastore_pool
21
mkdir -p samples/group      samples/group_pool
22
mkdir -p samples/vdc        samples/vdc_pool
23
mkdir -p samples/host       samples/host_pool
24
mkdir -p samples/image      samples/image_pool
25
mkdir -p samples/vmtemplate samples/vmtemplate_pool
26
mkdir -p samples/user       samples/user_pool
27
mkdir -p samples/vm         samples/vm_pool
28
mkdir -p samples/vnet       samples/vnet_pool
29
mkdir -p samples/acct
30
mkdir -p samples/vrouter            samples/vrouter_pool
31
mkdir -p samples/marketplace        samples/marketplace_pool
32
mkdir -p samples/marketplaceapp     samples/marketplaceapp_pool
33

    
34

    
35
onecluster create newcluster
36
onegroup create newgroup
37

    
38

    
39
# Host
40
onehost create host01 --im dummy --vm dummy
41
onehost create host02 --im dummy --vm dummy
42
onehost create host03 --im dummy --vm dummy
43

    
44
#Wait to monitor hosts
45
sleep 30
46

    
47
onecluster addhost newcluster host03
48

    
49
for i in `onehost list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
50
    onehost show $i -x > samples/host/$i.xml
51
done
52

    
53
onehost list -x > samples/host_pool/0.xml
54

    
55

    
56
# VNets
57
onevnet list -x > samples/vnet_pool/1.xml
58

    
59
onevnet create test/vnet.0
60

    
61
onevnet list -x > samples/vnet_pool/2.xml
62

    
63
onevnet create test/vnet.1
64
onevnet create test/vnet.2
65

    
66
onecluster addvnet newcluster 0
67
onecluster addvnet newcluster 2
68

    
69
onevnet reserve 1 --address_range 1 --size 2 --name reserve
70

    
71
for i in `onevnet list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
72
    onevnet show $i -x > samples/vnet/$i.xml
73
done
74

    
75
onevnet list -x > samples/vnet_pool/3.xml
76

    
77
# Cluster
78
onecluster create emptycluster
79

    
80
for i in `onecluster list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
81
    onecluster show $i -x > samples/cluster/$i.xml
82
done
83

    
84
onecluster list -x > samples/cluster_pool/0.xml
85

    
86

    
87
# Image
88
oneimage list -x > samples/image_pool/1.xml
89

    
90
oneimage create test/image.0 -d default
91
oneimage create test/image.1 -d default
92

    
93
for i in `oneimage list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
94
    oneimage show $i -x > samples/image/$i.xml
95
done
96

    
97
oneimage list -x > samples/image_pool/3.xml
98

    
99

    
100
# Datastore
101
onedatastore create test/datastore.0
102
onedatastore create test/datastore.1
103

    
104
onecluster adddatastore newcluster 100
105
onecluster adddatastore newcluster 101
106

    
107
for i in `onedatastore list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
108
    onedatastore show $i -x > samples/datastore/$i.xml
109
done
110

    
111
onedatastore list -x > samples/datastore_pool/0.xml
112

    
113

    
114
# User
115
oneuser defaultquota test/quota.txt
116

    
117
oneuser create newuser abc
118
oneuser chgrp newuser newgroup
119

    
120
oneuser token-create --user newuser --password abc --time 123
121
oneuser token-create --user newuser --password abc --time 456
122
oneuser token-create --user newuser --password abc --time 789
123

    
124
for i in `oneuser list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
125
    oneuser show $i -x > samples/user/$i.xml
126
done
127

    
128
oneuser list -x > samples/user_pool/0.xml
129

    
130

    
131
# Group
132
onegroup defaultquota test/quota.txt
133

    
134
onegroup create emptygroup
135

    
136
for i in `onegroup list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
137
    onegroup show $i -x > samples/group/$i.xml
138
done
139

    
140
onegroup list -x > samples/group_pool/0.xml
141

    
142
# VDC
143
onevdc create emptyvdc
144

    
145
onevdc create newvdc
146
onevdc addgroup newvdc newgroup
147
onevdc addhost newvdc 0 host01
148
onevdc addcluster newvdc 0 newcluster
149

    
150
for i in `onevdc list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
151
    onevdc show $i -x > samples/vdc/$i.xml
152
done
153

    
154
onevdc list -x > samples/vdc_pool/0.xml
155

    
156

    
157
# Template
158
onetemplate list -x > samples/vmtemplate_pool/1.xml
159

    
160
onetemplate create test/template.0 --user newuser --password abc
161
onetemplate create test/template.1 --user newuser --password abc
162
onetemplate create test/vr-template.0
163

    
164
for i in `onetemplate list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
165
    onetemplate show $i -x > samples/vmtemplate/$i.xml
166
done
167

    
168
onetemplate list -x > samples/vmtemplate_pool/2.xml
169

    
170
# VM
171
onetemplate instantiate 0 -m 2 --user newuser --password abc
172
onetemplate instantiate 1 -m 2 --user newuser --password abc
173

    
174
# Virtual Routers
175

    
176
onevrouter create test/vr.0
177
onevrouter instantiate 0 vr-tmpl -m 2
178

    
179
for i in `onevm list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
180
    onevm deploy $i host01
181
done
182

    
183
sleep 5
184

    
185
onevm migrate --live 0 host02
186
onevm terminate --hard 1
187
onevm poweroff 2
188

    
189
sleep 5
190

    
191
onevm suspend 0
192
onevm resume 2
193

    
194
sleep 5
195

    
196
for i in `onevm list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
197
    onevm show $i -x > samples/vm/$i.xml
198
done
199

    
200
onevm list -x > samples/vm_pool/0.xml
201

    
202
for i in `onevrouter list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
203
    onevrouter show $i -x > samples/vrouter/$i.xml
204
done
205

    
206
onevrouter list -x > samples/vrouter_pool/0.xml
207

    
208
# Marketplace
209

    
210
for i in `onemarket list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
211
    onemarket show $i -x > samples/marketplace/$i.xml
212
done
213

    
214
onemarket list -x > samples/marketplace_pool/0.xml
215

    
216
# Marketplace Apps
217

    
218
for i in `onemarketapp list | tail -n +2 | tr -s ' ' | cut -f2 -d ' '`; do
219
    onemarketapp show $i -x > samples/marketplaceapp/$i.xml
220
done
221

    
222
onemarketapp list -x > samples/marketplaceapp_pool/0.xml
223

    
224
for i in  cluster datastore group vdc host image vmtemplate user vm vnet vrouter marketplace marketplaceapp
225
do
226
    POOL_NAME="$i""_pool"
227

    
228
    sed -i "s%<${i^^}>%<${i^^} xmlns='http://opennebula.org/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://opennebula.org/XMLSchema ../../$i.xsd'>%" samples/$i/*.xml
229
    sed -i "s%<${i^^}_POOL/>%<${i^^}_POOL xmlns='http://opennebula.org/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://opennebula.org/XMLSchema ../../$POOL_NAME.xsd'/>%" samples/$POOL_NAME/*.xml
230
    sed -i "s%<${i^^}_POOL>%<${i^^}_POOL xmlns='http://opennebula.org/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://opennebula.org/XMLSchema ../../$POOL_NAME.xsd'>%" samples/$POOL_NAME/*.xml
231

    
232
    xmllint --noout --schema $i.xsd samples/$i/*
233
    xmllint --noout --schema $POOL_NAME.xsd samples/$POOL_NAME/*
234
done
235

    
236

    
237
# Accounting
238
oneacct -x > samples/acct/0.xml
239

    
240
sed -i "s%<HISTORY_RECORDS>%<HISTORY_RECORDS xmlns='http://opennebula.org/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://opennebula.org/XMLSchema ../../acct.xsd'>%" samples/acct/*.xml
241

    
242
xmllint --noout --schema acct.xsd samples/acct/*
243

    
244
exit 0