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
Gabriel Monnerat
slapos.core
Commits
3cfdceb7
Commit
3cfdceb7
authored
May 02, 2016
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: Moving consumption related code from ecoallocation to this business template.
parent
8cc3cf47
Changes
35
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
2059 additions
and
0 deletions
+2059
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Alarm_updateSoftwareReleaseCapacity.py
...slapos_consumption/Alarm_updateSoftwareReleaseCapacity.py
+10
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Alarm_updateSoftwareReleaseCapacity.xml
...lapos_consumption/Alarm_updateSoftwareReleaseCapacity.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getLatestCPUPercentLoad.py
...ns/slapos_consumption/Computer_getLatestCPUPercentLoad.py
+15
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getLatestCPUPercentLoad.xml
...s/slapos_consumption/Computer_getLatestCPUPercentLoad.xml
+70
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getWattConsumption.py
...l_skins/slapos_consumption/Computer_getWattConsumption.py
+46
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getWattConsumption.xml
..._skins/slapos_consumption/Computer_getWattConsumption.xml
+70
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getZeroEmissionRatio.py
...skins/slapos_consumption/Computer_getZeroEmissionRatio.py
+20
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getZeroEmissionRatio.xml
...kins/slapos_consumption/Computer_getZeroEmissionRatio.xml
+70
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscript_getEcoReallocationInformation.py
...umption/HostingSubscript_getEcoReallocationInformation.py
+17
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscript_getEcoReallocationInformation.xml
...mption/HostingSubscript_getEcoReallocationInformation.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscription_getMostEcoEfficientSoftwareInstance.py
...ostingSubscription_getMostEcoEfficientSoftwareInstance.py
+15
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscription_getMostEcoEfficientSoftwareInstance.xml
...stingSubscription_getMostEcoEfficientSoftwareInstance.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getAverageCPULoad.py
.../slapos_consumption/SoftwareInstance_getAverageCPULoad.py
+20
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getAverageCPULoad.xml
...slapos_consumption/SoftwareInstance_getAverageCPULoad.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getCurrentDeltaCO2.py
...slapos_consumption/SoftwareInstance_getCurrentDeltaCO2.py
+10
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getCurrentDeltaCO2.xml
...lapos_consumption/SoftwareInstance_getCurrentDeltaCO2.xml
+70
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getFutureDeltaCO2.py
.../slapos_consumption/SoftwareInstance_getFutureDeltaCO2.py
+15
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getFutureDeltaCO2.xml
...slapos_consumption/SoftwareInstance_getFutureDeltaCO2.xml
+70
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getLatestCPUPercentLoad.py
...s_consumption/SoftwareInstance_getLatestCPUPercentLoad.py
+12
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getLatestCPUPercentLoad.xml
..._consumption/SoftwareInstance_getLatestCPUPercentLoad.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getResilientMasterNode.py
...os_consumption/SoftwareInstance_getResilientMasterNode.py
+19
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getResilientMasterNode.xml
...s_consumption/SoftwareInstance_getResilientMasterNode.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getWattStats.py
...skins/slapos_consumption/SoftwareInstance_getWattStats.py
+17
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getWattStats.xml
...kins/slapos_consumption/SoftwareInstance_getWattStats.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_viewCurrentConsumption.xml
...s_consumption/SoftwareInstance_viewCurrentConsumption.xml
+153
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_viewCurrentConsumption/your_future_watt_consumption.xml
...e_viewCurrentConsumption/your_future_watt_consumption.xml
+290
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_viewCurrentConsumption/your_watt_consumption.xml
...Instance_viewCurrentConsumption/your_watt_consumption.xml
+275
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedCPULoad.py
..._consumption/SoftwareRelease_getAverageConsumedCPULoad.py
+24
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedCPULoad.xml
...consumption/SoftwareRelease_getAverageConsumedCPULoad.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedMemory.py
...s_consumption/SoftwareRelease_getAverageConsumedMemory.py
+24
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedMemory.xml
..._consumption/SoftwareRelease_getAverageConsumedMemory.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getDeltaCO2List.py
...ins/slapos_consumption/SoftwareRelease_getDeltaCO2List.py
+30
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getDeltaCO2List.xml
...ns/slapos_consumption/SoftwareRelease_getDeltaCO2List.xml
+62
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SotftwareRelease_updateCapacityQuantity.py
...os_consumption/SotftwareRelease_updateCapacityQuantity.py
+15
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SotftwareRelease_updateCapacityQuantity.xml
...s_consumption/SotftwareRelease_updateCapacityQuantity.xml
+62
-0
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Alarm_updateSoftwareReleaseCapacity.py
0 → 100644
View file @
3cfdceb7
"""
For all software releases, upgrade the Average CPU and Memory Capacity
"""
portal
=
context
.
getPortalObject
()
portal
.
portal_catalog
.
searchAndActivate
(
portal_type
=
"Software Release"
,
method_id
=
"SotftwareRelease_updateCapacityQuantity"
,
)
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Alarm_updateSoftwareReleaseCapacity.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Alarm_updateSoftwareReleaseCapacity
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getLatestCPUPercentLoad.py
0 → 100644
View file @
3cfdceb7
if
REQUEST
is
not
None
:
raise
Unauthorized
(
"Unauthorized call script from URL"
)
portal
=
context
.
getPortalObject
()
packing_list_line
=
portal
.
portal_catalog
.
getResultValue
(
sort_on
=
(
"creation_date"
,
"DESC"
),
portal_type
=
"Sale Packing List Line"
,
default_resource_uid
=
context
.
service_module
.
cpu_load_percent
.
getUid
(),
default_aggregate_uid
=
context
.
getUid
())
if
packing_list_line
is
not
None
:
return
packing_list_line
.
getQuantity
()
return
0.0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getLatestCPUPercentLoad.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
REQUEST=None
</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>
Computer_getLatestCPUPercentLoad
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getWattConsumption.py
0 → 100644
View file @
3cfdceb7
if
REQUEST
is
not
None
:
raise
Unauthorized
(
"Unauthorized call script from URL"
)
model_id
=
context
.
getWattConsumptionModel
(
"no_model"
)
######
# Introduce your Consumption Model here
######
def
consumption_model_shuttle_ds61_i7
(
load
):
""" Expected consumed watts for the computer load
"""
if
load
<=
25
:
return
21.5
+
1.06
*
load
else
:
return
48
+
0.29
*
load
def
consumption_model_shuttle_nuc_i7
(
load
):
""" Expected consumed watts for the computer load
"""
if
load
<=
25
:
return
8.5
+
0.46
*
load
else
:
return
20
+
0.08
*
load
def
consumption_model_rikomagic_mk802iv
(
load
):
""" Expected consumed watts for the computer load
"""
if
load
<=
25
:
return
2.2
+
0.04
*
load
else
:
return
3.2
+
0.008
*
load
def
no_model
(
load
):
return
0
model_map
=
{
"shuttle_ds61_i7"
:
consumption_model_shuttle_ds61_i7
,
"rikomagic_mk802iv"
:
consumption_model_rikomagic_mk802iv
,
"intel_nuc_i7"
:
consumption_model_shuttle_nuc_i7
}
if
cpu_load_percentage
is
None
:
cpu_load_percentage
=
context
.
Computer_getLatestCPUPercentLoad
()
cpu_load_percentage
+=
partition_increment
return
model_map
.
get
(
model_id
,
no_model
)(
cpu_load_percentage
)
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getWattConsumption.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
cpu_load_percentage=None, partition_increment=0, REQUEST=None
</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>
Computer_getWattConsumption
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getZeroEmissionRatio.py
0 → 100644
View file @
3cfdceb7
if
REQUEST
is
not
None
:
raise
Unauthorized
(
"Unauthorized call script from URL"
)
portal
=
context
.
getPortalObject
()
resource_uid
=
context
.
service_module
.
zero_emission_ratio
.
getUid
()
packing_list_line_list
=
portal
.
portal_catalog
(
limit
=
1
,
sort_on
=
(
"creation_date"
,
"DESC"
),
portal_type
=
"Sale Packing List Line"
,
default_resource_uid
=
resource_uid
,
default_aggregate_uid
=
context
.
getUid
())
if
len
(
packing_list_line_list
):
quantity
=
packing_list_line_list
[
0
].
getQuantity
()
if
quantity
>
0
:
return
quantity
return
0.0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/Computer_getZeroEmissionRatio.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
REQUEST=None
</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>
Computer_getZeroEmissionRatio
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscript_getEcoReallocationInformation.py
0 → 100644
View file @
3cfdceb7
instance
,
delta_co2
=
context
.
HostingSubscription_getMostEcoEfficientSoftwareInstance
()
if
instance
is
None
:
return
None
master_node
=
instance
.
SoftwareInstance_getResilientMasterNode
()
if
master_node
is
None
:
return
None
if
instance
.
getRelativeUrl
()
!=
master_node
.
getRelativeUrl
():
master_delta_co2
=
master_node
.
SoftwareInstance_getFutureDeltaCO2
()
saving_ratio
=
(
master_delta_co2
-
delta_co2
)
/
master_delta_co2
return
"Improve Power efficiency in %s%% by using %s instance as Main Node. We recommend you to a take over."
%
(
int
(
saving_ratio
*
100
),
instance
.
getTitle
())
return
None
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscript_getEcoReallocationInformation.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
HostingSubscript_getEcoReallocationInformation
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscription_getMostEcoEfficientSoftwareInstance.py
0 → 100644
View file @
3cfdceb7
partition_co2_dict
=
{}
min_delta_co2
=
2000
minimal_candidate
=
None
for
software_instance
in
context
.
getSpecialiseRelatedValueList
(
portal_type
=
"Software Instance"
):
delta_co2
=
software_instance
.
SoftwareInstance_getFutureDeltaCO2
()
if
delta_co2
!=
"Not Applicable"
:
if
delta_co2
<
min_delta_co2
:
minimal_candidate
=
software_instance
min_delta_co2
=
delta_co2
elif
(
delta_co2
==
min_delta_co2
)
and
\
(
software_instance
.
getTitle
()
in
[
"kvm0"
,
"runner0"
]):
minimal_candidate
=
software_instance
return
minimal_candidate
,
min_delta_co2
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/HostingSubscription_getMostEcoEfficientSoftwareInstance.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
HostingSubscription_getMostEcoEfficientSoftwareInstance
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getAverageCPULoad.py
0 → 100644
View file @
3cfdceb7
portal
=
context
.
getPortalObject
()
software_release_url
=
context
.
getUrlString
()
resource_uid
=
context
.
service_module
.
cpu_load_percent
.
getUid
()
# Select all software instances from a certain Software Release
packing_list_line_list
=
portal
.
portal_catalog
(
limit
=
20
,
sort_on
=
(
"creation_date"
,
"DESC"
),
portal_type
=
"Sale Packing List Line"
,
default_resource_uid
=
resource_uid
,
default_aggregate_uid
=
[
context
.
getUid
()]
)
if
len
(
packing_list_line_list
):
# Remove the /8 and update the value on the clients.
return
sum
([
i
.
getQuantity
()
for
i
in
packing_list_line_list
])
/
len
(
packing_list_line_list
)
return
0.0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getAverageCPULoad.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareInstance_getAverageCPULoad
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getCurrentDeltaCO2.py
0 → 100644
View file @
3cfdceb7
if
REQUEST
is
not
None
:
raise
Unauthorized
computer_partition_list
=
context
.
getAggregateValueList
(
portal_type
=
"Computer Partition"
)
current_watt
=
context
.
SoftwareRelease_getDeltaCO2List
(
computer_partition_list
,
context
.
SoftwareInstance_getAverageCPULoad
()
)
return
current_watt
.
keys
()[
0
]
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getCurrentDeltaCO2.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
REQUEST=None
</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>
SoftwareInstance_getCurrentDeltaCO2
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getFutureDeltaCO2.py
0 → 100644
View file @
3cfdceb7
if
REQUEST
is
not
None
:
raise
Unauthorized
computer_partition_list
=
context
.
getAggregateValueList
(
portal_type
=
"Computer Partition"
)
future_watt
=
"Not Applicable"
master_node
=
context
.
SoftwareInstance_getResilientMasterNode
()
if
master_node
is
not
None
:
future_watt
=
context
.
SoftwareRelease_getDeltaCO2List
(
computer_partition_list
,
master_node
.
SoftwareInstance_getAverageCPULoad
()
)
future_watt
=
future_watt
.
keys
()[
0
]
return
future_watt
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getFutureDeltaCO2.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
REQUEST=None
</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>
SoftwareInstance_getFutureDeltaCO2
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getLatestCPUPercentLoad.py
0 → 100644
View file @
3cfdceb7
portal
=
context
.
getPortalObject
()
packing_list_line
=
portal
.
portal_catalog
.
getResultValue
(
sort_on
=
(
"creation_date"
,
"DESC"
),
portal_type
=
"Sale Packing List Line"
,
default_resource_uid
=
context
.
service_module
.
cpu_load_percent
.
getUid
(),
default_aggregate_uid
=
context
.
getUid
())
if
packing_list_line
is
not
None
:
return
packing_list_line
.
getQuantity
()
return
0.0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getLatestCPUPercentLoad.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareInstance_getLatestCPUPercentLoad
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getResilientMasterNode.py
0 → 100644
View file @
3cfdceb7
"""
This script may contains specific prototyping code for
get master done for resilience.
"""
title
=
context
.
getTitle
()
if
not
(
title
.
startswith
(
"kvm"
)
or
title
.
startswith
(
"runner"
)):
# This instance is not a clone from resilience
return
None
hosting_subscription
=
context
.
getSpecialiseValue
()
for
instance
in
hosting_subscription
.
getSpecialiseRelatedValueList
(
portal_type
=
"Software Instance"
):
if
instance
.
getTitle
()
in
[
"kvm0"
,
"runner0"
]:
return
instance
return
None
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getResilientMasterNode.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareInstance_getResilientMasterNode
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getWattStats.py
0 → 100644
View file @
3cfdceb7
computer_partition_list
=
context
.
getAggregateValueList
(
portal_type
=
"Computer Partition"
)
master_node
=
context
.
SoftwareInstance_getResilientMasterNode
()
current_watt
=
context
.
SoftwareRelease_getDeltaCO2List
(
computer_partition_list
,
context
.
SoftwareInstance_getAverageCPULoad
()
)
current_watt
=
current_watt
.
keys
()
master_node
=
context
.
SoftwareInstance_getResilientMasterNode
()
if
master_node
is
not
None
:
future_watt
=
context
.
SoftwareRelease_getDeltaCO2List
(
computer_partition_list
,
master_node
.
SoftwareInstance_getAverageCPULoad
()
)
future_watt
=
future_watt
.
keys
()[
0
]
return
current_watt
,
future_watt
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_getWattStats.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareInstance_getWattStats
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_viewCurrentConsumption.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ERP5 Form"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
edit_order
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
enctype
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
group_list
</string>
</key>
<value>
<list>
<string>
normal
</string>
<string>
right width100 alignr
</string>
<string>
normal bis
</string>
<string>
center
</string>
<string>
hidden
</string>
</list>
</value>
</item>
<item>
<key>
<string>
groups
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
center
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
hidden
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
normal
</string>
</key>
<value>
<list>
<string>
your_watt_consumption
</string>
<string>
your_future_watt_consumption
</string>
</list>
</value>
</item>
<item>
<key>
<string>
normal bis
</string>
</key>
<value>
<list/>
</value>
</item>
<item>
<key>
<string>
right width100 alignr
</string>
</key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareInstance_viewCurrentConsumption
</string>
</value>
</item>
<item>
<key>
<string>
method
</string>
</key>
<value>
<string>
POST
</string>
</value>
</item>
<item>
<key>
<string>
name
</string>
</key>
<value>
<string>
SoftwareInstance_viewAsWeb
</string>
</value>
</item>
<item>
<key>
<string>
pt
</string>
</key>
<value>
<string>
form_view_editable
</string>
</value>
</item>
<item>
<key>
<string>
row_length
</string>
</key>
<value>
<int>
4
</int>
</value>
</item>
<item>
<key>
<string>
stored_encoding
</string>
</key>
<value>
<string>
UTF-8
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
unicode_mode
</string>
</key>
<value>
<int>
0
</int>
</value>
</item>
<item>
<key>
<string>
update_action
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
update_action_title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_viewCurrentConsumption/your_future_watt_consumption.xml
0 → 100644
View file @
3cfdceb7
This diff is collapsed.
Click to expand it.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareInstance_viewCurrentConsumption/your_watt_consumption.xml
0 → 100644
View file @
3cfdceb7
This diff is collapsed.
Click to expand it.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedCPULoad.py
0 → 100644
View file @
3cfdceb7
portal
=
context
.
getPortalObject
()
software_release_url
=
context
.
getUrlString
()
resource_uid
=
context
.
service_module
.
cpu_load_percent
.
getUid
()
# Select all software instances from a certain Software Release
software_instance_list
=
portal
.
portal_catalog
(
portal_type
=
"Software Instance"
,
limit
=
100
,
url_string
=
software_release_url
)
packing_list_line_list
=
portal
.
portal_catalog
(
limit
=
100
,
sort_on
=
(
"creation_date"
,
"DESC"
),
portal_type
=
"Sale Packing List Line"
,
default_resource_uid
=
resource_uid
,
default_aggregate_uid
=
[
i
.
getUid
()
for
i
in
software_instance_list
]
)
if
len
(
packing_list_line_list
):
return
sum
([
i
.
getQuantity
()
for
i
in
packing_list_line_list
])
/
len
(
packing_list_line_list
)
return
0.0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedCPULoad.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareRelease_getAverageConsumedCPULoad
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedMemory.py
0 → 100644
View file @
3cfdceb7
portal
=
context
.
getPortalObject
()
software_release_url
=
context
.
getUrlString
()
resource_uid
=
context
.
service_module
.
memory_used
.
getUid
()
# Select all software instances from a certain Software Release
software_instance_list
=
portal
.
portal_catalog
(
portal_type
=
"Software Instance"
,
limit
=
100
,
url_string
=
software_release_url
)
packing_list_line_list
=
portal
.
portal_catalog
(
limit
=
100
,
sort_on
=
(
"creation_date"
,
"DESC"
),
portal_type
=
"Sale Packing List Line"
,
default_resource_uid
=
resource_uid
,
default_aggregate_uid
=
[
i
.
getUid
()
for
i
in
software_instance_list
]
)
if
len
(
packing_list_line_list
):
return
sum
([
i
.
getQuantity
()
for
i
in
packing_list_line_list
])
/
len
(
packing_list_line_list
)
return
0.0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getAverageConsumedMemory.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareRelease_getAverageConsumedMemory
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getDeltaCO2List.py
0 → 100644
View file @
3cfdceb7
"""
Make a list with delta CO2 values
"""
if
simulated_cpu_load
is
not
None
:
partition_average_cpu_load
=
simulated_cpu_load
else
:
partition_average_cpu_load
=
context
.
getCpuCapacityQuantity
()
partition_delta_co2_dict
=
{}
for
computer_partition
in
computer_partition_list
:
computer
=
computer_partition
.
getParentValue
()
computer_zero_emission_ratio
=
computer
.
Computer_getZeroEmissionRatio
()
computer_cpu_load_percentage
=
computer
.
Computer_getLatestCPUPercentLoad
()
computer_watt
=
computer
.
Computer_getWattConsumption
(
computer_cpu_load_percentage
)
partition_watt
=
computer
.
Computer_getWattConsumption
(
computer_cpu_load_percentage
+
partition_average_cpu_load
)
delta_watt
=
(
partition_watt
-
computer_watt
)
delta_co2
=
delta_watt
-
delta_watt
*
(
computer_zero_emission_ratio
/
100
)
if
delta_co2
in
partition_delta_co2_dict
:
partition_delta_co2_dict
[
delta_co2
].
append
(
computer_partition
)
else
:
partition_delta_co2_dict
[
delta_co2
]
=
[
computer_partition
]
return
partition_delta_co2_dict
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SoftwareRelease_getDeltaCO2List.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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>
computer_partition_list, simulated_cpu_load=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SoftwareRelease_getDeltaCO2List
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SotftwareRelease_updateCapacityQuantity.py
0 → 100644
View file @
3cfdceb7
"""
"""
edit_kw
=
{}
average_cpu_load
=
context
.
SoftwareRelease_getAverageConsumedCPULoad
()
average_memory_usage
=
context
.
SoftwareRelease_getAverageConsumedMemory
()
if
average_cpu_load
!=
context
.
getCpuCapacityQuantity
():
edit_kw
[
"cpu_capacity_quantity"
]
=
average_cpu_load
if
average_memory_usage
!=
context
.
getMemoryCapacityQuantity
():
edit_kw
[
"memory_capacity_quantity"
]
=
average_memory_usage
if
len
(
edit_kw
)
>
0
:
context
.
edit
(
**
edit_kw
)
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_consumption/SotftwareRelease_updateCapacityQuantity.xml
0 → 100644
View file @
3cfdceb7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
SotftwareRelease_updateCapacityQuantity
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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