just fixed pylint warnings and errors
This commit is contained in:
parent
160bc22c3d
commit
82816e5193
|
@ -95,7 +95,6 @@ class Machine(object):
|
||||||
return self.name == 'edf' or re.match('^ups[0-9]*$', self.name)
|
return self.name == 'edf' or re.match('^ups[0-9]*$', self.name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Plug(object):
|
class Plug(object):
|
||||||
"""
|
"""
|
||||||
represents a power plug (input or output) of a device
|
represents a power plug (input or output) of a device
|
||||||
|
@ -131,20 +130,21 @@ class Plug(object):
|
||||||
# apply incoming connection amperes limitation
|
# apply incoming connection amperes limitation
|
||||||
capacity = add_capacity_constraints(capacity, in_con.get_max_amperes())
|
capacity = add_capacity_constraints(capacity, in_con.get_max_amperes())
|
||||||
if debug:
|
if debug:
|
||||||
print(str(self)+ 'after incoming connection amperes limitation, capacity = ' + str(capacity))
|
print(str(self) + 'after incoming connection amperes limitation, capacity = ' + str(capacity))
|
||||||
else:
|
else:
|
||||||
# apply the machine containing this plug's amperes limitation
|
# apply the machine containing this plug's amperes limitation
|
||||||
capacity = add_capacity_constraints(capacity, self.machine.get_max_amperes())
|
capacity = add_capacity_constraints(capacity, self.machine.get_max_amperes())
|
||||||
if debug:
|
if debug:
|
||||||
print(str(self)+'apply the machine containing this plug s amperes limitation, capacity = ' + str(capacity))
|
print(str(self) + 'apply the machine containing this plug s amperes limitation, capacity = ' + str(capacity))
|
||||||
|
|
||||||
# apply this plug's amperes limitation
|
# apply this plug's amperes limitation
|
||||||
capacity = add_capacity_constraints(capacity, self.current_capacity_constraint)
|
capacity = add_capacity_constraints(capacity, self.current_capacity_constraint)
|
||||||
if debug:
|
if debug:
|
||||||
print(str(self)+'after apply this plug s amperes limitation, capacity = ' + str(capacity), self.current_capacity_constraint)
|
print(str(self) + 'after apply this plug s amperes limitation, capacity = ' + str(capacity), self.current_capacity_constraint)
|
||||||
|
|
||||||
return capacity
|
return capacity
|
||||||
|
|
||||||
|
|
||||||
class Connection(object):
|
class Connection(object):
|
||||||
"""
|
"""
|
||||||
a power cable connecting an input power plug to an output power plug
|
a power cable connecting an input power plug to an output power plug
|
||||||
|
@ -217,6 +217,7 @@ class Connection(object):
|
||||||
power_consumption = to_machine.get_power_consumption(worst_case_scenario) / num_input_cables
|
power_consumption = to_machine.get_power_consumption(worst_case_scenario) / num_input_cables
|
||||||
return power_consumption
|
return power_consumption
|
||||||
|
|
||||||
|
|
||||||
class PowerConfig(object):
|
class PowerConfig(object):
|
||||||
"""
|
"""
|
||||||
the description of how machines are connected together (in terms of electric power)
|
the description of how machines are connected together (in terms of electric power)
|
||||||
|
@ -289,7 +290,6 @@ class PowerConfig(object):
|
||||||
if power_consumption is not None:
|
if power_consumption is not None:
|
||||||
machine.power_consumption = power_consumption
|
machine.power_consumption = power_consumption
|
||||||
|
|
||||||
|
|
||||||
def get_connection_to(self, to_plug):
|
def get_connection_to(self, to_plug):
|
||||||
for connection in self.connections:
|
for connection in self.connections:
|
||||||
if connection.to_plug == to_plug:
|
if connection.to_plug == to_plug:
|
||||||
|
@ -321,6 +321,7 @@ class PowerConfig(object):
|
||||||
s += str(c) + '\n'
|
s += str(c) + '\n'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
class CableColorer(object):
|
class CableColorer(object):
|
||||||
|
|
||||||
def get_cable_color(self, cable, worst_case_scenario):
|
def get_cable_color(self, cable, worst_case_scenario):
|
||||||
|
@ -329,6 +330,7 @@ class CableColorer(object):
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class SimpleColorer(CableColorer):
|
class SimpleColorer(CableColorer):
|
||||||
|
|
||||||
def get_cable_color(self, cable, worst_case_scenario):
|
def get_cable_color(self, cable, worst_case_scenario):
|
||||||
|
@ -349,6 +351,7 @@ class SimpleColorer(CableColorer):
|
||||||
color = '/svg/green'
|
color = '/svg/green'
|
||||||
return color
|
return color
|
||||||
|
|
||||||
|
|
||||||
class RampColorer(CableColorer):
|
class RampColorer(CableColorer):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -384,6 +387,7 @@ class RampColorer(CableColorer):
|
||||||
color = '/svg/red' # draw overloaded cables in red
|
color = '/svg/red' # draw overloaded cables in red
|
||||||
return color
|
return color
|
||||||
|
|
||||||
|
|
||||||
def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
"""
|
"""
|
||||||
creates a svg diagram representing the input power configuration
|
creates a svg diagram representing the input power configuration
|
||||||
|
@ -402,7 +406,6 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
graph.edge_attr['fontsize'] = 10 # default : 14 pt
|
graph.edge_attr['fontsize'] = 10 # default : 14 pt
|
||||||
graph.edge_attr['len'] = 1.5 # default : 1.0
|
graph.edge_attr['len'] = 1.5 # default : 1.0
|
||||||
|
|
||||||
|
|
||||||
# graph.add_node('a')
|
# graph.add_node('a')
|
||||||
# graph.add_node('b')
|
# graph.add_node('b')
|
||||||
# graph.add_edge(u'a',u'b',color='blue')
|
# graph.add_edge(u'a',u'b',color='blue')
|
||||||
|
@ -438,7 +441,6 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
</tr>\
|
</tr>\
|
||||||
</table>>' % (machine.name, machine_total_power_consumption)
|
</table>>' % (machine.name, machine_total_power_consumption)
|
||||||
|
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
x = 0.0
|
x = 0.0
|
||||||
for rack in racks.itervalues():
|
for rack in racks.itervalues():
|
||||||
|
@ -481,10 +483,9 @@ def power_config_to_svg(power_config, svg_file_path, worst_case_scenario=True):
|
||||||
sub.graph_attr['label'] = rack_id
|
sub.graph_attr['label'] = rack_id
|
||||||
# sub.graph_attr['rank']='same'
|
# sub.graph_attr['rank']='same'
|
||||||
# assert False
|
# assert False
|
||||||
#graph.layout(prog='twopi')
|
# graph.layout(prog='twopi')
|
||||||
with open('./toto.dot', 'w') as f:
|
with open('./toto.dot', 'w') as f:
|
||||||
f.write(graph.string())
|
f.write(graph.string())
|
||||||
|
|
||||||
|
|
||||||
graph.layout(prog='dot')
|
graph.layout(prog='dot')
|
||||||
graph.draw(svg_file_path)
|
graph.draw(svg_file_path)
|
||||||
|
|
10
inventory.py
10
inventory.py
|
@ -1,6 +1,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
import datetime
|
import datetime
|
||||||
#from Lib import SimpaDbUtil
|
# from Lib import SimpaDbUtil
|
||||||
import SimpaDbUtil
|
import SimpaDbUtil
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class Inventory(object):
|
||||||
def machine_name_to_machine_spec_id(self, machine_name):
|
def machine_name_to_machine_spec_id(self, machine_name):
|
||||||
try:
|
try:
|
||||||
machine_spec_id = self._sql_reader.get_table_attr('machines', 'name', machine_name, 'machine_spec_id')
|
machine_spec_id = self._sql_reader.get_table_attr('machines', 'name', machine_name, 'machine_spec_id')
|
||||||
except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable
|
except SimpaDbUtil.TableAttrNotFound as e: # noqa: F841 @UnusedVariable
|
||||||
raise MachineSpecIdNotFound(machine_name)
|
raise MachineSpecIdNotFound(machine_name)
|
||||||
if machine_spec_id == '':
|
if machine_spec_id == '':
|
||||||
raise MachineSpecIdNotFound(machine_name)
|
raise MachineSpecIdNotFound(machine_name)
|
||||||
|
@ -59,7 +59,7 @@ class Inventory(object):
|
||||||
def machine_spec_id_to_power_consumption(self, machine_spec_id):
|
def machine_spec_id_to_power_consumption(self, machine_spec_id):
|
||||||
try:
|
try:
|
||||||
power_consumption = float(self._sql_reader.get_table_attr('machine_spec_to_power_consumption', 'machine_spec_id', machine_spec_id, 'power_consumption'))
|
power_consumption = float(self._sql_reader.get_table_attr('machine_spec_to_power_consumption', 'machine_spec_id', machine_spec_id, 'power_consumption'))
|
||||||
except SimpaDbUtil.TableAttrNotFound as e: # @UnusedVariable
|
except SimpaDbUtil.TableAttrNotFound as e: # noqa: F841 @UnusedVariable
|
||||||
# some passive machines such as pdus are not detailed in the machine_spec_to_power_consumption because they don't consume power
|
# some passive machines such as pdus are not detailed in the machine_spec_to_power_consumption because they don't consume power
|
||||||
power_consumption = 0.0
|
power_consumption = 0.0
|
||||||
return power_consumption
|
return power_consumption
|
||||||
|
@ -105,7 +105,7 @@ class Inventory(object):
|
||||||
except MachineSpecIdNotFound:
|
except MachineSpecIdNotFound:
|
||||||
# some machines are not actual machines (eg edf, ups1pdu)
|
# some machines are not actual machines (eg edf, ups1pdu)
|
||||||
pass
|
pass
|
||||||
#except PlugTypeNotFound:
|
# except PlugTypeNotFound:
|
||||||
# some plugs are just plain connections, with no actual plug types
|
# some plugs are just plain connections, with no actual plug types
|
||||||
# pass
|
# pass
|
||||||
if plug_type is not None:
|
if plug_type is not None:
|
||||||
|
@ -163,7 +163,7 @@ class Inventory(object):
|
||||||
|
|
||||||
def get_computer_dflops(self, computer_name):
|
def get_computer_dflops(self, computer_name):
|
||||||
# print(computer_serial_number)
|
# print(computer_serial_number)
|
||||||
num_cpus = int(self._sql_reader.get_table_attr( 'computer_to_cpu', 'computer_id', computer_name, 'num_cpu'))
|
num_cpus = int(self._sql_reader.get_table_attr('computer_to_cpu', 'computer_id', computer_name, 'num_cpu'))
|
||||||
cpu_model = self._sql_reader.get_table_attr('computer_to_cpu', 'computer_id', computer_name, 'cpu_model')
|
cpu_model = self._sql_reader.get_table_attr('computer_to_cpu', 'computer_id', computer_name, 'cpu_model')
|
||||||
flops = num_cpus * self.get_cpu_dflops(cpu_model)
|
flops = num_cpus * self.get_cpu_dflops(cpu_model)
|
||||||
return flops
|
return flops
|
||||||
|
|
Loading…
Reference in New Issue