def do_containers(self): sections = [] loads = [] iac = [] ac = [] sections.append(["Active", ac]) sections.append(["Inactive", iac]) delete_id = self.get_argument("delete_id", '') stop_id = self.get_argument("stop_id", '') stop_all = (self.get_argument('stop_all', None) is not None) if stop_all: all_containers = JBoxContainer.DCKR.containers(all=False) for c in all_containers: cont = JBoxContainer(c['Id']) cname = cont.get_name() if None == cname: self.log_info("Admin: Not stopping unknown " + cont.debug_str()) elif cname not in self.config("protected_docknames"): cont.stop() elif not (stop_id == ''): cont = JBoxContainer(stop_id) cont.stop() elif not (delete_id == ''): cont = JBoxContainer(delete_id) cont.delete() # get them all again (in case we deleted some) jsonobj = JBoxContainer.DCKR.containers(all=all) for c in jsonobj: o = dict() o["Id"] = c["Id"][0:12] o["Status"] = c["Status"] if ("Names" in c) and (c["Names"] is not None): o["Name"] = c["Names"][0] else: o["Name"] = "/None" if (c["Ports"] is None) or (c["Ports"] == []): iac.append(o) else: ac.append(o) # get cluster loads average_load = CloudHelper.get_cluster_average_stats('Load') if None != average_load: loads.append({'instance': 'Average', 'load': average_load}) machine_loads = CloudHelper.get_cluster_stats('Load') if None != machine_loads: for n, v in machine_loads.iteritems(): loads.append({'instance': n, 'load': v}) return sections, loads
def do_containers(self): sections = [] iac = [] ac = [] sections.append(["Active", ac]) sections.append(["Inactive", iac]) delete_id = self.get_argument("delete_id", '') stop_id = self.get_argument("stop_id", '') stop_all = (self.get_argument('stop_all', None) is not None) if stop_all: all_containers = JBoxContainer.DCKR.containers(all=False) for c in all_containers: cont = JBoxContainer(c['Id']) cname = cont.get_name() if None == cname: self.log_info("Admin: Not stopping unknown " + cont.debug_str()) elif cname not in self.config("protected_docknames"): cont.stop() elif not (stop_id == ''): cont = JBoxContainer(stop_id) cont.stop() elif not (delete_id == ''): cont = JBoxContainer(delete_id) cont.delete() # get them all again (in case we deleted some) jsonobj = JBoxContainer.DCKR.containers(all=all) for c in jsonobj: o = dict() o["Id"] = c["Id"][0:12] o["Status"] = c["Status"] if ("Names" in c) and (c["Names"] is not None): o["Name"] = c["Names"][0] else: o["Name"] = "/None" if (c["Ports"] is None) or (c["Ports"] == []): iac.append(o) else: ac.append(o) return sections