Commit fc128a05 authored by Alain Takoudjou's avatar Alain Takoudjou

Improve script to create Upgrade Decision for Hosting Subscription

parent e4f85807
......@@ -73,36 +73,25 @@ for partition in partition_list:\n
hosting_subscription_list.append(hosting_subscription)\n
else:\n
continue\n
\n
is_upgradable = hosting_subscription.HostingSubscription_isUpgradable()\n
if not is_upgradable:\n
continue\n
\n
newer_release_string = hosting_subscription.\\\n
HostingSubscription_getNewerSofwareRelease()\n
if not newer_release_string:\n
continue\n
# XXX - Should try to change method HostingSubscription_getNewerSofwareRelease\n
# to return software_release object directly\n
software_release = portal.portal_catalog.getResultValue(\n
portal_type=\'Software Release\',\n
url_string=newer_release_string)\n
if not software_release:\n
newer_release = hosting_subscription.\\\n
HostingSubscription_getUpgradableSoftwareRelease()\n
if newer_release is None:\n
continue\n
\n
title = \'A new software release is available for %s\' % \\\n
hosting_subscription.getReference()\n
decision_in_progress = software_release.\\\n
decision_in_progress = newer_release.\\\n
SoftwareRelease_getUpgradeDecisionInProgress(hosting_subscription.getUid())\n
\n
if decision_in_progress and \\\n
not decision_in_progress.UpgradeDecision_tryToCancel(newer_release_string):\n
not decision_in_progress.UpgradeDecision_tryToCancel(\n
newer_release.getUrlString()):\n
continue\n
\n
upgrade_decision = software_release.SoftwareRelease_createUpgradeDecision(\n
upgrade_decision = newer_release.SoftwareRelease_createUpgradeDecision(\n
source_url=hosting_subscription.getRelativeUrl(),\n
title=title)\n
upgrade_decision.confirm()\n
title=\'A new upgrade is available for %s\' % hosting_subscription.getTitle()\n
)\n
upgrade_decision.plan()\n
upgrade_decision_list.append(upgrade_decision)\n
\n
return upgrade_decision_list\n
......
......@@ -57,7 +57,7 @@ if upgrade_decision.getSimulationState() in cancel_state_list:\n
current_release = upgrade_decision.UpgradeDecision_getSoftwareRelease()\n
if not current_release:\n
# This upgrade decision is not valid\n
return True\n
return False\n
if current_release.getUrlString() == new_url_string:\n
# Cannot cancel because the software releases are the same\n
return False\n
......
31
\ No newline at end of file
32
\ 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