Merge lp:~gnuoy/charms/precise/daisy/add-upgrade-charm into lp:~daisy-pluckers/charms/precise/daisy/trunk

Proposed by Liam Young
Status: Merged
Merged at revision: 30
Proposed branch: lp:~gnuoy/charms/precise/daisy/add-upgrade-charm
Merge into: lp:~daisy-pluckers/charms/precise/daisy/trunk
Diff against target: 168 lines (+94/-5)
8 files modified
config.yaml (+14/-0)
hooks/common (+36/-0)
hooks/install (+1/-5)
hooks/nrpe-external-master-relation-changed (+16/-0)
hooks/upgrade-charm (+7/-0)
metadata.yaml (+4/-0)
templates/nrpe_cmd_file.tmpl (+6/-0)
templates/nrpe_service_file.tmpl (+10/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/precise/daisy/add-upgrade-charm
Reviewer Review Type Date Requested Status
Evan (community) Approve
Review via email: mp+162328@code.launchpad.net
To post a comment you must log in.
31. By Liam Young

Actually include the upgrade-charm hook

32. By Liam Young

Add nrpe hooks and config

33. By Liam Young

New hooks need to be executable

34. By Liam Young

nrpe hook also needed +x

Revision history for this message
Evan (ev) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'config.yaml'
--- config.yaml 2013-03-21 16:17:19 +0000
+++ config.yaml 2013-05-03 14:19:28 +0000
@@ -96,7 +96,21 @@
96 default: ''96 default: ''
97 description: |97 description: |
98 The Cassandra RPC password. Leave blank if one is not needed.98 The Cassandra RPC password. Leave blank if one is not needed.
99 daisy_code_dirs:
100 type: int
101 default: 3
102 description: |
103 How many old copies of daisy code to retain (candidates for backouts)
99 repository:104 repository:
100 type: string105 type: string
101 default: 'ppa:daisy-pluckers/daisy-seeds'106 default: 'ppa:daisy-pluckers/daisy-seeds'
102 description: The location for the daisy-dependencies package.107 description: The location for the daisy-dependencies package.
108 nrpe_url_check_params:
109 default: "-e '400' -u /"
110 type: string
111 description: The parameters to use for the check against gunicorn
112 region:
113 default: "prodstack"
114 type: string
115 description: Region deploying to. Used by nrpe to define servicegroup
116
103117
=== modified file 'hooks/common'
--- hooks/common 2013-03-22 02:14:17 +0000
+++ hooks/common 2013-05-03 14:19:28 +0000
@@ -13,6 +13,9 @@
13OOPS_LOCAL="$DEPLOY_ROOT/oops-local"13OOPS_LOCAL="$DEPLOY_ROOT/oops-local"
14LISTEN_PORT="$(config-get listen_port)"14LISTEN_PORT="$(config-get listen_port)"
15LOG_DIR="/srv/$BASEDIR/$INSTANCE_TYPE-logs"15LOG_DIR="/srv/$BASEDIR/$INSTANCE_TYPE-logs"
16DAISY_CODE_DIRS="$(config-get daisy_code_dirs)"
17REGION="$(config-get region)"
18NRPE_URL_CHECK_PARAMS="$(config-get nrpe_url_check_params)"
1619
17save_setting () {20save_setting () {
18 key="$1"21 key="$1"
@@ -50,3 +53,36 @@
50 relation-set -r $relid wsgi_timestamp=$(date +%s)53 relation-set -r $relid wsgi_timestamp=$(date +%s)
51 done54 done
52}55}
56
57deploy_code () {
58 local tarball="$1"
59 local codedir="$2"
60 local codedir_count="$3"
61 local codename=$(basename "$codedir")
62 local coderoot=$(dirname "$codedir")
63 local tmpdir=$(mktemp -d --tmpdir="${coderoot}")
64 tar -C ${tmpdir} -xf ${tarball}
65 local coderevno=$(bzr revno ${tmpdir})
66 if [[ -d "${coderoot}/${codename}-${coderevno}" ]]; then
67 juju-log "${coderevno} of ${codename} already deployed"
68 rm -rf ${tmpdir}
69 else
70 juju-log "Deploying ${coderevno} of ${codename}"
71 chown -R $USER_CODE_OWNER:$USER_CODE_RUNNER "${tmpdir}"
72 mv "${tmpdir}" "${coderoot}/${codename}-${coderevno}"
73 [ -d "${coderoot}/${codename}" ] && rm -rf "${coderoot}/${codename}"
74 ln -s "${coderoot}/${codename}-${coderevno}" "${coderoot}/${codename}"
75 remove_old_codedirs $codedir_count "${coderoot}/${codename}-*"
76 fi
77}
78
79remove_old_codedirs () {
80 local codedir_count="$1"
81 local codedir_regex="$2"
82 local current_code_dirs=$(ls -d ${codedir_regex} | wc -l)
83 if [[ $current_code_dirs -gt $codedir_count ]]; then
84 juju-log "More than $codedir_count found, deleting:"
85 juju-log "$(ls -td ${codedir_regex} | tail -n +$(($codedir_count+1)))"
86 ls -1rd ${codedir_regex} | tail -n +$(($codedir_count+1)) | xargs rm -rf
87 fi
88}
5389
=== modified file 'hooks/install'
--- hooks/install 2013-03-22 02:14:17 +0000
+++ hooks/install 2013-05-03 14:19:28 +0000
@@ -33,11 +33,7 @@
3333
34# Unpack tarred Daisy code34# Unpack tarred Daisy code
35charm_dir="$(pwd)"35charm_dir="$(pwd)"
36tarball="$charm_dir/files/daisy.tgz"36deploy_code "$charm_dir/files/daisy.tgz" $CODE_LOCATION $DAISY_CODE_DIRS
37
38if [ -f "$tarball" ]; then
39 tar -C "$CODE_LOCATION" -xvf "$tarball"
40fi
4137
42if [ ! -e "$LOCAL_CONFIG_PATH" ]; then38if [ ! -e "$LOCAL_CONFIG_PATH" ]; then
43 cp "$CODE_LOCATION/daisy/configuration.py" "$LOCAL_CONFIG_PATH"39 cp "$CODE_LOCATION/daisy/configuration.py" "$LOCAL_CONFIG_PATH"
4440
=== added file 'hooks/nrpe-external-master-relation-changed'
--- hooks/nrpe-external-master-relation-changed 1970-01-01 00:00:00 +0000
+++ hooks/nrpe-external-master-relation-changed 2013-05-03 14:19:28 +0000
@@ -0,0 +1,16 @@
1#!/bin/bash
2set -eux
3. hooks/common
4export NAGIOS_HOSTNAME="ue-${REGION}-et-${JUJU_UNIT_NAME//\//-}"
5
6export INSTANCE_TYPE
7export NAGIOS_SERVICEGROUP="ue-${REGION}-et"
8export PROJECT="UE"
9
10export SERVICE_DESCRIPTION="Daisy app server"
11export NRPE_CMD_NAME="check_ue_daisry_app_${INSTANCE_TYPE}"
12export NRPE_CMD="/usr/lib/nagios/plugins/check_http -I 127.0.0.1 -p ${LISTEN_PORT} ${NRPE_URL_CHECK_PARAMS}"
13cheetah fill --env -p templates/nrpe_cmd_file.tmpl > /etc/nagios/nrpe.d/${NRPE_CMD_NAME}.cfg
14cheetah fill --env -p templates/nrpe_service_file.tmpl > /var/lib/nagios/export/service__${NAGIOS_HOSTNAME}_${NRPE_CMD_NAME}.cfg
15
16/etc/init.d/nagios-nrpe-server reload
017
=== added file 'hooks/upgrade-charm'
--- hooks/upgrade-charm 1970-01-01 00:00:00 +0000
+++ hooks/upgrade-charm 2013-05-03 14:19:28 +0000
@@ -0,0 +1,7 @@
1#!/bin/bash
2set -eux
3
4. hooks/common
5charm_dir="$(pwd)"
6deploy_code "$charm_dir/files/daisy.tgz" $CODE_LOCATION $DAISY_CODE_DIRS
7service gunicorn restart
08
=== modified file 'metadata.yaml'
--- metadata.yaml 2012-12-19 14:34:13 +0000
+++ metadata.yaml 2013-05-03 14:19:28 +0000
@@ -10,6 +10,10 @@
10 scope: container10 scope: container
11 daisy:11 daisy:
12 interface: http12 interface: http
13 nrpe-external-master:
14 interface: nrpe-external-master
15 scope: container
16
13requires:17requires:
14 db:18 db:
15 interface: cassandra19 interface: cassandra
1620
=== added directory 'templates'
=== added file 'templates/nrpe_cmd_file.tmpl'
--- templates/nrpe_cmd_file.tmpl 1970-01-01 00:00:00 +0000
+++ templates/nrpe_cmd_file.tmpl 2013-05-03 14:19:28 +0000
@@ -0,0 +1,6 @@
1#---------------------------------------------------
2# This file is Juju managed
3#---------------------------------------------------
4# ${PROJECT} ${INSTANCE_TYPE} ${SERVICE_DESCRIPTION}
5command[${NRPE_CMD_NAME}]=${NRPE_CMD}
6
07
=== added file 'templates/nrpe_service_file.tmpl'
--- templates/nrpe_service_file.tmpl 1970-01-01 00:00:00 +0000
+++ templates/nrpe_service_file.tmpl 2013-05-03 14:19:28 +0000
@@ -0,0 +1,10 @@
1#---------------------------------------------------
2# This file is Juju managed
3#---------------------------------------------------
4define service {
5 use active-service
6 host_name ${NAGIOS_HOSTNAME}
7 service_description ${NAGIOS_HOSTNAME} ${PROJECT} ${INSTANCE_TYPE} ${SERVICE_DESCRIPTION}
8 check_command check_nrpe!${NRPE_CMD_NAME}
9 servicegroups ${NAGIOS_SERVICEGROUP},
10}

Subscribers

People subscribed via source and target branches

to all changes: