-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.sh.old
executable file
·122 lines (93 loc) · 2.71 KB
/
convert.sh.old
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
#!/bin/bash
if [ -z "$ravelloDomain" ];
then
ravelloDomain=None
fi
if [ ! -f creds.inc ]
then
echo "Please create creds.inc from creds.inc.example"
exit 1
fi
. creds.inc
if [ -z "$1" ]
then
echo "Usage: $0 <blueprint>"
exit 1
fi
blueprint=$1
outputdir="imported/${blueprint}-playbooks"
mkdir -p $outputdir
python ravello2osp.py --blueprint $blueprint --output $outputdir --user $ravelloUser --password $ravelloPass --domain $ravelloDomain
if [ $? -ne 0 ]
then
echo "ravello2osp.py failed."
exit 1
fi
if [ -n "$2" ]
then
if [ $2 == "metaonly" ]
then
echo "Meta files stored in $outputdir. Not converting disk."
exit
fi
fi
outfile=/tmp/.convert.$$
appName="exporter-app-${ravelloUser}"
if [ -n "$pubKeyFile" ]
then
echo "Using public key $pubKeyFile"
pk="--pubkeyfile $pubKeyFile"
else
echo "Using password auth"
pk=""
fi
echo "Deploying Ravello app: $appName"
python create_ravello_disks_project.py -n $appName -u $ravelloUser -p $ravelloPass $pk --domain $ravelloDomain > $outfile
if [ $? -ne 0 ]
then
echo "create_ravello_disks_project.py failed."
exit 1
fi
appID=`grep 'App id' $outfile|cut -f2 -d:`
vmID=`grep 'VM id' $outfile|cut -f2 -d:`
ravelloHost=`grep 'DNS:' $outfile|cut -f2 -d:|sed 's/ //g'`
rm -f $outfile
python ravellodisks2glance.py --auth-url $ospAuthURL --auth-user $ospUser --auth-password $ospPass \
-o $outputdir -bp $blueprint -u $ravelloUser -p $ravelloPass -a $appID -m $vmID --host $ravelloHost \
--osp-project $ospProject --ibm-auth-endpoint $ibm_auth_endpoint --ibm-endpoint $ibm_endpoint \
--ibm-api-key $ibm_api_key --ibm-bucket-name $ibm_bucket_name --ibm-resource-id "$ibm_resource_id" \
--importhost $import_host --domain $ravelloDomain
if [ $? -ne 0 ]
then
echo "ravellodisks2glance.py failed."
exit 1
fi
echo "Waiting for SSH service to start on VM."
sleep 35
if [ -z "$pubKeyFile" ]
then
echo "Enter the root password for exporter VM 'r3dh4t1!'"
ssh-copy-id -o StrictHostKeyChecking=no root@${ravelloHost}
if [ $? -ne 0 ]
then
echo "ssh-copy-id failed."
exit 1
fi
fi
export ANSIBLE_HOST_KEY_CHECKING=False
cp -a library $outputdir
ansible-playbook --skip-tags shutdown -i $outputdir/playbook_import_disks.hosts $outputdir/playbook_export_disks.yaml -u root
if [ $? -ne 0 ]
then
echo "ansible-playbook export disks failed."
exit 1
fi
#ansible-playbook --skip-tags shutdown -i $outputdir/playbook_import_disks.hosts $outputdir/playbook_import_disks.yaml -u root
#
#if [ $? -ne 0 ]
#then
# echo "ansible-playbook import failed."
# exit 1
#fi
#curl -s -X DELETE --user ${ravelloUser}:${ravelloPass} https://cloud.ravellosystems.com/api/v1/applications/${appID}
echo "The HEAT templates are in $outputdir/{stack_admin.yaml,stack_user.yaml}"