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
Titouan Soulard
slapos.core
Commits
64f7fab7
Commit
64f7fab7
authored
Apr 11, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: create Subscription Request for Compute Node
parent
d9d4f419
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
5 deletions
+32
-5
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Alarm_createSubscriptionRequestFromOrphanedItem.py
...equest/Alarm_createSubscriptionRequestFromOrphanedItem.py
+21
-2
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Item_createSubscriptionRequest.py
...os_subscription_request/Item_createSubscriptionRequest.py
+6
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Resource_createSubscriptionRequest.py
...ubscription_request/Resource_createSubscriptionRequest.py
+3
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_validateIfSubmitted.py
...iption_request/SubscriptionRequest_validateIfSubmitted.py
+1
-0
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionAlarm.py
...ortal_components/test.erp5.testSlapOSSubscriptionAlarm.py
+1
-2
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Alarm_createSubscriptionRequestFromOrphanedItem.py
View file @
64f7fab7
portal
=
context
.
getPortalObject
()
from
Products.ZSQLCatalog.SQLCatalog
import
SimpleQuery
,
NegatedQuery
# XXX TODO this is really not efficient
# this does not scale with millions of uid
# how to use a left join instead? or a single query with the embedded subquery?
subscribed_uid_list
=
[
x
.
uid
for
x
in
portal
.
portal_catalog
(
portal_type
=
[
"Compute Node"
,
"Instance Tree"
],
aggregate__related__portal_type
=
"Subscription Request"
)]
sql_kw
=
{}
if
subscribed_uid_list
:
sql_kw
[
'subscribed_uid_list'
]
=
NegatedQuery
(
SimpleQuery
(
uid
=
subscribed_uid_list
))
return
portal
.
portal_catalog
.
searchAndActivate
(
method_id
=
'Item_createSubscriptionRequest'
,
portal_type
=
[
"Compute Node"
,
"Instance Tree"
],
activate_kw
=
{
'tag'
:
tag
},
**
sql_kw
)
"""
# XXX if there is a non Subscription Request with such aggregate link
# it will lead to not creating the Subscription Request
# TODO find a way to check the portal type
...
...
@@ -12,9 +31,9 @@ kw.update(select_dict)
portal.portal_catalog.searchAndActivate(
method_id='Item_createSubscriptionRequest',
# Project are created only from UI for now
portal_type
=
[
"Instance Tree"
],
portal_type=["Instance Tree"
, "Compute Node"
],
activate_kw={'tag': tag},
**kw
)
"""
context
.
activate
(
after_tag
=
tag
).
getId
()
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Item_createSubscriptionRequest.py
View file @
64f7fab7
...
...
@@ -40,6 +40,12 @@ if item.getPortalType() == 'Instance Tree':
'software_type/%s'
%
software_type
.
getRelativeUrl
()
]
resource_vcl
.
sort
()
elif
item
.
getPortalType
()
==
'Compute Node'
:
service
=
portal
.
restrictedTraverse
(
'service_module/slapos_compute_node_subscription'
)
resource_vcl
=
None
project_value
=
item
.
getFollowUpValue
(
portal_type
=
"Project"
)
if
project_value
is
not
None
:
source_decision_value
=
project_value
.
getDestinationValue
(
portal_type
=
"Person"
)
else
:
raise
ValueError
(
'Unsupported portal type: %s (%s)'
%
(
item
.
getPortalType
(),
item
.
getRelativeUrl
()))
# service = self.portal.restrictedTraverse('service_module/slapos_virtual_master_subscription')
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Resource_createSubscriptionRequest.py
View file @
64f7fab7
...
...
@@ -8,7 +8,9 @@ project_value = None
if
resource
.
getPortalType
()
==
"Software Product"
:
project_value
=
resource
.
getFollowUpValue
(
portal_type
=
"Project"
)
elif
resource
.
getPortalType
()
==
"Service"
:
if
resource
.
getRelativeUrl
()
!=
"service_module/slapos_virtual_master_subscription"
:
if
resource
.
getRelativeUrl
()
not
in
(
"service_module/slapos_virtual_master_subscription"
,
"service_module/slapos_compute_node_subscription"
):
raise
NotImplementedError
(
'Unsupported resource: %s'
%
resource
.
getRelativeUrl
())
else
:
raise
NotImplementedError
(
'Unsupported resource: %s'
%
resource
.
getRelativeUrl
())
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequest_validateIfSubmitted.py
View file @
64f7fab7
...
...
@@ -11,6 +11,7 @@ if item is None:
# create the project
item
=
portal
.
project_module
.
newContent
(
portal_type
=
'Project'
,
destination_value
=
customer
)
item
.
validate
()
...
...
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionAlarm.py
View file @
64f7fab7
...
...
@@ -50,7 +50,6 @@ class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin):
#####################################################
# Instance Tree aggregated to another portal type
# TODO how to ensure Instance Tree is visited?
instance_tree
=
self
.
portal
.
instance_tree_module
.
newContent
(
portal_type
=
'Instance Tree'
,
title
=
"Test Instance Tree another portal type %s"
%
self
.
new_id
...
...
@@ -62,4 +61,4 @@ class TestSlapOSSubscriptionRequestProcessAlarm(SlapOSTestCaseMixin):
portal_type
=
"Sale Packing List Line"
,
aggregate_value
=
instance_tree
)
self
.
_test_alarm
_not_visited
(
alarm
,
instance_tree
,
script_name
)
self
.
_test_alarm
(
alarm
,
instance_tree
,
script_name
)
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