blob: ced6d109d01c2c0b9c734905b89ba6fe0221b808 [file] [log] [blame]
Alex Miller7a489782014-06-04 18:24:16 -07001#!/bin/bash
2FROM_HOST=cautotest
3TO_HOST=cautotest-cq
4POOL=pool:cq
5
6function quiet() {
7 $@ > /dev/null
8}
9
10function silent() {
11 $@ > /dev/null 2>&1
12}
13
14function host_labels() {
15 ./cli/atest host list --web=$FROM_HOST --parse $1 | awk -F '|' '{ print $5 }' | sed 's/Labels=//' | sed 's/, /,/g'
16}
17
18function host_platform() {
19 ./cli/atest host list --web=$FROM_HOST $1 | sed 1d | awk '{ print $4; }'
20}
21
22function lock_host() {
23 ./cli/atest host mod --web=$FROM_HOST -l $1
24}
25
26function create_labels() {
27 ./cli/atest label create --web=$TO_HOST $1
28}
29
30function create_platform() {
31 ./cli/atest label create -t --web=$TO_HOST $1
32}
33
34function create_host() {
35 ./cli/atest host create --web=$TO_HOST -b $2 $1
36}
37
38function remove_host() {
39 ./cli/atest host delete --web=$FROM_HOST $1
40}
41
42HOSTS_TO_MOVE=$(./cli/atest host list --web=$FROM_HOST -b $POOL | sed 1d | awk '{ print $1 }')
43
44for host in $HOSTS_TO_MOVE
45do
46 # if ! silent lock_host $host; then echo $host already handled; continue; fi
47 LABELS=$(host_labels $host)
48 PLATFORM=$(host_platform $host)
49 silent create_labels $LABELS
50 silent create_platform $PLATFORM
51 if create_host $host $LABELS
52 then
53 silent remove_host $host
54 echo $host migrated
55 else
56 echo $host failed
57 fi
58done