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): ...@@ -190,13 +190,19 @@ class SoftwareRelease(SlapDocument):
return self._software_release return self._software_release
def error(self, error_log, logger=None): def error(self, error_log, logger=None):
try:
# Does not follow interface # Does not follow interface
self._connection_helper.POST('softwareReleaseError', data={ try:
self._connection_helper.callJsonRpcAPI(
'slapos.put.software_installation',
{
'url': self.getURI(), 'url': self.getURI(),
'computer_id': self.getComputerId(), 'computer_id': self.getComputerId(),
'error_log': error_log}) 'error_log': error_log
except Exception: }
)
except (RequestException, ConnectionError):
# Do not block the caller if the connection
# to the slapos master fails
(logger or fallback_logger).exception('') (logger or fallback_logger).exception('')
def available(self): def available(self):
...@@ -533,30 +539,52 @@ class ComputerPartition(SlapRequester): ...@@ -533,30 +539,52 @@ class ComputerPartition(SlapRequester):
return self._requestComputerPartition(request_dict) return self._requestComputerPartition(request_dict)
def destroyed(self): def destroyed(self):
self._connection_helper.POST('destroyedComputerPartition', data={ self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"reported_state": "destroyed",
'computer_id': self._computer_id, 'computer_id': self._computer_id,
'computer_partition_id': self.getId(), 'computer_partition_id': self.getId()
}) }
)
def started(self): def started(self):
self._connection_helper.POST('startedComputerPartition', data={ self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"reported_state": "started",
'computer_id': self._computer_id, 'computer_id': self._computer_id,
'computer_partition_id': self.getId(), 'computer_partition_id': self.getId()
}) }
)
def stopped(self): def stopped(self):
self._connection_helper.POST('stoppedComputerPartition', data={ self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"reported_state": "stopped",
'computer_id': self._computer_id, 'computer_id': self._computer_id,
'computer_partition_id': self.getId(), 'computer_partition_id': self.getId()
}) }
)
def error(self, error_log, logger=None): def error(self, error_log, logger=None):
try: try:
self._connection_helper.POST('softwareInstanceError', data={ self._connection_helper.callJsonRpcAPI(
'slapos.put.software_instance',
{
"portal_type": "Software Instance",
"status_message": str(error_log),
'computer_id': self._computer_id, 'computer_id': self._computer_id,
'computer_partition_id': self.getId(), 'computer_partition_id': self.getId()
'error_log': error_log}) }
except Exception: )
except (RequestException, ConnectionError):
# Do not block the caller if the connection
# to the slapos master fails
(logger or fallback_logger).exception('') (logger or fallback_logger).exception('')
def bang(self, message): 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