Created
October 4, 2018 15:13
-
-
Save kamidzi/784b566cc0d93e95a733f59a163f36f3 to your computer and use it in GitHub Desktop.
Use string literals for novaclient api versions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from novaclient.client import Client as NovaClient | |
from ka_auth import get_session | |
from decimal import Decimal | |
str_versions = ['2', '2.1', '2.10', '2.26', '2.59', '2.60'] | |
if __name__ == '__main__': | |
novaclient = __import__('novaclient') | |
attrs = ('API_MAX_VERSION', 'API_MIN_VERSION', '__version__') | |
for a in attrs: | |
print('novaclient.{:16}: {}'.format(a, getattr(novaclient, a))) | |
def typed_versions(ver): | |
types = (float, int, str, Decimal) | |
for t in types: | |
try: | |
yield (t, t(ver)) | |
except ValueError: | |
pass | |
sess = get_session() | |
print() | |
print('Versions to test:', str_versions) | |
print() | |
for ver in str_versions: | |
for type_, arg in typed_versions(ver): | |
nova = NovaClient(arg, session=sess) | |
print( | |
'{:4} as {:8} ({:>4}): {}'.format(ver, type_.__name__, arg, nova.api_version) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
novaclient.API_MAX_VERSION : API Version Major: 2, Minor: 65 | |
novaclient.API_MIN_VERSION : API Version Major: 2, Minor: 1 | |
novaclient.__version__ : 11.0.0 | |
Versions to test: ['2', '2.1', '2.10', '2.26', '2.59', '2.60'] | |
2 as float ( 2.0): API Version Major: 2, Minor: 0 | |
2 as int ( 2): API Version Major: 2, Minor: 0 | |
2 as str ( 2): API Version Major: 2, Minor: 0 | |
2 as Decimal ( 2): API Version Major: 2, Minor: 0 | |
2.1 as float ( 2.1): API Version Major: 2, Minor: 1 | |
2.1 as str ( 2.1): API Version Major: 2, Minor: 1 | |
2.1 as Decimal ( 2.1): API Version Major: 2, Minor: 1 | |
2.10 as float ( 2.1): API Version Major: 2, Minor: 1 | |
2.10 as str (2.10): API Version Major: 2, Minor: 10 | |
2.10 as Decimal (2.10): API Version Major: 2, Minor: 10 | |
2.26 as float (2.26): API Version Major: 2, Minor: 26 | |
2.26 as str (2.26): API Version Major: 2, Minor: 26 | |
2.26 as Decimal (2.26): API Version Major: 2, Minor: 26 | |
2.59 as float (2.59): API Version Major: 2, Minor: 59 | |
2.59 as str (2.59): API Version Major: 2, Minor: 59 | |
2.59 as Decimal (2.59): API Version Major: 2, Minor: 59 | |
2.60 as float ( 2.6): API Version Major: 2, Minor: 6 | |
2.60 as str (2.60): API Version Major: 2, Minor: 60 | |
2.60 as Decimal (2.60): API Version Major: 2, Minor: 60 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment