+
+ def _write_log(self, d, path, action):
+ """
+ Helper to log RM info for experiments.
+ :param d: container
+ :param path: log path
+ :param action: allocate or free
+ :return:
+ """
+ if path is None:
+ return
+ # we have a path: write out RM info
+ l = dict()
+ l["t"] = time.time()
+ l["container_state"] = d.getStatus()
+ l["action"] = action
+ l["rm_state"] = self.get_state_dict()
+ # append to logfile
+ with open(path, "a") as f:
+ f.write("%s\n" % json.dumps(l))