Commit fc74fe8b authored by Romain Courteaud's avatar Romain Courteaud

slapos_cloud: test: check remote node parameters propagation

parent df876a5e
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject() portal = context.getPortalObject()
compute_partition = context compute_partition = context
...@@ -21,18 +25,37 @@ else: ...@@ -21,18 +25,37 @@ else:
)] )]
for local_instance in local_instance_list: for local_instance in local_instance_list:
# XXX TODO this will increase the workflow history # do not increase the workflow history
# Use the 'cached' API instead # Use the 'cached' API instead
remote_person.requestSoftwareInstance( # manually search the instance and compare all parameters
project_reference=remote_project.getReference(), remote_instance_tree = portal.portal_catalog.getResultValue(
software_release=local_instance.getUrlString(), portal_type='Instance Tree',
software_title='_remote_%s_%s' % (remote_node.getFollowUpReference(), local_instance.getReference()), validation_state='validated',
software_type=local_instance.getSourceReference(), destination_section__uid=remote_person.getUid(),
instance_xml=local_instance.getTextContent(), follow_up__uid=remote_project.getUid(),
sla_xml=None, title='_remote_%s_%s' % (local_instance.getFollowUpReference(),
shared=(local_instance.getPortalType() == 'Slave Instance'), local_instance.getReference())
state={'start_requested': 'started', 'stop_requested': 'stopped'}[local_instance.getSlapState()]
) )
requested_software_instance = context.REQUEST.get('request_instance')
if requested_software_instance is not None: if remote_instance_tree is not None:
local_instance.setConnectionXml(requested_software_instance.getConnectionXml()) requested_software_instance = remote_instance_tree.getSuccessorValue(title=remote_instance_tree.getTitle())
if (remote_instance_tree is None) or \
(local_instance.getTextContent() != remote_instance_tree.getTextContent()) or \
(local_instance.getSlapState() != remote_instance_tree.getSlapState()):
remote_person.requestSoftwareInstance(
project_reference=remote_project.getReference(),
software_release=local_instance.getUrlString(),
software_title='_remote_%s_%s' % (remote_node.getFollowUpReference(), local_instance.getReference()),
software_type=local_instance.getSourceReference(),
instance_xml=local_instance.getTextContent(),
sla_xml=None,
shared=(local_instance.getPortalType() == 'Slave Instance'),
state={'start_requested': 'started', 'stop_requested': 'stopped'}[local_instance.getSlapState()]
)
requested_software_instance = context.REQUEST.get('request_instance')
if (requested_software_instance is not None) and \
(requested_software_instance.getConnectionXml() != local_instance.getConnectionXml()):
local_instance.edit(connection_xml=requested_software_instance.getConnectionXml())
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>REQUEST=None</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -345,19 +345,29 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -345,19 +345,29 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
self.requested_software_instance.validate() self.requested_software_instance.validate()
self.tic() self.tic()
def addComputeNodeAndPartition(self, project=None): def addComputeNodeAndPartition(self, project=None,
portal_type='Compute Node'):
# XXX replace _makeComputeNode # XXX replace _makeComputeNode
if project is None: if project is None:
project = self.addProject() project = self.addProject()
self.tic() self.tic()
edit_kw = {}
if portal_type == 'Remote Node':
# Be nice, and create remote user/project
remote_project = self.addProject()
remote_user = self.makePerson(remote_project)
edit_kw['destination_project_value'] = remote_project
edit_kw['destination_section_value'] = remote_user
reference = 'TESTCOMP-%s' % self.generateNewId() reference = 'TESTCOMP-%s' % self.generateNewId()
compute_node = self.portal.compute_node_module.newContent( compute_node = self.portal.compute_node_module.newContent(
portal_type="Compute Node", portal_type=portal_type,
#allocation_scope=allocation_scope, #allocation_scope=allocation_scope,
reference=reference, reference=reference,
title=reference, title=reference,
follow_up_value=project follow_up_value=project,
**edit_kw
) )
# The edit above will update capacity scope due the interaction workflow # The edit above will update capacity scope due the interaction workflow
# The line above force capacity scope to be open, keeping the previous # The line above force capacity scope to be open, keeping the previous
......
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