Commit 3b7416ea authored by Romain Courteaud's avatar Romain Courteaud 🐸

slap/slap.py: error, started, stopped, destroyed

parent 52fec046
......@@ -190,13 +190,19 @@ class SoftwareRelease(SlapDocument):
return self._software_release
def error(self, error_log, logger=None):
# Does not follow interface
try:
# Does not follow interface
self._connection_helper.POST('softwareReleaseError', data={
'url': self.getURI(),
'computer_id': self.getComputerId(),
'error_log': error_log})
except Exception:
self._connection_helper.callJsonRpcAPI(
'slapos.put.software_installation',
{
'url': self.getURI(),
'computer_id': self.getComputerId(),
'error_log': error_log
}
)
except (RequestException, ConnectionError):
# Do not block the caller if the connection
# to the slapos master fails
(logger or fallback_logger).exception('')
def available(self):
......@@ -533,30 +539,52 @@ class ComputerPartition(SlapRequester):
return self._requestComputerPartition(request_dict)
def destroyed(self):
self._connection_helper.POST('destroyedComputerPartition', data={
'computer_id': self._computer_id,
'computer_partition_id': self.getId(),
})
self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"reported_state": "destroyed",
'computer_id': self._computer_id,
'computer_partition_id': self.getId()
}
)
def started(self):
self._connection_helper.POST('startedComputerPartition', data={
'computer_id': self._computer_id,
'computer_partition_id': self.getId(),
})
self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"reported_state": "started",
'computer_id': self._computer_id,
'computer_partition_id': self.getId()
}
)
def stopped(self):
self._connection_helper.POST('stoppedComputerPartition', data={
'computer_id': self._computer_id,
'computer_partition_id': self.getId(),
})
self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"reported_state": "stopped",
'computer_id': self._computer_id,
'computer_partition_id': self.getId()
}
)
def error(self, error_log, logger=None):
try:
self._connection_helper.POST('softwareInstanceError', data={
'computer_id': self._computer_id,
'computer_partition_id': self.getId(),
'error_log': error_log})
except Exception:
self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"status_message": str(error_log),
'computer_id': self._computer_id,
'computer_partition_id': self.getId()
}
)
except (RequestException, ConnectionError):
# Do not block the caller if the connection
# to the slapos master fails
(logger or fallback_logger).exception('')
def bang(self, message):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment