diff options
| author | Juan L. Negron <juan.negron@canonical.com> | 2012-11-16 19:28:16 -0800 |
|---|---|---|
| committer | Juan L. Negron <juan.negron@canonical.com> | 2012-11-16 19:28:16 -0800 |
| commit | a737f2e5f715914d1da5f40bc34605100869c6cf (patch) | |
| tree | ce717e5351d783638b2b971cecc89a18072a1357 | |
| parent | 10b27cde5a0e31c579fcef0ac9af2593a2b60f0d (diff) | |
Re-worked interfaces, fixes sharding issue with replsets
| -rwxr-xr-x | hooks/hooks.py | 16 | ||||
| l--------- | hooks/mongos-cfg-relation-broken (renamed from hooks/mongos-relation-broken) | 0 | ||||
| l--------- | hooks/mongos-cfg-relation-changed (renamed from hooks/mongos-relation-changed) | 0 | ||||
| l--------- | hooks/mongos-cfg-relation-joined (renamed from hooks/mongos-relation-joined) | 0 | ||||
| -rw-r--r-- | metadata.yaml | 4 |
5 files changed, 17 insertions, 3 deletions
diff --git a/hooks/hooks.py b/hooks/hooks.py index 502e091..1fcaa46 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -1087,6 +1087,7 @@ def mongos_relation_joined(): def mongos_relation_changed(): juju_log("mongos_relation_changed") config_data = config_get() + retVal = False for member in relation_list(): hostname = relation_get('hostname', member) port = relation_get('port', member) @@ -1110,8 +1111,13 @@ def mongos_relation_changed(): mongos_host = "%s:%s" % ( unit_get('public-address'), config_get('mongos_port')) - shard_command = "sh.addShard(\"%s:%s\")" % (hostname, port) - retVal = mongo_client(mongos_host, shard_command) + shard_command1 = "sh.addShard(\"%s:%s\")" % (hostname, port) + retVal1 = mongo_client(mongos_host, shard_command1) + replicaset = relation_get('replset', member) + shard_command2 = "sh.addShard(\"%s/%s:%s\")" % \ + (replicaset, hostname, port) + retVal2 = mongo_client(mongos_host, shard_command2) + retVal = retVal1 is True and retVal2 is True else: juju_log("mongos_relation_change: undefined rel_type: %s" % rel_type) @@ -1151,6 +1157,12 @@ elif hook_name == "configsvr-relation-joined": retVal = configsvr_relation_joined() elif hook_name == "configsvr-relation-changed": retVal = configsvr_relation_changed() +elif hook_name == "mongos-cfg-relation-joined": + retVal = mongos_relation_joined() +elif hook_name == "mongos-cfg-relation-changed": + retVal = mongos_relation_changed() +elif hook_name == "mongos-cfg-relation-broken": + retVal = mongos_relation_broken() elif hook_name == "mongos-relation-joined": retVal = mongos_relation_joined() elif hook_name == "mongos-relation-changed": diff --git a/hooks/mongos-relation-broken b/hooks/mongos-cfg-relation-broken index f94593a..f94593a 120000 --- a/hooks/mongos-relation-broken +++ b/hooks/mongos-cfg-relation-broken diff --git a/hooks/mongos-relation-changed b/hooks/mongos-cfg-relation-changed index 9416ca6..9416ca6 120000 --- a/hooks/mongos-relation-changed +++ b/hooks/mongos-cfg-relation-changed diff --git a/hooks/mongos-relation-joined b/hooks/mongos-cfg-relation-joined index 9416ca6..9416ca6 120000 --- a/hooks/mongos-relation-joined +++ b/hooks/mongos-cfg-relation-joined diff --git a/metadata.yaml b/metadata.yaml index 6891335..79f7088 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -18,8 +18,10 @@ provides: database: interface: mongodb configsvr: - interface: mongodb + interface: shard requires: + mongos-cfg: + interface: shard mongos: interface: mongodb peers: |
