diff options
| author | Wes Mason <wesley.mason@canonical.com> | 2014-06-18 10:18:00 +0100 |
|---|---|---|
| committer | Wes Mason <wesley.mason@canonical.com> | 2014-06-18 10:18:00 +0100 |
| commit | dcbf8085bc9aa5cc3b6ab1e28f495ca8cae9db68 (patch) | |
| tree | 8d566399b7b0c178bf9486de70ce26397d4b3d3a | |
| parent | 8f84a4e75ececccaf8e7ce17522ee23fb73d7036 (diff) | |
Use the same mount path that the charm already expects
| -rw-r--r-- | config.yaml | 6 | ||||
| -rwxr-xr-x | hooks/hooks.py | 48 |
2 files changed, 37 insertions, 17 deletions
diff --git a/config.yaml b/config.yaml index a9738a4..3bb40a2 100644 --- a/config.yaml +++ b/config.yaml @@ -199,9 +199,3 @@ options: Deprecated, use the storage subordinate. Block device for attached volumes as seen by the VM, will be "scanned" for an unused device when "volume-map" is valid for the unit. - storage-mountpoint: - type: string - default: "/mnt/mongodb-data" - description: > - Mountpoint to mount persistent volume to, this is sent to the - storage subordinate. diff --git a/hooks/hooks.py b/hooks/hooks.py index 44ca8e3..c78ac93 100755 --- a/hooks/hooks.py +++ b/hooks/hooks.py @@ -1164,8 +1164,13 @@ def replica_set_relation_changed(): def data_relation_joined(): juju_log("data_relation_joined") - mountpoint = config_get('storage_mountpoint') - juju_log('mountpoint: %s' % (mountpoint,)) + volume_id = volume_get_id_from_storage_subordinate() + + if not volume_id: + juju_log("No volume_id found in storage subordinate config volume_map") + return(False) + + mountpoint = "/srv/juju/%s" % (volume_id,) return(relation_set( { @@ -1340,20 +1345,41 @@ def volume_mount_point_from_volid(volid): return None -# Do we have a valid storage state? -# @returns volid -# None config state is invalid - we should not serve -def volume_get_volume_id(): +#------------------------------ +# Returns a vol-id from the data relation with the storage subordinate +# if present. +# +# @return volid eg vol-000012345 +#------------------------------ +def volume_get_id_from_storage_subordinate(): + unit_name = os.environ['JUJU_UNIT_NAME'] # storage charm is a subordinate so we should only ever have one # relation_id for the data relation ids = relation_ids('data') if len(ids) > 0: - mountpoint = relation_get('mountpoint', - os.environ['JUJU_UNIT_NAME'], - ids[0]) - if mountpoint: - return mountpoint + volume_map_yaml = relation_get('volume_map', + unit_name, + ids[0]) + + try: + volume_map = yaml.load(volume_map_yaml.strip()) + except: + volume_map = {} + finally: + if volume_map and unit_name in volume_map: + return volume_map[unit_name] + + +# Do we have a valid storage state? +# @returns volid +# None config state is invalid - we should not serve +def volume_get_volume_id(): + + + volid = volume_get_id_from_storage_subordinate() + if volid: + return volid config_data = config_get() ephemeral_storage = config_data['volume-ephemeral-storage'] |
