diff options
author | Tzu-Mainn Chen <tzumainn@redhat.com> | 2018-01-26 17:01:42 +0000 |
---|---|---|
committer | Tzu-Mainn Chen <tzumainn@redhat.com> | 2018-01-27 04:51:17 +0100 |
commit | 693824ba52eca910fc6df760f7d663892bb2b31c (patch) | |
tree | 20794ecb7d21a998e8d3c00d2b04481a70eae73c | |
parent | c6423636a4d14139960f4677dbab8fa646d1cb0c (diff) | |
download | openshift-693824ba52eca910fc6df760f7d663892bb2b31c.tar.gz openshift-693824ba52eca910fc6df760f7d663892bb2b31c.tar.bz2 openshift-693824ba52eca910fc6df760f7d663892bb2b31c.tar.xz openshift-693824ba52eca910fc6df760f7d663892bb2b31c.zip |
add cinder mountpoint to inventory
4 files changed, 25 insertions, 1 deletions
diff --git a/playbooks/openstack/inventory.py b/playbooks/openstack/inventory.py index 76e658eb7..98ce57c8d 100755 --- a/playbooks/openstack/inventory.py +++ b/playbooks/openstack/inventory.py @@ -76,6 +76,16 @@ def build_inventory(): inventory['_meta'] = {'hostvars': {}} + # cinder volumes used for docker storage + docker_storage_volume_mountpoints = {} + for volume in cloud.list_volumes(): + if 'purpose' in volume.metadata and volume.metadata.purpose == "openshift_docker_storage": + for attachment in volume.attachments: + if attachment.server_id in docker_storage_volume_mountpoints: + docker_storage_volume_mountpoints[attachment.server_id].append(attachment.device) + else: + docker_storage_volume_mountpoints[attachment.server_id] = [attachment.device] + for server in cluster_hosts: ssh_ip_address = server.public_v4 or server.private_v4 hostvars = { @@ -111,9 +121,13 @@ def build_inventory(): if node_labels: hostvars['openshift_node_labels'] = node_labels + # check for attached docker storage volumes + if 'os-extended-volumes:volumes_attached' in server: + if server.id in docker_storage_volume_mountpoints: + hostvars['docker_storage_volume_mountpoints'] = ' '.join(docker_storage_volume_mountpoints[server.id]) + inventory['_meta']['hostvars'][server.name] = hostvars return inventory - if __name__ == '__main__': print(json.dumps(build_inventory(), indent=4, sort_keys=True)) diff --git a/roles/openshift_openstack/templates/docker-storage-setup-dm.j2 b/roles/openshift_openstack/templates/docker-storage-setup-dm.j2 index 32c6b5838..eeed750cf 100644 --- a/roles/openshift_openstack/templates/docker-storage-setup-dm.j2 +++ b/roles/openshift_openstack/templates/docker-storage-setup-dm.j2 @@ -1,4 +1,8 @@ +{% if docker_storage_volume_mountpoints is defined %} +DEVS="{{ docker_storage_volume_mountpoints }}" +{% else %} DEVS="{{ openshift_openstack_container_storage_setup.docker_dev }}" +{% endif %} VG="{{ openshift_openstack_container_storage_setup.docker_vg }}" DATA_SIZE="{{ openshift_openstack_container_storage_setup.docker_data_size }}" EXTRA_DOCKER_STORAGE_OPTIONS="--storage-opt dm.basesize={{ openshift_openstack_container_storage_setup.docker_dm_basesize }}" diff --git a/roles/openshift_openstack/templates/docker-storage-setup-overlayfs.j2 b/roles/openshift_openstack/templates/docker-storage-setup-overlayfs.j2 index 1bf366bdc..19beba09e 100644 --- a/roles/openshift_openstack/templates/docker-storage-setup-overlayfs.j2 +++ b/roles/openshift_openstack/templates/docker-storage-setup-overlayfs.j2 @@ -1,4 +1,8 @@ +{% if docker_storage_volume_mountpoints is defined %} +DEVS="{{ docker_storage_volume_mountpoints }}" +{% else %} DEVS="{{ openshift_openstack_container_storage_setup.docker_dev }}" +{% endif %} VG="{{ openshift_openstack_container_storage_setup.docker_vg }}" DATA_SIZE="{{ openshift_openstack_container_storage_setup.docker_data_size }}" STORAGE_DRIVER=overlay2 diff --git a/roles/openshift_openstack/templates/heat_stack_server.yaml.j2 b/roles/openshift_openstack/templates/heat_stack_server.yaml.j2 index 29b09f3c9..32f018814 100644 --- a/roles/openshift_openstack/templates/heat_stack_server.yaml.j2 +++ b/roles/openshift_openstack/templates/heat_stack_server.yaml.j2 @@ -261,6 +261,8 @@ resources: properties: size: { get_param: volume_size } availability_zone: { get_param: availability_zone } + metadata: + purpose: openshift_docker_storage volume_attachment: type: OS::Cinder::VolumeAttachment |