Merge lp:~ajkavanagh/charm-helpers/add-v3-keystone-catalog-check into lp:charm-helpers

Proposed by Alex Kavanagh
Status: Merged
Merged at revision: 616
Proposed branch: lp:~ajkavanagh/charm-helpers/add-v3-keystone-catalog-check
Merge into: lp:charm-helpers
Diff against target: 133 lines (+117/-0)
1 file modified
charmhelpers/contrib/openstack/amulet/utils.py (+117/-0)
To merge this branch: bzr merge lp:~ajkavanagh/charm-helpers/add-v3-keystone-catalog-check
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+301646@code.launchpad.net

Description of the change

Addition to contrib/openstack/amulet/utils.py that provides keystone v3 versions of service catalog checking and endpoint checking.

To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

Minor niggle inline

Revision history for this message
Alex Kavanagh (ajkavanagh) wrote :

See in line reply - changing code to remove offending code!

622. By Alex Kavanagh

Remove obsolete testing code

Revision history for this message
Liam Young (gnuoy) wrote :

Approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
--- charmhelpers/contrib/openstack/amulet/utils.py 2016-07-06 14:41:05 +0000
+++ charmhelpers/contrib/openstack/amulet/utils.py 2016-08-01 13:43:59 +0000
@@ -83,6 +83,56 @@
83 if not found:83 if not found:
84 return 'endpoint not found'84 return 'endpoint not found'
8585
86 def validate_v3_endpoint_data(self, endpoints, admin_port, internal_port,
87 public_port, expected):
88 """Validate keystone v3 endpoint data.
89
90 Validate the v3 endpoint data which has changed from v2. The
91 ports are used to find the matching endpoint.
92
93 The new v3 endpoint data looks like:
94
95 [<Endpoint enabled=True,
96 id=0432655fc2f74d1e9fa17bdaa6f6e60b,
97 interface=admin,
98 links={u'self': u'<RESTful URL of this endpoint>'},
99 region=RegionOne,
100 region_id=RegionOne,
101 service_id=17f842a0dc084b928e476fafe67e4095,
102 url=http://10.5.6.5:9312>,
103 <Endpoint enabled=True,
104 id=6536cb6cb92f4f41bf22b079935c7707,
105 interface=admin,
106 links={u'self': u'<RESTful url of this endpoint>'},
107 region=RegionOne,
108 region_id=RegionOne,
109 service_id=72fc8736fb41435e8b3584205bb2cfa3,
110 url=http://10.5.6.6:35357/v3>,
111 ... ]
112 """
113 self.log.debug('Validating v3 endpoint data...')
114 self.log.debug('actual: {}'.format(repr(endpoints)))
115 found = []
116 for ep in endpoints:
117 self.log.debug('endpoint: {}'.format(repr(ep)))
118 if ((admin_port in ep.url and ep.interface == 'admin') or
119 (internal_port in ep.url and ep.interface == 'internal') or
120 (public_port in ep.url and ep.interface == 'public')):
121 found.append(ep.interface)
122 # note we ignore the links member.
123 actual = {'id': ep.id,
124 'region': ep.region,
125 'region_id': ep.region_id,
126 'interface': self.not_null,
127 'url': ep.url,
128 'service_id': ep.service_id, }
129 ret = self._validate_dict_data(expected, actual)
130 if ret:
131 return 'unexpected endpoint data - {}'.format(ret)
132
133 if len(found) != 3:
134 return 'Unexpected number of endpoints found'
135
86 def validate_svc_catalog_endpoint_data(self, expected, actual):136 def validate_svc_catalog_endpoint_data(self, expected, actual):
87 """Validate service catalog endpoint data.137 """Validate service catalog endpoint data.
88138
@@ -100,6 +150,73 @@
100 return "endpoint {} does not exist".format(k)150 return "endpoint {} does not exist".format(k)
101 return ret151 return ret
102152
153 def validate_v3_svc_catalog_endpoint_data(self, expected, actual):
154 """Validate the keystone v3 catalog endpoint data.
155
156 Validate a list of dictinaries that make up the keystone v3 service
157 catalogue.
158
159 It is in the form of:
160
161
162 {u'identity': [{u'id': u'48346b01c6804b298cdd7349aadb732e',
163 u'interface': u'admin',
164 u'region': u'RegionOne',
165 u'region_id': u'RegionOne',
166 u'url': u'http://10.5.5.224:35357/v3'},
167 {u'id': u'8414f7352a4b47a69fddd9dbd2aef5cf',
168 u'interface': u'public',
169 u'region': u'RegionOne',
170 u'region_id': u'RegionOne',
171 u'url': u'http://10.5.5.224:5000/v3'},
172 {u'id': u'd5ca31440cc24ee1bf625e2996fb6a5b',
173 u'interface': u'internal',
174 u'region': u'RegionOne',
175 u'region_id': u'RegionOne',
176 u'url': u'http://10.5.5.224:5000/v3'}],
177 u'key-manager': [{u'id': u'68ebc17df0b045fcb8a8a433ebea9e62',
178 u'interface': u'public',
179 u'region': u'RegionOne',
180 u'region_id': u'RegionOne',
181 u'url': u'http://10.5.5.223:9311'},
182 {u'id': u'9cdfe2a893c34afd8f504eb218cd2f9d',
183 u'interface': u'internal',
184 u'region': u'RegionOne',
185 u'region_id': u'RegionOne',
186 u'url': u'http://10.5.5.223:9311'},
187 {u'id': u'f629388955bc407f8b11d8b7ca168086',
188 u'interface': u'admin',
189 u'region': u'RegionOne',
190 u'region_id': u'RegionOne',
191 u'url': u'http://10.5.5.223:9312'}]}
192
193 Note, that an added complication is that the order of admin, public,
194 internal against 'interface' in each region.
195
196 Thus, the function sorts the expected and actual lists using the
197 interface key as a sort key, prior to the comparison.
198 """
199 self.log.debug('Validating v3 service catalog endpoint data...')
200 self.log.debug('actual: {}'.format(repr(actual)))
201 for k, v in six.iteritems(expected):
202 if k in actual:
203 l_expected = sorted(v, key=lambda x: x['interface'])
204 l_actual = sorted(actual[k], key=lambda x: x['interface'])
205 if len(l_actual) != len(l_expected):
206 return ("endpoint {} has differing number of interfaces "
207 " - expected({}), actual({})"
208 .format(k, len(l_expected), len(l_actual)))
209 for i_expected, i_actual in zip(l_expected, l_actual):
210 self.log.debug("checking interface {}"
211 .format(i_expected['interface']))
212 ret = self._validate_dict_data(i_expected, i_actual)
213 if ret:
214 return self.endpoint_error(k, ret)
215 else:
216 return "endpoint {} does not exist".format(k)
217 return ret
218
219
103 def validate_tenant_data(self, expected, actual):220 def validate_tenant_data(self, expected, actual):
104 """Validate tenant data.221 """Validate tenant data.
105222

Subscribers

People subscribed via source and target branches