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
Labels
Merge Requests
22
Merge Requests
22
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
d5b76d68
Commit
d5b76d68
authored
Oct 30, 2018
by
Bryton Lacquement
🚪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip
parent
9de598f2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
76 deletions
+65
-76
slapos/collect/snapshot.py
slapos/collect/snapshot.py
+10
-11
slapos/collect/temperature/__init__.py
slapos/collect/temperature/__init__.py
+5
-13
slapos/proxy/views.py
slapos/proxy/views.py
+44
-48
slapos/slap/slap.py
slapos/slap/slap.py
+2
-2
slapos/tests/slapproxy/__init__.py
slapos/tests/slapproxy/__init__.py
+4
-2
No files found.
slapos/collect/snapshot.py
View file @
d5b76d68
...
...
@@ -218,8 +218,7 @@ class ComputerSnapshot(_Snapshot):
#
self
.
system_snapshot
=
SystemSnapshot
()
self
.
temperature_snapshot_list
=
self
.
_get_temperature_snapshot_list
()
self
.
disk_snapshot_list
=
[]
self
.
partition_list
=
self
.
_get_physical_disk_info
()
self
.
_get_physical_disk_info
()
if
test_heating
and
model_id
is
not
None
\
and
sensor_id
is
not
None
:
...
...
@@ -234,16 +233,16 @@ class ComputerSnapshot(_Snapshot):
return
temperature_snapshot_list
def
_get_physical_disk_info
(
self
):
partition_dict
=
{}
# XXX: merge the following 2 to avoid calling disk_usage() twice
self
.
disk_snapshot_list
=
[]
self
.
partition_list
=
[]
partition_set
=
set
()
for
partition
in
psutil
.
disk_partitions
():
if
partition
.
device
not
in
partition_dict
:
dev
=
partition
.
device
if
dev
not
in
partition_set
:
# XXX: useful ?
partition_set
.
add
(
dev
)
usage
=
psutil
.
disk_usage
(
partition
.
mountpoint
)
partition_dict
[
partition
.
device
]
=
usage
.
total
self
.
partition_list
.
append
((
dev
,
usage
.
total
))
self
.
disk_snapshot_list
.
append
(
DiskPartitionSnapshot
(
partition
.
device
,
partition
.
mountpoint
))
return
[(
k
,
v
)
for
k
,
v
in
six
.
iteritems
(
partition_dict
)]
DiskPartitionSnapshot
(
dev
,
partition
.
mountpoint
))
slapos/collect/temperature/__init__.py
View file @
d5b76d68
...
...
@@ -15,29 +15,21 @@ except NotImplementedError:
DEFAULT_CPU
=
1
def
collectComputerTemperature
(
sensor_bin
=
"sensors"
):
cmd
=
[
"%s -u"
%
sensor_bin
]
sp
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
,
shell
=
True
,
universal_newlines
=
True
)
stdout
,
stderr
=
sp
.
communicate
()
stdout
=
subprocess
.
check_output
((
sensor_bin
,
'-u'
),
universal_newlines
=
True
)
sensor_output_list
=
stdout
.
splitlines
()
adapter_name
=
""
sensor_temperature_list
=
[]
for
line_number
in
range
(
len
(
sensor_output_list
)):
found_sensor
=
None
stripped_line
=
sensor_output_list
[
line_number
].
strip
()
for
line_number
,
sensor_output
in
enumerate
(
sensor_output_list
):
stripped_line
=
sensor_output
.
strip
()
if
stripped_line
.
startswith
(
"Adapter:"
):
adapter_name
=
sensor_output_list
[
line_number
-
1
]
elif
stripped_line
.
startswith
(
"temp"
)
and
"_input"
in
stripped_line
:
temperature
=
sensor_output
_list
[
line_number
].
split
()[
-
1
]
temperature
=
sensor_output
.
split
()[
-
1
]
found_sensor
=
[
"%s %s"
%
(
adapter_name
,
sensor_output_list
[
line_number
-
1
]),
float
(
temperature
)]
if
found_sensor
is
not
None
:
critical
=
'1000'
maximal
=
'1000'
for
next_line
in
sensor_output_list
[
line_number
+
1
:
line_number
+
3
]:
...
...
slapos/proxy/views.py
View file @
d5b76d68
This diff is collapsed.
Click to expand it.
slapos/slap/slap.py
View file @
d5b76d68
...
...
@@ -96,8 +96,8 @@ class SlapRequester(SlapDocument):
)
software_instance
=
xml_marshaller
.
loads
(
xml
)
computer_partition
=
ComputerPartition
(
software_instance
.
slap_computer_id
.
encode
(
'UTF-8'
)
,
software_instance
.
slap_computer_partition_id
.
encode
(
'UTF-8'
)
,
software_instance
.
slap_computer_id
,
software_instance
.
slap_computer_partition_id
,
connection_helper
=
self
.
_connection_helper
,
)
# Hack to give all object attributes to the ComputerPartition instance
...
...
slapos/tests/slapproxy/__init__.py
View file @
d5b76d68
...
...
@@ -78,7 +78,8 @@ class BasicMixin(object):
self
.
startProxy
()
def
createSlapOSConfigurationFile
(
self
):
open
(
self
.
slapos_cfg
,
'w'
).
write
(
"""[slapos]
with
open
(
self
.
slapos_cfg
,
'w'
)
as
f
:
f
.
write
(
"""[slapos]
software_root = %(tempdir)s/opt/slapgrid
instance_root = %(tempdir)s/srv/slapgrid
master_url = %(proxyaddr)s
...
...
@@ -1007,7 +1008,8 @@ class TestMultiMasterSupport(MasterMixin):
super
(
TestMultiMasterSupport
,
self
).
tearDown
()
def
createExternalProxyConfigurationFile
(
self
):
open
(
self
.
external_slapproxy_configuration_file_location
,
'w'
).
write
(
"""[slapos]
with
open
(
self
.
external_slapproxy_configuration_file_location
,
'w'
)
as
f
:
f
.
write
(
"""[slapos]
computer_id = %(external_computer_id)s
[slapproxy]
host = %(host)s
...
...
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