def __init__(self, server_key, enable_thermal=False): self._server_key = server_key self._graph_ref = GraphReference() self._sensor_file_locks = SensorFileLocks() self._sensor_dir = os.path.join(get_temp_workplace_dir(), str(server_key), "sensor_dir") self._sensors = {} with self._graph_ref.get_session() as session: sensors = GraphReference.get_asset_sensors(session, server_key) for sensor_info in sensors: sensor = Sensor( self._sensor_dir, server_key, sensor_info, self._sensor_file_locks, graph_ref=self._graph_ref, ) self._sensors[sensor.name] = sensor if enable_thermal: self._load_thermal = True if not os.path.isdir(self._sensor_dir): os.mkdir(self._sensor_dir) for s_name in self._sensors: self._sensors[s_name].set_to_defaults()
def snmp_config(self): """Snmp lan configurations""" a_info = self._asset_info snmp_dir = (a_info["workDir"] if "workDir" in a_info else get_temp_workplace_dir()) return { "host": a_info["host"], "port": a_info["port"], "work_dir": snmp_dir }
def _create_asset_workplace_dir(self): """Create temp workplace directory for the asset (under /tmp/$SIMENGINE_WORKPLACE_TEMP/<asset_key>) Returns: str: path to newly created asset directory """ asset_dir = os.path.join(get_temp_workplace_dir(), str(self.key)) if not os.path.exists(asset_dir): os.makedirs(asset_dir) return asset_dir