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
1f330244
Commit
1f330244
authored
Oct 19, 2022
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_cloud: check Allocation Supply to filter where allocation can be done
parent
e88d2877
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
5 deletions
+72
-5
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Person_findPartition.py
...ateItem/portal_skins/slapos_cloud/Person_findPartition.py
+72
-5
No files found.
master/bt5/slapos_cloud/SkinTemplateItem/portal_skins/slapos_cloud/Person_findPartition.py
View file @
1f330244
...
@@ -6,22 +6,90 @@ portal = person.getPortalObject()
...
@@ -6,22 +6,90 @@ portal = person.getPortalObject()
assert
project_uid
assert
project_uid
compute_partition
=
None
compute_partition
=
None
filter_kw_copy
=
filter_kw
.
copy
()
query_kw
=
{
query_kw
=
{
'portal_type'
:
'Compute Partition'
,
'parent__follow_up__uid'
:
project_uid
,
'parent__follow_up__uid'
:
project_uid
,
'allocation_scope__uid'
:
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open"
).
getUid
(),
'allocation_scope__uid'
:
portal
.
restrictedTraverse
(
"portal_categories/allocation_scope/open"
).
getUid
(),
'software_release_url'
:
software_release_url
,
'portal_type'
:
'Compute Partition'
,
}
}
if
software_instance_portal_type
==
"Slave Instance"
:
if
software_instance_portal_type
==
"Slave Instance"
:
query_kw
[
'free_for_request'
]
=
0
query_kw
[
'free_for_request'
]
=
0
query_kw
[
'software_type'
]
=
software_type
compute_node_portal_type
=
'Instance Node'
elif
software_instance_portal_type
==
"Software Instance"
:
elif
software_instance_portal_type
==
"Software Instance"
:
query_kw
[
'free_for_request'
]
=
1
query_kw
[
'free_for_request'
]
=
1
query_kw
[
'software_release_url'
]
=
software_release_url
compute_node_portal_type
=
'Compute Node'
else
:
else
:
raise
NotImplementedError
(
"Unknown portal type %s"
%
raise
NotImplementedError
(
"Unknown portal type %s"
%
software_instance_portal_type
)
software_instance_portal_type
)
### Step 1, check where the allocation is allowed
from
Products.CMFCore.utils
import
getToolByName
domain_tool
=
getToolByName
(
portal
,
'portal_domains'
)
# XXX prototype for now
tmp_instance
=
portal
.
portal_trash
.
newContent
(
portal_type
=
'Instance Tree'
,
temp_object
=
1
,
url_string
=
software_release_url
,
source_reference
=
software_type
,
follow_up_uid
=
project_uid
)
software_product
,
release_variation
,
type_variation
=
tmp_instance
.
InstanceTree_getSoftwareProduct
()
if
software_product
is
None
:
raise
ValueError
(
'No Software Product matching'
)
tmp_context
=
portal
.
portal_trash
.
newContent
(
portal_type
=
'Movement'
,
temp_object
=
1
,
resource_value
=
software_product
,
software_type_value
=
type_variation
,
software_release_value
=
release_variation
,
)
allocation_cell_list
=
[
x
.
getObject
()
for
x
in
\
domain_tool
.
searchPredicateList
(
tmp_context
,
portal_type
=
[
'Allocation Supply Cell'
],
validation_state
=
'validated'
,
destination_project__uid
=
project_uid
,
tested_base_category_list
=
[
'resource'
,
'software_type'
,
'software_release'
])
if
x
.
isAllocable
()]
#context.log('allocation_cell_list %s' % str(allocation_cell_list))
if
not
allocation_cell_list
:
raise
ValueError
(
'No Allocation Supply allowing this operation'
)
# Get the list of allowed Compute Node, Instance Node
compute_node_list_list
=
[
x
.
getParentValue
().
getParentValue
().
getAggregateValueList
(
portal_type
=
compute_node_portal_type
)
for
x
in
allocation_cell_list
]
parent_uid_list
=
[]
partition_uid_list
=
[]
for
compute_node_list
in
compute_node_list_list
:
for
compute_node
in
compute_node_list
:
if
compute_node
.
getPortalType
()
==
'Compute Node'
:
parent_uid_list
.
append
(
compute_node
.
getUid
())
elif
compute_node
.
getPortalType
()
==
'Instance Node'
:
shared_instance
=
compute_node
.
getSpecialiseValue
(
portal_type
=
'Software Instance'
)
if
shared_instance
is
not
None
:
# No need to search for original software type/url
#query_kw['software_release_url'] = software_release_url
#query_kw['software_type'] = software_type
shared_partition
=
shared_instance
.
getAggregateValue
(
portal_type
=
'Compute Partition'
)
if
shared_partition
is
not
None
:
partition_uid_list
.
append
(
shared_partition
.
getUid
())
else
:
raise
NotImplementedError
(
'Unsupported Node type: %s'
%
compute_node
.
getPortalType
())
if
len
(
parent_uid_list
)
==
0
:
# Ensure nothing will be found
parent_uid_list
.
append
(
-
1
)
if
len
(
partition_uid_list
)
==
0
:
# Ensure nothing will be found
partition_uid_list
.
append
(
-
1
)
if
software_instance_portal_type
==
"Slave Instance"
:
query_kw
[
'uid'
]
=
partition_uid_list
elif
software_instance_portal_type
==
"Software Instance"
:
query_kw
[
'parent_uid'
]
=
parent_uid_list
# Explicit location
# Explicit location
if
"computer_guid"
in
filter_kw
:
if
"computer_guid"
in
filter_kw
:
query_kw
[
"parent_reference"
]
=
SimpleQuery
(
parent_reference
=
filter_kw
.
pop
(
"computer_guid"
))
query_kw
[
"parent_reference"
]
=
SimpleQuery
(
parent_reference
=
filter_kw
.
pop
(
"computer_guid"
))
...
@@ -107,7 +175,6 @@ if offset >= SQL_WINDOW_SIZE:
...
@@ -107,7 +175,6 @@ if offset >= SQL_WINDOW_SIZE:
else
:
else
:
limit
=
(
0
,
SQL_WINDOW_SIZE
)
limit
=
(
0
,
SQL_WINDOW_SIZE
)
for
compute_partition_candidate
in
portal
.
portal_catalog
(
for
compute_partition_candidate
in
portal
.
portal_catalog
(
limit
=
limit
,
**
query_kw
):
limit
=
limit
,
**
query_kw
):
compute_partition_candidate
=
compute_partition_candidate
.
getObject
()
compute_partition_candidate
=
compute_partition_candidate
.
getObject
()
...
...
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