Merge lp:~thomnico/sademos/juju-on-openstack-resumed into lp:sademos/16.04

Proposed by Nicolas Thomas
Status: Needs review
Proposed branch: lp:~thomnico/sademos/juju-on-openstack-resumed
Merge into: lp:sademos/16.04
Diff against target: 474 lines (+240/-107)
5 files modified
00-bootstrap.sh (+1/-1)
openstack/01-deploy.sh (+4/-8)
openstack/configure-juju-on-openstack (+106/-51)
openstack/get-cloud-images (+5/-4)
openstack/orange-box-configure-openstack (+124/-43)
To merge this branch: bzr merge lp:~thomnico/sademos/juju-on-openstack-resumed
Reviewer Review Type Date Requested Status
CPE SA Pending
Review via email: mp+297745@code.launchpad.net
To post a comment you must log in.
Revision history for this message
mahmoh (mahmoh) wrote :

Noticed one thing on a quick overview:

openstack/01-deploy.sh:

+juju set-model-config cloudimg-base-url=http://172.27.60.1/mirrors/cloud-images.ubuntu.com/query
31

^static IP, I'm guessing you have OB60?

Note: for grabbing the cloud images from /srv/, definitely the way to go but would be nice to have a checksum check to ensure they were all downloaded properly the first time although testing one's setup would reveal this problem also.

Revision history for this message
Nicolas Thomas (thomnico) wrote :

Good catch,

It is a remains of the offline work that I plan to provide separately
to avoid a huge review.

Will remove from now

On Fri, Jun 17, 2016 at 3:15 PM, M.Morana <email address hidden> wrote:
> Noticed one thing on a quick overview:
>
> openstack/01-deploy.sh:
>
> +juju set-model-config cloudimg-base-url=http://172.27.60.1/mirrors/cloud-images.ubuntu.com/query
> 31
>
> ^static IP, I'm guessing you have OB60?
>
> Note: for grabbing the cloud images from /srv/, definitely the way to go but would be nice to have a checksum check to ensure they were all downloaded properly the first time although testing one's setup would reveal this problem also.
> --
> https://code.launchpad.net/~thomnico/sademos/juju-on-openstack-resumed/+merge/297745
> You are the owner of lp:~thomnico/sademos/juju-on-openstack-resumed.

--
Best Regards,
       Nicolas Thomas
http://insights.ubuntu.com/?p=889
EMEA Solution Architect Canonical
GPG FPR: D592 4185 F099 9031 6590 6292 492F C740 F03A 7EB9

95. By Nicolas Thomas

Remove the off-line related part.
clean up the code

modified:
  openstack/01-deploy.sh

96. By Nicolas Thomas

Add Xenial to the mix ..

modified:
  openstack/get-cloud-images

Revision history for this message
Scott Croft (secroft) wrote :

Also, with juju 2.0, it's add-model now
On Jun 17, 2016 08:30, "Nicolas Thomas" <email address hidden>
wrote:

> Good catch,
>
> It is a remains of the offline work that I plan to provide separately
> to avoid a huge review.
>
> Will remove from now
>
> On Fri, Jun 17, 2016 at 3:15 PM, M.Morana <email address hidden> wrote:
> > Noticed one thing on a quick overview:
> >
> > openstack/01-deploy.sh:
> >
> > +juju set-model-config cloudimg-base-url=
> http://172.27.60.1/mirrors/cloud-images.ubuntu.com/query
> > 31
> >
> > ^static IP, I'm guessing you have OB60?
> >
> > Note: for grabbing the cloud images from /srv/, definitely the way to go
> but would be nice to have a checksum check to ensure they were all
> downloaded properly the first time although testing one's setup would
> reveal this problem also.
> > --
> >
> https://code.launchpad.net/~thomnico/sademos/juju-on-openstack-resumed/+merge/297745
> > You are the owner of lp:~thomnico/sademos/juju-on-openstack-resumed.
>
>
>
> --
> Best Regards,
> Nicolas Thomas
> http://insights.ubuntu.com/?p=889
> EMEA Solution Architect Canonical
> GPG FPR: D592 4185 F099 9031 6590 6292 492F C740 F03A 7EB9
>
>
> https://code.launchpad.net/~thomnico/sademos/juju-on-openstack-resumed/+merge/297745
> Your team CPE SA is requested to review the proposed merge of
> lp:~thomnico/sademos/juju-on-openstack-resumed into lp:sademos/16.04.
>

97. By Nicolas Thomas

fix create to add model

Revision history for this message
Nicolas Thomas (thomnico) wrote :

Fixed

Lost in translating to a limited scope ...

On Fri, Jun 17, 2016 at 3:48 PM, Scott Croft <email address hidden> wrote:
> Also, with juju 2.0, it's add-model now
> On Jun 17, 2016 08:30, "Nicolas Thomas" <email address hidden>
> wrote:
>
>> Good catch,
>>
>> It is a remains of the offline work that I plan to provide separately
>> to avoid a huge review.
>>
>> Will remove from now
>>
>> On Fri, Jun 17, 2016 at 3:15 PM, M.Morana <email address hidden> wrote:
>> > Noticed one thing on a quick overview:
>> >
>> > openstack/01-deploy.sh:
>> >
>> > +juju set-model-config cloudimg-base-url=
>> http://172.27.60.1/mirrors/cloud-images.ubuntu.com/query
>> > 31
>> >
>> > ^static IP, I'm guessing you have OB60?
>> >
>> > Note: for grabbing the cloud images from /srv/, definitely the way to go
>> but would be nice to have a checksum check to ensure they were all
>> downloaded properly the first time although testing one's setup would
>> reveal this problem also.
>> > --
>> >
>> https://code.launchpad.net/~thomnico/sademos/juju-on-openstack-resumed/+merge/297745
>> > You are the owner of lp:~thomnico/sademos/juju-on-openstack-resumed.
>>
>>
>>
>> --
>> Best Regards,
>> Nicolas Thomas
>> http://insights.ubuntu.com/?p=889
>> EMEA Solution Architect Canonical
>> GPG FPR: D592 4185 F099 9031 6590 6292 492F C740 F03A 7EB9
>>
>>
>> https://code.launchpad.net/~thomnico/sademos/juju-on-openstack-resumed/+merge/297745
>> Your team CPE SA is requested to review the proposed merge of
>> lp:~thomnico/sademos/juju-on-openstack-resumed into lp:sademos/16.04.
>>
>
> --
> https://code.launchpad.net/~thomnico/sademos/juju-on-openstack-resumed/+merge/297745
> You are the owner of lp:~thomnico/sademos/juju-on-openstack-resumed.

--
Best Regards,
       Nicolas Thomas
http://insights.ubuntu.com/?p=889
EMEA Solution Architect Canonical
GPG FPR: D592 4185 F099 9031 6590 6292 492F C740 F03A 7EB9

Unmerged revisions

97. By Nicolas Thomas

fix create to add model

96. By Nicolas Thomas

Add Xenial to the mix ..

modified:
  openstack/get-cloud-images

95. By Nicolas Thomas

Remove the off-line related part.
clean up the code

modified:
  openstack/01-deploy.sh

94. By Nicolas Thomas

Rework the configure openstack to collect info from juju (no more passwd issues)
Set to use 172.72.(obnum+1) (need the range to be free TBC).
If setting VIP or os-public use it for nova (usefull for 2 network scenario).
Update Windows..

Rename to configure-juju-on-opnestack as it has nothing OB specific .. YES !!
Move to use swift for metadata and generate metadata for images created (juju doc is misleading).

renamed:
  openstack/orange-box-launch-openstack-juju => openstack/configure-juju-on-openstack
modified:
  00-bootstrap.sh
  openstack/01-deploy.sh
  openstack/orange-box-configure-openstack
  openstack/configure-juju-on-openstack

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '00-bootstrap.sh'
--- 00-bootstrap.sh 2016-04-21 20:21:52 +0000
+++ 00-bootstrap.sh 2016-06-17 14:41:49 +0000
@@ -11,7 +11,7 @@
1111
12obnum=`hostname | cut -c 10- -`12obnum=`hostname | cut -c 10- -`
1313
14time juju bootstrap --to node00vm0ob${obnum}.maas --show-log --upload-tools maas-controller maas/172.27.${obnum}.114time juju bootstrap --to node00vm0ob${obnum}.maas --show-log maas-controller maas/172.27.${obnum}.1
15time juju switch admin15time juju switch admin
1616
17URL=`juju gui --no-browser`17URL=`juju gui --no-browser`
1818
=== modified file 'openstack/01-deploy.sh'
--- openstack/01-deploy.sh 2016-04-21 19:55:54 +0000
+++ openstack/01-deploy.sh 2016-06-17 14:41:49 +0000
@@ -4,14 +4,10 @@
44
5model=`juju list-models |awk '{print $1}'|grep openstack`5model=`juju list-models |awk '{print $1}'|grep openstack`
66
7if [ ${model} = "openstack" ]; then7[ "${model}" == "openstack" ] || juju add-model openstack
8 juju switch openstack8juju switch openstack
9 juju deploy openstack-liberty.yaml9
10else10juju deploy openstack-liberty.yaml
11 juju create-model openstack
12 juju switch openstack
13 juju deploy openstack-liberty.yaml
14fi
1511
16juju show-controllers --show-passwords|egrep "user|password"12juju show-controllers --show-passwords|egrep "user|password"
1713
1814
=== renamed file 'openstack/orange-box-launch-openstack-juju' => 'openstack/configure-juju-on-openstack'
--- openstack/orange-box-launch-openstack-juju 2015-10-09 18:44:36 +0000
+++ openstack/configure-juju-on-openstack 2016-06-17 14:41:49 +0000
@@ -3,7 +3,7 @@
3# orange-box-launch-openstack-juju3# orange-box-launch-openstack-juju
4# Copyright (C) 2014 Canonical Ltd.4# Copyright (C) 2014 Canonical Ltd.
5#5#
6# Authors: Darryl Weaver <darryl.weaver@canonical.com>6# Authors: Nicolas Thomss <nicolas.thomas@canonical.com>
7#7#
8# This program is free software: you can redistribute it and/or modify8# 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 by9# it under the terms of the GNU General Public License as published by
@@ -17,70 +17,123 @@
17# You should have received a copy of the GNU General Public License17# You should have received a copy of the GNU General Public License
1818
19set -ex19set -ex
20## TODO use sudo apt-get install python-openstackclient instead
21## examples:
22## openstack ip floating list --format=csv
23##  openstack ip floating create --format=shell ext_net
24## to avoid table parsing..
25## openstack server show -c status --format value my-instance-name
26
2027
21echo "This command is run to launch the first instance on a new Orange box Openstack deployment"28echo "This command is run to launch the first instance on a new Orange box Openstack deployment"
2229
23source ~/nova.rc30source ~/nova.rc
2431
32
25#Create a floating IP for the instance33#Create a floating IP for the instance
26FLOAT_IP="$(nova floating-ip-create | grep ext_net | awk '{ print $2}')"34if ( nova list | grep jumpserver2 >/dev/null )
2735then
36 FLOAT_IP="$(nova list | grep jumpserver2 | awk '{ print $13 }')"
37else
38 FLOAT_IP="$(nova floating-ip-create | grep ext_net | awk 'BEGIN { FS = "|" } ; { print $2}'|tr -d '[[:space:]]')"
39fi
40
28#Launch an instance41#Launch an instance
29NET_UUID="$(nova net-list | grep private | awk '{ print $2 }')"42NET_UUID="$(nova net-list | grep private | awk '{ print $2 }')"
30IMAGE_UUID="$(nova image-list | grep Trusty | awk '{ print $2 }')"43IMAGE_UUID="$(nova image-list | grep Xenial | awk '{ print $2 }')"
31nova boot --flavor 2 --key_name default --image $IMAGE_UUID --nic net-id=$NET_UUID --security_group default jumpserver44nova list | grep jumpserver2 ||nova boot --flavor m1.small --key_name default --image $IMAGE_UUID --nic net-id=$NET_UUID --security_group default jumpserver2
32sleep 4045# checking jumpserver2 state until active ..
3346INST_STATE=` nova show jumpserver2 | grep status | awk '{print $4}'`
47while [ $INST_STATE != "ACTIVE" ];
48do
49 INST_STATE=` nova show jumpserver2 | grep status | awk '{print $4}'`
50 echo "Jumpserver2 instance state is: "$INST_STATE" waiting to be active"
51 sleep 1
52done
53sleep 6
34#Associate the floating IP with the new instance54#Associate the floating IP with the new instance
35nova floating-ip-associate jumpserver $FLOAT_IP55nova floating-ip-associate jumpserver2 $FLOAT_IP || true
36sleep 1056sleep 10
57
58### make it more Readable
59export SSH="ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP"
60
61
62#Add juju stable repo
63$SSH sudo add-apt-repository -y ppa:juju/stable
64
37#SSH into the instance and install Juju65#SSH into the instance and install Juju
38ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP sudo apt-get -y install juju-core juju-quickstart juju-deployer66$SSH sudo apt-get -y update
3967
40#Set up the Juju default environment68$SSH sudo apt-get -y install juju python-novaclient python-swiftclient
41ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP juju init69
4270
43#copy over SSH keys71#copy over SSH keys
44scp -o StrictHostKeyChecking=no ~/.ssh/id_rsa* ubuntu@$FLOAT_IP:72scp -o StrictHostKeyChecking=no ~/.ssh/id_rsa* ubuntu@$FLOAT_IP:~/.ssh/
4573
46#Output a juju env file that works on this cloud74
47ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP "echo 'default: openstack75#Output a juju cloud file that works on this cloud
48environments:76$SSH \
49 openstack:77"echo 'clouds:
50 type: openstack78 openstack:
51 use-floating-ip: true79 type: openstack
52 network: private80 auth-types: [access-key, userpass]
53 auth-url: $OS_AUTH_URL81 regions:
54 tenant-name: $OS_TENANT_NAME82 $OS_REGION_NAME:
55 region: $OS_REGION_NAME83 endpoint: $OS_AUTH_URL
56 auth-mode: userpass84' > os-cloud.yaml"
57 username: $OS_USERNAME85$SSH juju add-cloud openstack os-cloud.yaml
58 password: $OS_PASSWORD86
59 admin-secret: $OS_PASSWORD87#Output a juju cred file that works on this cloud
60 default-series: trusty88$SSH \
61 http-proxy: http://10.14.4.1:800089"echo 'credentials:
62 https-proxy: http://10.14.4.1:800090 openstack:
63 ftp-proxy: http://10.14.4.1:800091 openstack:
64 no-proxy: localhost,10.14.4.192 auth-type: userpass
65 apt-http-proxy: http://10.14.4.1:800093 password: $OS_PASSWORD
66 apt-https-proxy: http://10.14.4.1:800094 tenant-name: $OS_TENANT_NAME
67 apt-ftp-proxy: http://10.14.4.1:800095 username: $OS_USERNAME
68' > ~/.juju/environments.yaml"96' > os-creds.yaml"
6997
98$SSH "juju add-credential openstack -f os-creds.yaml"
99
100## Creating images metadata
101$SSH mkdir -p ~/juju-meta
102for s in precise trusty xenial win2012r2
103do
70#Create juju metadata104#Create juju metadata
71ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP "juju-metadata generate-image -a amd64 -u $OS_AUTH_URL -i $IMAGE_UUID -r $OS_REGION_NAME -s trusty"105 IMAGE_UUID="$(nova image-list | grep -i $s | awk '{ print $2 }')"
72106 [ -n "$IMAGE_UUID" ] && $SSH "juju metadata generate-image -a amd64 -u $OS_AUTH_URL -i $IMAGE_UUID -r $OS_REGION_NAME -d juju-meta/ -s $s"
73IMAGE_UUID="$(nova image-list | grep Precise | awk '{ print $2 }')"107done
74ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP "juju-metadata generate-image -a amd64 -u $OS_AUTH_URL -i $IMAGE_UUID -r $OS_REGION_NAME -s precise"108
75109## Generate tools (needed if windows is in).
110$SSH "juju metadata generate-tools -d juju-meta/ "
111
112## upload images and tools streams to swift and make public
113$SSH "cd ~/juju-meta/ && swift --os-auth-url $OS_AUTH_URL --os-username $OS_USERNAME \
114 --os-password $OS_PASSWORD --os-tenant-name $OS_TENANT_NAME \
115upload juju-meta images"
116$SSH "cd ~/juju-meta/ && swift --os-auth-url $OS_AUTH_URL --os-username $OS_USERNAME \
117 --os-password $OS_PASSWORD --os-tenant-name $OS_TENANT_NAME \
118upload juju-meta tools"
119
120$SSH swift --os-auth-url $OS_AUTH_URL --os-username $OS_USERNAME --os-password $OS_PASSWORD \
121 --os-tenant-name $OS_TENANT_NAME post -r '.r:*' juju-meta
122
123## collect the URL for getting the images
124$($SSH swift --os-auth-url $OS_AUTH_URL --os-username $OS_USERNAME --os-password $OS_PASSWORD \
125 --os-tenant-name $OS_TENANT_NAME auth)
126
127###
128###juju bootstrap openstack openstack --config image-metadata-url=http://192.168.16.5/juju/images/ --config network=private --upload-tools --debug -v
129###
130
131my_ip=`ip route | grep src| grep -v virb|grep -v lxcb| head -1| cut -d " " -f 12 `
76#Bootstrap Juju132#Bootstrap Juju
77ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP "juju bootstrap --metadata-source=/home/ubuntu --upload-tools=true --series=precise,trusty"133##$SSH "juju bootstrap openstack openstack --metadata-source=/var/www/html/juju-meta/ --upload-tools"
78134$SSH "juju bootstrap openstack openstack --config image-metadata-url=$OS_STORAGE_URL/juju-meta/images/ --config tools-metadata-url=$OS_STORAGE_URL/juju-meta/tools/ --config network=private"
79#Deploy juju-gui135
80ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP "juju deploy --to 0 juju-gui && juju expose juju-gui"136
81
82#Install the Orange-box-examples package
83ssh -o StrictHostKeyChecking=no ubuntu@$FLOAT_IP "sudo apt-add-repository ppa:orange-box-examples/ppa && sudo apt-get update && sudo apt-get install -y orange-box-examples"
84137
85## useless if juju floating ip option on.138## useless if juju floating ip option on.
86#########################################139#########################################
@@ -93,7 +146,9 @@
93echo "Now connect to the Juju-GUI at: http://$FLOAT_IP2/ to continue deployments on Openstack."146echo "Now connect to the Juju-GUI at: http://$FLOAT_IP2/ to continue deployments on Openstack."
94echo "Pass: $OS_PASSWORD"147echo "Pass: $OS_PASSWORD"
95148
96echo "OR Log in to openstack Jumpserver to deploy from command line"149echo "OR Log in to openstack Jumpserver2 to deploy from command line"
97echo "ssh ubuntu@$FLOAT_IP"150echo "ssh ubuntu@$FLOAT_IP"
151echo " You must set the following if creating a new model:"
152echo " juju set-model-config image-metadata-url=$OS_STORAGE_URL/juju-meta/images/ tools-metadata-url=$OS_STORAGE_URL/juju-meta/tools/ network=private"
98exit153exit
99154
100155
=== modified file 'openstack/get-cloud-images'
--- openstack/get-cloud-images 2016-01-31 11:07:43 +0000
+++ openstack/get-cloud-images 2016-06-17 14:41:49 +0000
@@ -2,11 +2,12 @@
22
33
44
5folder=/srv/data5folder=/srv/data/
6URLS="http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img \6URLS="http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-amd64-disk1.img \
7http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img \7http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img \
8http://cloud-images.ubuntu.com/wily/current/wily-server-cloudimg-amd64-disk1.img \8http://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-disk1.img \
9http://mirror.catn.com/pub/catn/images/qcow2/centos6.4-x86_64-gold-master.img \9http://mirror.catn.com/pub/catn/images/qcow2/centos6.4-x86_64-gold-master.img \
10http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 \
10http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img "11http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img "
1112
12for URL in $URLS13for URL in $URLS
@@ -16,9 +17,9 @@
16then17then
17 echo "$FILENAME already downloaded." 18 echo "$FILENAME already downloaded."
18else19else
19 wget -q -O $folder/$FILENAME $URL20 wget -O $folder/$FILENAME $URL
20fi21fi
21done22done
2223
2324
24echo "To download Windows image get there : http://www.cloudbase.it/cloud-init-for-windows-instances/"25echo "To download Windows image get there : https://cloudbase.it/windows-cloud-images/"
2526
=== modified file 'openstack/orange-box-configure-openstack'
--- openstack/orange-box-configure-openstack 2015-10-09 18:44:36 +0000
+++ openstack/orange-box-configure-openstack 2016-06-17 14:41:49 +0000
@@ -3,7 +3,7 @@
3# orange-box-configure-openstack3# orange-box-configure-openstack
4# Copyright (C) 2014 Canonical Ltd.4# Copyright (C) 2014 Canonical Ltd.
5#5#
6# Authors: Darryl Weaver <darryl.weaver@canonical.com>6# Authors: Nicolas Thomss <nicolas.thomas@canonical.com>
7#7#
8# This program is free software: you can redistribute it and/or modify8# 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 by9# it under the terms of the GNU General Public License as published by
@@ -21,74 +21,155 @@
2121
22echo "This command is run to configure an Orange-Box Openstack deployment"22echo "This command is run to configure an Orange-Box Openstack deployment"
2323
24PKGS=" python-keystone python-neutronclient python-novaclient python-glanceclient"24## This is the only OB specific section:
25dpkg -l $PKGS > /dev/null || sudo apt-get install -y $PKGS25obnum=$(hostname | cut -c 10- -)
2626external_net=$((obnum+1))
27NEUTRON_EXT_NET_GW="10.14.4.1"27
28NEUTRON_EXT_NET_CIDR="10.14.0.0/16"28NEUTRON_EXT_NET_GW="172.27.${external_net}.254"
29NEUTRON_EXT_NET_NAME="ext_net"29NEUTRON_EXT_NET_CIDR="172.27.${external_net}.0/23"
30NEUTRON_DNS="10.14.4.1"30
31NEUTRON_FLOAT_RANGE_START="10.14.200.1"31NEUTRON_EXT_NET_NAME="ext_net" # Unused
32NEUTRON_FLOAT_RANGE_END="10.14.249.254"32NEUTRON_DNS="172.27.$((obnum)).1"
3333NEUTRON_FLOAT_RANGE_START="172.27.${external_net}.151"
34NEUTRON_FIXED_NET_CIDR="192.168.14.0/24"34NEUTRON_FLOAT_RANGE_END="172.27.${external_net}.252"
35NEUTRON_FIXED_NET_NAME="admin_net"35
3636NEUTRON_FIXED_NET_CIDR="192.168.16.0/22"
37keystone=$(juju status keystone | grep public-address | head -1 | awk '{print $2}')37#NEUTRON_FIXED_NET_NAME="admin_net" # Unused
38
39#Check if VIP is set on keystone
40keystone_VIP=`juju get-config keystone| python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"settings\"][\"vip\"][\"value\"]"||true`
41
42if [ -n "$keystone_VIP" ]
43then
44 keystone=$keystone_VIP
45else
46 #if os-public-hostname is set and not VIP assume we need to use those at OpenStack endpoints.
47 keystone_PUBENDPOINT=`juju get-config keystone| python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"settings\"][\"os-public-hostname\"][\"value\"]"||true`
48 if [ -n "$keystone_PUBENDPOINT" ]
49 then
50 ## will need to add the PUBENPOINT to the different services interfaces to enable access on ob-num+2 network.
51 ## Assume a fresh install where the unit ID is 0 keystone/0 for example (TO BE FIXED)
52 unset DEVICE
53 for service in keystone cinder glance neutron-api nova-cloud-controller ceph-radosgw
54 do
55 DEVICE=`juju ssh ${service}/0 "ip route" | grep 172.27.$((obnum+2)). |head -1 | awk '{ print $3}'`
56 # assuming the os-public-name are IPs not names will fail if not set
57 OSPUBLICIP=`juju get-config ${service}| python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"settings\"][\"os-public-hostname\"][\"value\"]"||true`
58 [ -n "$OSPUBLICIP" ] && juju ssh ${service}/0 "sudo ifconfig $DEVICE:1 $OSPUBLICIP"
59 done
60 keystone=$keystone_PUBENDPOINT
61 else
62 keystone=$(juju status keystone --format=yaml | grep public-address | head -1 | awk '{print $2}')
63 fi
64fi
65
3866
39echo "export SERVICE_ENDPOINT=http://$keystone:35357/v2.0/67echo "export SERVICE_ENDPOINT=http://$keystone:35357/v2.0/
40export SERVICE_TOKEN=admin68unset SERVICE_TOKEN
69unset SERVICE_ENDPOINT
41export OS_AUTH_URL=http://$keystone:35357/v2.0/70export OS_AUTH_URL=http://$keystone:35357/v2.0/
42export OS_USERNAME=admin71export OS_USERNAME=$(juju get-config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"settings\"][\"admin-user\"][\"value\"]")
43export OS_PASSWORD=admin72export OS_PASSWORD=$(juju get-config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"settings\"][\"admin-password\"][\"value\"]")
44export OS_TENANT_NAME=admin73export OS_TENANT_NAME=admin
45export OS_REGION_NAME=RegionOne74export OS_REGION_NAME=$(juju get-config keystone | python -c "import yaml; import sys; print yaml.load(sys.stdin)[\"settings\"][\"region\"][\"value\"]")
46" > ~/nova.rc75" > ~/nova.rc
4776
48. ~/nova.rc77source ~/nova.rc
4978
50# Determine the tenant id for the configured tenant name.79# Determine the tenant id for the configured tenant name.
51export TENANT_ID="$(keystone tenant-list | grep $OS_TENANT_NAME | awk '{ print $2 }')"80export TENANT_ID="$(keystone tenant-list | grep $OS_TENANT_NAME | awk '{ print $2 }')"
5281
82if [ "$TENANT_ID" = "" ]; then
83 echo "Unable to find tenant ID, keystone auth problem"
84 exit
85fi
86
87echo "Configuring Openstack Neutron Networking"
88
53#create ext network with neutron for floating IPs89#create ext network with neutron for floating IPs
54EXTERNAL_NETWORK_ID=$(neutron net-create ext_net --tenant-id $TENANT_ID -- --router:external=True | grep " id" | awk '{print $4}')90neutron net-show ext_net > /dev/null 2>&1 || neutron net-create ext_net --tenant-id $TENANT_ID -- --router:external=True
55neutron subnet-create ext_net $NEUTRON_EXT_NET_CIDR --name ext_net_subnet --tenant-id $TENANT_ID \91EXTERNAL_NETWORK_ID=$(neutron net-show ext_net | grep " id" | awk '{print $4}')
92neutron subnet-show ext_net_subnet > /dev/null 2>&1 || 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 \93--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=true94--gateway $NEUTRON_EXT_NET_GW --disable-dhcp --dns_nameservers $NEUTRON_DNS list=true
5895
59#Create private network for neutron for tenant VMs96#Create private network for neutron for tenant VMs
60neutron net-create private97neutron net-show private > /dev/null 2>&1 || neutron net-create private
61SUBNET_ID=$(neutron subnet-create private $NEUTRON_FIXED_NET_CIDR -- --name private_subnet --dns_nameservers list=true $NEUTRON_DNS | grep " id" | awk '{print $4}')98neutron subnet-show private_subnet > /dev/null 2>&1 || neutron subnet-create private $NEUTRON_FIXED_NET_CIDR -- --name private_subnet --dns_nameservers list=true $NEUTRON_DNS
99SUBNET_ID=$(neutron subnet-show private_subnet | grep " id" | awk '{print $4}')
62100
63#Create router for external network and private network101#Create router for external network and private network
64ROUTER_ID=$(neutron router-create --tenant-id $TENANT_ID provider-router | grep " id" | awk '{print $4}')102neutron router-show provider-router > /dev/null 2>&1 || neutron router-create --tenant-id $TENANT_ID provider-router
65neutron router-interface-add $ROUTER_ID $SUBNET_ID103ROUTER_ID=$(neutron router-show provider-router | grep " id" | awk '{print $4}')
104
105neutron router-gateway-clear provider-router || true
66neutron router-gateway-set $ROUTER_ID $EXTERNAL_NETWORK_ID106neutron router-gateway-set $ROUTER_ID $EXTERNAL_NETWORK_ID
107## make it always ok to have it indempodent.
108neutron router-interface-add $ROUTER_ID $SUBNET_ID || true
109
110
111echo "Configuring security groups for access to ICMP, SSH and RDP by default"
67112
68#Configure the default security group to allow ICMP and SSH113#Configure the default security group to allow ICMP and SSH
69nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0114nova secgroup-list-rules default | grep icmp > /dev/null 2>&1 || nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 > /dev/null 2>&1
70nova secgroup-add-rule default tcp 22 22 0.0.0.0/0115nova secgroup-list-rules default | grep 22 > /dev/null 2>&1 || nova secgroup-add-rule default tcp 22 22 0.0.0.0/0 > /dev/null 2>&1
71#for rdp116#for rdp
72nova secgroup-add-rule default tcp 3389 3389 0.0.0.0/0117nova secgroup-list-rules default | grep 3389 > /dev/null 2>&1 || nova secgroup-add-rule default tcp 3389 3389 0.0.0.0/0 > /dev/null 2>&1
118
119
120
121echo "Uploading default SSH key"
73122
74#Upload a default SSH key123#Upload a default SSH key
75nova keypair-add --pub-key ~/.ssh/id_rsa.pub default124nova keypair-list | grep default > /dev/null 2>&1 || nova keypair-add --pub-key ~/.ssh/id_rsa.pub default > /dev/null 2>&1
76125
77#Remove the m1.tiny as it is too small for Ubuntu.126echo "Modifying the flavors to be better sized for the Orange Box"
78nova flavor-delete m1.tiny127
79nova flavor-delete m1.xlarge128#Modify the flavours to fit better on the OB
129#nova flavor-create FLAVOR_NAME FLAVOR_ID RAM_IN_MB ROOT_DISK_IN_GB NUMBER_OF_VCPUS
130nova flavor-delete m1.tiny > /dev/null 2>&1
131nova flavor-delete m1.small > /dev/null 2>&1
132nova flavor-delete m1.medium > /dev/null 2>&1
133nova flavor-delete m1.large > /dev/null 2>&1
134nova flavor-delete m1.xlarge > /dev/null 2>&1
135nova flavor-create --is-public true m1.tiny auto 512 5 1 > /dev/null 2>&1
136nova flavor-create --is-public true m1.small auto 1024 10 1 > /dev/null 2>&1
137nova flavor-create --is-public true m1.medium auto 2048 10 2 > /dev/null 2>&1
138nova flavor-create --is-public true m1.large auto 3072 10 2 > /dev/null 2>&1
139## need extra for windows image (15g)
140nova flavor-create --is-public true m1.xlarge auto 8096 30 4 > /dev/null 2>&1
141
142echo "modifying default quotas for admin user"
80143
81#Modify quotas for the tenant to allow large deployments144#Modify quotas for the tenant to allow large deployments
82nova quota-update --instances 100 $TENANT_ID145nova quota-update --instances 400 $TENANT_ID
83nova quota-update --cores 200 $TENANT_ID146nova quota-update --cores 800 $TENANT_ID
84nova quota-update --ram 204800 $TENANT_ID147nova quota-update --ram 404800 $TENANT_ID
85nova quota-update --security-groups 200 $TENANT_ID148nova quota-update --security-groups 4000 $TENANT_ID
149nova quota-update --floating_ips -1 $TENANT_ID
150nova quota-update --security-group-rules -1 $TENANT_ID
151
152### need to find how to change quota for the project not the tenant
153
154### modify default quota the same way..
155nova quota-class-update --instances 400 $TENANT_ID
156nova quota-class-update --cores 800 $TENANT_ID
157nova quota-class-update --ram 404800 $TENANT_ID
158nova quota-class-update --security-groups 4000 $TENANT_ID
159nova quota-class-update --floating_ips -1 $TENANT_ID
160nova quota-class-update --security-group-rules -1 $TENANT_ID
161
162echo "Uploading images to glance"
86163
87#Upload images to glance164#Upload images to glance
88glance add name="Precise x86_64" is_public=true container_format=ovf disk_format=qcow2 < /srv/data/precise-server-cloudimg-amd64-disk1.img 165glance image-show "Precise x86_64" > /dev/null 2>&1 || glance image-create --name="Precise x86_64" --is-public=true --container-format=ovf --disk-format=qcow2 < /srv/data/precise-server-cloudimg-amd64-disk1.img
89glance add name="Trusty x86_64" is_public=true container_format=ovf disk_format=qcow2 < /srv/data/trusty-server-cloudimg-amd64-disk1.img166glance image-show "Trusty x86_64" > /dev/null 2>&1 || glance image-create --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.img167glance image-show "Xenial x86_64" > /dev/null 2>&1 || glance image-create --name="Xenial x86_64" --is-public=true --container-format=ovf --disk-format=qcow2 < /srv/data/xenial-server-cloudimg-amd64-disk1.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.img168
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 &169glance image-show "CentOS 6.4" > /dev/null 2>&1 || glance image-create --name="CentOS 6.4" --is-public=true --container-format=bare --disk-format=qcow2 < /srv/data/centos6.4-x86_64-gold-master.img
170glance image-show "Cirros 0.3" > /dev/null 2>&1 || glance image-create --name="Cirros 0.3" --is-public=true --container-format=bare --disk-format=qcow2 < /srv/data/cirros-0.3.2-x86_64-disk.img
171## image name is used by script to generate metadata .. don't screw the series
172glance image-show "win2012r2" > /dev/null 2>&1 || gzip -cd /srv/data/windows_server_2012_r2_standard_eval_kvm_20151021.qcow2.gz |glance image-create --name="Windows Server 2012" --is-public=true --container-format=bare --disk-format=qcow2
173
93174
94exit175exit

Subscribers

People subscribed via source and target branches

to all changes: