Commit 40246bbd authored by Rafael Monnerat's avatar Rafael Monnerat

Revert getComputerConnectionParameterList implementation

  Revert the implementation for now as it still not decided
  if we want this as part of the API or not.

Revert "Fix commit on getComputerConnectionParameterList"

This reverts commit 9d25d12b.

Revert "Delete Computer_getConnectionParameterList from slapos_cloud"

This reverts commit 75c5217f.

Revert "Add unit test for getComputerConnectionParameterList"

This reverts commit 4691a18b.

Revert "Computer: Get connection parameters for aggregated hosting subscriptions"

This reverts commit 995bea7a.

Revert "Hosting Subscription: Add aggregate base category"

This reverts commit b3e8a8ab.

Revert "Computer request software instance workflow"

This reverts commit 1350e574.
parent 75a0c7b5
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
<item>source_administration</item> <item>source_administration</item>
</portal_type> </portal_type>
<portal_type id="Hosting Subscription"> <portal_type id="Hosting Subscription">
<item>aggregate</item>
<item>destination_section</item> <item>destination_section</item>
</portal_type> </portal_type>
<portal_type id="Hosting Subscription Module"> <portal_type id="Hosting Subscription Module">
......
...@@ -333,220 +333,6 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin): ...@@ -333,220 +333,6 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
self.computer.requestSoftwareRelease, software_release_url=url, self.computer.requestSoftwareRelease, software_release_url=url,
state='available') state='available')
transaction.abort() transaction.abort()
def test_Computer_requestSoftwareInstance_returnHostingSubscription(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "Test Software Instance from Computer"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared = True
state = "started"
computer = self.computer
expected_sla_xml = """<?xml version='1.0' encoding='utf-8'?><instance>
<parameter id="computer_guid">%s</parameter>
</instance>
""" % computer.getReference()
computer.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state=state,
)
hosting_subscription = computer.REQUEST.get('request_hosting_subscription')
self.assertEquals("Hosting Subscription",
hosting_subscription.getPortalType())
self.assertEquals(computer.getRelativeUrl(),
hosting_subscription.getAggregateValue().getRelativeUrl())
self.assertEquals(hosting_subscription.getSlaXml(), expected_sla_xml)
self.assertEquals(hosting_subscription.getPredecessorValue().getSlaXml(),
expected_sla_xml)
def test_Computer_requestSoftwareInstance_requiredParameter(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "Test Software Instance from Computer"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared = True
state = "started"
computer = self.computer
self.assertRaises(TypeError, computer.requestSoftwareInstance)
# software_release is mandatory
self.assertRaises(TypeError, computer.requestSoftwareInstance,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state=state,
)
# software_title is mandatory
self.assertRaises(TypeError, computer.requestSoftwareInstance,
software_release=software_release,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state=state,
)
# software_type is mandatory
self.assertRaises(TypeError, computer.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
instance_xml=instance_xml,
shared=shared,
state=state,
)
# instance_xml is mandatory
self.assertRaises(TypeError, computer.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
shared=shared,
state=state,
)
# shared is mandatory
self.assertRaises(TypeError, computer.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
state=state,
)
# state is mandatory
self.assertRaises(TypeError, computer.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
)
def test_Computer_requestSoftwareInstance_acceptedState(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "Test Software Instance from Computer"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared = True
state = "started"
computer = self.computer
# Only started, stopped, destroyed
self.assertRaises(ValueError, computer.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state="foo",
)
computer.requestSoftwareInstance(
software_release=software_release,
software_title="Computer started Software Instance",
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state="started",
)
hosting_subscription = computer.REQUEST.get('request_hosting_subscription')
self.assertEquals("start_requested", hosting_subscription.getSlapState())
computer.requestSoftwareInstance(
software_release=software_release,
software_title="Computer stopped Software Instance",
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state="stopped",
)
hosting_subscription = computer.REQUEST.get('request_hosting_subscription')
self.assertEquals("stop_requested", hosting_subscription.getSlapState())
computer.requestSoftwareInstance(
software_release=software_release,
software_title="Computer destroyed Software Instance",
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state="destroyed",
)
hosting_subscription = computer.REQUEST.get('request_hosting_subscription')
self.assertEquals(None, hosting_subscription)
def test_Computer_requestSoftwareInstance_duplicatedHostingSubscription(self):
self._makePerson()
self.computer.edit(source_administration=self.person_user.getRelativeUrl())
self.tic()
self.login(self.person_user.getReference())
software_release = self.generateNewSoftwareReleaseUrl()
software_title = "Test Software Instance from Computer"
software_type = "test"
instance_xml = """<?xml version="1.0" encoding="utf-8"?>
<instance>
</instance>
"""
shared = True
state = "started"
computer = self.computer
computer.requestSoftwareInstance(
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state=state,
)
hosting_subscription = computer.REQUEST.get('request_hosting_subscription')
transaction.commit()
hosting_subscription2 = hosting_subscription.Base_createCloneDocument(
batch_mode=1)
hosting_subscription2.validate()
transaction.commit()
self.tic()
self.assertRaises(NotImplementedError, computer.requestSoftwareInstance,
software_release=software_release,
software_title=software_title,
software_type=software_type,
instance_xml=instance_xml,
shared=shared,
state=state,
)
def test_revokeCertificate(self): def test_revokeCertificate(self):
self.login(self.computer.getReference()) self.login(self.computer.getReference())
...@@ -715,7 +501,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): ...@@ -715,7 +501,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def test_supply_available_createdSoftwareInstallation(self): def test_supply_available_createdSoftwareInstallation(self):
previous_id = self.getPortalObject().portal_ids\ previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference', .generateNewId(id_group='slap_software_installation_reference',
id_generator='uid') id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl() software_release = self.generateNewSoftwareReleaseUrl()
...@@ -739,7 +525,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): ...@@ -739,7 +525,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def test_multiple_supply_available_createdSoftwareInstallation(self): def test_multiple_supply_available_createdSoftwareInstallation(self):
previous_id = self.getPortalObject().portal_ids\ previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference', .generateNewId(id_group='slap_software_installation_reference',
id_generator='uid') id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl() software_release = self.generateNewSoftwareReleaseUrl()
...@@ -771,7 +557,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): ...@@ -771,7 +557,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def test_supply_available_destroyed(self): def test_supply_available_destroyed(self):
previous_id = self.getPortalObject().portal_ids\ previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference', .generateNewId(id_group='slap_software_installation_reference',
id_generator='uid') id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl() software_release = self.generateNewSoftwareReleaseUrl()
...@@ -812,7 +598,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): ...@@ -812,7 +598,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def test_supply_available_destroyed_available(self): def test_supply_available_destroyed_available(self):
previous_id = self.getPortalObject().portal_ids\ previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference', .generateNewId(id_group='slap_software_installation_reference',
id_generator='uid') id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl() software_release = self.generateNewSoftwareReleaseUrl()
...@@ -859,7 +645,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin): ...@@ -859,7 +645,7 @@ class TestSlapOSCorePersonComputerSupply(testSlapOSMixin):
def test_supply_available_destroyed_finalised_available(self): def test_supply_available_destroyed_finalised_available(self):
previous_id = self.getPortalObject().portal_ids\ previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_software_installation_reference', .generateNewId(id_group='slap_software_installation_reference',
id_generator='uid') id_generator='uid')
software_release = self.generateNewSoftwareReleaseUrl() software_release = self.generateNewSoftwareReleaseUrl()
...@@ -2359,7 +2145,7 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin): ...@@ -2359,7 +2145,7 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
state=state, state=state,
) )
hosting_subscription = person.REQUEST.get('request_hosting_subscription') hosting_subscription = person.REQUEST.get('request_hosting_subscription')
self.assertEquals("Hosting Subscription", self.assertEquals("Hosting Subscription",
hosting_subscription.getPortalType()) hosting_subscription.getPortalType())
def test_Person_requestSoftwareInstance_createHostingSubscription(self): def test_Person_requestSoftwareInstance_createHostingSubscription(self):
...@@ -2377,7 +2163,7 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin): ...@@ -2377,7 +2163,7 @@ class TestSlapOSCorePersonRequest(testSlapOSMixin):
state = "started" state = "started"
previous_id = self.getPortalObject().portal_ids\ previous_id = self.getPortalObject().portal_ids\
.generateNewId(id_group='slap_hosting_subscription_reference', .generateNewId(id_group='slap_hosting_subscription_reference',
id_generator='uid') id_generator='uid')
person.requestSoftwareInstance( person.requestSoftwareInstance(
...@@ -2967,7 +2753,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin): ...@@ -2967,7 +2753,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def verify_activeSense_call(self): def verify_activeSense_call(self):
if self.getRelativeUrl() == 'portal_alarms/slapos_allocate_instance': if self.getRelativeUrl() == 'portal_alarms/slapos_allocate_instance':
instance.portal_workflow.doActionFor(instance, action='edit_action', instance.portal_workflow.doActionFor(instance, action='edit_action',
comment='activeSense triggered') comment='activeSense triggered')
else: else:
return self.activeSense_call() return self.activeSense_call()
...@@ -3033,7 +2819,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin): ...@@ -3033,7 +2819,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def verify_reindexObject_call(self, *args, **kw): def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() == computer.getRelativeUrl(): if self.getRelativeUrl() == computer.getRelativeUrl():
computer.portal_workflow.doActionFor(computer, action='edit_action', computer.portal_workflow.doActionFor(computer, action='edit_action',
comment='reindexObject triggered on %s' % method_id) comment='reindexObject triggered on %s' % method_id)
else: else:
return self.reindexObject_call(*args, **kw) return self.reindexObject_call(*args, **kw)
...@@ -3094,7 +2880,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin): ...@@ -3094,7 +2880,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def verify_reindexObject_call(self, *args, **kw): def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() == partition.getRelativeUrl(): if self.getRelativeUrl() == partition.getRelativeUrl():
partition.portal_workflow.doActionFor(partition, action='edit_action', partition.portal_workflow.doActionFor(partition, action='edit_action',
comment='reindexObject triggered on %s' % method_id) comment='reindexObject triggered on %s' % method_id)
else: else:
return self.reindexObject_call(*args, **kw) return self.reindexObject_call(*args, **kw)
...@@ -3219,7 +3005,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin): ...@@ -3219,7 +3005,7 @@ class TestSlapOSCoreSlapOSCloudInteractionWorkflow(testSlapOSMixin):
def verify_reindexObject_call(self, *args, **kw): def verify_reindexObject_call(self, *args, **kw):
if self.getRelativeUrl() in (instance2.getRelativeUrl(), if self.getRelativeUrl() in (instance2.getRelativeUrl(),
instance3.getRelativeUrl()): instance3.getRelativeUrl()):
self.portal_workflow.doActionFor(instance1, action='edit_action', self.portal_workflow.doActionFor(instance1, action='edit_action',
comment='reindexObject triggered') comment='reindexObject triggered')
else: else:
return self.reindexObject_call(*args, **kw) return self.reindexObject_call(*args, **kw)
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
computer = state_change[\'object\']\n
person = computer.getSourceAdministrationValue()\n
\n
# Get required arguments\n
kwargs = state_change.kwargs\n
\n
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
software_release_url_string = kwargs[\'software_release\']\n
software_title = kwargs["software_title"]\n
software_type = kwargs["software_type"]\n
instance_xml = kwargs["instance_xml"]\n
is_slave = kwargs["shared"]\n
root_state = kwargs["state"]\n
except KeyError:\n
raise TypeError, "Computer_requestSoftwareInstance takes exactly 6 arguments"\n
\n
if person is None:\n
return\n
\n
sla_xml = """<?xml version=\'1.0\' encoding=\'utf-8\'?><instance>\n
<parameter id="computer_guid">%s</parameter>\n
</instance>\n
""" % computer.getReference()\n
\n
person.requestSoftwareInstance(\n
state=root_state,\n
software_release=software_release_url_string,\n
software_title=software_title,\n
software_type=software_type,\n
instance_xml=instance_xml,\n
sla_xml=sla_xml,\n
shared=is_slave\n
)\n
\n
hosting_subscription = context.REQUEST.get(\'request_hosting_subscription\', None)\n
if hosting_subscription is None:\n
return\n
\n
hosting_subscription.setAggregateValue(computer)\n
]]></string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Computer_requestSoftwareInstanceChange</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
<string>generate_certificate</string> <string>generate_certificate</string>
<string>report_computer_bang</string> <string>report_computer_bang</string>
<string>request_computer_registration</string> <string>request_computer_registration</string>
<string>request_software_instance</string>
<string>request_software_release</string> <string>request_software_release</string>
<string>revoke_certificate</string> <string>revoke_certificate</string>
</tuple> </tuple>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TransitionDefinition" module="Products.DCWorkflow.Transitions"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>actbox_category</string> </key>
<value> <string>workflow</string> </value>
</item>
<item>
<key> <string>actbox_icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>actbox_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string>Computer_requestSoftwareInstanceChange</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>guard</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>request_software_instance</string> </value>
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>trigger_type</string> </key>
<value> <int>2</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
327 323
\ No newline at end of file \ No newline at end of file
...@@ -3,7 +3,6 @@ Computer Network | source_administration ...@@ -3,7 +3,6 @@ Computer Network | source_administration
Computer | destination_section Computer | destination_section
Computer | source_administration Computer | source_administration
Hosting Subscription Module | business_application Hosting Subscription Module | business_application
Hosting Subscription | aggregate
Hosting Subscription | destination_section Hosting Subscription | destination_section
Slave Instance | aggregate Slave Instance | aggregate
Slave Instance | specialise Slave Instance | specialise
......
...@@ -1849,7 +1849,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1849,7 +1849,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<marshal> <marshal>
<list id='i2'/> <list id='i2'/>
</marshal> </marshal>
""" """
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
...@@ -1867,7 +1867,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1867,7 +1867,7 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
<marshal> <marshal>
<list id='i2'/> <list id='i2'/>
</marshal> </marshal>
""" """
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
...@@ -1915,171 +1915,6 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin): ...@@ -1915,171 +1915,6 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
""" % (software_release2.getUrlString(), software_release1.getUrlString()) """ % (software_release2.getUrlString(), software_release1.getUrlString())
self.assertEqual(expected_xml, got_xml, self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))])) '\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputerConnectionParameterList(self):
self._makeComplexComputer()
software_instance = self.start_requested_software_instance
hosting_subscription = software_instance.getSpecialiseValue(
software_type="Hosting Subscription")
hosting_subscription.setAggregateValue(self.computer)
connection_xml = """<?xml version="1.0" encoding="utf-8"?><instance>
<parameter id="parameter_1">value_1</parameter>
</instance>"""
software_instance.updateConnection(connection_xml=connection_xml)
self.assertEquals(software_instance.getConnectionXml(), connection_xml)
self.tic()
connection_response = self.portal_slap.getComputerConnectionParameterList(
self.computer.getReference())
# check returned XML
xml_fp = StringIO.StringIO()
xml.dom.ext.PrettyPrint(xml.dom.ext.reader.Sax.FromXml(connection_response),
stream=xml_fp)
xml_fp.seek(0)
got_xml = xml_fp.read()
expected_xml = """\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'>
<dictionary id='i3'>
<string>parameter_1</string>
<string>value_1</string>
</dictionary>
</list>
</marshal>
"""
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputerConnectionParameterList_two_hostingSubscriptions(self):
self._makeComplexComputer()
software_instance = self.start_requested_software_instance
hosting_subscription = software_instance.getSpecialiseValue(
software_type="Hosting Subscription")
hosting_subscription.setAggregateValue(self.computer)
# Stop_requested HostingSubsctiption
software_instance2 = self.stop_requested_software_instance
hosting_subscription2 = software_instance2.getSpecialiseValue(
software_type="Hosting Subscription")
hosting_subscription2.setAggregateValue(self.computer)
connection_xml = """<?xml version="1.0" encoding="utf-8"?><instance>
<parameter id="parameter_1">value_1</parameter>
</instance>"""
software_instance.updateConnection(connection_xml=connection_xml)
self.assertEquals(software_instance.getConnectionXml(), connection_xml)
software_instance2.updateConnection(connection_xml=connection_xml)
self.assertEquals(software_instance2.getConnectionXml(), connection_xml)
self.tic()
connection_response = self.portal_slap.getComputerConnectionParameterList(
self.computer.getReference())
# check returned XML
xml_fp = StringIO.StringIO()
xml.dom.ext.PrettyPrint(xml.dom.ext.reader.Sax.FromXml(connection_response),
stream=xml_fp)
xml_fp.seek(0)
got_xml = xml_fp.read()
expected_xml = """\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'>
<dictionary id='i3'>
<string>parameter_1</string>
<string>value_1</string>
</dictionary>
<dictionary id='i4'>
<string>parameter_1</string>
<string>value_1</string>
</dictionary>
</list>
</marshal>
"""
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputerConnectionParameterList_no_parameters(self):
self._makeComplexComputer()
software_instance = self.start_requested_software_instance
hosting_subscription = software_instance.getSpecialiseValue(
software_type="Hosting Subscription")
hosting_subscription.setAggregateValue(self.computer)
self.tic()
connection_response = self.portal_slap.getComputerConnectionParameterList(
self.computer.getReference())
# check returned XML
xml_fp = StringIO.StringIO()
xml.dom.ext.PrettyPrint(xml.dom.ext.reader.Sax.FromXml(connection_response),
stream=xml_fp)
xml_fp.seek(0)
got_xml = xml_fp.read()
expected_xml = """\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'>
<dictionary id='i3'/>
</list>
</marshal>
"""
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
def test_getComputerConnectionParameterList_invalid_hs(self):
self._makeComplexComputer()
software_instance = self.start_requested_software_instance
hosting_subscription = software_instance.getSpecialiseValue(
software_type="Hosting Subscription")
hosting_subscription.setAggregateValue(self.computer)
software_instance.invalidate()
# Destroy_requested HostingSubsctiption
software_instance2 = self.destroy_requested_software_instance
hosting_subscription2 = software_instance2.getSpecialiseValue(
software_type="Hosting Subscription")
hosting_subscription2.setAggregateValue(self.computer)
self.assertEqual(hosting_subscription2.getSlapState(),
'destroy_requested')
connection_xml = """<?xml version="1.0" encoding="utf-8"?><instance>
<parameter id="parameter_1">value_1</parameter>
</instance>"""
software_instance.updateConnection(connection_xml=connection_xml)
software_instance2.updateConnection(connection_xml=connection_xml)
self.tic()
connection_response = self.portal_slap.getComputerConnectionParameterList(
self.computer.getReference())
# check returned XML
xml_fp = StringIO.StringIO()
xml.dom.ext.PrettyPrint(xml.dom.ext.reader.Sax.FromXml(connection_response),
stream=xml_fp)
xml_fp.seek(0)
got_xml = xml_fp.read()
expected_xml = """\
<?xml version='1.0' encoding='UTF-8'?>
<marshal>
<list id='i2'/>
</marshal>
"""
self.assertEqual(expected_xml, got_xml,
'\n'.join([q for q in difflib.unified_diff(expected_xml.split('\n'), got_xml.split('\n'))]))
class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
...@@ -2848,7 +2683,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2848,7 +2683,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
try: try:
self.login(self.person_reference) self.login(self.person_reference)
self.computer.generateCertificate = Simulator( self.computer.generateCertificate = Simulator(
self.generate_computer_certificate_simulator, self.generate_computer_certificate_simulator,
'generateComputerCertificate') 'generateComputerCertificate')
computer_certificate = 'live_\ncertificate_%s' % self.generateNewId() computer_certificate = 'live_\ncertificate_%s' % self.generateNewId()
...@@ -2895,7 +2730,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin): ...@@ -2895,7 +2730,7 @@ class TestSlapOSSlapToolPersonAccess(TestSlapOSSlapToolMixin):
try: try:
self.login(self.person_reference) self.login(self.person_reference)
self.computer.revokeCertificate = Simulator( self.computer.revokeCertificate = Simulator(
self.revoke_computer_certificate_simulator, self.revoke_computer_certificate_simulator,
'revokeComputerCertificate') 'revokeComputerCertificate')
response = self.portal_slap.revokeComputerCertificate(self.computer_id) response = self.portal_slap.revokeComputerCertificate(self.computer_id)
......
37 36
\ No newline at end of file \ No newline at end of file
...@@ -424,12 +424,7 @@ class SlapTool(BaseTool): ...@@ -424,12 +424,7 @@ class SlapTool(BaseTool):
[software_release.getUrlString() [software_release.getUrlString()
for software_release in software_release_list for software_release in software_release_list
if software_release.getValidationState() == 'published']) if software_release.getValidationState() == 'published'])
security.declareProtected(Permissions.AccessContentsInformation,
'getComputerConnectionParameterList')
def getComputerConnectionParameterList(self, computer_id):
parameter_list = self._getComputerConnectionParameterList(computer_id)
return xml_marshaller.xml_marshaller.dumps(parameter_list)
#################################################### ####################################################
# Public POST methods # Public POST methods
...@@ -1391,36 +1386,6 @@ class SlapTool(BaseTool): ...@@ -1391,36 +1386,6 @@ class SlapTool(BaseTool):
computer_id, computer_partition_id) computer_id, computer_partition_id)
else: else:
return software_instance return software_instance
def _getComputerConnectionParameterList(self, computer_id):
computer = self._getComputerDocument(computer_id)
parameter_list = []
item_list = computer.getAggregateRelatedValueList(
portal_type='Hosting Subscription'
)
hosting_subscription_list = sorted(item_list,
key=lambda x: x.getCreationDate())
for hosting_subscription in hosting_subscription_list:
if hosting_subscription.getValidationState() != 'validated' and \
hosting_subscription.getSlapState() == "destroy_requested":
continue
# Get the main instance
instance = hosting_subscription.getPredecessorValue(
portal_type="Software Instance")
if not instance or instance.getSlapState() == "destroy_requested" or \
instance.getValidationState() != 'validated':
continue
parameter_dict = instance.getConnectionXmlAsDict()
if not parameter_dict:
parameter_dict = {}
parameter_list.append(parameter_dict)
return parameter_list
@UnrestrictedMethod @UnrestrictedMethod
def _getSoftwareInstanceAsParameterDict(self, software_instance): def _getSoftwareInstanceAsParameterDict(self, software_instance):
......
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