Example #1
0
    def clear_user_containers(self, user_manage_id):
        if not (current_user.get_id() == repository_user.get_id()):
            return jsonify({"success": False, "message": "not authorized", "alert_type": "alert-warning"})
        try:
            self.show_um_message("removing user containers", user_manage_id)
            all_containers = cli.containers(all=True)
            for cont in all_containers:
                if cont["Image"] in ["tactic_main_image"]:
                    self.show_um_message("removing main container " + cont["Id"], user_manage_id)
                    cli.remove_container(cont["Id"], force=True)
                    continue
                if cont["Image"] in ["tactic_tile_image"]:
                    if not cont["Id"] == global_tile_manager.test_tile_container_id:
                        self.show_um_message("removing tile container " + cont["Id"], user_manage_id)
                        cli.remove_container(cont["Id"], force=True)
                    continue
                if cont["Image"] == cont["ImageID"]:
                    self.show_um_message("removing image container " + cont["Id"], user_manage_id)
                    cli.remove_container(cont["Id"], force=True)
        except Exception as ex:
            template = "<pre>An exception of type {0} occured. Arguments:\n{1!r}</pre>"
            error_string = template.format(type(ex).__name__, ex.args)
            error_string += traceback.format_exc()
            return jsonify({"success": False, "message": error_string, "alert_type": "alert-warning"})

        self.clear_um_message(user_manage_id)
        self.update_selector_list()
        return jsonify({"success": True, "message": "User Containers Cleared", "alert_type": "alert-success"})
Example #2
0
 def build_resource_array(self):
     larray = [["Name", "Image", "Owner", "Status", "Id"]]
     all_containers = cli.containers(all=True)
     for cont in all_containers:
         if cont["Id"] in container_owners:
             owner_id = container_owners[cont["Id"]]
             if owner_id == "host":
                 owner_name = "host"
             else:
                 owner_name = load_user(owner_id).username
         else:
             owner_name = "system"
         larray.append([cont["Names"][0], cont["Image"], owner_name, cont["Status"], cont["Id"]])
     return larray