Merge lp://qastaging/~jtv/maas/single-cluster into lp://qastaging/~maas-committers/maas/trunk
Proposed by
Jeroen T. Vermeulen
Status: | Merged |
---|---|
Merged at revision: | 7 |
Proposed branch: | lp://qastaging/~jtv/maas/single-cluster |
Merge into: | lp://qastaging/~maas-committers/maas/trunk |
Diff against target: |
295 lines (+82/-39) 6 files modified
.bzrignore (+1/-0) Makefile (+11/-8) README.txt (+14/-13) bin/maasdb (+45/-10) src/maas/development.py (+1/-1) src/maas/settings.py (+10/-7) |
To merge this branch: | bzr merge lp://qastaging/~jtv/maas/single-cluster |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+88739@code.qastaging.launchpad.net |
Commit message
Single development db cluster per branch.
Description of the change
Allocate just a single local database cluster per branch, and make sure the "make" targets that need it will start it up. Also, rename maasdb.sh to maasdb and add a simple command set so it's easier to use.
Finally, update settings.py with the applicable changes we've made in development.py.
To post a comment you must log in.
[1]
-build: bin/buildout
+build: bin/buildout dev-db
I know it's early days, but we probably don't want to create the dev
database for just a build.
[2]
-run:
+run: build
bin/django runserver 8000
If you agree with [1] then this needs to depend on build and dev-db.
[3]
-harness:
- . bin/maasdb.sh ; maasdb_init_db db/development disposable
+harness: dev-db
bin/django shell
-syncdb:
+syncdb: dev-db
bin/django syncdb
However, these don't depend on build, so perhaps run doesn't need to
either.
[4]
+main() {
+ COMMAND="$1"
COMMAND will end up in the calling environment. The local command
sorts this out:
main() {
local COMMAND="$1"
Please also let's not pretend we're writing for a plain /bin/sh; let's
just use bash and not go quite as insane. Or, read [6] and use Python,
or just about anything *but* shell.
[5]
+if test -n "$*"
+then
+ main $*
+fi
This won't work if sourced within a script that itself has args, or if
"set -- $something" has been used in the shell before sourcing this
script. Because main() defaults to doing nothing if the argument does
not match I think it's safe to just call main() unconditionally.
[6]
+ case $COMMAND in delete_ cluster $* ;;
+ start) maasdb_init_db $* ;;
+ stop) maasdb_stop_cluster $* ;;
+ query) maasdb_query $* ;;
+ shell) maasdb_shell $* ;;
+ delete-cluster) maasdb_
+ esac
...
+ main $*
Avoid $* because it rarely does the right thing (in bash at
least). Also, more quotes needed. The code above behaves badly if
there are spaces in the arguments passed in. I think the following
will work without surprises:
main() {
delete- cluster) maasdb_ delete_ cluster "$@" ;;
COMMAND="$1"
shift
case "$COMMAND" in
start) maasdb_init_db "$@" ;;
stop) maasdb_stop_cluster "$@" ;;
query) maasdb_query "$@" ;;
shell) maasdb_shell "$@" ;;
esac
}
if [ $# -gt 1 ]
then
main "$@"
fi
Similar modifications ought to be made throughout the script.
To be honest, having to remember crap like this makes me avoid shell
script these days for anything other than the very most trivial
things.