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
Klaus Wölfel
slapos.core
Commits
148367e5
Commit
148367e5
authored
May 31, 2012
by
Łukasz Nowak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid External method decoration.
It just does not work [tm].
parent
b734cf39
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
150 additions
and
147 deletions
+150
-147
master/bt5/vifib_upgrader/ExtensionTemplateItem/VifibUpgrader.py
...bt5/vifib_upgrader/ExtensionTemplateItem/VifibUpgrader.py
+149
-146
master/bt5/vifib_upgrader/bt/revision
master/bt5/vifib_upgrader/bt/revision
+1
-1
No files found.
master/bt5/vifib_upgrader/ExtensionTemplateItem/VifibUpgrader.py
View file @
148367e5
...
...
@@ -91,163 +91,166 @@ def fixSaleOrder(slap_document):
sale_packing_list
.
getParentValue
().
deleteContent
(
sale_packing_list
.
getId
())
return
new_sale_order
.
contentValues
(
portal_type
=
'Sale Order Line'
)[
0
]
@
WorkflowMethod
.
disable
def
SlapDocument_migrateSlapState
(
self
):
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
ComplexQuery
def
setUpPeriodicity
(
hosting_subscription
):
from
Products.ERP5Type.DateUtils
import
addToDate
,
getClosestDate
start_date
=
hosting_subscription
.
getCreationDate
()
start_date
=
getClosestDate
(
target_date
=
start_date
,
precision
=
'day'
)
while
start_date
.
day
()
>=
29
:
start_date
=
addToDate
(
start_date
,
to_add
=
{
'day'
:
-
1
})
periodicity_month_day_list
=
[
start_date
.
day
()]
periodicity_hour_list
=
[
0
]
periodicity_minute_list
=
[
0
]
hosting_subscription
.
edit
(
periodicity_month_day_list
=
periodicity_month_day_list
,
periodicity_hour_list
=
periodicity_hour_list
,
periodicity_minute_list
=
periodicity_minute_list
)
slap_document
=
self
portal
=
self
.
getPortalObject
()
portal_type_list
=
(
'Hosting Subscription'
,
'Software Instance'
,
'Slave Instance'
)
portal_type
=
slap_document
.
getPortalType
()
if
portal_type
not
in
portal_type_list
:
raise
TypeError
(
'%s is not %s'
%
(
slap_document
.
getPath
(),
portal_type_list
))
explanation_delivery_line
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Sale Packing List Line'
,
simulation_state
=
[
'ready'
,
'confirmed'
,
'started'
,
'stopped'
,
'delivered'
],
query
=
ComplexQuery
(
Query
(
default_aggregate_uid
=
slap_document
.
getUid
()),
Query
(
default_resource_uid
=
[
portal
.
restrictedTraverse
(
portal
.
portal_preferences
.
getPreferredInstanceSetupResource
()).
getUid
(),
portal
.
restrictedTraverse
(
portal
.
portal_preferences
.
getPreferredInstanceHostingResource
()).
getUid
(),
portal
.
restrictedTraverse
(
portal
.
portal_preferences
.
getPreferredInstanceCleanupResource
()).
getUid
(),
]),
operator
=
'AND'
,
),
sort_on
=
((
'movement.start_date'
,
'DESC'
),)
)
if
explanation_delivery_line
is
None
:
explanation_delivery_line
=
slap_document
.
getAggregateRelatedValue
(
portal_type
=
'Sale Order Line'
)
if
slap_document
.
getRelativeUrl
()
==
'hosting_subscription_module/20120521-C46CA2'
:
# special case of destroyed data
explanation_delivery_line
=
fixSaleOrder
(
slap_document
)
if
portal_type
==
'Hosting Subscription'
:
current_periodicity
=
slap_document
.
getPeriodicityMonthDayList
()
if
current_periodicity
is
None
or
len
(
current_periodicity
)
==
0
:
setUpPeriodicity
(
slap_document
)
# Person is now directly associated on the HS
slap_document
.
edit
(
destination_section_value
=
explanation_delivery_line
.
getDestinationSectionValue
(
portal_type
=
"Person"
),
)
assert
(
slap_document
.
getDestinationSection
()
==
explanation_delivery_line
.
getDestinationSectionValue
().
getRelativeUrl
())
else
:
hosting_subscription
=
explanation_delivery_line
.
getAggregateValue
(
portal_type
=
'Hosting Subscription'
)
slap_document
.
edit
(
specialise_value
=
hosting_subscription
,
root_software_release_url
=
explanation_delivery_line
.
getAggregateValue
(
portal_type
=
'Software Release'
).
getUrlString
()
@
WorkflowMethod
.
disable
def
real
(
self
):
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
ComplexQuery
def
setUpPeriodicity
(
hosting_subscription
):
from
Products.ERP5Type.DateUtils
import
addToDate
,
getClosestDate
start_date
=
hosting_subscription
.
getCreationDate
()
start_date
=
getClosestDate
(
target_date
=
start_date
,
precision
=
'day'
)
while
start_date
.
day
()
>=
29
:
start_date
=
addToDate
(
start_date
,
to_add
=
{
'day'
:
-
1
})
periodicity_month_day_list
=
[
start_date
.
day
()]
periodicity_hour_list
=
[
0
]
periodicity_minute_list
=
[
0
]
hosting_subscription
.
edit
(
periodicity_month_day_list
=
periodicity_month_day_list
,
periodicity_hour_list
=
periodicity_hour_list
,
periodicity_minute_list
=
periodicity_minute_list
)
slap_document
=
self
portal
=
self
.
getPortalObject
()
portal_type_list
=
(
'Hosting Subscription'
,
'Software Instance'
,
'Slave Instance'
)
portal_type
=
slap_document
.
getPortalType
()
if
portal_type
not
in
portal_type_list
:
raise
TypeError
(
'%s is not %s'
%
(
slap_document
.
getPath
(),
portal_type_list
))
explanation_delivery_line
=
portal
.
portal_catalog
.
getResultValue
(
portal_type
=
'Sale Packing List Line'
,
simulation_state
=
[
'ready'
,
'confirmed'
,
'started'
,
'stopped'
,
'delivered'
],
query
=
ComplexQuery
(
Query
(
default_aggregate_uid
=
slap_document
.
getUid
()),
Query
(
default_resource_uid
=
[
portal
.
restrictedTraverse
(
portal
.
portal_preferences
.
getPreferredInstanceSetupResource
()).
getUid
(),
portal
.
restrictedTraverse
(
portal
.
portal_preferences
.
getPreferredInstanceHostingResource
()).
getUid
(),
portal
.
restrictedTraverse
(
portal
.
portal_preferences
.
getPreferredInstanceCleanupResource
()).
getUid
(),
]),
operator
=
'AND'
,
),
sort_on
=
((
'movement.start_date'
,
'DESC'
),)
)
assert
(
slap_document
.
getSpecialise
()
==
hosting_subscription
.
getRelativeUrl
())
# Migrate slap state
if
portal_type
==
'Hosting Subscription'
:
state
=
slap_document
.
getRootState
()
promise_kw
=
{
'instance_xml'
:
slap_document
.
getTextContent
(),
'software_type'
:
slap_document
.
getSourceReference
(),
'sla_xml'
:
slap_document
.
getSlaXml
(),
'software_release'
:
slap_document
.
getRootSoftwareReleaseUrl
(),
'shared'
:
slap_document
.
isRootSlave
()
}
else
:
if
explanation_delivery_line
.
getPortalType
()
==
'Sale Packing List Line'
:
resource
=
explanation_delivery_line
.
getResource
()
if
resource
==
portal
.
portal_preferences
.
getPreferredInstanceSetupResource
():
state
=
'stopped'
elif
resource
==
portal
.
portal_preferences
.
getPreferredInstanceCleanupResource
():
state
=
'destroyed'
elif
resource
==
portal
.
portal_preferences
.
getPreferredInstanceHostingResource
():
if
explanation_delivery_line
.
getSimulationState
()
in
(
'confirmed'
,
'started'
):
state
=
'started'
else
:
if
explanation_delivery_line
is
None
:
explanation_delivery_line
=
slap_document
.
getAggregateRelatedValue
(
portal_type
=
'Sale Order Line'
)
if
slap_document
.
getRelativeUrl
()
==
'hosting_subscription_module/20120521-C46CA2'
:
# special case of destroyed data
explanation_delivery_line
=
fixSaleOrder
(
slap_document
)
if
portal_type
==
'Hosting Subscription'
:
current_periodicity
=
slap_document
.
getPeriodicityMonthDayList
()
if
current_periodicity
is
None
or
len
(
current_periodicity
)
==
0
:
setUpPeriodicity
(
slap_document
)
# Person is now directly associated on the HS
slap_document
.
edit
(
destination_section_value
=
explanation_delivery_line
.
getDestinationSectionValue
(
portal_type
=
"Person"
),
)
assert
(
slap_document
.
getDestinationSection
()
==
explanation_delivery_line
.
getDestinationSectionValue
().
getRelativeUrl
())
else
:
hosting_subscription
=
explanation_delivery_line
.
getAggregateValue
(
portal_type
=
'Hosting Subscription'
)
slap_document
.
edit
(
specialise_value
=
hosting_subscription
,
root_software_release_url
=
explanation_delivery_line
.
getAggregateValue
(
portal_type
=
'Software Release'
).
getUrlString
()
)
assert
(
slap_document
.
getSpecialise
()
==
hosting_subscription
.
getRelativeUrl
())
# Migrate slap state
if
portal_type
==
'Hosting Subscription'
:
state
=
slap_document
.
getRootState
()
promise_kw
=
{
'instance_xml'
:
slap_document
.
getTextContent
(),
'software_type'
:
slap_document
.
getSourceReference
(),
'sla_xml'
:
slap_document
.
getSlaXml
(),
'software_release'
:
slap_document
.
getRootSoftwareReleaseUrl
(),
'shared'
:
slap_document
.
isRootSlave
()
}
else
:
if
explanation_delivery_line
.
getPortalType
()
==
'Sale Packing List Line'
:
resource
=
explanation_delivery_line
.
getResource
()
if
resource
==
portal
.
portal_preferences
.
getPreferredInstanceSetupResource
():
state
=
'stopped'
elif
resource
==
portal
.
portal_preferences
.
getPreferredInstanceCleanupResource
():
state
=
'destroyed'
elif
resource
==
portal
.
portal_preferences
.
getPreferredInstanceHostingResource
():
if
explanation_delivery_line
.
getSimulationState
()
in
(
'confirmed'
,
'started'
):
state
=
'started'
else
:
state
=
'stopped'
pass
else
:
raise
TypeError
(
'Bad resource %s'
%
resource
)
pass
else
:
raise
TypeError
(
'Bad resource %s'
%
resource
)
pass
else
:
if
explanation_delivery_line
.
getSimulationState
()
==
'cancelled'
:
state
=
'destroyed'
else
:
assert
(
explanation_delivery_line
.
getSimulationState
()
in
[
'ordered'
,
'confirmed'
])
previous_workflow_state
=
self
.
workflow_history
[
'software_instance_slap_interface_workflow'
][
-
1
][
'slap_state'
]
if
previous_workflow_state
==
'start_requested'
:
state
=
'started'
elif
previous_workflow_state
==
'stop_requested'
:
state
=
'stopped'
if
explanation_delivery_line
.
getSimulationState
()
==
'cancelled'
:
state
=
'destroyed'
else
:
raise
NotImplementedError
(
"Previous state %r not supported"
%
previous_workflow_state
)
promise_kw
=
{
'instance_xml'
:
slap_document
.
getTextContent
(),
'software_type'
:
slap_document
.
getSourceReference
(),
'sla_xml'
:
slap_document
.
getSlaXml
(),
'software_release'
:
slap_document
.
getRootSoftwareReleaseUrl
(),
'shared'
:
slap_document
.
getPortalType
()
==
'Slave Instance'
assert
(
explanation_delivery_line
.
getSimulationState
()
in
[
'ordered'
,
'confirmed'
])
previous_workflow_state
=
self
.
workflow_history
[
'software_instance_slap_interface_workflow'
][
-
1
][
'slap_state'
]
if
previous_workflow_state
==
'start_requested'
:
state
=
'started'
elif
previous_workflow_state
==
'stop_requested'
:
state
=
'stopped'
else
:
raise
NotImplementedError
(
"Previous state %r not supported"
%
previous_workflow_state
)
promise_kw
=
{
'instance_xml'
:
slap_document
.
getTextContent
(),
'software_type'
:
slap_document
.
getSourceReference
(),
'sla_xml'
:
slap_document
.
getSlaXml
(),
'software_release'
:
slap_document
.
getRootSoftwareReleaseUrl
(),
'shared'
:
slap_document
.
getPortalType
()
==
'Slave Instance'
}
slap_document
.
setCausalityValue
(
explanation_delivery_line
.
getParentValue
())
if
state
!=
'destroyed'
or
explanation_delivery_line
.
getSimulationState
()
!=
'delivered'
:
slap_document
.
setAggregateValue
(
explanation_delivery_line
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
assert
(
slap_document
.
getAggregate
()
==
explanation_delivery_line
.
getAggregate
(
portal_type
=
'Computer Partition'
))
state_map
=
{
'started'
:
'start_requested'
,
'stopped'
:
'stop_requested'
,
'destroyed'
:
'destroy_requested'
}
slap_document
.
setCausalityValue
(
explanation_delivery_line
.
getParentValue
())
if
state
!=
'destroyed'
or
explanation_delivery_line
.
getSimulationState
()
!=
'delivered'
:
slap_document
.
setAggregateValue
(
explanation_delivery_line
.
getAggregateValue
(
portal_type
=
'Computer Partition'
))
assert
(
slap_document
.
getAggregate
()
==
explanation_delivery_line
.
getAggregate
(
portal_type
=
'Computer Partition'
))
state_map
=
{
'started'
:
'start_requested'
,
'stopped'
:
'stop_requested'
,
'destroyed'
:
'destroy_requested'
}
required_state
=
state_map
[
state
]
_jumpToStateFor
=
portal
.
portal_workflow
.
_jumpToStateFor
if
slap_document
.
getSlapState
()
!=
required_state
:
_jumpToStateFor
(
slap_document
,
required_state
,
'instance_slap_interface_workflow'
)
if
not
(
slap_document
.
getSlapState
()
==
required_state
):
raise
ValueError
(
'%s: %s != %s'
%
(
state
,
slap_document
.
getSlapState
(),
required_state
))
# Migrate validation state
if
portal_type
==
'Hosting Subscription'
:
if
state
==
'destroyed'
:
_jumpToStateFor
(
slap_document
,
'archived'
,
'hosting_subscription_workflow'
)
assert
(
slap_document
.
getValidationState
()
==
'archived'
)
else
:
_jumpToStateFor
(
slap_document
,
'validated'
,
'hosting_subscription_workflow'
)
assert
(
slap_document
.
getValidationState
()
==
'validated'
)
else
:
if
state
==
'destroyed'
and
\
(
explanation_delivery_line
.
getPortalType
()
==
'Sale Order Line'
or
\
explanation_delivery_line
.
getSimulationState
()
==
'delivered'
):
_jumpToStateFor
(
slap_document
,
'invalidated'
,
'item_workflow'
)
required_state
=
state_map
[
state
]
_jumpToStateFor
=
portal
.
portal_workflow
.
_jumpToStateFor
if
slap_document
.
getSlapState
()
!=
required_state
:
_jumpToStateFor
(
slap_document
,
required_state
,
'instance_slap_interface_workflow'
)
if
not
(
slap_document
.
getSlapState
()
==
required_state
):
raise
ValueError
(
'%s: %s != %s'
%
(
state
,
slap_document
.
getSlapState
(),
required_state
))
# Migrate validation state
if
portal_type
==
'Hosting Subscription'
:
if
state
==
'destroyed'
:
_jumpToStateFor
(
slap_document
,
'archived'
,
'hosting_subscription_workflow'
)
assert
(
slap_document
.
getValidationState
()
==
'archived'
)
else
:
_jumpToStateFor
(
slap_document
,
'validated'
,
'hosting_subscription_workflow'
)
assert
(
slap_document
.
getValidationState
()
==
'validated'
)
else
:
if
not
(
slap_document
.
getValidationState
()
==
'validated'
):
raise
ValueError
(
'%s != %s'
%
(
slap_document
.
getValidationState
(),
'validated'
))
if
state
==
'destroyed'
and
\
(
explanation_delivery_line
.
getPortalType
()
==
'Sale Order Line'
or
\
explanation_delivery_line
.
getSimulationState
()
==
'delivered'
):
_jumpToStateFor
(
slap_document
,
'invalidated'
,
'item_workflow'
)
else
:
if
not
(
slap_document
.
getValidationState
()
==
'validated'
):
raise
ValueError
(
'%s != %s'
%
(
slap_document
.
getValidationState
(),
'validated'
))
# Update Local Roles
slap_document
.
updateLocalRolesOnSecurityGroups
()
# Update Local Roles
slap_document
.
updateLocalRolesOnSecurityGroups
()
@
WorkflowMethod
.
disable
def
SalePackingListLine_deliver
(
self
):
portal
=
self
.
getPortalObject
()
assert
(
self
.
getResource
()
in
[
portal
.
portal_preferences
.
getPreferredInstanceSetupResource
(),
portal
.
portal_preferences
.
getPreferredInstanceUpdateResource
()])
if
self
.
getSimulationState
()
!=
'delivered'
:
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
getParentValue
(),
'delivered'
)
self
.
recursiveReindexObject
()
@
WorkflowMethod
.
disable
def
real
(
self
):
portal
=
self
.
getPortalObject
()
assert
(
self
.
getResource
()
in
[
portal
.
portal_preferences
.
getPreferredInstanceSetupResource
(),
portal
.
portal_preferences
.
getPreferredInstanceUpdateResource
()])
if
self
.
getSimulationState
()
!=
'delivered'
:
portal
.
portal_workflow
.
_jumpToStateFor
(
self
.
getParentValue
(),
'delivered'
)
self
.
recursiveReindexObject
()
real
(
self
)
def
Computer_updateLocalRoles
(
self
):
self
.
updateLocalRolesOnSecurityGroups
(
reindex
=
False
)
...
...
master/bt5/vifib_upgrader/bt/revision
View file @
148367e5
113
\ No newline at end of file
114
\ 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