Commit d5b76d68 authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

wip

parent 9de598f2
......@@ -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))
......@@ -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]:
......
This diff is collapsed.
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment