Beispiel #1
0
def notify_agent():
    """
    desc: 启动时,告知agent的ip:port
    """
    host = Util.get_host()
    port = Util.get_conf()[0]
    notify_url = Util.get_conf()[1]
    payload = {
        "machine_ip": host,
        "machine_port": port,
    }
    print payload
    requests.post(notify_url, params=payload)
Beispiel #2
0
 def execute(self):
     """
     desc: 主程序
     """
     host = Util.get_host()
     port = Util.get_conf()[0]
     self.logger.info("host is: %s" % host)
     return self.get_return({"online": 1, "host": host, "port": port})
Beispiel #3
0
 def prepare(self):
     """
     desc: prepare:解压入参数据,初始化环境变量,目录等
     """
     home = Util.get_conf()[2]
     self.decouple_data()
     self.logger.info("action is: %s" % self.action)
     self.logger.info("desc is: %s" % self.desc)
     self.logger.info("task_id is: %s" % self.task_id)
     self.logger.info("params is %s" % json.dumps(self.params))
     self.logger.info("import env variables in .bashrc.")
     subprocess.Popen("source %s/.bashrc" % home, shell=True)
     self.logger.info('init dirs.')
     os.system("/bin/sh init_task.sh %s" % self.task_id)
Beispiel #4
0
 def get_workspace():
     """
     desc: 获取workspace路径
     """
     confs = Util.get_conf()
     return "%s/performance/workspace" % confs[2]