コード例 #1
0
ファイル: node.py プロジェクト: guolikai/mydjangos
    def post(self, *args, **kwargs):
        con_dict = {}
        for key in ['name', 'node_ip', 'port', 'node_group']:
            con_dict[key] = self.get_argument(key)

        name = con_dict["name"]
        node_ip = con_dict["node_ip"]
        port = con_dict["port"]
        node_group = con_dict["node_group"]
        myswarm = Myswarm()

        if myswarm.ping_port(node_ip, port) == 0:
            if len(name) == 0:
                node_info = myswarm.node_info(node_ip, port)
                name = node_info["Name"]
            if len(node_group) == 0:
                group_msg = NodeInfo.get_node_name_group(node_ip, port)
                node_group = group_msg[0][1]
            get_node_ret = NodeInfo.get_node_name_group(node_ip, port)
            if len(get_node_ret) == 0:
                NodeInfo.insert_node_usage(name, node_ip, port, node_group)
                self.write(u"Node [Ip:%s port:%s] add successfully" %
                           (node_ip, port))
            else:
                NodeInfo.update_node_name_group(name, node_group, node_ip,
                                                port)
                self.write(u"Node modify successfully")
        else:
            self.write(u"Node [Ip:%s port:%s] Docker has not Running" %
                       (node_ip, port))
コード例 #2
0
ファイル: node.py プロジェクト: guolikai/mydjangos
 def post(self, *args, **kwargs):
     con_dict = {}
     for key in ['name', 'node_ip', 'port', 'node_group']:
         con_dict[key] = self.get_argument(key)
     node_ip = con_dict["node_ip"]
     port = con_dict["port"]
     node_group = con_dict["node_group"]
     name = con_dict["name"]
     myswarm = Myswarm()
     if myswarm.ping_port(node_ip, port) == 0:
         if len(name) == 0:
             node_info = myswarm.node_info(node_ip, port)
             name = node_info["Name"]
         get_node_ret = NodeInfo.get_node_name_group(node_ip, port)
         #print(get_node_ret)
         if len(get_node_ret) == 0:
             NodeInfo.insert_node_usage(name, node_ip, port, node_group)
             self.write(u"Node [Ip:%s port:%s]  add successfully" %
                        (node_ip, port))
         elif get_node_ret[0][0] == node_group:
             self.write(
                 "There is already exists node[Ip:%s port:%s group:%s] of the node"
                 % (node_ip, port, node_group))
         else:
             NodeInfo.update_node_name_group(name, node_group, node_ip,
                                             port)
     else:
         self.write(u"Node [Ip:%s port:%s] Docker has not Running" %
                    (node_ip, port))