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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
052da26e
Commit
052da26e
authored
Feb 20, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_crm: delete instance, compute node, project if regularisation request reach the end
parent
2170cfba
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
10 deletions
+54
-10
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_deleteInstanceTreeList.py
...lapos_crm/RegularisationRequest_deleteInstanceTreeList.py
+54
-10
No files found.
master/bt5/slapos_crm/SkinTemplateItem/portal_skins/slapos_crm/RegularisationRequest_deleteInstanceTreeList.py
View file @
052da26e
...
...
@@ -10,13 +10,57 @@ if (state == 'suspended') and \
(
ticket
.
getResource
()
==
'service_module/slapos_crm_delete_acknowledgement'
):
portal
=
context
.
getPortalObject
()
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Instance Tree"
,
validation_state
=
[
"validated"
],
destination_section__uid
=
person
.
getUid
(),
method_id
=
'InstanceTree_deleteFromRegularisationRequest'
,
method_args
=
(
person
.
getRelativeUrl
(),),
activate_kw
=
{
'tag'
:
tag
}
)
return
True
return
False
subscribed_item_list
=
[]
ledger_uid
=
portal
.
portal_categories
.
ledger
.
automated
.
getUid
()
# Gather the list of not paid services
for
outstanding_amount
in
person
.
Entity_getOutstandingAmountList
(
ledger_uid
=
ledger_uid
,
include_planned
=
True
):
for
outstanding_invoice
in
person
.
Entity_getOutstandingAmountList
(
section_uid
=
outstanding_amount
.
getSourceSectionUid
(),
resource_uid
=
outstanding_amount
.
getPriceCurrencyUid
(),
ledger_uid
=
outstanding_amount
.
getLedgerUid
(),
group_by_node
=
False
):
subscribed_item
=
None
for
invoice_line
in
outstanding_invoice
.
getMovementList
(
portal_type
=
[
'Invoice Line'
,
'Invoice Cell'
]
):
hosting_subscription
=
invoice_line
.
getAggregateValue
(
portal_type
=
'Hosting Subscription'
)
if
hosting_subscription
is
not
None
:
subscribed_item
=
invoice_line
.
getAggregateValue
(
portal_type
=
[
'Project'
,
'Instance Tree'
,
'Compute Node'
])
if
subscribed_item
is
None
:
raise
NotImplementedError
(
'Unhandled invoice line %s'
%
invoice_line
.
getRelativeUrl
())
subscribed_item_list
.
append
(
subscribed_item
)
if
subscribed_item
is
None
:
raise
NotImplementedError
(
'Unhandled invoice %s'
%
outstanding_invoice
.
getRelativeUrl
())
for
subscribed_item
in
subscribed_item_list
:
if
((
subscribed_item
.
getPortalType
()
==
'Compute Node'
)
and
(
subscribed_item
.
getAllocationScope
()
!=
'close/forever'
)):
# allow cleaning up the compute node even if deleted
subscribed_item
.
edit
(
allocation_scope
=
'close/forever'
)
elif
(
subscribed_item
.
getPortalType
()
==
'Instance Tree'
):
# change the slap state to deleted, to allow propagation of the state
# even on remote node
subscribed_item
.
InstanceTree_deleteFromRegularisationRequest
(
person
.
getRelativeUrl
())
elif
((
subscribed_item
.
getPortalType
()
==
'Project'
)
and
(
subscribed_item
.
getValidationState
()
!=
'invalidated'
)):
# do not close the project until all node and instance trees are corrected deleted
can_invalidate_project
=
True
for
other_item
in
portal
.
portal_catalog
(
portal_type
=
[
'Compute Node'
,
'Instance Tree'
],
follow_up__uid
=
subscribed_item
.
getUid
()
):
if
other_item
.
getValidationState
()
not
in
[
'invalidated'
,
'archived'
]:
can_invalidate_project
=
False
subscribed_item_list
.
append
(
other_item
)
if
can_invalidate_project
:
subscribed_item
.
invalidate
(
comment
=
'Not paid'
)
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