diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-01-31 05:57:09 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-31 05:57:09 -0800 |
commit | 0e77fc1ca03d00e253a1baf5fbd49c08ea22ac98 (patch) | |
tree | c37f536044761176bf2996fc29e044ebcfa3a8e7 /playbooks | |
parent | 26430dcbbbba6ac31e4f0380f12871c3e083c104 (diff) | |
parent | 9ceadb2718e714cba7126a4a575123a42157f103 (diff) | |
download | openshift-0e77fc1ca03d00e253a1baf5fbd49c08ea22ac98.tar.gz openshift-0e77fc1ca03d00e253a1baf5fbd49c08ea22ac98.tar.bz2 openshift-0e77fc1ca03d00e253a1baf5fbd49c08ea22ac98.tar.xz openshift-0e77fc1ca03d00e253a1baf5fbd49c08ea22ac98.zip |
Merge pull request #6908 from tzumainn/fix-cinder-mount
Automatic merge from submit-queue.
add cinder mountpoint to inventory
Although the heat templates specify /dev/sdb as a mountpoint for cinder volumes, openstack does not always respect that setting. This PR updates inventory.py to figure out the correct mountpoint from the openstack API; and passes that information into the docker-storage-setup.
Diffstat (limited to 'playbooks')
-rwxr-xr-x | playbooks/openstack/inventory.py | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/playbooks/openstack/inventory.py b/playbooks/openstack/inventory.py index 76e658eb7..d5a8c3e24 100755 --- a/playbooks/openstack/inventory.py +++ b/playbooks/openstack/inventory.py @@ -15,18 +15,10 @@ import json import shade -def build_inventory(): - '''Build the dynamic inventory.''' - cloud = shade.openstack_cloud() - +def base_openshift_inventory(cluster_hosts): + '''Set the base openshift inventory.''' inventory = {} - # TODO(shadower): filter the servers based on the `OPENSHIFT_CLUSTER` - # environment variable. - cluster_hosts = [ - server for server in cloud.list_servers() - if 'metadata' in server and 'clusterid' in server.metadata] - masters = [server.name for server in cluster_hosts if server.metadata['host-type'] == 'master'] @@ -67,6 +59,34 @@ def build_inventory(): inventory['dns'] = {'hosts': dns} inventory['lb'] = {'hosts': load_balancers} + return inventory + + +def get_docker_storage_mountpoints(volumes): + '''Check volumes to see if they're being used for docker storage''' + docker_storage_mountpoints = {} + for volume in volumes: + if volume.metadata.get('purpose') == "openshift_docker_storage": + for attachment in volume.attachments: + if attachment.server_id in docker_storage_mountpoints: + docker_storage_mountpoints[attachment.server_id].append(attachment.device) + else: + docker_storage_mountpoints[attachment.server_id] = [attachment.device] + return docker_storage_mountpoints + + +def build_inventory(): + '''Build the dynamic inventory.''' + cloud = shade.openstack_cloud() + + # TODO(shadower): filter the servers based on the `OPENSHIFT_CLUSTER` + # environment variable. + cluster_hosts = [ + server for server in cloud.list_servers() + if 'metadata' in server and 'clusterid' in server.metadata] + + inventory = base_openshift_inventory(cluster_hosts) + for server in cluster_hosts: if 'group' in server.metadata: group = server.metadata.group @@ -76,6 +96,9 @@ def build_inventory(): inventory['_meta'] = {'hostvars': {}} + # cinder volumes used for docker storage + docker_storage_mountpoints = get_docker_storage_mountpoints(cloud.list_volumes()) + for server in cluster_hosts: ssh_ip_address = server.public_v4 or server.private_v4 hostvars = { @@ -111,6 +134,11 @@ 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_mountpoints: + hostvars['docker_storage_mountpoints'] = ' '.join(docker_storage_mountpoints[server.id]) + inventory['_meta']['hostvars'][server.name] = hostvars return inventory |