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
4d17595c
Commit
4d17595c
authored
May 12, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: drop SubscriptionCondition_renderKVMClusterParameter
parent
2ab0f527
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
206 deletions
+0
-206
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionCondition_renderKVMClusterParameter.py
...equest/SubscriptionCondition_renderKVMClusterParameter.py
+0
-40
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionCondition_renderKVMClusterParameter.xml
...quest/SubscriptionCondition_renderKVMClusterParameter.xml
+0
-70
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
...ortal_components/test.erp5.testSlapOSSubscriptionSkins.py
+0
-96
No files found.
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionCondition_renderKVMClusterParameter.py
deleted
100644 → 0
View file @
2ab0f527
"""
Take the Text Content and adapt it as template for create
an variation for a specific software release.
This adapt the definition of KVM to instantiate multiple VMs instead a single
for example.
"""
from
zExceptions
import
Unauthorized
if
REQUEST
is
not
None
:
raise
Unauthorized
import
json
parameter_text
=
context
.
getTextContent
()
if
not
amount
or
parameter_text
is
None
:
return
None
json_parameter
=
context
.
Base_instanceXmlToDict
(
parameter_text
)
if
"_"
in
json_parameter
:
# This is json-in-xml serialisation
json_parameter
=
json
.
loads
(
json_parameter
[
"_"
])
else
:
raise
ValueError
(
"KVM Cluster only supports serialised values!"
)
KVM0
=
json_parameter
[
"kvm-partition-dict"
][
"KVM0"
]
for
i
in
range
(
amount
):
if
i
==
0
:
k
=
KVM0
.
copy
()
k
[
"sticky-compute-node"
]
=
True
json_parameter
[
"kvm-partition-dict"
][
"KVM"
+
str
(
i
)]
=
k
else
:
json_parameter
[
"kvm-partition-dict"
][
"KVM"
+
str
(
i
)]
=
KVM0
xml_parameter
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="_">%s</parameter>
</instance>"""
%
json
.
dumps
(
json_parameter
,
indent
=
2
)
return
xml_parameter
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionCondition_renderKVMClusterParameter.xml
deleted
100644 → 0
View file @
2ab0f527
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"_reconstructor"
module=
"copy_reg"
/>
</klass>
<tuple>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
<global
name=
"object"
module=
"__builtin__"
/>
<none/>
</tuple>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
amount=0, REQUEST=None, **kw
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SubscriptionCondition_renderKVMClusterParameter
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/TestTemplateItem/portal_components/test.erp5.testSlapOSSubscriptionSkins.py
View file @
4d17595c
...
...
@@ -127,102 +127,6 @@ class TestBase_instanceXmlToDict(TestSubscriptionSkinsMixin):
self
.
assertEqual
(
self
.
portal
.
Base_instanceXmlToDict
(
xml
),
{
'_'
:
'{"aa": "bb"}'
})
class
TestSubscriptionCondition_renderKVMClusterParameter
(
TestSubscriptionSkinsMixin
):
def
test_simple_raise_if_request_is_present
(
self
):
subscription_condition
=
self
.
newSubscriptionCondition
()
self
.
assertRaises
(
Unauthorized
,
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
,
REQUEST
=
self
.
portal
.
REQUEST
)
def
test_simple_parameter_is_none
(
self
):
subscription_condition
=
self
.
newSubscriptionCondition
()
self
.
assertEqual
(
None
,
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
(
amount
=
0
))
self
.
assertEqual
(
None
,
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
(
amount
=
1
))
def
test_simple_raise_if_parameter_isnt_serialised
(
self
):
parameter_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="oioi">notserialised</parameter>
</instance>"""
subscription_condition
=
self
.
newSubscriptionCondition
(
text_content
=
parameter_xml
)
self
.
assertRaises
(
ValueError
,
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
,
amount
=
5
)
def
test_simple_kvm_rendering
(
self
):
parameter_xml
=
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="_">{
"kvm-partition-dict": {
"KVM0": {
"cpu-count": 40,
"cpu-max-count": 41,
"ram-size": 245760,
"ram-max-size": 245761,
"disk-device-path": "/dev/sdb",
"project-guid": "PROJ-XXXX",
"disable-ansible-promise": true
}
}
}</parameter>
</instance>"""
subscription_condition
=
self
.
newSubscriptionCondition
(
text_content
=
parameter_xml
)
# Amount is 0, so return None
self
.
assertEqual
(
None
,
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
())
self
.
assertEqual
(
None
,
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
(
amount
=
0
))
self
.
assertEqual
(
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
(
amount
=
1
).
strip
(),
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="_">{
"kvm-partition-dict": {
"KVM0": {
"disable-ansible-promise": true,
"disk-device-path": "/dev/sdb",
"cpu-count": 40,
"ram-max-size": 245761,
"ram-size": 245760,
"project-guid": "PROJ-XXXX",
"cpu-max-count": 41,
"sticky-compute-node": true
}
}
}</parameter>
</instance>"""
)
self
.
assertEqual
(
subscription_condition
.
SubscriptionCondition_renderKVMClusterParameter
(
amount
=
2
).
strip
(),
"""<?xml version="1.0" encoding="utf-8"?>
<instance>
<parameter id="_">{
"kvm-partition-dict": {
"KVM0": {
"disable-ansible-promise": true,
"disk-device-path": "/dev/sdb",
"cpu-count": 40,
"ram-max-size": 245761,
"ram-size": 245760,
"project-guid": "PROJ-XXXX",
"cpu-max-count": 41,
"sticky-compute-node": true
},
"KVM1": {
"disk-device-path": "/dev/sdb",
"cpu-count": 40,
"ram-max-size": 245761,
"cpu-max-count": 41,
"disable-ansible-promise": true,
"ram-size": 245760,
"project-guid": "PROJ-XXXX"
}
}
}</parameter>
</instance>"""
)
class
TestSubscriptionCondition_renderParameter
(
TestSubscriptionSkinsMixin
):
@
simulate
(
'SubscriptionCondition_renderParameterSampleScript'
,
'*args, **kwargs'
,
'return args, kwargs'
)
...
...
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