Commit 75029c17 authored by Vivien Alger's avatar Vivien Alger

Mass upgrade: check for installed software before upgrade

parent 8ba70847
...@@ -52,16 +52,19 @@ ...@@ -52,16 +52,19 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>person = context.getDestinationSectionValue(portal_type="Person")\n <value> <string>person = context.getDestinationSectionValue(portal_type="Person")\n
\n \n
status = context.getSlapState()\n computer = context.getSpecialiseRelatedValue().getAggregateValue().getParentValue()\n
\n \n
if status == "start_requested":\n if new_sr_url in computer.Computer_getSoftwareReleaseUrlStringList():\n
status = context.getSlapState()\n
\n
if status == "start_requested":\n
state = "started"\n state = "started"\n
elif status == "stop_requested":\n elif status == "stop_requested":\n
state = "stopped"\n state = "stopped"\n
elif status == "destroy_requested":\n elif status == "destroy_requested":\n
state = "destroyed"\n state = "destroyed"\n
\n \n
person.requestSoftwareInstance(\n person.requestSoftwareInstance(\n
state=state,\n state=state,\n
software_release=new_sr_url,\n software_release=new_sr_url,\n
software_title=context.getTitle(),\n software_title=context.getTitle(),\n
...@@ -69,7 +72,7 @@ person.requestSoftwareInstance(\n ...@@ -69,7 +72,7 @@ person.requestSoftwareInstance(\n
instance_xml=context.getTextContent(),\n instance_xml=context.getTextContent(),\n
sla_xml=context.getSlaXml(),\n sla_xml=context.getSlaXml(),\n
shared=context.isRootSlave()\n shared=context.isRootSlave()\n
)\n )\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -56,21 +56,26 @@ if listbox is None:\n ...@@ -56,21 +56,26 @@ if listbox is None:\n
listbox = []\n listbox = []\n
\n \n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
message_list = []\n
\n \n
for parameters in listbox:\n for parameters in listbox:\n
new_sr_path = parameters[\'workflow_action\']\n new_sr_path = parameters[\'workflow_action\']\n
\n \n
if new_sr_path is not None and new_sr_path != \'\':\n if new_sr_path is not None and new_sr_path != \'\':\n
old_sr_document = portal.restrictedTraverse(parameters[\'listbox_key\'])\n
new_sr_document = portal.restrictedTraverse(new_sr_path)\n new_sr_document = portal.restrictedTraverse(new_sr_path)\n
new_sr_url = new_sr_document.getUrlString()\n
\n
comp_reference_list = parameters[\'computer_filter\']\n
if comp_reference_list != []:\n
for comp_reference in comp_reference_list:\n
if new_sr_url not in portal.portal_catalog.getResultValue(portal_type=\'Computer\', reference=comp_reference).Computer_getSoftwareReleaseUrlStringList():\n
message_list.append("Software Release %s not installed on %s." % (new_sr_document.getTitle(), comp_reference))\n
\n
old_sr_document = portal.restrictedTraverse(parameters[\'listbox_key\'])\n
\n \n
tag = \'software_release_change_from_%s_to_%s\' % (old_sr_document.getReference(), new_sr_document.getReference())\n tag = \'software_release_change_from_%s_to_%s\' % (old_sr_document.getReference(), new_sr_document.getReference())\n
\n \n
comp_uid_list = []\n old_sr_document.activate(tag=tag).SoftwareRelease_requestInstanceUpgrade(new_sr_url, comp_reference_list, tag)\n
for comp in parameters[\'computer_filter\']:\n
comp_uid_list.append(portal.restrictedTraverse(comp).getUid())\n
\n
old_sr_document.activate(tag=tag).SoftwareRelease_requestInstanceUpgrade(new_sr_document.getUrlString(), comp_uid_list, tag)\n
\n \n
# activate something on the module after everything, so that user can know that something is happening in the background\n # activate something on the module after everything, so that user can know that something is happening in the background\n
context.activate(after_tag=tag).getTitle()\n context.activate(after_tag=tag).getTitle()\n
...@@ -78,8 +83,13 @@ for parameters in listbox:\n ...@@ -78,8 +83,13 @@ for parameters in listbox:\n
# reset selection checked uids\n # reset selection checked uids\n
context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])\n context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])\n
\n \n
portal_status_message = "Upgrade of instances in progress.\\r\\n"\n
\n
if message_list != []:\n
portal_status_message += "\\r\\n".join(message_list)\n
\n
return context.Base_redirect(form_id,\n return context.Base_redirect(form_id,\n
keep_items=dict(portal_status_message=translateString("Upgrade of instances in progress.")))\n keep_items=dict(portal_status_message=translateString(portal_status_message)))\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -263,7 +263,7 @@ ...@@ -263,7 +263,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>python: [(x.getReference(),x.getUrl()) for x in cell.SoftwareRelease_getUsableComputerList()]</string> </value> <value> <string>python: [(x.getReference(),x.getReference()) for x in cell.SoftwareRelease_getUsableComputerList()]</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -56,14 +56,14 @@ ...@@ -56,14 +56,14 @@
old_sr_url = context.getUrlString()\n old_sr_url = context.getUrlString()\n
portal = context.getPortalObject()\n portal = context.getPortalObject()\n
\n \n
if comp_uid_list != []:\n if comp_reference_list != []:\n
hosting_sub_list = portal.portal_catalog.searchAndActivate(\n hosting_sub_list = portal.portal_catalog.searchAndActivate(\n
portal_type = \'Hosting Subscription\',\n portal_type = \'Hosting Subscription\',\n
default_specialise_related_uid = [x.getUid() for x in portal.portal_catalog(\n default_specialise_related_uid = [x.getUid() for x in portal.portal_catalog(\n
portal_type = [\'Software Instance\', \'Slave Instance\'],\n portal_type = [\'Software Instance\', \'Slave Instance\'],\n
default_aggregate_uid = [y.getUid() for y in portal.portal_catalog(\n default_aggregate_uid = [y.getUid() for y in portal.portal_catalog(\n
portal_type = \'Computer Partition\',\n portal_type = \'Computer Partition\',\n
parent_uid = comp_uid_list,\n parent_reference = comp_reference_list,\n
free_for_request = 0,\n free_for_request = 0,\n
software_release_url = old_sr_url\n software_release_url = old_sr_url\n
)]\n )]\n
...@@ -85,7 +85,7 @@ else:\n ...@@ -85,7 +85,7 @@ else:\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>new_sr_url, comp_uid_list, tag, **kw</string> </value> <value> <string>new_sr_url, comp_reference_list, tag, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
290 291
\ No newline at end of file \ No newline at end of file
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