Commit 6588072b authored by Cédric Le Ninivin's avatar Cédric Le Ninivin Committed by Cédric Le Ninivin

slapos_cloud: Fixes to Software Instance Document and ip list is empty for shared instances

* getSlapTimeStamp use unrestricted method
* use sort by jip_api_revision and not slap_date when sorting shared instances to calculate timestamp
* ip list is empty for shared instances
parent 921482ca
...@@ -181,6 +181,10 @@ class SoftwareInstance(Item, JSONType): ...@@ -181,6 +181,10 @@ class SoftwareInstance(Item, JSONType):
return software_instance_dict return software_instance_dict
def getSlapTimestamp(self): def getSlapTimestamp(self):
return self._getSlapTimestamp()
@UnrestrictedMethod
def _getSlapTimestamp(self):
compute_partition = self.getAggregateValue(portal_type="Compute Partition") compute_partition = self.getAggregateValue(portal_type="Compute Partition")
if compute_partition is None: if compute_partition is None:
return int(self.getModificationDate()) return int(self.getModificationDate())
...@@ -198,13 +202,16 @@ class SoftwareInstance(Item, JSONType): ...@@ -198,13 +202,16 @@ class SoftwareInstance(Item, JSONType):
default_aggregate_uid=compute_partition.getUid(), default_aggregate_uid=compute_partition.getUid(),
portal_type='Slave Instance', portal_type='Slave Instance',
validation_state="validated", validation_state="validated",
sort_on=(("slap_date", "DESC"),), sort_on=(("jio_api_revision.revision", "DESC"),),
select_list=("slap_date",), select_list=('jio_api_revision.revision',),
limit=1, limit=1,
**{"slapos_item.slap_state": "start_requested"} **{"slapos_item.slap_state": "start_requested"}
) )
if shared_instance_sql_list: if shared_instance_sql_list:
most_recent_hosted_instance_timestamp = int(shared_instance_sql_list[0].slap_date) shared_instance = shared_instance_sql_list[0].getObject()
most_recent_hosted_instance_timestamp = int(
shared_instance.getBangTimestamp(int(shared_instance.getModificationDate()))
)
if (most_recent_hosted_instance_timestamp > timestamp): if (most_recent_hosted_instance_timestamp > timestamp):
timestamp = most_recent_hosted_instance_timestamp timestamp = most_recent_hosted_instance_timestamp
...@@ -222,20 +229,21 @@ class SoftwareInstance(Item, JSONType): ...@@ -222,20 +229,21 @@ class SoftwareInstance(Item, JSONType):
ip_list = [] ip_list = []
full_ip_list = [] full_ip_list = []
for internet_protocol_address in compute_partition.contentValues(portal_type='Internet Protocol Address'): if (self.getPortalType() == "Software Instance"):
# XXX - There is new values, and we must keep compatibility for internet_protocol_address in compute_partition.contentValues(portal_type='Internet Protocol Address'):
address_tuple = ( # XXX - There is new values, and we must keep compatibility
internet_protocol_address.getNetworkInterface('').decode("UTF-8"), address_tuple = (
internet_protocol_address.getIpAddress().decode("UTF-8")) internet_protocol_address.getNetworkInterface('').decode("UTF-8"),
if internet_protocol_address.getGatewayIpAddress('') and \ internet_protocol_address.getIpAddress().decode("UTF-8"))
internet_protocol_address.getNetmask(''): if internet_protocol_address.getGatewayIpAddress('') and \
address_tuple = address_tuple + ( internet_protocol_address.getNetmask(''):
internet_protocol_address.getGatewayIpAddress().decode("UTF-8"), address_tuple = address_tuple + (
internet_protocol_address.getNetmask().decode("UTF-8"), internet_protocol_address.getGatewayIpAddress().decode("UTF-8"),
internet_protocol_address.getNetworkAddress('').decode("UTF-8")) internet_protocol_address.getNetmask().decode("UTF-8"),
full_ip_list.append(address_tuple) internet_protocol_address.getNetworkAddress('').decode("UTF-8"))
else: full_ip_list.append(address_tuple)
ip_list.append(address_tuple) else:
ip_list.append(address_tuple)
shared_instance_list = [] shared_instance_list = []
if (self.getPortalType() == "Software Instance"): if (self.getPortalType() == "Software Instance"):
......
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
</pickle> </pickle>
<pickle> <pickle>
<dictionary> <dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>default_reference</string> </key> <key> <string>default_reference</string> </key>
<value> <string>SoftwareInstance</string> </value> <value> <string>SoftwareInstance</string> </value>
...@@ -55,28 +49,13 @@ ...@@ -55,28 +49,13 @@
<item> <item>
<key> <string>workflow_history</string> </key> <key> <string>workflow_history</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="PersistentMapping" module="Persistence.mapping"/> <global name="PersistentMapping" module="Persistence.mapping"/>
</pickle> </pickle>
...@@ -89,7 +68,7 @@ ...@@ -89,7 +68,7 @@
<item> <item>
<key> <string>component_validation_workflow</string> </key> <key> <string>component_validation_workflow</string> </key>
<value> <value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
</dictionary> </dictionary>
...@@ -98,7 +77,7 @@ ...@@ -98,7 +77,7 @@
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ="> <record id="3" aka="AAAAAAAAAAM=">
<pickle> <pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/> <global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle> </pickle>
......
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