Skip to content

Commit

Permalink
Ambient affects storage sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
belavina committed Feb 14, 2019
1 parent a71abed commit 55e19ca
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 9 deletions.
25 changes: 25 additions & 0 deletions enginecore/enginecore/model/graph_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,31 @@ def add_to_hd_component_temperature(cls, session, target, temp_change, limit):
return True, new_temp


@classmethod
def get_all_hd_thermal_elements(cls, session, server_key):
"""Retrieve all storage components that support temperature sensors"""

query = []
query.extend([
"MATCH (:ServerWithBMC {{ key: {} }})-[:HAS_CONTROLLER]->(controller:Controller)"
.format(server_key),
"MATCH (controller)-[:HAS_CACHEVAULT|:HAS_PHYSICAL_DRIVE]->(hd_component)",
"WHERE hd_component:PhysicalDrive or hd_component:CacheVault",
"RETURN controller, hd_component"
])

results = session.run("\n".join(query))

hd_thermal_elements = []

for record in results:
hd_thermal_elements.append({
"controller": dict(record.get('controller')),
"component": dict(record.get('hd_component'))
})

return hd_thermal_elements

@classmethod
def get_psu_sensor_names(cls, session, server_key, psu_num):
"""Retrieve server-specific psu sensor names
Expand Down
1 change: 1 addition & 0 deletions enginecore/enginecore/state/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ def add_storage_pd_thermal_impact(self, source, controller, drive, event):
def on_ambient_updated(self, event, *args, **kwargs):
"""Update thermal sensor readings on ambient changes """
self._sensor_repo.adjust_thermal_sensors(new_ambient=kwargs['new_value'], old_ambient=kwargs['old_value'])
self.state.update_storage_temperature(new_ambient=kwargs['new_value'], old_ambient=kwargs['old_value'])


@handler("ParentAssetPowerDown")
Expand Down
14 changes: 5 additions & 9 deletions enginecore/enginecore/state/sensor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def _init_thermal_impact(self):
)

for target in thermal_storage_rel_details['targets']:
print(target)
if 'DID' in target and target['DID']:
hd_type = HDComponents.PhysicalDrive
hd_element = target['DID']
Expand Down Expand Up @@ -288,8 +287,8 @@ def _target_storage(self, controller, target, hd_type, event):
updated, new_temp = GraphReference.add_to_hd_component_temperature(
session,
target={
'server_key': self._server_key,
'controller': controller,
'server_key': self._server_key,
'controller': controller,
"attribute": target_attr,
'value': target_value,
'hd_type': hd_type.name
Expand All @@ -302,10 +301,8 @@ def _target_storage(self, controller, target, hd_type, event):
)

if updated:
logging.info('\n\nstorage: s:{}, t:{}, e:{} new VALUE {} \n\n'.format(
controller, target, event, new_temp
))

logging.info('temperature sensor was updated to %s°', new_temp)

time.sleep(rel['rate'])


Expand Down Expand Up @@ -391,8 +388,6 @@ def _target_sensor(self, target, event):
sf_handler.truncate()
sf_handler.write(str(new_sensor_value))



time.sleep(int(rel['rate']))


Expand All @@ -409,6 +404,7 @@ def _get_sensor_filename(self):
def add_cv_thermal_impact(self, controller, cv, event):
self._launch_thermal_storage_thread(controller, cv, HDComponents.CacheVault, event)


def add_pd_thermal_impact(self, controller, pd, event):
self._launch_thermal_storage_thread(controller, pd, HDComponents.PhysicalDrive, event)

Expand Down
32 changes: 32 additions & 0 deletions enginecore/enginecore/state/state_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,38 @@ def update_cpu_load(self, value):
StateManager.get_store().set(self.redis_key + ":cpu_load", str(int(value)))


def update_storage_temperature(self, old_ambient, new_ambient):

with self._graph_ref.get_session() as db_s:

hd_elements = GraphReference.get_all_hd_thermal_elements(db_s, self.key)

for hd_e in hd_elements:

if 'DID' in hd_e['component']:
target_attr = 'DID'
target_value = hd_e['component']['DID']
target_type = 'PhysicalDrive'
else:
target_attr = 'serialNumber'
target_value = '"{}"'.format(hd_e['component']['serialNumber'])
target_type = 'CacheVault'

updated, new_temp = GraphReference.add_to_hd_component_temperature(
db_s,
target={
'server_key': self.key,
'controller': hd_e['controller']['controllerNum'],
"attribute": target_attr,
'value': target_value,
'hd_type': target_type
},
temp_change=new_ambient - old_ambient,
limit={
'lower': new_ambient,
'upper': None
}
)

class PSUStateManager(StateManager):
"""Power Supply"""
Expand Down

0 comments on commit 55e19ca

Please sign in to comment.