-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert-offset.sh
executable file
·85 lines (69 loc) · 2.16 KB
/
convert-offset.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
#!/bin/bash
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
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"
python3 convert-blueprint.py --blueprint $blueprint --output $outputdir --user $ravelloUser \
--password $ravelloPass --name $appName $pk --importhost $import_host --auth-url $ospAuthURL \
--auth-user $ospUser --auth-password $ospPass --ibm-endpoint $ibm_endpoint --ibm-api-key $ibm_api_key \
--ibm-bucket-name $ibm_bucket_name --ibm-resource-id $ibm_resource_id --domain-id $ravelloDomain -of 4
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
CURRENT=$PWD
cd $outputdir
ln -s ../../library
cd $CURRENT
ansible-playbook --skip-tags shutdown -i $outputdir/inventory $outputdir/class_playbook_export_disks.yaml -u root
if [ $? -ne 0 ]
then
echo "ansible-playbook export disks failed."
#curl -s -X DELETE --user ${ravelloUser}:${ravelloPass} https://cloud.ravellosystems.com/api/v1/applications/${appID}
exit 1
fi
#ansible-playbook --skip-tags shutdown -i $outputdir/inventory $outputdir/class_playbook_import_disks.yaml -u root
#
#if [ $? -ne 0 ]
#then
# echo "ansible-playbook import failed."
# #curl -s -X DELETE --user ${ravelloUser}:${ravelloPass} https://cloud.ravellosystems.com/api/v1/applications/${appID}
# exit 1
#fi
echo "Deleting $appName from Ravello"
python3 delete-app.py --user $ravelloUser --password $ravelloPass --domain-id $ravelloDomain -a ${appName}
echo "The HEAT templates are in $outputdir/{stack_admin.yaml,stack_user.yaml}"