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
1=== modified file 'charmhelpers/contrib/openstack/amulet/utils.py'
2--- charmhelpers/contrib/openstack/amulet/utils.py 2016-07-06 14:41:05 +0000
3+++ charmhelpers/contrib/openstack/amulet/utils.py 2016-08-01 13:43:59 +0000
4@@ -83,6 +83,56 @@
5 if not found:
6 return 'endpoint not found'
7
8+ def validate_v3_endpoint_data(self, endpoints, admin_port, internal_port,
9+ public_port, expected):
10+ """Validate keystone v3 endpoint data.
11+
12+ Validate the v3 endpoint data which has changed from v2. The
13+ ports are used to find the matching endpoint.
14+
15+ The new v3 endpoint data looks like:
16+
17+ [<Endpoint enabled=True,
18+ id=0432655fc2f74d1e9fa17bdaa6f6e60b,
19+ interface=admin,
20+ links={u'self': u'<RESTful URL of this endpoint>'},
21+ region=RegionOne,
22+ region_id=RegionOne,
23+ service_id=17f842a0dc084b928e476fafe67e4095,
24+ url=http://10.5.6.5:9312>,
25+ <Endpoint enabled=True,
26+ id=6536cb6cb92f4f41bf22b079935c7707,
27+ interface=admin,
28+ links={u'self': u'<RESTful url of this endpoint>'},
29+ region=RegionOne,
30+ region_id=RegionOne,
31+ service_id=72fc8736fb41435e8b3584205bb2cfa3,
32+ url=http://10.5.6.6:35357/v3>,
33+ ... ]
34+ """
35+ self.log.debug('Validating v3 endpoint data...')
36+ self.log.debug('actual: {}'.format(repr(endpoints)))
37+ found = []
38+ for ep in endpoints:
39+ self.log.debug('endpoint: {}'.format(repr(ep)))
40+ if ((admin_port in ep.url and ep.interface == 'admin') or
41+ (internal_port in ep.url and ep.interface == 'internal') or
42+ (public_port in ep.url and ep.interface == 'public')):
43+ found.append(ep.interface)
44+ # note we ignore the links member.
45+ actual = {'id': ep.id,
46+ 'region': ep.region,
47+ 'region_id': ep.region_id,
48+ 'interface': self.not_null,
49+ 'url': ep.url,
50+ 'service_id': ep.service_id, }
51+ ret = self._validate_dict_data(expected, actual)
52+ if ret:
53+ return 'unexpected endpoint data - {}'.format(ret)
54+
55+ if len(found) != 3:
56+ return 'Unexpected number of endpoints found'
57+
58 def validate_svc_catalog_endpoint_data(self, expected, actual):
59 """Validate service catalog endpoint data.
60
61@@ -100,6 +150,73 @@
62 return "endpoint {} does not exist".format(k)
63 return ret
64
65+ def validate_v3_svc_catalog_endpoint_data(self, expected, actual):
66+ """Validate the keystone v3 catalog endpoint data.
67+
68+ Validate a list of dictinaries that make up the keystone v3 service
69+ catalogue.
70+
71+ It is in the form of:
72+
73+
74+ {u'identity': [{u'id': u'48346b01c6804b298cdd7349aadb732e',
75+ u'interface': u'admin',
76+ u'region': u'RegionOne',
77+ u'region_id': u'RegionOne',
78+ u'url': u'http://10.5.5.224:35357/v3'},
79+ {u'id': u'8414f7352a4b47a69fddd9dbd2aef5cf',
80+ u'interface': u'public',
81+ u'region': u'RegionOne',
82+ u'region_id': u'RegionOne',
83+ u'url': u'http://10.5.5.224:5000/v3'},
84+ {u'id': u'd5ca31440cc24ee1bf625e2996fb6a5b',
85+ u'interface': u'internal',
86+ u'region': u'RegionOne',
87+ u'region_id': u'RegionOne',
88+ u'url': u'http://10.5.5.224:5000/v3'}],
89+ u'key-manager': [{u'id': u'68ebc17df0b045fcb8a8a433ebea9e62',
90+ u'interface': u'public',
91+ u'region': u'RegionOne',
92+ u'region_id': u'RegionOne',
93+ u'url': u'http://10.5.5.223:9311'},
94+ {u'id': u'9cdfe2a893c34afd8f504eb218cd2f9d',
95+ u'interface': u'internal',
96+ u'region': u'RegionOne',
97+ u'region_id': u'RegionOne',
98+ u'url': u'http://10.5.5.223:9311'},
99+ {u'id': u'f629388955bc407f8b11d8b7ca168086',
100+ u'interface': u'admin',
101+ u'region': u'RegionOne',
102+ u'region_id': u'RegionOne',
103+ u'url': u'http://10.5.5.223:9312'}]}
104+
105+ Note, that an added complication is that the order of admin, public,
106+ internal against 'interface' in each region.
107+
108+ Thus, the function sorts the expected and actual lists using the
109+ interface key as a sort key, prior to the comparison.
110+ """
111+ self.log.debug('Validating v3 service catalog endpoint data...')
112+ self.log.debug('actual: {}'.format(repr(actual)))
113+ for k, v in six.iteritems(expected):
114+ if k in actual:
115+ l_expected = sorted(v, key=lambda x: x['interface'])
116+ l_actual = sorted(actual[k], key=lambda x: x['interface'])
117+ if len(l_actual) != len(l_expected):
118+ return ("endpoint {} has differing number of interfaces "
119+ " - expected({}), actual({})"
120+ .format(k, len(l_expected), len(l_actual)))
121+ for i_expected, i_actual in zip(l_expected, l_actual):
122+ self.log.debug("checking interface {}"
123+ .format(i_expected['interface']))
124+ ret = self._validate_dict_data(i_expected, i_actual)
125+ if ret:
126+ return self.endpoint_error(k, ret)
127+ else:
128+ return "endpoint {} does not exist".format(k)
129+ return ret
130+
131+
132 def validate_tenant_data(self, expected, actual):
133 """Validate tenant data.
134

Subscribers

People subscribed via source and target branches