-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutotest_Create_job_XML_file.sh
141 lines (123 loc) · 4.21 KB
/
Autotest_Create_job_XML_file.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#if HOSTNAME="",job will search available machine to reserve.
#if KICKSTART="",will install os with the latest ks.
#Default RESERVETIME is 24h,maximum of 356400 seconds (99 hours),you can define the duration (in seconds)
#HOST_CONTROL defines in which lab to select machine.
HOSTNAME=""
KICKSTART=""
RESERVETIME="86400"
PYTHON_CMD="python ConfigTest.py --testcase=boot --guestname=RHEL.7.1 --drive_cache=unsafe"
NFS_LOG="10.66.90.121:/vol/s2coredump/test_result"
KS_URL="http://pxe.englab.nay.redhat.com/kickstarts/kvm/RHEL7/"
HOSTTYPE="RHEV-7.2-Server"
NETWORK="bridge"
REG="^ak.*$HOSTTYPE.*$NETWORK"
JOB="job_rhev7.xml"
get_ks(){
if [[ "$KICKSTART" != "" ]]; then
rm -rf $KICKSTART*
wget $KS_URL$KICKSTART
if [[ $? -eq 0 ]]; then
return 0
fi
fi
reg=$1
ks_url=$2
hosttype=$3
rm -rf index.html*
wget -c $KS_URL
LATEST_KS=`awk -F"\"" '{print $8}' index.html | grep $reg | tail -n1`
if [[ $LATEST_KS == "" ]]; then
return 1
fi
PREV_KS=`ls |grep $reg`
if [[ "$LATEST_KS" == $PREV_KS ]]; then
return 1
fi
rm -rf $PREV_KS
wget $KS_URL$LATEST_KS
if [[ $? -eq 0 ]]; then
KICKSTART=$LATEST_KS
return 0
fi
return 1
}
# Create beaker job xml
create_beaker_xml () {
rm -rf $JOB
# Get the distro info from kickstart
SIG=`grep "url --url" $KICKSTART | awk -F "/" '{print $8}'`
if [[ "$SIG" == "compose" ]]; then
DISTRO_NAME=`grep "url --url" $KICKSTART | awk -F"/" '{print $7}'`
else
DISTRO_NAME=`grep "url --url" $KICKSTART | awk -F"/" '{print "RHEL-"$8}'`
fi
DISTRO_FAMILY="RedHatEnterpriseLinux"`echo $DISTRO_NAME | cut -b 6`
#Create job.xml
echo "<job retention_tag=\"scratch\">
<whiteboard>
Run $PYTHON_CMD for $KICKSTART
</whiteboard>
<recipeSet priority=\"High\">
<recipe kernel_options=\"\" kernel_options_post=\"\" ks_meta=\"\" role=\"RECIPE_MEMBERS\" whiteboard=\"\">
<autopick random=\"false\"/>
<watchdog panic=\"ignore\"/>
<packages/>
<ks_appends>
<ks_append>
<![CDATA[
" > $JOB
# Modify the kickstart and put it into job.xml
grep rootpw $KICKSTART >> $JOB
sed '0, /^reboot$/d' $KICKSTART | grep "rm -rf /etc/yum.repos.d/*" -v | grep "sed -i '/upgrade-pkg.sh/ s/^./#./' /etc/rc.d/rc.local" -v | grep "^reboot" -v >> $JOB
sed -i '/upgrade-pkg.log/ s/^./#./' $JOB
echo "]]>
</ks_append>
</ks_appends>
<repos/>
<distroRequires>
<and>
<distro_family op=\"=\" value=\"$DISTRO_FAMILY\"/>
<distro_variant op=\"=\" value=\"Server\"/>
<distro_name op=\"=\" value=\"$DISTRO_NAME\"/>
<distro_arch op=\"=\" value=\"x86_64\"/>
</and>
</distroRequires>
<hostRequires>
<and>
<hostname op=\"like\" value=\"$HOSTNAME\"/>
<arch op=\"=\" value=\"x86_64\"/>
<system_type op=\"=\" value=\"Machine\"/>
<key_value key=\"CPUFLAGS\" op=\"=\" value=\"svm\"/>
<hostlabcontroller op=\"=\" value=\"lab-02.rhts.eng.nay.redhat.com\"/>
</and>
</hostRequires>
<partitions/>
<task name=\"/distribution/install\" role=\"STANDALONE\"/>
<task name=\"/virt/kvmauto-task/Sanity/upgrade-package\" role=\"STANDALONE\"/>
<task name=\"/distribution/utils/reboot\" role=\"STANDALONE\"/>
<task name=\"/virt/kvmauto-task/Sanity/run-kvm-autotest-common\" role=\"STANDALONE\">
<params>
<param name=\"PYTHON_CMD\" value=\"$PYTHON_CMD\"/>
<param name=\"NFS_LOG\" value=\"$NFS_LOG\"/>
</params>
</task>
<task name=\"/distribution/reservesys\" role=\"STANDALONE\">
<params>
<param name=\"RESERVETIME\" value=\"$RESERVETIME\"/>
</params>
</task>
</recipe>
</recipeSet>
</job>
" >> $JOB
}
echo "######get latest ks######"
get_ks $REG $KS_URL $HOSTTYPE
if [[ $? == 0 ]]; then
echo "######create job xml######"
create_beaker_xml
echo "######JOB=$JOB######"
exit 0
fi
exit 1