1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

fixed Publication manager error on full persistent services

This commit is contained in:
Adolfo Gómez García 2020-04-20 10:18:45 +02:00
parent 8b8135ea98
commit f67730cfad
6 changed files with 48 additions and 30 deletions

View File

@ -142,7 +142,7 @@ class PublicationFinishChecker(DelayedTask):
pc.register(GlobalConfig.SESSION_EXPIRE_TIME.getInt(True) * 3600, 'pclean-' + str(old.id), True) pc.register(GlobalConfig.SESSION_EXPIRE_TIME.getInt(True) * 3600, 'pclean-' + str(old.id), True)
servicePoolPub.setState(State.USABLE) servicePoolPub.setState(State.USABLE)
servicePoolPub.deployed_service.markOldUserServicesAsRemovables(servicePoolPub) # servicePoolPub.deployed_service.markOldUserServicesAsRemovables(servicePoolPub)
elif State.isRemoving(prevState): elif State.isRemoving(prevState):
servicePoolPub.setState(State.REMOVED) servicePoolPub.setState(State.REMOVED)
else: # State is canceling else: # State is canceling

View File

@ -97,20 +97,20 @@ class LiveService(Service):
servicesTypeProvided = (serviceTypes.VDI,) servicesTypeProvided = (serviceTypes.VDI,)
# Now the form part # Now the form part
region = gui.ChoiceField(label=_('Region'), order=1, tooltip=_('Service region'), required=True, rdonly=True) #region = gui.ChoiceField(label=_('Region'), order=1, tooltip=_('Service region'), required=True, rdonly=True)
project = gui.ChoiceField(label=_('Project'), order=2, #project = gui.ChoiceField(label=_('Project'), order=2,
fills={ # fills={
'callbackName' : 'osFillResources', # 'callbackName' : 'osFillResources',
'function' : helpers.getResources, # 'function' : helpers.getResources,
'parameters' : ['ov', 'ev', 'project', 'region', 'legacy'] # 'parameters' : ['ov', 'ev', 'project', 'region', 'legacy']
}, # },
tooltip=_('Project for this service'), required=True, rdonly=True # tooltip=_('Project for this service'), required=True, rdonly=True
) #)
availabilityZone = gui.ChoiceField(label=_('Availability Zones'), order=3, availabilityZone = gui.ChoiceField(label=_('Availability Zones'), order=3,
fills={ fills={
'callbackName' : 'osFillVolumees', 'callbackName' : 'osFillVolumees',
'function' : helpers.getVolumes, 'function' : helpers.getVolumes,
'parameters' : ['ov', 'ev', 'project', 'region', 'availabilityZone', 'legacy'] 'parameters' : ['ov', 'ev', 'availabilityZone', 'legacy']
}, },
tooltip=_('Service availability zones'), required=True, rdonly=True tooltip=_('Service availability zones'), required=True, rdonly=True
) )
@ -168,11 +168,17 @@ class LiveService(Service):
Loads required values inside Loads required values inside
''' '''
api = self.parent().api() api = self.parent().api()
regions = [gui.choiceItem(r['id'], r['id']) for r in api.listRegions()] #regions = [gui.choiceItem(r['id'], r['id']) for r in api.listRegions()]
self.region.setValues(regions) #self.region.setValues(regions)
tenants = [gui.choiceItem(t['id'], t['name']) for t in api.listProjects()] #tenants = [gui.choiceItem(t['id'], t['name']) for t in api.listProjects()]
self.project.setValues(tenants) #self.project.setValues(tenants)
self.availabilityZone.setValues([gui.choiceItem(z, z) for z in api.listAvailabilityZones()])
self.network.setValues([gui.choiceItem(z['id'], z['name']) for z in api.listNetworks()])
self.flavor.setValues([gui.choiceItem(z['id'], z['name']) for z in api.listFlavors()])
self.securityGroups.setValues([gui.choiceItem(z['id'], z['name']) for z in api.listSecurityGroups()])
# volumeTypes = [gui.choiceItem('-', _('None'))] + [gui.choiceItem(t['id'], t['name']) for t in api.listVolumeTypes()]
# So we can instantiate parent to get API # So we can instantiate parent to get API
logger.debug(self.parent().serialize()) logger.debug(self.parent().serialize())
@ -184,7 +190,7 @@ class LiveService(Service):
@property @property
def api(self): def api(self):
if self._api is None: if self._api is None:
self._api = self.parent().api(projectId=self.project.value, region=self.region.value) self._api = self.parent().api()
return self._api return self._api

View File

@ -109,8 +109,8 @@ 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='eu-de')
legacy = False legacy = False
@ -127,6 +127,8 @@ class Provider(ServiceProvider):
self.timeout.value = validators.validateTimeout(self.timeout.value, returnAsInteger=False) self.timeout.value = validators.validateTimeout(self.timeout.value, returnAsInteger=False)
def api(self, projectId=None, region=None): def api(self, projectId=None, region=None):
projectId = projectId or self.tenant.value
region = region or self.region.value
return openStack.Client(self.endpoint.value, -1, return openStack.Client(self.endpoint.value, -1,
self.domain.value, self.username.value, self.password.value, self.domain.value, self.username.value, self.password.value,
legacyVersion=False, legacyVersion=False,

View File

@ -30,7 +30,7 @@ def getResources(parameters):
provider = Provider(env) provider = Provider(env)
provider.unserialize(parameters['ov']) provider.unserialize(parameters['ov'])
api = provider.api(parameters['project'], parameters['region']) api = provider.api()
zones = [gui.choiceItem(z, z) for z in api.listAvailabilityZones()] zones = [gui.choiceItem(z, z) for z in api.listAvailabilityZones()]
networks = [gui.choiceItem(z['id'], z['name']) for z in api.listNetworks()] networks = [gui.choiceItem(z['id'], z['name']) for z in api.listNetworks()]
@ -63,7 +63,7 @@ def getVolumes(parameters):
provider = Provider(env) provider = Provider(env)
provider.unserialize(parameters['ov']) provider.unserialize(parameters['ov'])
api = provider.api(parameters['project'], parameters['region']) api = provider.api()
volumes = [gui.choiceItem(v['id'], v['name']) for v in api.listVolumes() if v['name'] != '' and v['availability_zone'] == parameters['availabilityZone']] volumes = [gui.choiceItem(v['id'], v['name']) for v in api.listVolumes() if v['name'] != '' and v['availability_zone'] == parameters['availabilityZone']]

View File

@ -73,6 +73,7 @@ def getRecurringUrlJson(url, headers, key, params=None, errMsg=None, timeout=10)
counter += 1 counter += 1
logger.debug('Requesting url #{}: {} / {}'.format(counter, url, params)) logger.debug('Requesting url #{}: {} / {}'.format(counter, url, params))
r = requests.get(url, params=params, headers=headers, verify=VERIFY_SSL, timeout=timeout) r = requests.get(url, params=params, headers=headers, verify=VERIFY_SSL, timeout=timeout)
logger.debug('Response: %s', r.content)
ensureResponseIsValid(r, errMsg) ensureResponseIsValid(r, errMsg)
@ -212,6 +213,8 @@ class Client(object):
if self._projectId is not None: if self._projectId is not None:
self._catalog = token['catalog'] self._catalog = token['catalog']
# logger.debug(self._catalog)
def ensureAuthenticated(self): def ensureAuthenticated(self):
if self._authenticated is False or self._projectId != self._authenticatedProjectId: if self._authenticated is False or self._projectId != self._authenticatedProjectId:
self.authPassword() self.authPassword()
@ -474,13 +477,20 @@ class Client(object):
@authProjectRequired @authProjectRequired
def deleteServer(self, serverId): def deleteServer(self, serverId):
r = requests.post(self._getEndpointFor('compute') + '/servers/{server_id}/action'.format(server_id=serverId), r = requests.delete(
data='{"forceDelete": null}', self._getEndpointFor('compute') + '/servers/{server_id}'.format(server_id=serverId),
headers=self._requestHeaders(), headers=self._requestHeaders(),
verify=VERIFY_SSL, verify=VERIFY_SSL,
timeout=self._timeout) timeout=self._timeout
)
ensureResponseIsValid(r, 'Cannot start server (probably server does not exists).') # r = requests.post(self._getEndpointFor('compute') + '/servers/{server_id}/action'.format(server_id=serverId),
# data='{"forceDelete": null}',
# headers=self._requestHeaders(),
# verify=VERIFY_SSL,
# timeout=self._timeout)
ensureResponseIsValid(r, 'Cannot delete server (probably server does not exists).')
# This does not returns anything # This does not returns anything
@ -570,7 +580,7 @@ class Client(object):
logger.exception('Authenticating') logger.exception('Authenticating')
raise Exception(_('Authentication error')) raise Exception(_('Authentication error'))
except Exception: # Not json except Exception: # Not json
# logger.exception('xx') logger.exception('xx')
raise Exception('Invalid endpoint (maybe invalid version selected?)') 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.'))