Merge lp://staging/~rharding/charms/precise/charmworld/deploymgr into lp://staging/~juju-jitsu/charms/precise/charmworld/trunk

Proposed by Richard Harding
Status: Merged
Merged at revision: 35
Proposed branch: lp://staging/~rharding/charms/precise/charmworld/deploymgr
Merge into: lp://staging/~juju-jitsu/charms/precise/charmworld/trunk
Diff against target: 80 lines (+61/-0)
3 files modified
hooks/install (+1/-0)
scripts/gen_deploymgr.py (+37/-0)
templates/deploymgr.sh (+23/-0)
To merge this branch: bzr merge lp://staging/~rharding/charms/precise/charmworld/deploymgr
Reviewer Review Type Date Requested Status
Juju-Jitsu Hackers Pending
Review via email: mp+145969@code.staging.launchpad.net

Description of the change

Add support for creating a /srv/deploymgr script

- Add a template that has the path filled in.
- Add a python script to generate the deploymgr script from the template

https://codereview.appspot.com/7237063/

To post a comment you must log in.
Revision history for this message
Richard Harding (rharding) wrote :

Reviewers: mp+145969_code.launchpad.net,

Message:
Please take a look.

Description:
Add support for creating a /srv/deploymgr script

- Add a template that has the path filled in.
- Add a python script to generate the deploymgr script from the template

https://code.launchpad.net/~rharding/charms/precise/charmworld/deploymgr/+merge/145969

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/7237063/

Affected files:
   A [revision details]
   M hooks/install
   A scripts/gen_deploymgr.py
   A templates/deploymgr.sh

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: hooks/install
=== modified file 'hooks/install'
--- hooks/install 2013-01-24 17:34:53 +0000
+++ hooks/install 2013-01-31 19:25:09 +0000
@@ -18,3 +18,4 @@
  mkdir -p ~ubuntu/var/charms
  chown -R ubuntu.ubuntu ~ubuntu/var
  cp shhh.py ~ubuntu
+python scripts/gen_deploymgr.py

Index: scripts/gen_deploymgr.py
=== added file 'scripts/gen_deploymgr.py'
--- scripts/gen_deploymgr.py 1970-01-01 00:00:00 +0000
+++ scripts/gen_deploymgr.py 2013-01-31 19:25:09 +0000
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+from os import chown
+from os import chmod
+from os import makedirs
+from os.path import abspath
+from os.path import dirname
+from os.path import exists
+from string import Template
+
+
+DEPLOYMGR_TEMPLATE = 'templates/deploymgr.sh'
+DEPLOYMGR_OUT = '/srv/deploymgr/charmworld'
+CHARM_DIR = abspath(dirname(dirname(__file__)))
+
+
+def prep_output_path(path):
+ """Verify that we can write to the output location."""
+ directory = dirname(path)
+ if not exists(directory):
+ makedirs(directory)
+ chown(directory, 1500, 1500)
+ chmod(directory, 0755)
+
+
+def write_deploymgr():
+ with open(DEPLOYMGR_TEMPLATE) as handle:
+ template = Template(handle.read())
+ rendered = template.substitute({
+ 'charm_dir': CHARM_DIR
+ })
+
+ with open(DEPLOYMGR_OUT, 'w') as output:
+ output.writelines(rendered)
+ chmod(DEPLOYMGR_OUT, 0755)
+
+
+if __name__ == "__main__":
+ prep_output_path(DEPLOYMGR_OUT)
+ write_deploymgr()

Index: templates/deploymgr.sh
=== added file 'templates/deploymgr.sh'
--- templates/deploymgr.sh 1970-01-01 00:00:00 +0000
+++ templates/deploymgr.sh 2013-01-31 18:05:32 +0000
@@ -0,0 +1,23 @@
+#!/bin/bash
+set -u
+
+# Deployment script for charmworld service
+# Cribbed from lp:~canonical-losas/canonical-marshal/fenchurch
+case $$1 in
+ start)
+ cd $charm_dir && ./hooks/start
+ ;;
+ stop)
+ cd $charm_dir && ./hooks/stop
+ ;;
+ restart)
+ cd $charm_dir && ./hooks/restart
+ ;;
+ install)
+ cd $charm_dir && ./hooks/install
+ ;;
+ *)
+ echo "Unrecognised deployment command"
+ exit 1
+ ;;
+esac

39. By Richard Harding

Remove the chown to non-existant user

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: