Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arnaud Véron
slapos.core
Commits
737a4d06
Commit
737a4d06
authored
May 29, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Continue migration implemnetation.
parent
8d8a4d69
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
187 additions
and
4 deletions
+187
-4
master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/ERP5Site_migrateSlapState.xml
...portal_skins/vifib_upgrader/ERP5Site_migrateSlapState.xml
+3
-3
master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/SlapDocument_migrateSlapState.xml
...al_skins/vifib_upgrader/SlapDocument_migrateSlapState.xml
+183
-0
master/bt5/vifib_upgrader/bt/revision
master/bt5/vifib_upgrader/bt/revision
+1
-1
No files found.
master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/ERP5Site_migrate
HostingSubscription
SlapState.xml
→
master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/ERP5Site_migrateSlapState.xml
View file @
737a4d06
...
...
@@ -51,8 +51,8 @@
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
context.getPortalObject().portal_catalog.searchAndActivate(\n
portal_type=
\'Hosting Subscription\'
,\n
method_id=\'
HostingSubscription
_migrateSlapState\'\n
portal_type=
[\'Hosting Subscription\', \'Software Instance\', \'Slave Instance\']
,\n
method_id=\'
SlapDocument
_migrateSlapState\'\n
)\n
</string>
</value>
</item>
...
...
@@ -62,7 +62,7 @@
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_migrate
HostingSubscription
SlapState
</string>
</value>
<value>
<string>
ERP5Site_migrateSlapState
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/
HostingSubscription
_migrateSlapState.xml
→
master/bt5/vifib_upgrader/SkinTemplateItem/portal_skins/vifib_upgrader/
SlapDocument
_migrateSlapState.xml
View file @
737a4d06
...
...
@@ -50,29 +50,123 @@
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
hosting_subscription = context\n
assert(context.getPortalType() == \'Hosting Subscription\')\n
<value>
<string>
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery\n
\n
sale_order_line_list = context.getAggregateRelatedValueList(portal_type=\'Sale Order Line\')\n
sale_order_line = sale_order_line_list[0]\n
slap_document = context\n
portal = context.getPortalObject()\n
\n
portal_type_list = (\'Hosting Subscription\', \'Software Instance\', \'Slave Instance\')\n
portal_type = slap_document.getPortalType()\n
if portal_type not in portal_type_list:\n
raise TypeError(\'%s is not %s\' % (slap_document.getPath(), portal_type_list))\n
\n
sale_order_line = slap_document.getAggregateRelatedValue(portal_type=\'Sale Order Line\')\n
\n
\n
if portal_type == \'Hosting Subscription\':\n
# Person is now directly associated on the HS\n
slap_document.edit(\n
destination_section_value=sale_order_line.getDestinationSectionValue(portal_type="Person"),\n
)\n
assert(slap_document.getDestinationSection() == sale_order_line.getDestinationSectionValue().getRelativeUrl())\n
else:\n
hosting_subscription = sale_order_line.getAggregateValue(portal_type=\'Hosting Subscription\')\n
slap_document.edit(\n
specialise_value=hosting_subscription\n
)\n
assert(slap_document.getSpecialise() == hosting_subscription.getRelativeUrl())\n
\n
# Person is now directly associated on the HS\n
hosting_subscription.edit(\n
destination_section_value=sale_order_line.getDestinationSectionValue(portal_type="Person"),\n
)\n
assert(hosting_subscription.getDestinationSection() == sale_order_line.getDestinationSectionValue().getRelativeUrl())\n
\n
# Migrate slap state\n
state = hosting_subscription.getRootState()\n
assert(hosting_subscription.getSlapState() == \'draft\')\n
if state == "started":\n
hosting_subscription.requestStarted()\n
elif state == "stopped":\n
hosting_subscription.requestStopped()\n
elif state == "destroyed":\n
hosting_subscription.requestDestroyed()\n
if portal_type == \'Hosting Subscription\':\n
state = slap_document.getRootState()\n
promise_kw = {\n
\'instance_xml\': context.getTextContent(),\n
\'software_type\': context.getSourceReference(),\n
\'sla_xml\': context.getSlaXml(),\n
\'software_release\': context.getRootSoftwareReleaseUrl(),\n
\'shared\': slap_document.isRootSlave()\n
}\n
else:\n
explanation_delivery_line = portal.portal_catalog.getResultValue(\n
portal_type=\'Sale Packing List Line\',\n
query=ComplexQuery(\n
Query(default_aggregate_uid=slap_document.getUid()),\n
Query(default_resource_uid=[\n
portal.restrictedTraverse(portal.portal_preferences.getPreferredInstanceSetupResource()).getUid(),\n
portal.restrictedTraverse(portal.portal_preferences.getPreferredInstanceHostingResource()).getUid(),\n
portal.restrictedTraverse(portal.portal_preferences.getPreferredInstanceCleanupResource()).getUid(),\n
]),\n
operator=\'AND\',\n
),\n
sort_on=((\'movement.start_date\', \'DESC\'),)\n
)\n
if explanation_delivery_line is None:\n
explanation_delivery_line = sale_order_line\n
\n
if explanation_delivery_line.getPortalType() == \'Sale Packing List Line\':\n
resource = explanation_delivery_line.getResource()\n
if resource == portal.portal_preferences.getPreferredInstanceSetupResource():\n
state = \'stopped\'\n
elif resource == portal.portal_preferences.getPreferredInstanceCleanupResource():\n
state = \'destroyed\'\n
elif resource == portal.portal_preferences.getPreferredInstanceHostingResource():\n
if explanation_delivery_line.getSimulationState() in (\'confirmed\', \'started\'):\n
state = \'started\'\n
else:\n
state = \'stopped\'\n
pass\n
else:\n
raise TypeError(\'Bad resource %s\' % resource)\n
pass\n
else:\n
if explanation_delivery_line.getSimulationState() == \'cancelled\':\n
state = \'destoyed\'\n
else:\n
raise NotImplementedError\n
promise_kw = {\n
\'instance_xml\': context.getTextContent(),\n
\'software_type\': context.getSourceReference(),\n
\'sla_xml\': context.getSlaXml(),\n
\'software_release\': context.getRootSoftwareReleaseUrl(),\n
\'shared\': slap_document.getPortalType() == \'Slave Instance\'\n
}\n
\n
slap_document.setCausalityValue(explanation_delivery_line.getParentValue())\n
state_map = {\n
\'started\': \'start_requested\',\n
\'stopped\': \'stop_requested\',\n
\'destroyed\': \'destroy_requested\'\n
}\n
\n
if slap_document.getSlapState() == \'draft\':\n
if state == "started":\n
slap_document.requestStart(comment=\'Migration.\', **promise_kw)\n
elif state == "stopped":\n
slap_document.requestStop(comment=\'Migration.\', **promise_kw)\n
elif state == "destroyed":\n
slap_document.requestStop(comment=\'Migration, in order to reach destroy.\', **promise_kw)\n
slap_document.requestDestroy(comment=\'Migration.\', **promise_kw)\n
else:\n
raise ValueError("Unknown state %s for %s" % (state, slap_document.getRelativeUrl()))\n
if not(slap_document.getSlapState() == state_map[state]):\n
raise ValueError(\'%s: %s != %s\' % (state, slap_document.getSlapState(), state_map[state]))\n
\n
# Migrate validation state\n
if portal_type == \'Hosting Subscription\':\n
if state == \'destroyed\':\n
slap_document.validate()\n
slap_document.archive()\n
assert(slap_document.getValidationState() == \'archived\')\n
else:\n
assert(slap_document.getValidationState() == \'validated\')\n
else:\n
raise NotImplementedError, "Unknown state %s for %s" % (state, hosting_subscription.getRelativeUrl())\n
if state == \'destroyed\' and \\\n
(explanation_delivery_line.getPortalType() == \'Sale Order Line\' or \\\n
explanation_delivery_line.getSimulationState() == \'delivered\'):\n
slap_document.invalidate()\n
else:\n
assert(slap_document.getValidationState() == \'validated\')\n
</string>
</value>
</item>
<item>
...
...
@@ -81,7 +175,7 @@ else:\n
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
HostingSubscription
_migrateSlapState
</string>
</value>
<value>
<string>
SlapDocument
_migrateSlapState
</string>
</value>
</item>
</dictionary>
</pickle>
...
...
master/bt5/vifib_upgrader/bt/revision
View file @
737a4d06
85
\ No newline at end of file
86
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment