Merge lp:~jimbaker/pyjuju/must-specify-relation-name into lp:pyjuju
Proposed by
Jim Baker
Status: | Merged |
---|---|
Approved by: | Kapil Thangavelu |
Approved revision: | 516 |
Merged at revision: | 519 |
Proposed branch: | lp:~jimbaker/pyjuju/must-specify-relation-name |
Merge into: | lp:pyjuju |
Diff against target: |
188 lines (+72/-11) 4 files modified
juju/hooks/commands.py (+11/-3) juju/hooks/protocol.py (+16/-2) juju/hooks/tests/test_communications.py (+16/-2) juju/hooks/tests/test_invoker.py (+29/-4) |
To merge this branch: | bzr merge lp:~jimbaker/pyjuju/must-specify-relation-name |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email:
|
Description of the change
relation-ids should default to $JUJU_RELATION
If no relation name is specified for the relation-ids hook command, it should default to $JUJU_RELATION. If that's not available, it should raise an error stating "Relation name must be specified".
To post a comment you must log in.
Reviewers: mp+101156_ code.launchpad. net,
Message:
Please take a look.
Description:
relation-ids should default to $JUJU_RELATION
If no relation name is specified for the relation-ids hook command, it
should default to $JUJU_RELATION. If that's not available, it should
raise an error stating "Relation name must be specified".
https:/ /code.launchpad .net/~jimbaker/ juju/must- specify- relation- name/+merge/ 101156
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/5991058/
Affected files: commands. py protocol. py tests/test_ communications. py tests/test_ invoker. py
A [revision details]
M juju/hooks/
M juju/hooks/
M juju/hooks/
M juju/hooks/
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: juju/hooks/ commands. py commands. py' commands. py 2012-04-05 00:58:19 +0000 commands. py 2012-04-06 20:29:41 +0000 pairs = False
=== modified file 'juju/hooks/
--- juju/hooks/
+++ juju/hooks/
@@ -98,12 +98,15 @@
keyvalue_
def customize_ parser( self): get("JUJU_ RELATION" , "")
self. parser. add_argument(
"relation_ name",
metavar= "RELATION NAME",
nargs=" ?", relation_ name,
+ relation_name = os.environ.
+
- default="",
- help="Specify the relation name of the relation ids to list.")
+ default=
+ help=("Specify the relation name of the relation ids to list. "
+ "Defaults to $JUJU_RELATION, if available."))
def run(self): relation_ ids(
return self.client.
Index: juju/hooks/ protocol. py protocol. py' protocol. py 2012-04-05 16:38:15 +0000 protocol. py 2012-04-06 20:29:41 +0000
=== modified file 'juju/hooks/
--- juju/hooks/
+++ juju/hooks/
@@ -73,11 +73,19 @@
"""
+class MustSpecifyRela tionName( JujuError) : amp.Command) :
NoSuchKey: "NoSuchKey",
NotRelationCo ntext: "NotRelationCon text", teNotFound: "UnitRelationSt ateNotFound" } teNotFound: "UnitRelationSt ateNotFound" , tionName: "MustSpecifyRel ationName" }
+ """No relation name was specified."""
+
+ def __str__(self):
+ return "Relation name must be specified"
+
+
class BaseCommand(
errors = {NoSuchUnit: "NoSuchUnit",
- UnitRelationSta
+ UnitRelationSta
+ MustSpecifyRela
# All the commands below this point should be documented in the RelationHookCon text.
@@ -243,9 +251,15 @@
def relation_ids(self, client_id, relation_name):
"""Set values into state.hook.
+ :client_id: hooks client id that is used to define a context ationName` .
+ for a consistent view of state.
+
:param relation_name: The relation name to query relation ids
- for this context.
+ for this context. If no such relation name is specified,
+ raises `MustSpecifyRel
"""
+ if not relation_name:
+ raise MustS...