3
# orange-box-configure-openstack
4
# Copyright (C) 2014 Canonical Ltd.
6
# Authors: Darryl Weaver <darryl.weaver@canonical.com>
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, version 3 of the License.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
22
echo "This command is run to configure an Orange-Box Openstack deployment"
24
PKGS=" python-keystone python-neutronclient python-novaclient python-glanceclient"
25
dpkg -l $PKGS > /dev/null || sudo apt-get install -y $PKGS
27
NEUTRON_EXT_NET_GW="10.14.4.1"
28
NEUTRON_EXT_NET_CIDR="10.14.0.0/16"
29
NEUTRON_EXT_NET_NAME="ext_net"
30
NEUTRON_DNS="10.14.4.1"
31
NEUTRON_FLOAT_RANGE_START="10.14.200.1"
32
NEUTRON_FLOAT_RANGE_END="10.14.249.254"
34
NEUTRON_FIXED_NET_CIDR="192.168.14.0/24"
35
NEUTRON_FIXED_NET_NAME="admin_net"
37
keystone=$(juju status keystone | grep public-address | head -1 | awk '{print $2}')
39
echo "export SERVICE_ENDPOINT=http://$keystone:35357/v2.0/
40
export SERVICE_TOKEN=admin
41
export OS_AUTH_URL=http://$keystone:35357/v2.0/
42
export OS_USERNAME=admin
43
export OS_PASSWORD=admin
44
export OS_TENANT_NAME=admin
45
export OS_REGION_NAME=RegionOne
50
# Determine the tenant id for the configured tenant name.
51
export TENANT_ID="$(keystone tenant-list | grep $OS_TENANT_NAME | awk '{ print $2 }')"
53
#create ext network with neutron for floating IPs
54
EXTERNAL_NETWORK_ID=$(neutron net-create ext_net --tenant-id $TENANT_ID -- --router:external=True | grep " id" | awk '{print $4}')
55
neutron subnet-create ext_net $NEUTRON_EXT_NET_CIDR --name ext_net_subnet --tenant-id $TENANT_ID \
56
--allocation-pool start=$NEUTRON_FLOAT_RANGE_START,end=$NEUTRON_FLOAT_RANGE_END \
57
--gateway $NEUTRON_EXT_NET_GW --disable-dhcp --dns_nameservers $NEUTRON_DNS list=true
59
#Create private network for neutron for tenant VMs
60
neutron net-create private
61
SUBNET_ID=$(neutron subnet-create private $NEUTRON_FIXED_NET_CIDR -- --name private_subnet --dns_nameservers list=true $NEUTRON_DNS | grep " id" | awk '{print $4}')
63
#Create router for external network and private network
64
ROUTER_ID=$(neutron router-create --tenant-id $TENANT_ID provider-router | grep " id" | awk '{print $4}')
65
neutron router-interface-add $ROUTER_ID $SUBNET_ID
66
neutron router-gateway-set $ROUTER_ID $EXTERNAL_NETWORK_ID
68
#Configure the default security group to allow ICMP and SSH
69
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
70
nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
72
nova secgroup-add-rule default tcp 3389 3389 0.0.0.0/0
74
#Upload a default SSH key
75
nova keypair-add --pub-key ~/.ssh/id_rsa.pub default
77
#Remove the m1.tiny as it is too small for Ubuntu.
78
nova flavor-delete m1.tiny
79
nova flavor-delete m1.xlarge
81
#Modify quotas for the tenant to allow large deployments
82
nova quota-update --instances 100 $TENANT_ID
83
nova quota-update --cores 200 $TENANT_ID
84
nova quota-update --ram 204800 $TENANT_ID
85
nova quota-update --security-groups 200 $TENANT_ID
87
#Upload images to glance
88
glance add name="Precise x86_64" is_public=true container_format=ovf disk_format=qcow2 < /srv/data/precise-server-cloudimg-amd64-disk1.img
89
glance add name="Trusty x86_64" is_public=true container_format=ovf disk_format=qcow2 < /srv/data/trusty-server-cloudimg-amd64-disk1.img
90
#glance add name="CentOS 6.4" is_public=true container_format=bare disk_format=qcow2 < /srv/data/centos6.4-x86_64-gold-master.img
91
#glance add name="Cirros 0.3" is_public=true container_format=bare disk_format=qcow2 < /srv/data/cirros-0.3.2-x86_64-disk.img
92
##glance add name="Windows Server 2012" is_public=true container_format=bare disk_format=qcow2 < /srv/data/windows_server_2012_r2_standard_eval_kvm_20140607.qcow2 &