def start_container(self, node_ip, node_port, container_id): if len(container_id) > 0: container_ip = "" client_ins = docker.Client(base_url='tcp://' + node_ip + ":" + node_port, version='1.20', timeout=5) client_ins.start(container_id) time.sleep(0.5) con_info = self._container_detail(node_ip, node_port, container_id) ret = NodeInfo.get_con_usage_info(container_id, node_ip) print(ret) if len(ret) == 0: NodeInfo.insert_con_usage( container_id[0:12], con_info['NetworkSettings']['IPAddress'], con_info['Name'].replace('/', ''), node_ip) else: #print('update_con_usage') #print(con_info['NetworkSettings']['IPAddress'], con_info['Name'].replace('/', ''), node_ip, container_id[0:12]) NodeInfo.update_con_usage( container_id[0:12], con_info['NetworkSettings']['IPAddress'], con_info['Name'].replace('/', ''), node_ip) return 0 else: print("Please enter the Container ID") return
def get(self, *args, **kwargs): node_ip = self.get_argument('node_ip', None) #print(node_ip) if node_ip is None: self.write("Something Wrong") return else: node_port = NodeInfo.get_node_port(node_ip)[0][0] myswarm = Myswarm() con_data = myswarm.container_list(node_ip, node_port) #print("con_data",con_data) for con in con_data: #print(con_data[con]["id_num"],con_data[con]["con_ip"],node_ip) ret = NodeInfo.get_con_usage_info(con_data[con]["id_num"], node_ip) if len(ret) == 0: NodeInfo.insert_con_usage(con_data[con]["id_num"], con_data[con]["con_ip"], con_data[con]["con_name"], node_ip) else: continue self.render('node/rightnode.html', con_data=con_data, node_ip=node_ip)