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()
compute_partition = context
......@@ -21,18 +25,37 @@ else:
)]
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
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()]
# manually search the instance and compare all parameters
remote_instance_tree = portal.portal_catalog.getResultValue(
portal_type='Instance Tree',
validation_state='validated',
destination_section__uid=remote_person.getUid(),
follow_up__uid=remote_project.getUid(),
title='_remote_%s_%s' % (local_instance.getFollowUpReference(),
local_instance.getReference())
)
requested_software_instance = context.REQUEST.get('request_instance')
if requested_software_instance is not None:
local_instance.setConnectionXml(requested_software_instance.getConnectionXml())
if remote_instance_tree is not None:
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 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -345,19 +345,29 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
self.requested_software_instance.validate()
self.tic()
def addComputeNodeAndPartition(self, project=None):
def addComputeNodeAndPartition(self, project=None,
portal_type='Compute Node'):
# XXX replace _makeComputeNode
if project is None:
project = self.addProject()
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()
compute_node = self.portal.compute_node_module.newContent(
portal_type="Compute Node",
portal_type=portal_type,
#allocation_scope=allocation_scope,
reference=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 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