Commit 3b63e39d authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Romain Courteaud

slapos_cloud: Add useRevision to SoftwareInstance

parent 495e6e93
......@@ -183,6 +183,9 @@ class SoftwareInstance(Item, JSONType):
def getSlapTimestamp(self):
return self._getSlapTimestamp()
def useRevision(self):
return getattr(self, "use_jio_api_revision", False)
@UnrestrictedMethod
def _getSlapTimestamp(self):
compute_partition = self.getAggregateValue(portal_type="Compute Partition")
......@@ -198,6 +201,8 @@ class SoftwareInstance(Item, JSONType):
# XXX In the current what shared instances are processed, they cannot be reprocessed if the
# host instance is not processed
if (self.getPortalType() == "Software Instance"):
shared_instance_sql_list = []
if self.useRevision():
shared_instance_sql_list = self.getPortalObject().portal_catalog.unrestrictedSearchResults(
default_aggregate_uid=compute_partition.getUid(),
portal_type='Slave Instance',
......@@ -207,13 +212,20 @@ class SoftwareInstance(Item, JSONType):
limit=1,
**{"slapos_item.slap_state": "start_requested"}
)
if shared_instance_sql_list:
shared_instance = shared_instance_sql_list[0].getObject()
most_recent_hosted_instance_timestamp = int(
shared_instance.getBangTimestamp(int(shared_instance.getModificationDate()))
else:
shared_instance_sql_list = self.getPortalObject().portal_catalog.unrestrictedSearchResults(
default_aggregate_uid=compute_partition.getUid(),
portal_type='Slave Instance',
validation_state="validated",
**{"slapos_item.slap_state": "start_requested"}
)
if (most_recent_hosted_instance_timestamp > timestamp):
timestamp = most_recent_hosted_instance_timestamp
for shared_instance in shared_instance_sql_list:
shared_instance = _assertACI(shared_instance.getObject())
# XXX Use catalog to filter more efficiently
if shared_instance.getSlapState() == "start_requested":
newtimestamp = int(shared_instance.getBangTimestamp(int(shared_instance.getModificationDate())))
if (newtimestamp > timestamp):
timestamp = newtimestamp
return timestamp
......@@ -398,6 +410,7 @@ class SoftwareInstance(Item, JSONType):
"access_status_message": self.getTextAccessStatus(),
"portal_type": self.getPortalType(),
}
if self.useRevision():
web_section = self.getWebSectionValue()
web_section = web_section.getRelativeUrl() if web_section else self.REQUEST.get("web_section_relative_url", None)
if web_section:
......
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