Skip to content

0.4.1.5

Choose a tag to compare

@Jerry-se Jerry-se released this 04 Jun 03:01
· 10 commits to master since this release

安装&升级DBC算力节点:

  1. 安装&升级-文档:https://deepbrainchain.github.io/DBC-Wiki/install-update-dbc-node/install-update-dbc/
  2. 安装&升级-脚本:http://112.192.16.27:9000/dbc/install_update_script/mainnet
  3. 辅助工具:check_env、sign_tool:http://112.192.16.27:9000/dbc/package

修改内容:

  1. 增加对网吧电源管理插件的调用功能。

插件只需要实现如下命令行调用即可。不限制编程语言,使用最简单的 Python 也可以。

power_manager --poweron '{\"uuid\":\"3156995b\",\"ipmi_hostname\": \"192.168.0.110\"}'
power_manager --poweroff '{\"uuid\":\"3156995b\",\"ipmi_hostname\": \"192.168.0.110\"}'
power_manager --status '{\"uuid\":\"3156995b\",\"ipmi_hostname\": \"192.168.0.110\"}'
  1. 命令行参数1: 表示要执行的命令。
  • poweron: 开机
  • poweroff: 关机
  • status: 查询机器电源状态
  1. 命令行参数2: 为哪台机器执行命令,JSON格式字符串形式。
  2. 进程返回 0 表示成功,非 0 表示失败,电源状态信息直接输出到控制台即可。
  3. 编译打包后放在 dbc 的安装目录下,在 conf/core.conf 配置文件中写明插件的文件路径即可。
  • netbar_power_manager=/home/dbtu/dbc_baremetal_node/power_manager

代码实现示例:

#include <string>

const char* help_context =
    "power_manager poweron|poweroff|status "
    "'{\"uuid\":\"3156995b\",\"ipmi_hostname\": \"192.168.0.110\"}'";

int main(int argc, char* argv[]) {
    if (argc == 2 && std::string(argv[1]).find("help") != std::string::npos) {
        printf("%s\n", help_context);
        return 0;
    } else if (argc != 3) {
        printf("%s\n", help_context);
        return 1;
    }
    std::string command(argv[1]);
    if (command == "poweron") {
        // 将 argv[2] 中指定的机器开机
        printf("Power on\n");
    } else if (command == "poweroff") {
        // 将 argv[2] 中指定的机器关机
        printf("Power off\n");
    } else if (command == "status") {
        // 查询 argv[2] 中指定的机器电源状态并输出到控制台
        printf("Power is on\n");
    } else {
        // 不支持的命令参数返回非0值即可
        printf("Not supported\n");
        return 1;
    }
    return 0;
}