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
1=== modified file 'debian/postinst'
2--- debian/postinst 2014-08-01 11:01:16 +0000
3+++ debian/postinst 2014-08-02 15:50:37 +0000
4@@ -74,8 +74,12 @@
5 mkdir -p /srv/mirrors/archive.ubuntu.com
6 echo '<meta http-equiv="refresh" content="0; url=MAAS/">' > /srv/mirrors/archive.ubuntu.com/index.html
7 invoke-rc.d apache2 restart
8- mkdir -p /srv/charmstore/precise
9+ #sync the charm store to /srv/charmstore
10+ orange-box-sync-charmstore
11 run-one charm getall /srv/charmstore/precise 2>/dev/null &
12+ #Branch the Landscape charm - required for Landscape demo to minimise network dependencies
13+ cd /srv/charmstore/precise
14+ bzr branch lp:~landscape/landscape-charm/stable landscape
15 }
16
17 setup_boot_resources() {
18@@ -163,6 +167,9 @@
19 git clone https://github.com/juju/plugins /home/ubuntu/.juju-plugins
20 sudo chown -R ubuntu:ubuntu /home/ubuntu/
21 echo "PATH=\$PATH:/home/ubuntu/.juju-plugins" >> /home/ubuntu/.bashrc
22+ #Required for local charm deployments to work.
23+ sed -i -e '/^export JUJU_REPOSITORY=/d' /home/ubuntu/.bashrc
24+ echo "export JUJU_REPOSITORY=/srv/charmstore" >> /home/ubuntu/.bashrc
25 }
26
27 ensure_running() {
28
29=== added file 'etc/cron.d/charmstore-mirror'
30--- etc/cron.d/charmstore-mirror 1970-01-01 00:00:00 +0000
31+++ etc/cron.d/charmstore-mirror 2014-08-02 15:50:37 +0000
32@@ -0,0 +1,4 @@
33+#Run every Staurday at 03:23 in the morning, if plugged in and internet is accessible the charmstore will be updated.
34+#Remove any charmstore directories inot modified in the last 90 days to save space.
35+23 3 * * 6 root run-one orange-box-sync-charmstore >>/var/log/orange-box-sync-charmstore.log 2>&1
36+38 4 1 * * root run-one find /srv/charmstore/ -maxdepth 1 -mindepth 1 -type d -mtime +90 -exec rm -rf {} \;
37
38=== modified file 'usr/bin/orange-box-create-package-mirror'
39--- usr/bin/orange-box-create-package-mirror 2014-04-14 21:07:34 +0000
40+++ usr/bin/orange-box-create-package-mirror 2014-08-02 15:50:37 +0000
41@@ -30,7 +30,7 @@
42 IP=10.14.4.1
43
44 function run_mirror {
45- echo "apt-mirror /etc/apt/mirror.list"
46+ echo "apt-mirror /etc/apt/orange-box-mirror.list >>/var/log/orange-box-mirror.log 2>&1"
47 }
48
49 echo THIS IS MEANT TO BE RUN FROM WITHIN THE TOP LEVEL micro-cluster BRANCH
50@@ -78,24 +78,19 @@
51 # Create our charm mirror
52 echo Creating Charm Store Mirror ...
53 echo Creating Charm Store directories ...
54-[ -e /srv/charmstore/precise ] || mkdir -p /srv/charmstore/precise
55+[ -e /srv/charmstore ] || mkdir -p /srv/charmstore
56
57 echo Mirroring the Charmstore ...
58-# This may not work :/ Ran into issues on my test precise VM
59-cd /srv/charmstore/
60-charm getall precise
61-
62-echo Making Trusty Charms *THIS IS A HACK TO BE FIXED WHEN TRUSTY CHARMS EXIST
63-cp -a /srv/charmstore/precise /srv/charmstore/trusty
64+orange-box-sync-charmstore
65 echo Done. && echo
66
67 # Set up apt-mirror to mirror the archives
68 echo Setting up Apt Mirror ...
69 cd $home
70-if [ -f /etc/apt/mirror.list ]; then
71- mv /etc/apt/mirror.list /etc/apt/mirror.list.orig
72+if [ -f /etc/apt/orange-box-mirror.list ]; then
73+ mv /etc/apt/orange-box-mirror.list /etc/apt/orange-box-mirror.list.orig
74 fi
75-cp etc/apt/mirror.list /etc/apt
76+cp etc/apt/orange-box-mirror.list /etc/apt
77
78 echo Making mirror directories ...
79 mkdir -p /srv/mirrors /srv/skel /srv/var
80@@ -117,7 +112,9 @@
81
82 echo Copying config file to apache ...
83 cd $home
84-cp etc/apache2/sites-enabled/000-default.conf /etc/apache2/sites-enabled
85+cp etc/apache2/sites-enabled/* /etc/apache2/sites-enabled
86+a2ensite archive
87+a2ensite ubuntu-cloud
88
89 echo Restarting Apache ...
90 service apache2 restart
91
92=== added file 'usr/bin/orange-box-sync-charmstore'
93--- usr/bin/orange-box-sync-charmstore 1970-01-01 00:00:00 +0000
94+++ usr/bin/orange-box-sync-charmstore 2014-08-02 15:50:37 +0000
95@@ -0,0 +1,55 @@
96+#!/bin/bash
97+#
98+# orange-box-sync-charmstore
99+# Copyright (C) 2014 Canonical Ltd.
100+#
101+# Authors: Darryl Weaver <darryl.weaver@canonical.com>
102+#
103+# This program is free software: you can redistribute it and/or modify
104+# it under the terms of the GNU General Public License as published by
105+# the Free Software Foundation, version 3 of the License.
106+#
107+# This program is distributed in the hope that it will be useful,
108+# but WITHOUT ANY WARRANTY; without even the implied warranty of
109+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
110+# GNU General Public License for more details.
111+#
112+# You should have received a copy of the GNU General Public License
113+# along with this program. If not, see <http://www.gnu.org/licenses/>.
114+
115+
116+# Only run this as root
117+if [ $EUID -ne 0 ]
118+then
119+ echo Execute as root or with \"sudo $0\"
120+ exit 1
121+fi
122+
123+echo Creating Charm Store directories ...
124+[ -e /srv/charmstore/ ] || mkdir -p /srv/charmstore/
125+DATE=`date +%Y%m%d-%H%M%S`
126+mkdir -p /srv/charmstore/snapshot-$DATE
127+
128+echo Mirroring the Charmstore ...
129+cd /srv/charmstore/
130+run-one charm getall snapshot-$DATE 2>/dev/null
131+#Branch the Landscape charm - required for Landscape demo to minimise network dependencies
132+cd snapshot-$DATE
133+bzr branch lp:~landscape/landscape-charm/stable landscape
134+#Branch the cinder-ceph charm - required for openstack
135+bzr branch lp:charms/cinder-ceph
136+#Link directories for service aliases
137+ln -s quantum-gateway neutron-gateway
138+ln -s rabbitmq-server rabbitmq
139+#Re-linking to current directories
140+rm -f /srv/charmstore/current
141+ln -s /srv/charmstore/snapshot-$DATE /srv/charmstore/current
142+#Re-linking precise
143+rm -rf /srv/charmstore/precise
144+ln -s /srv/charmstore/current /srv/charmstore/precise
145+#Re-linking trusty
146+rm -rf /srv/charmstore/trusty
147+ln -s /srv/charmstore/current /srv/charmstore/trusty
148+echo Done. && echo
149+
150+echo "Charm store synced to directory /srv/charmstore/"

Subscribers

People subscribed via source and target branches