diff --git a/server/src/uds/core/managers/PublicationManager.py b/server/src/uds/core/managers/PublicationManager.py index 5a26026a1..2a94c84d2 100644 --- a/server/src/uds/core/managers/PublicationManager.py +++ b/server/src/uds/core/managers/PublicationManager.py @@ -142,7 +142,7 @@ class PublicationFinishChecker(DelayedTask): pc.register(GlobalConfig.SESSION_EXPIRE_TIME.getInt(True) * 3600, 'pclean-' + str(old.id), True) servicePoolPub.setState(State.USABLE) - servicePoolPub.deployed_service.markOldUserServicesAsRemovables(servicePoolPub) + # servicePoolPub.deployed_service.markOldUserServicesAsRemovables(servicePoolPub) elif State.isRemoving(prevState): servicePoolPub.setState(State.REMOVED) else: # State is canceling diff --git a/server/src/uds/core/managers/userservice/opchecker.py b/server/src/uds/core/managers/userservice/opchecker.py index 3f55eaa92..656c5e864 100644 --- a/server/src/uds/core/managers/userservice/opchecker.py +++ b/server/src/uds/core/managers/userservice/opchecker.py @@ -72,9 +72,9 @@ class StateUpdater(object): def run(self, state): executor = { - State.RUNNING: self.running, - State.ERROR: self.error, - State.FINISHED: self.finish + State.RUNNING: self.running, + State.ERROR: self.error, + State.FINISHED: self.finish }.get(state, self.error) logger.debug('Running updater with state {} and executor {}'.format(State.toString(state), executor)) diff --git a/server/src/uds/services/OpenStack/LiveService.py b/server/src/uds/services/OpenStack/LiveService.py index bee7c0f0b..12c458305 100644 --- a/server/src/uds/services/OpenStack/LiveService.py +++ b/server/src/uds/services/OpenStack/LiveService.py @@ -97,20 +97,20 @@ class LiveService(Service): servicesTypeProvided = (serviceTypes.VDI,) # Now the form part - region = gui.ChoiceField(label=_('Region'), order=1, tooltip=_('Service region'), required=True, rdonly=True) - project = gui.ChoiceField(label=_('Project'), order=2, - fills={ - 'callbackName' : 'osFillResources', - 'function' : helpers.getResources, - 'parameters' : ['ov', 'ev', 'project', 'region', 'legacy'] - }, - tooltip=_('Project for this service'), 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, + # fills={ + # 'callbackName' : 'osFillResources', + # 'function' : helpers.getResources, + # 'parameters' : ['ov', 'ev', 'project', 'region', 'legacy'] + # }, + # tooltip=_('Project for this service'), required=True, rdonly=True + #) availabilityZone = gui.ChoiceField(label=_('Availability Zones'), order=3, fills={ 'callbackName' : 'osFillVolumees', 'function' : helpers.getVolumes, - 'parameters' : ['ov', 'ev', 'project', 'region', 'availabilityZone', 'legacy'] + 'parameters' : ['ov', 'ev', 'availabilityZone', 'legacy'] }, tooltip=_('Service availability zones'), required=True, rdonly=True ) @@ -168,11 +168,17 @@ class LiveService(Service): Loads required values inside ''' api = self.parent().api() - regions = [gui.choiceItem(r['id'], r['id']) for r in api.listRegions()] - self.region.setValues(regions) + #regions = [gui.choiceItem(r['id'], r['id']) for r in api.listRegions()] + #self.region.setValues(regions) - tenants = [gui.choiceItem(t['id'], t['name']) for t in api.listProjects()] - self.project.setValues(tenants) + #tenants = [gui.choiceItem(t['id'], t['name']) for t in api.listProjects()] + #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 logger.debug(self.parent().serialize()) @@ -184,7 +190,7 @@ class LiveService(Service): @property def api(self): 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 diff --git a/server/src/uds/services/OpenStack/Provider.py b/server/src/uds/services/OpenStack/Provider.py index d5757dadd..a1dbcfd2d 100644 --- a/server/src/uds/services/OpenStack/Provider.py +++ b/server/src/uds/services/OpenStack/Provider.py @@ -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) - # 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') + 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='eu-de') legacy = False @@ -127,6 +127,8 @@ class Provider(ServiceProvider): self.timeout.value = validators.validateTimeout(self.timeout.value, returnAsInteger=False) 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, self.domain.value, self.username.value, self.password.value, legacyVersion=False, diff --git a/server/src/uds/services/OpenStack/helpers.py b/server/src/uds/services/OpenStack/helpers.py index ac02eb106..934119e2a 100644 --- a/server/src/uds/services/OpenStack/helpers.py +++ b/server/src/uds/services/OpenStack/helpers.py @@ -30,7 +30,7 @@ def getResources(parameters): provider = Provider(env) provider.unserialize(parameters['ov']) - api = provider.api(parameters['project'], parameters['region']) + api = provider.api() zones = [gui.choiceItem(z, z) for z in api.listAvailabilityZones()] networks = [gui.choiceItem(z['id'], z['name']) for z in api.listNetworks()] @@ -63,7 +63,7 @@ def getVolumes(parameters): provider = Provider(env) 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']] diff --git a/server/src/uds/services/OpenStack/openStack/UDSOpenStackClient.py b/server/src/uds/services/OpenStack/openStack/UDSOpenStackClient.py index 23fee91ac..57d8837bc 100644 --- a/server/src/uds/services/OpenStack/openStack/UDSOpenStackClient.py +++ b/server/src/uds/services/OpenStack/openStack/UDSOpenStackClient.py @@ -73,6 +73,7 @@ def getRecurringUrlJson(url, headers, key, params=None, errMsg=None, timeout=10) counter += 1 logger.debug('Requesting url #{}: {} / {}'.format(counter, url, params)) r = requests.get(url, params=params, headers=headers, verify=VERIFY_SSL, timeout=timeout) + logger.debug('Response: %s', r.content) ensureResponseIsValid(r, errMsg) @@ -212,6 +213,8 @@ class Client(object): if self._projectId is not None: self._catalog = token['catalog'] + # logger.debug(self._catalog) + def ensureAuthenticated(self): if self._authenticated is False or self._projectId != self._authenticatedProjectId: self.authPassword() @@ -474,13 +477,20 @@ class Client(object): @authProjectRequired def deleteServer(self, serverId): - 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) + r = requests.delete( + self._getEndpointFor('compute') + '/servers/{server_id}'.format(server_id=serverId), + headers=self._requestHeaders(), + verify=VERIFY_SSL, + 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 @@ -570,7 +580,7 @@ class Client(object): logger.exception('Authenticating') raise Exception(_('Authentication error')) except Exception: # Not json - # logger.exception('xx') + 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.'))