blob: dbc384049e316207ca4517844801d201f2a54526 (
plain)
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
|
#!/bin/bash
# Copyright 2015-2016 AT&T Intellectual Property, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# What this is: Setup script for the Cloudify Manager starting from an
# Unbuntu Trusty docker container.
#
# Status: this is a work in progress, under test.
#
# How to use:
# $ bash cloudify-setup.sh [ 1 || 2 ]
# 1: Initial setup of the docker container
# 2: Setup of the Cloudify Manager in the docker container
# Find external network name
func get_external_net () {
LINE=4
ID=$(openstack network list | awk "NR==$LINE{print \$2}")
while [[ $ID ]]
do
if [[ $(openstack network show $ID | awk "/ router:external / { print \$4 }") == "True" ]]; then break; fi
let ID=$ID+1
done
if [[ $ID ]]; then
EXTERNAL_NETWORK_NAME=$(openstack network show $ID | awk "/ name / { print \$4 }")
else
echo "External network not found"
return 1
fi
}
dist=`grep DISTRIB_ID /etc/*-release | awk -F '=' '{print $2}'`
if [ "$1" == "1" ]; then
# Setup container
if [ "$dist" == "Ubuntu" ]; then
sudo docker pull ubuntu:trusty
sudo service docker start
sudo docker run -it -v ~/git/joid/ci/cloud/admin-openrc:/root/admin-openrc -v ~/cloudify/cloudify-setup.sh:/root/cloudify-setup.sh ubuntu /bin/bash
else
# Centos
fi
else
# Install dependencies - OS specific
if [ "$dist" == "Ubuntu" ]; then
apt-get update
apt-get install -y python python-dev python-pip wget
# apt-get install -y apg git gcc python-dev libxml2 libxslt1-dev libzip-dev
# pip install --upgrade pip virtualenv setuptools pbr tox
else
# Centos
fi
fi
cd ~
# Install dependencies - generic
pip install --upgrade pip virtualenv
# Upgrage pip again - needs to be the latest version due to errors found in earlier testing
pip install --upgrade pip
pip install python-openstackclient python-glanceclient
# Create virtualenv
virtualenv ~/cloudify/venv
source ~/cloudify/venv/bin/activate
# Get Cloudify
wget http://gigaspaces-repository-eu.s3.amazonaws.com/org/cloudify3/get-cloudify.py
python get-cloudify.py --upgrade
# Initialize Cloudify
cfy init
# Prepare the Cloudify Manager data
mkdir -p ~/cloudify-manager
cd ~/cloudify-manager
wget https://github.com/cloudify-cosmo/cloudify-manager-blueprints/archive/3.4.tar.gz
mv 3.4.tar.gz cloudify-manager-blueprints.tar.gz
tar -xzvf cloudify-manager-blueprints.tar.gz
cd cloudify-manager-blueprints-3.4
source ~/admin-openrc
sed -i -- "s/keystone_username: ''/keystone_username: '$OS_USERNAME'/g" openstack-manager-blueprint-inputs.yaml
sed -i -- "s/keystone_password: ''/keystone_password: '$OS_PASSWORD'/g" openstack-manager-blueprint-inputs.yaml
sed -i -- "s/keystone_tenant_name: ''/keystone_tenant_name: '$OS_TENANT_NAME'/g" openstack-manager-blueprint-inputs.yaml
sed -i -- "s/keystone_url: ''/keystone_url: '$OS_AUTH_URL'/g" openstack-manager-blueprint-inputs.yaml
sed -i -- "s/region: ''/region: '$OS_REGION_NAME'/g" openstack-manager-blueprint-inputs.yaml
sed -i -- "s/#manager_public_key_name: ''/manager_public_key_name: 'manager-key'/g" openstack-manager-blueprint-inputs.yaml
sed -i -- "s/#agent_public_key_name: ''/agent_public_key_name: 'manager-key'/g" openstack-manager-blueprint-inputs.yaml
image=$(openstack image list | awk "/ cirros-0.3.3-x86_64 / { print \$2 }")
if [ -z $image ]; then glance --os-image-api-version 1 image-create --name cirros-0.3.3-x86_64 --disk-format qcow2 --location http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img --container-format bare
fi
sed -i -- "s/image_id: ''/image_id: '$image'/g" openstack-manager-blueprint-inputs.yaml
flavor=$(nova flavor-show m1.tiny | awk "/ id / { print \$4 }")
if [ -z $image ]; then glance --os-image-api-version 1 image-create --name cirros-0.3.3-x86_64 --disk-format qcow2 --location http://download.cirros-cloud.net/0.3.3/cirros-0.3.3-x86_64-disk.img --container-format bare
fi
sed -i -- "s/flavor_id: ''/flavor_id: 'm1.tiny'/g" openstack-manager-blueprint-inputs.yaml
get_external_net
sed -i -- "s/external_network_name: ''/external_network_name: '$EXTERNAL_NETWORK_NAME'/g" openstack-manager-blueprint-inputs.yaml
# Bootstrap the manager
cfy bootstrap --install-plugins -p openstack-manager-blueprint.yaml -i openstack-manager-blueprint-inputs.yaml
|