Commit 2ea03f18 authored by Łukasz Nowak's avatar Łukasz Nowak

Move out utility methods in order to have them shared.

parent f23b64a8
......@@ -69,185 +69,10 @@ class TestSlapOSSlapToolMixin(testSlapOSMixin):
self.computer_id = self.computer.getReference()
self.pinDateTime(DateTime())
def _cleaupREQUEST(self):
self.portal.REQUEST['request_instance'] = None
self.portal.REQUEST.headers = {}
def beforeTearDown(self):
self.unpinDateTime()
self._cleaupREQUEST()
def _makeComplexComputer(self):
for i in range(1, 5):
id_ = 'partition%s' % i
p = self.computer.newContent(portal_type='Computer Partition',
id=id_,
title=id_,
reference=id_,
default_network_address_ip_address='ip_address_%s' % i,
default_network_address_netmask='netmask_%s' % i)
p.markFree()
p.validate()
self.start_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.start_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Start requested for %s' % self.computer.getTitle()
)
self.start_requested_software_installation.validate()
self.start_requested_software_installation.requestStart()
self.destroy_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroy_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroy requested for %s' % self.computer.getTitle()
)
self.destroy_requested_software_installation.validate()
self.destroy_requested_software_installation.requestStart()
self.destroy_requested_software_installation.requestDestroy()
self.destroyed_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroyed_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroyed for %s' % self.computer.getTitle()
)
self.destroyed_software_installation.validate()
self.destroyed_software_installation.requestStart()
self.destroyed_software_installation.requestDestroy()
self.destroyed_software_installation.invalidate()
self.computer.partition1.markBusy()
self.computer.partition2.markBusy()
self.computer.partition3.markBusy()
# prepare some trees
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='started'
)
hosting_subscription.requestStart(**kw)
hosting_subscription.requestInstance(**kw)
self.start_requested_software_instance = hosting_subscription.getPredecessorValue()
self.start_requested_software_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
self.stop_requested_software_instance = hosting_subscription.getPredecessorValue()
self.stop_requested_software_instance.edit(
aggregate=self.computer.partition2.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroy_requested_software_instance = hosting_subscription.getPredecessorValue()
self.destroy_requested_software_instance.requestDestroy(**kw)
self.destroy_requested_software_instance.edit(
aggregate=self.computer.partition3.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroyed_software_instance = hosting_subscription.getPredecessorValue()
self.destroyed_software_instance.edit(
aggregate=self.computer.partition4.getRelativeUrl()
)
self.destroyed_software_instance.requestDestroy(**kw)
self.destroyed_software_instance.invalidate()
self.tic()
self._cleaupREQUEST()
class TestSlapOSSlapToolComputerAccess(TestSlapOSSlapToolMixin):
def _getPartitionXml(self):
return """\
......
6
\ No newline at end of file
7
\ No newline at end of file
......@@ -139,6 +139,181 @@ class testSlapOSMixin(Products.Vifib.tests.VifibMixin.testVifibMixin):
]
return result
def _makeComplexComputer(self):
for i in range(1, 5):
id_ = 'partition%s' % i
p = self.computer.newContent(portal_type='Computer Partition',
id=id_,
title=id_,
reference=id_,
default_network_address_ip_address='ip_address_%s' % i,
default_network_address_netmask='netmask_%s' % i)
p.markFree()
p.validate()
self.start_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.start_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Start requested for %s' % self.computer.getTitle()
)
self.start_requested_software_installation.validate()
self.start_requested_software_installation.requestStart()
self.destroy_requested_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroy_requested_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroy requested for %s' % self.computer.getTitle()
)
self.destroy_requested_software_installation.validate()
self.destroy_requested_software_installation.requestStart()
self.destroy_requested_software_installation.requestDestroy()
self.destroyed_software_installation = self.portal.software_installation_module\
.template_software_installation.Base_createCloneDocument(batch_mode=1)
self.destroyed_software_installation.edit(
url_string=self.generateNewSoftwareReleaseUrl(),
aggregate=self.computer.getRelativeUrl(),
reference='TESTSOFTINST-%s' % self.generateNewId(),
title='Destroyed for %s' % self.computer.getTitle()
)
self.destroyed_software_installation.validate()
self.destroyed_software_installation.requestStart()
self.destroyed_software_installation.requestDestroy()
self.destroyed_software_installation.invalidate()
self.computer.partition1.markBusy()
self.computer.partition2.markBusy()
self.computer.partition3.markBusy()
# prepare some trees
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='started'
)
hosting_subscription.requestStart(**kw)
hosting_subscription.requestInstance(**kw)
self.start_requested_software_instance = hosting_subscription.getPredecessorValue()
self.start_requested_software_instance.edit(aggregate=self.computer.partition1.getRelativeUrl())
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
self.stop_requested_software_instance = hosting_subscription.getPredecessorValue()
self.stop_requested_software_instance.edit(
aggregate=self.computer.partition2.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroy_requested_software_instance = hosting_subscription.getPredecessorValue()
self.destroy_requested_software_instance.requestDestroy(**kw)
self.destroy_requested_software_instance.edit(
aggregate=self.computer.partition3.getRelativeUrl()
)
hosting_subscription = self.portal.hosting_subscription_module\
.template_hosting_subscription.Base_createCloneDocument(batch_mode=1)
hosting_subscription.edit(
)
hosting_subscription.validate()
hosting_subscription.edit(
title=self.generateNewSoftwareTitle(),
reference="TESTSI-%s" % self.generateNewId(),
)
kw = dict(
software_release=\
self.start_requested_software_installation.getUrlString(),
software_type=self.generateNewSoftwareType(),
instance_xml=self.generateSafeXml(),
sla_xml=self.generateSafeXml(),
shared=False,
software_title=hosting_subscription.getTitle(),
state='stopped'
)
hosting_subscription.requestStop(**kw)
hosting_subscription.requestInstance(**kw)
kw['state'] = 'destroyed'
hosting_subscription.requestDestroy(**kw)
self.destroyed_software_instance = hosting_subscription.getPredecessorValue()
self.destroyed_software_instance.edit(
aggregate=self.computer.partition4.getRelativeUrl()
)
self.destroyed_software_instance.requestDestroy(**kw)
self.destroyed_software_instance.invalidate()
self.tic()
self._cleaupREQUEST()
def _cleaupREQUEST(self):
self.portal.REQUEST['request_instance'] = None
self.portal.REQUEST.headers = {}
class TestSlapOSDummy(testSlapOSMixin):
run_all_test = 1
def test(self):
......
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