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 @@
<item>source_administration</item>
</portal_type>
<portal_type id="Hosting Subscription">
<item>aggregate</item>
<item>destination_section</item>
</portal_type>
<portal_type id="Hosting Subscription Module">
......
......@@ -334,220 +334,6 @@ class TestSlapOSCoreComputerSlapInterfaceWorkflow(testSlapOSMixin):
state='available')
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):
self.login(self.computer.getReference())
self.computer.generateCertificate()
......
<?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 @@
<string>generate_certificate</string>
<string>report_computer_bang</string>
<string>request_computer_registration</string>
<string>request_software_instance</string>
<string>request_software_release</string>
<string>revoke_certificate</string>
</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
\ No newline at end of file
323
\ No newline at end of file
......@@ -3,7 +3,6 @@ Computer Network | source_administration
Computer | destination_section
Computer | source_administration
Hosting Subscription Module | business_application
Hosting Subscription | aggregate
Hosting Subscription | destination_section
Slave Instance | aggregate
Slave Instance | specialise
......
......@@ -1917,171 +1917,6 @@ class TestSlapOSSlapToolInstanceAccess(TestSlapOSSlapToolMixin):
'\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):
def afterSetUp(self):
password = self.generateNewId()
......
37
\ No newline at end of file
36
\ No newline at end of file
......@@ -425,11 +425,6 @@ class SlapTool(BaseTool):
for software_release in software_release_list
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
......@@ -1392,36 +1387,6 @@ class SlapTool(BaseTool):
else:
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
def _getSoftwareInstanceAsParameterDict(self, software_instance):
portal = software_instance.getPortalObject()
......
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