File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #!/usr/bin/python3
2+
3+ import itertools
4+ import json
5+ import os
6+ import yaml
7+
8+ def cloud_to_env (d ):
9+ return itertools .chain .from_iterable (
10+ cloud_to_env (v ) if isinstance (v , dict )
11+ else (("OS_%s" % k .upper (), v ),)
12+ for k , v in d .items ())
13+
14+ with open ("%s/.config/openstack/clouds.yaml" % os .environ ['HOME' ]) as f :
15+ clouds = yaml .safe_load (f )
16+
17+ os_cloud = os .environ ['OS_CLOUD' ]
18+ cloud = clouds ['clouds' ][os_cloud ]
19+ env_vars = dict (cloud_to_env (cloud ))
20+ print (json .dumps (env_vars ))
Original file line number Diff line number Diff line change 111111 environment :
112112 OS_CLOUD : standalone
113113
114+ # openstack cli doesn't have manila support (no openstack share type ...)in RHEL/OSP
114115 - name : Create Manila share type for CephFS NFS # noqa 301
115- shell : |
116- if ! openstack share type show cephfsnfstype; then
117- openstack share type create --snapshot-support false cephfsnfstype false
118- fi
119116 when : manila_enabled
120- environment :
121- OS_CLOUD : standalone
122- # https://bugzilla.redhat.com/show_bug.cgi?id=1960710
123- OS_SHARE_API_VERSION : 2.60
117+ block :
118+ - name : Convert clouds.yaml to legacy environment variables
119+ script : files/cloud-to-env.py
120+ register : os_env_vars
121+ environment :
122+ OS_CLOUD : standalone
123+
124+ # type-show MUST NOT have OS_SHARE_API_VERSION set
125+ # type-create MUST have OS_SHARE_API_VERSION set
126+ - name : Create Manila share type
127+ shell : |
128+ if ! OS_SHARE_API_VERSION= manila type-show cephfsnfstype; then
129+ manila type-create --snapshot_support false cephfsnfstype false
130+ fi
131+ environment : " {{ legacy_vars | combine(extra_vars) }}"
132+ vars :
133+ legacy_vars : " {{ os_env_vars.stdout | from_json }}"
134+ extra_vars :
135+ # https://bugzilla.redhat.com/show_bug.cgi?id=1960710
136+ OS_SHARE_API_VERSION : 2.60
124137
125138 - name : Read clouds.yaml
126139 slurp :
You can’t perform that action at this time.
0 commit comments