summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-04-25 16:40:07 +0000
committerGerrit Code Review <review@openstack.org>2018-04-25 16:40:07 +0000
commit33ccb1955739d99f15573702fede3804133a5f8f (patch)
tree017d1c1e23428a813a6a816ba833324c0167d0f7
parentf41e30484902d305bab56c9194b32d215f08b7cf (diff)
parent43c6e378f944227068ed815d84c124d6a7cc9d08 (diff)
Merge "Expose version status in EndpointData"
-rw-r--r--keystoneauth1/discover.py32
-rw-r--r--keystoneauth1/tests/unit/test_discovery.py10
-rw-r--r--releasenotes/notes/expose-endpoint-status-6195a6b76d8a8de8.yaml6
3 files changed, 46 insertions, 2 deletions
diff --git a/keystoneauth1/discover.py b/keystoneauth1/discover.py
index 4cc1bf1..222602d 100644
--- a/keystoneauth1/discover.py
+++ b/keystoneauth1/discover.py
@@ -129,6 +129,26 @@ def get_version_data(session, url, authenticated=None):
129 'returned: %s' % err_text) 129 'returned: %s' % err_text)
130 130
131 131
132def normalize_status(raw_status):
133 """Turn a status into a canonical status value.
134
135 If the status from the version discovery document does not match one
136 of the known values, it will be set to 'UNKNOWN'.
137
138 :param str raw_status: Status value from a discovery document.
139
140 :returns: A canonicalized version of the status. Valid values
141 are CURRENT, SUPPORTED, DEPRECATED, EXPERIMENTAL and UNKNOWN
142 :rtype: str
143 """
144 status = raw_status.upper()
145 if status == 'STABLE':
146 status = 'CURRENT'
147 if status not in ('CURRENT', 'SUPPORTED', 'DEPRECATED', 'EXPERIMENTAL'):
148 status = 'UNKNOWN'
149 return status
150
151
132def normalize_version_number(version): 152def normalize_version_number(version):
133 """Turn a version representation into a tuple. 153 """Turn a version representation into a tuple.
134 154
@@ -459,6 +479,8 @@ class Discover(object):
459 endpoint. May be None. 479 endpoint. May be None.
460 :max_microversion: The maximum microversion supported by the 480 :max_microversion: The maximum microversion supported by the
461 endpoint. May be None. 481 endpoint. May be None.
482 :status str: A canonicalized version of the status. Valid values
483 are CURRENT, SUPPORTED, DEPRECATED and EXPERIMENTAL
462 :raw_status str: The status as provided by the server 484 :raw_status str: The status as provided by the server
463 :rtype: list(dict) 485 :rtype: list(dict)
464 """ 486 """
@@ -525,6 +547,7 @@ class Discover(object):
525 'max_microversion': max_microversion, 547 'max_microversion': max_microversion,
526 'next_min_version': next_min_version, 548 'next_min_version': next_min_version,
527 'not_before': not_before, 549 'not_before': not_before,
550 'status': normalize_status(v['status']),
528 'raw_status': v['status']}) 551 'raw_status': v['status']})
529 552
530 versions.sort(key=lambda v: v['version'], reverse=reverse) 553 versions.sort(key=lambda v: v['version'], reverse=reverse)
@@ -688,7 +711,8 @@ class EndpointData(object):
688 min_microversion=None, 711 min_microversion=None,
689 max_microversion=None, 712 max_microversion=None,
690 next_min_version=None, 713 next_min_version=None,
691 not_before=None): 714 not_before=None,
715 status=None):
692 self.catalog_url = catalog_url 716 self.catalog_url = catalog_url
693 self.service_url = service_url 717 self.service_url = service_url
694 self.service_type = service_type 718 self.service_type = service_type
@@ -703,6 +727,7 @@ class EndpointData(object):
703 self.max_microversion = max_microversion 727 self.max_microversion = max_microversion
704 self.next_min_version = next_min_version 728 self.next_min_version = next_min_version
705 self.not_before = not_before 729 self.not_before = not_before
730 self.status = status
706 self._saved_project_id = None 731 self._saved_project_id = None
707 self._catalog_matches_version = False 732 self._catalog_matches_version = False
708 self._catalog_matches_exactly = False 733 self._catalog_matches_exactly = False
@@ -727,7 +752,9 @@ class EndpointData(object):
727 min_microversion=self.min_microversion, 752 min_microversion=self.min_microversion,
728 max_microversion=self.max_microversion, 753 max_microversion=self.max_microversion,
729 next_min_version=self.next_min_version, 754 next_min_version=self.next_min_version,
730 not_before=self.not_before) 755 not_before=self.not_before,
756 status=self.status,
757 )
731 # Save cached discovery object - but we don't want to 758 # Save cached discovery object - but we don't want to
732 # actually provide a constructor argument 759 # actually provide a constructor argument
733 new_data._disc = self._disc 760 new_data._disc = self._disc
@@ -900,6 +927,7 @@ class EndpointData(object):
900 self.next_min_version = discovered_data['next_min_version'] 927 self.next_min_version = discovered_data['next_min_version']
901 self.not_before = discovered_data['not_before'] 928 self.not_before = discovered_data['not_before']
902 self.api_version = discovered_data['version'] 929 self.api_version = discovered_data['version']
930 self.status = discovered_data['status']
903 931
904 # TODO(mordred): these next two things should be done by Discover 932 # TODO(mordred): these next two things should be done by Discover
905 # in versioned_data_for. 933 # in versioned_data_for.
diff --git a/keystoneauth1/tests/unit/test_discovery.py b/keystoneauth1/tests/unit/test_discovery.py
index 949746d..23326f7 100644
--- a/keystoneauth1/tests/unit/test_discovery.py
+++ b/keystoneauth1/tests/unit/test_discovery.py
@@ -497,6 +497,7 @@ class VersionDataTests(utils.TestCase):
497 497
498 for v in clean_data: 498 for v in clean_data:
499 self.assertEqual(v['version'], (3, 0)) 499 self.assertEqual(v['version'], (3, 0))
500 self.assertEqual(v['status'], 'CURRENT')
500 self.assertEqual(v['raw_status'], 'stable') 501 self.assertEqual(v['raw_status'], 'stable')
501 self.assertEqual(v['url'], V3_URL) 502 self.assertEqual(v['url'], V3_URL)
502 503
@@ -536,6 +537,7 @@ class VersionDataTests(utils.TestCase):
536 'collection': None, 537 'collection': None,
537 'version': (2, 2), 538 'version': (2, 2),
538 'url': V3_URL, 539 'url': V3_URL,
540 'status': 'CURRENT',
539 'raw_status': 'CURRENT', 541 'raw_status': 'CURRENT',
540 }, 542 },
541 **versions_out 543 **versions_out
@@ -808,6 +810,7 @@ class VersionDataTests(utils.TestCase):
808 'not_before': None, 810 'not_before': None,
809 'version': (1, 0), 811 'version': (1, 0),
810 'url': v1_url, 812 'url': v1_url,
813 'status': 'CURRENT',
811 'raw_status': 'CURRENT', 814 'raw_status': 'CURRENT',
812 }, 815 },
813 { 816 {
@@ -818,6 +821,7 @@ class VersionDataTests(utils.TestCase):
818 'not_before': None, 821 'not_before': None,
819 'version': (2, 0), 822 'version': (2, 0),
820 'url': v2_url, 823 'url': v2_url,
824 'status': 'CURRENT',
821 'raw_status': 'CURRENT', 825 'raw_status': 'CURRENT',
822 }, 826 },
823 { 827 {
@@ -828,6 +832,7 @@ class VersionDataTests(utils.TestCase):
828 'not_before': u'2019-12-31', 832 'not_before': u'2019-12-31',
829 'version': (3, 0), 833 'version': (3, 0),
830 'url': v3_url, 834 'url': v3_url,
835 'status': 'CURRENT',
831 'raw_status': 'CURRENT', 836 'raw_status': 'CURRENT',
832 }, 837 },
833 ]) 838 ])
@@ -893,6 +898,7 @@ class VersionDataTests(utils.TestCase):
893 'not_before': None, 898 'not_before': None,
894 'version': (1, 0), 899 'version': (1, 0),
895 'url': v1_url, 900 'url': v1_url,
901 'status': 'SUPPORTED',
896 'raw_status': 'SUPPORTED', 902 'raw_status': 'SUPPORTED',
897 }, 903 },
898 { 904 {
@@ -903,6 +909,7 @@ class VersionDataTests(utils.TestCase):
903 'not_before': None, 909 'not_before': None,
904 'version': (1, 1), 910 'version': (1, 1),
905 'url': v1_url, 911 'url': v1_url,
912 'status': 'CURRENT',
906 'raw_status': 'CURRENT', 913 'raw_status': 'CURRENT',
907 }, 914 },
908 { 915 {
@@ -913,6 +920,7 @@ class VersionDataTests(utils.TestCase):
913 'not_before': None, 920 'not_before': None,
914 'version': (2, 0), 921 'version': (2, 0),
915 'url': v2_url, 922 'url': v2_url,
923 'status': 'SUPPORTED',
916 'raw_status': 'SUPPORTED', 924 'raw_status': 'SUPPORTED',
917 }, 925 },
918 { 926 {
@@ -923,6 +931,7 @@ class VersionDataTests(utils.TestCase):
923 'not_before': None, 931 'not_before': None,
924 'version': (2, 1), 932 'version': (2, 1),
925 'url': v2_url, 933 'url': v2_url,
934 'status': 'SUPPORTED',
926 'raw_status': 'SUPPORTED', 935 'raw_status': 'SUPPORTED',
927 }, 936 },
928 { 937 {
@@ -933,6 +942,7 @@ class VersionDataTests(utils.TestCase):
933 'not_before': None, 942 'not_before': None,
934 'version': (2, 2), 943 'version': (2, 2),
935 'url': v2_url, 944 'url': v2_url,
945 'status': 'CURRENT',
936 'raw_status': 'CURRENT', 946 'raw_status': 'CURRENT',
937 }, 947 },
938 ]) 948 ])
diff --git a/releasenotes/notes/expose-endpoint-status-6195a6b76d8a8de8.yaml b/releasenotes/notes/expose-endpoint-status-6195a6b76d8a8de8.yaml
new file mode 100644
index 0000000..f625c77
--- /dev/null
+++ b/releasenotes/notes/expose-endpoint-status-6195a6b76d8a8de8.yaml
@@ -0,0 +1,6 @@
1---
2features:
3 - |
4 Added a 'status' field to the `EndpointData` object which contains a
5 canonicalized version of the information in the status field of discovery
6 documents.