mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
Fixed so UDS now works correctly with versiones newer that OCATA
This commit is contained in:
parent
5fbdb6834d
commit
8c85639dfe
@ -44,7 +44,7 @@ from . import openStack
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
__updated__ = '2016-04-25'
|
__updated__ = '2018-09-18'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -54,6 +54,7 @@ INTERFACE_VALUES = [
|
|||||||
gui.choiceItem('admin', 'admin'),
|
gui.choiceItem('admin', 'admin'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class Provider(ServiceProvider):
|
class Provider(ServiceProvider):
|
||||||
'''
|
'''
|
||||||
This class represents the sample services provider
|
This class represents the sample services provider
|
||||||
@ -97,9 +98,10 @@ class Provider(ServiceProvider):
|
|||||||
# "random"
|
# "random"
|
||||||
host = gui.TextField(length=64, label=_('Host'), order=1, tooltip=_('OpenStack Host'), required=True)
|
host = gui.TextField(length=64, label=_('Host'), order=1, tooltip=_('OpenStack Host'), required=True)
|
||||||
port = gui.NumericField(length=5, label=_('Port'), defvalue='5000', order=2, tooltip=_('OpenStack Port'), required=True)
|
port = gui.NumericField(length=5, label=_('Port'), defvalue='5000', order=2, tooltip=_('OpenStack Port'), required=True)
|
||||||
ssl = gui.CheckBoxField(label=_('Use SSL'), order=3, tooltip=_('If checked, the connection will be forced to be ssl (will not work if server is not providing ssl)'))
|
newVersion = gui.CheckBoxField(label=_('Newer Openstack'), order=3, tooltip=_('Check this if your openstack is newer than OCATA'))
|
||||||
|
ssl = gui.CheckBoxField(label=_('Use SSL'), order=4, tooltip=_('If checked, the connection will be forced to be ssl (will not work if server is not providing ssl)'))
|
||||||
|
|
||||||
access = gui.ChoiceField(label=_('Access interface'), order=4, tooltip=_('Access interface to be used'), values=INTERFACE_VALUES, defvalue='public')
|
access = gui.ChoiceField(label=_('Access interface'), order=5, tooltip=_('Access interface to be used'), values=INTERFACE_VALUES, defvalue='public')
|
||||||
|
|
||||||
domain = gui.TextField(length=64, label=_('Domain'), order=8, tooltip=_('Domain name (default is Default)'), required=True, defvalue='Default')
|
domain = gui.TextField(length=64, label=_('Domain'), order=8, tooltip=_('Domain name (default is Default)'), required=True, defvalue='Default')
|
||||||
username = gui.TextField(length=64, label=_('Username'), order=9, tooltip=_('User with valid privileges on OpenStack'), required=True, defvalue='admin')
|
username = gui.TextField(length=64, label=_('Username'), order=9, tooltip=_('User with valid privileges on OpenStack'), required=True, defvalue='admin')
|
||||||
@ -110,7 +112,6 @@ class Provider(ServiceProvider):
|
|||||||
|
|
||||||
timeout = gui.NumericField(length=3, label=_('Timeout'), defvalue='10', minValue=1, maxValue=128, order=99, tooltip=_('Timeout in seconds of connection to OpenStack'), required=True, tab=gui.ADVANCED_TAB)
|
timeout = gui.NumericField(length=3, label=_('Timeout'), defvalue='10', minValue=1, maxValue=128, order=99, tooltip=_('Timeout in seconds of connection to OpenStack'), required=True, tab=gui.ADVANCED_TAB)
|
||||||
|
|
||||||
|
|
||||||
# tenant = gui.TextField(length=64, label=_('Project'), order=6, tooltip=_('Project (tenant) for this provider'), required=True, defvalue='')
|
# tenant = gui.TextField(length=64, label=_('Project'), order=6, tooltip=_('Project (tenant) for this provider'), required=True, defvalue='')
|
||||||
# region = gui.TextField(length=64, label=_('Region'), order=7, tooltip=_('Region for this provider'), required=True, defvalue='RegionOne')
|
# region = gui.TextField(length=64, label=_('Region'), order=7, tooltip=_('Region for this provider'), required=True, defvalue='RegionOne')
|
||||||
|
|
||||||
@ -129,6 +130,7 @@ class Provider(ServiceProvider):
|
|||||||
def api(self, projectId=None, region=None):
|
def api(self, projectId=None, region=None):
|
||||||
return openStack.Client(self.host.value, self.port.value,
|
return openStack.Client(self.host.value, self.port.value,
|
||||||
self.domain.value, self.username.value, self.password.value,
|
self.domain.value, self.username.value, self.password.value,
|
||||||
|
newVersion=self.newVersion.isTrue(),
|
||||||
useSSL=self.ssl.isTrue(),
|
useSSL=self.ssl.isTrue(),
|
||||||
projectId=projectId,
|
projectId=projectId,
|
||||||
region=region,
|
region=region,
|
||||||
|
@ -39,7 +39,7 @@ import json
|
|||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
import six
|
import six
|
||||||
|
|
||||||
__updated__ = '2018-06-29'
|
__updated__ = '2018-09-18'
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -117,7 +117,8 @@ class Client(object):
|
|||||||
PRIVATE = 'private'
|
PRIVATE = 'private'
|
||||||
INTERNAL = 'url'
|
INTERNAL = 'url'
|
||||||
|
|
||||||
def __init__(self, host, port, domain, username, password, useSSL=False, projectId=None, region=None, access=None):
|
# NewVersion is True for versions >= Ocata
|
||||||
|
def __init__(self, host, port, domain, username, password, newVersion=False, useSSL=False, projectId=None, region=None, access=None):
|
||||||
self._authenticated = False
|
self._authenticated = False
|
||||||
self._tokenId = None
|
self._tokenId = None
|
||||||
self._catalog = None
|
self._catalog = None
|
||||||
@ -131,7 +132,7 @@ class Client(object):
|
|||||||
self._region = region
|
self._region = region
|
||||||
self._timeout = 10
|
self._timeout = 10
|
||||||
|
|
||||||
self._authUrl = 'http{}://{}:{}/'.format('s' if useSSL else '', host, port)
|
self._authUrl = 'http{}://{}:{}/{}'.format('s' if useSSL else '', host, port, 'identity/' if newVersion else '')
|
||||||
|
|
||||||
def _getEndpointFor(self, type_): # If no region is indicatad, first endpoint is returned
|
def _getEndpointFor(self, type_): # If no region is indicatad, first endpoint is returned
|
||||||
for i in self._catalog:
|
for i in self._catalog:
|
||||||
@ -543,13 +544,18 @@ class Client(object):
|
|||||||
except Exception:
|
except Exception:
|
||||||
raise Exception('Connection error')
|
raise Exception('Connection error')
|
||||||
|
|
||||||
|
try:
|
||||||
for v in r.json()['versions']['values']:
|
for v in r.json()['versions']['values']:
|
||||||
if v['id'] >= 'v3.2':
|
if v['id'] >= 'v3.1':
|
||||||
# Tries to authenticate
|
# Tries to authenticate
|
||||||
try:
|
try:
|
||||||
self.authPassword()
|
self.authPassword()
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
|
logger.exception('Authenticating')
|
||||||
raise Exception(_('Authentication error'))
|
raise Exception(_('Authentication error'))
|
||||||
|
except Exception: # Not json
|
||||||
|
# logger.exception('xx')
|
||||||
|
raise Exception('Invalid endpoint (maybe invalid version selected?)')
|
||||||
|
|
||||||
raise Exception(_('Openstack does not support identity API 3.2 or newer. This OpenStack server is not compatible with UDS.'))
|
raise Exception(_('Openstack does not support identity API 3.2 or newer. This OpenStack server is not compatible with UDS.'))
|
||||||
|
Loading…
Reference in New Issue
Block a user