mirror of
https://github.com/dkmstr/openuds.git
synced 2024-12-22 13:34:04 +03:00
* Deadline now on its own method
* Removed deadline from notifyUrls. It was a nonsense :).
This commit is contained in:
parent
1f5a647ff3
commit
7c3e289a6b
@ -104,21 +104,13 @@ class OGDeployment(UserDeployment):
|
||||
|
||||
def setReady(self):
|
||||
'''
|
||||
Right now, this does nothing on OG.
|
||||
Notifies the current "deadline" to the user, before accessing by UDS
|
||||
The machine has been already been started.
|
||||
The problem is that currently there is no way that a machine is in FACT started.
|
||||
OpenGnsys will try it best by sending an WOL
|
||||
'''
|
||||
# if self.cache.get('ready') == '1':
|
||||
# return State.FINISHED
|
||||
self.service().notifyDeadline(self.dbservice().deployed_service.getDeadline())
|
||||
|
||||
# status = self.service().status(self._machineId)
|
||||
# possible status are ("off", "oglive", "busy", "linux", "windows", "macos" o "unknown").
|
||||
# if status['status'] != 'off':
|
||||
# self.cache.put('ready', '1')
|
||||
# return State.FINISHED
|
||||
|
||||
# Return back machine to preparing?...
|
||||
return State.FINISHED
|
||||
|
||||
def deployForUser(self, user):
|
||||
@ -236,8 +228,7 @@ class OGDeployment(UserDeployment):
|
||||
'''
|
||||
try:
|
||||
r = self.service().reserve()
|
||||
deadLine = self.dbservice().deployed_service.getDeadline()
|
||||
self.service().notifyEvents(r['id'], self._uuid, deadLine)
|
||||
self.service().notifyEvents(r['id'], self._uuid)
|
||||
except Exception as e:
|
||||
# logger.exception('Creating machine')
|
||||
return self.__error('Error creating reservation: {}'.format(e))
|
||||
|
@ -163,8 +163,11 @@ class OGService(Service):
|
||||
def unreserve(self, machineId):
|
||||
return self.parent().unreserve(machineId)
|
||||
|
||||
def notifyEvents(self, machineId, serviceUUID, deadLine):
|
||||
return self.parent().notifyEvents(machineId, self.getLoginNotifyURL(serviceUUID), self.getLogoutNotifyURL(serviceUUID), deadLine)
|
||||
def notifyEvents(self, machineId, serviceUUID):
|
||||
return self.parent().notifyEvents(machineId, self.getLoginNotifyURL(serviceUUID), self.getLogoutNotifyURL(serviceUUID))
|
||||
|
||||
def notifyDeadline(self, machineId, deadLine):
|
||||
return self.parent().notifyDeadline(machineId, deadLine)
|
||||
|
||||
def _notifyURL(self, uuid, message):
|
||||
# The URL is "GET messages URL".
|
||||
|
@ -191,8 +191,11 @@ class OGProvider(ServiceProvider):
|
||||
def unreserve(self, machineId):
|
||||
return self.api.unreserve(machineId)
|
||||
|
||||
def notifyEvents(self, machineId, loginURL, logoutURL, deadLine):
|
||||
return self.api.notifyURLs(machineId, loginURL, logoutURL, deadLine)
|
||||
def notifyEvents(self, machineId, loginURL, logoutURL):
|
||||
return self.api.notifyURLs(machineId, loginURL, logoutURL)
|
||||
|
||||
def notifyDeadline(self, machineId, deadLine):
|
||||
return self.api.notifyDeadline(machineId, deadLine)
|
||||
|
||||
def status(self, machineId):
|
||||
return self.api.status(machineId)
|
||||
|
@ -45,8 +45,6 @@ import six
|
||||
import requests
|
||||
import json
|
||||
|
||||
__updated__ = '2017-10-16'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# URLS
|
||||
@ -216,17 +214,26 @@ class OpenGnsysClient(object):
|
||||
return self._delete(urls.UNRESERVE.format(ou=ou, lab=lab, client=client), errMsg=errMsg)
|
||||
|
||||
@ensureConnected
|
||||
def notifyURLs(self, machineId, loginURL, logoutURL, deadLine):
|
||||
def notifyURLs(self, machineId, loginURL, logoutURL):
|
||||
ou, lab, client = machineId.split('.')
|
||||
errMsg = 'Notifying login/logout urls'
|
||||
data = {
|
||||
'urlLogin': loginURL,
|
||||
'urlLogout': logoutURL,
|
||||
'deadLine': deadLine
|
||||
'urlLogout': logoutURL
|
||||
}
|
||||
|
||||
return self._post(urls.EVENTS.format(ou=ou, lab=lab, client=client), data, errMsg=errMsg)
|
||||
|
||||
@ensureConnected
|
||||
def notifyDeadline(self, machineId, deadLine):
|
||||
ou, lab, client = machineId.split('.')
|
||||
errMsg = 'Notifying deadline'
|
||||
data = {
|
||||
'deadLine': deadLine
|
||||
}
|
||||
|
||||
return self._post(urls.SESSIONS.format(ou=ou, lab=lab, client=client), data, errMsg=errMsg)
|
||||
|
||||
|
||||
@ensureConnected
|
||||
def status(self, id):
|
||||
|
@ -44,3 +44,4 @@ RESERVE = '/ous/{ou}/images/{image}/reserve'
|
||||
UNRESERVE = '/ous/{ou}/labs/{lab}/clients/{client}/unreserve'
|
||||
STATUS = '/ous/{ou}/labs/{lab}/clients/{client}/status'
|
||||
EVENTS = '/ous/{ou}/labs/{lab}/clients/{client}/events'
|
||||
SESSIONS = '/ous/{ou}/labs/{lab}/clients/{client}/session'
|
||||
|
Loading…
Reference in New Issue
Block a user