Merge lp:~dweaver/orange-box/orange-box-improve-local-charmstore-handling into lp:orange-box

Proposed by Darryl Weaver
Status: Merged
Merged at revision: 408
Proposed branch: lp:~dweaver/orange-box/orange-box-improve-local-charmstore-handling
Merge into: lp:orange-box
Diff against target: 150 lines (+76/-13)
4 files modified
debian/postinst (+8/-1)
etc/cron.d/charmstore-mirror (+4/-0)
usr/bin/orange-box-create-package-mirror (+9/-12)
usr/bin/orange-box-sync-charmstore (+55/-0)
To merge this branch: bzr merge lp:~dweaver/orange-box/orange-box-improve-local-charmstore-handling
Reviewer Review Type Date Requested Status
Dustin Kirkland  Pending
Review via email: mp+228937@code.launchpad.net

Description of the change

Improvements in local charm store sync handling.
Versioned directories to allow linking to use older sync.
Weekly cron job to sync the charm store.
Monthly cron job to delete charm store syncs older than 90 days.

To post a comment you must log in.
400. By Darryl Weaver

Modified orange-box-create-package-mirror to use orange-box-mirror.list instead of mirror.list.

401. By Darryl Weaver

Fixed bug in charm store sync and make it run in foreground.

402. By Darryl Weaver

Corrected bug with paths.

403. By Darryl Weaver

Added cinder-ceph to charmstore sync.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/postinst'
--- debian/postinst 2014-08-01 11:01:16 +0000
+++ debian/postinst 2014-08-02 15:50:37 +0000
@@ -74,8 +74,12 @@
74 mkdir -p /srv/mirrors/archive.ubuntu.com74 mkdir -p /srv/mirrors/archive.ubuntu.com
75 echo '<meta http-equiv="refresh" content="0; url=MAAS/">' > /srv/mirrors/archive.ubuntu.com/index.html75 echo '<meta http-equiv="refresh" content="0; url=MAAS/">' > /srv/mirrors/archive.ubuntu.com/index.html
76 invoke-rc.d apache2 restart76 invoke-rc.d apache2 restart
77 mkdir -p /srv/charmstore/precise77 #sync the charm store to /srv/charmstore
78 orange-box-sync-charmstore
78 run-one charm getall /srv/charmstore/precise 2>/dev/null &79 run-one charm getall /srv/charmstore/precise 2>/dev/null &
80 #Branch the Landscape charm - required for Landscape demo to minimise network dependencies
81 cd /srv/charmstore/precise
82 bzr branch lp:~landscape/landscape-charm/stable landscape
79}83}
8084
81setup_boot_resources() {85setup_boot_resources() {
@@ -163,6 +167,9 @@
163 git clone https://github.com/juju/plugins /home/ubuntu/.juju-plugins167 git clone https://github.com/juju/plugins /home/ubuntu/.juju-plugins
164 sudo chown -R ubuntu:ubuntu /home/ubuntu/168 sudo chown -R ubuntu:ubuntu /home/ubuntu/
165 echo "PATH=\$PATH:/home/ubuntu/.juju-plugins" >> /home/ubuntu/.bashrc169 echo "PATH=\$PATH:/home/ubuntu/.juju-plugins" >> /home/ubuntu/.bashrc
170 #Required for local charm deployments to work.
171 sed -i -e '/^export JUJU_REPOSITORY=/d' /home/ubuntu/.bashrc
172 echo "export JUJU_REPOSITORY=/srv/charmstore" >> /home/ubuntu/.bashrc
166}173}
167174
168ensure_running() {175ensure_running() {
169176
=== added file 'etc/cron.d/charmstore-mirror'
--- etc/cron.d/charmstore-mirror 1970-01-01 00:00:00 +0000
+++ etc/cron.d/charmstore-mirror 2014-08-02 15:50:37 +0000
@@ -0,0 +1,4 @@
1#Run every Staurday at 03:23 in the morning, if plugged in and internet is accessible the charmstore will be updated.
2#Remove any charmstore directories inot modified in the last 90 days to save space.
323 3 * * 6 root run-one orange-box-sync-charmstore >>/var/log/orange-box-sync-charmstore.log 2>&1
438 4 1 * * root run-one find /srv/charmstore/ -maxdepth 1 -mindepth 1 -type d -mtime +90 -exec rm -rf {} \;
05
=== modified file 'usr/bin/orange-box-create-package-mirror'
--- usr/bin/orange-box-create-package-mirror 2014-04-14 21:07:34 +0000
+++ usr/bin/orange-box-create-package-mirror 2014-08-02 15:50:37 +0000
@@ -30,7 +30,7 @@
30IP=10.14.4.130IP=10.14.4.1
3131
32function run_mirror { 32function run_mirror {
33 echo "apt-mirror /etc/apt/mirror.list" 33 echo "apt-mirror /etc/apt/orange-box-mirror.list >>/var/log/orange-box-mirror.log 2>&1"
34}34}
3535
36echo THIS IS MEANT TO BE RUN FROM WITHIN THE TOP LEVEL micro-cluster BRANCH36echo THIS IS MEANT TO BE RUN FROM WITHIN THE TOP LEVEL micro-cluster BRANCH
@@ -78,24 +78,19 @@
78# Create our charm mirror78# Create our charm mirror
79echo Creating Charm Store Mirror ...79echo Creating Charm Store Mirror ...
80echo Creating Charm Store directories ...80echo Creating Charm Store directories ...
81[ -e /srv/charmstore/precise ] || mkdir -p /srv/charmstore/precise81[ -e /srv/charmstore ] || mkdir -p /srv/charmstore
8282
83echo Mirroring the Charmstore ...83echo Mirroring the Charmstore ...
84# This may not work :/ Ran into issues on my test precise VM84orange-box-sync-charmstore
85cd /srv/charmstore/
86charm getall precise
87
88echo Making Trusty Charms *THIS IS A HACK TO BE FIXED WHEN TRUSTY CHARMS EXIST
89cp -a /srv/charmstore/precise /srv/charmstore/trusty
90echo Done. && echo85echo Done. && echo
9186
92# Set up apt-mirror to mirror the archives87# Set up apt-mirror to mirror the archives
93echo Setting up Apt Mirror ...88echo Setting up Apt Mirror ...
94cd $home89cd $home
95if [ -f /etc/apt/mirror.list ]; then90if [ -f /etc/apt/orange-box-mirror.list ]; then
96 mv /etc/apt/mirror.list /etc/apt/mirror.list.orig91 mv /etc/apt/orange-box-mirror.list /etc/apt/orange-box-mirror.list.orig
97fi92fi
98cp etc/apt/mirror.list /etc/apt93cp etc/apt/orange-box-mirror.list /etc/apt
9994
100echo Making mirror directories ...95echo Making mirror directories ...
101mkdir -p /srv/mirrors /srv/skel /srv/var96mkdir -p /srv/mirrors /srv/skel /srv/var
@@ -117,7 +112,9 @@
117112
118echo Copying config file to apache ...113echo Copying config file to apache ...
119cd $home114cd $home
120cp etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled115cp etc/apache2/sites-enabled/* /etc/apache2/sites-enabled
116a2ensite archive
117a2ensite ubuntu-cloud
121118
122echo Restarting Apache ...119echo Restarting Apache ...
123service apache2 restart120service apache2 restart
124121
=== added file 'usr/bin/orange-box-sync-charmstore'
--- usr/bin/orange-box-sync-charmstore 1970-01-01 00:00:00 +0000
+++ usr/bin/orange-box-sync-charmstore 2014-08-02 15:50:37 +0000
@@ -0,0 +1,55 @@
1#!/bin/bash
2#
3# orange-box-sync-charmstore
4# Copyright (C) 2014 Canonical Ltd.
5#
6# Authors: Darryl Weaver <darryl.weaver@canonical.com>
7#
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.
11#
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.
16#
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/>.
19
20
21# Only run this as root
22if [ $EUID -ne 0 ]
23then
24 echo Execute as root or with \"sudo $0\"
25 exit 1
26fi
27
28echo Creating Charm Store directories ...
29[ -e /srv/charmstore/ ] || mkdir -p /srv/charmstore/
30DATE=`date +%Y%m%d-%H%M%S`
31mkdir -p /srv/charmstore/snapshot-$DATE
32
33echo Mirroring the Charmstore ...
34cd /srv/charmstore/
35run-one charm getall snapshot-$DATE 2>/dev/null
36#Branch the Landscape charm - required for Landscape demo to minimise network dependencies
37cd snapshot-$DATE
38bzr branch lp:~landscape/landscape-charm/stable landscape
39#Branch the cinder-ceph charm - required for openstack
40bzr branch lp:charms/cinder-ceph
41#Link directories for service aliases
42ln -s quantum-gateway neutron-gateway
43ln -s rabbitmq-server rabbitmq
44#Re-linking to current directories
45rm -f /srv/charmstore/current
46ln -s /srv/charmstore/snapshot-$DATE /srv/charmstore/current
47#Re-linking precise
48rm -rf /srv/charmstore/precise
49ln -s /srv/charmstore/current /srv/charmstore/precise
50#Re-linking trusty
51rm -rf /srv/charmstore/trusty
52ln -s /srv/charmstore/current /srv/charmstore/trusty
53echo Done. && echo
54
55echo "Charm store synced to directory /srv/charmstore/"

Subscribers

People subscribed via source and target branches