Ejemplo n.º 1
0
 def post(self, **kwargs):
     svc = ProResourceApplyService(self, kwargs)
     delete_res = svc.do_delete()
     pro_resource_applies_res = svc.get_list()
     svc = ProjectService(self)
     pro_list_res = svc.get_project_list()
     # svc = ProResourceApplyService(self)
     if pro_list_res.return_code < 0:
         raise SystemError(pro_list_res.return_code,
                           pro_list_res.return_message)
     logger.info(pro_list_res)
     data = dict(pro_list_res=pro_list_res,
                 page=self.getPage(pro_resource_applies_res.data))
     if isinstance(delete_res, Exception):
         raise delete_res
     # data = self.get_pro_info_res(kwargs["pro_id"])
     if delete_res.return_code == 0:
         self.add_message(
             "云资源[%s-%s]记录删除成功!" %
             (delete_res.data.project.name, delete_res.data.desc),
             level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(
             "云资源记录删除失败!(%s)%s" %
             (delete_res.return_code, delete_res.return_message),
             level="warning")
     # logger.info("\t [data]: %s" % data )
     # logger.info("\t [data pro_info_res]: %s" % data["pro_info_res"])
     tmpl = self.render_to_string("admin/apply/resource/index_pjax.html",
                                  **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 2
0
 def post(self):
     svc = ApplyLoadBalance(self)
     pro_loadbalance_res = svc.do_loadbalance()
     pro_id = self.args.get("pro_id")
     data = self.get_pro_data(pro_id=pro_id)
     # svc = ApplyLoadBalance(self)
     # loadbalance_res = svc.get_loadbalance()
     # svc = ApplyBackups(self)
     # backups_res = svc.get_backups()
     data.update(pro_loadbalance_res=pro_loadbalance_res)
     logger.info(pro_loadbalance_res)
     if pro_loadbalance_res.return_code == 0:
         self.add_message(u"负载均衡信息添加成功!%s" % STATUS_PRO_TABLES.get(pro_loadbalance_res.data.status).todo_value, level="success")
         tmpl = self.render_to_string("admin/guide/_step_3_balance_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
         mail_title = u"%s申请的负载均衡信息添加成功!待受理" % (
             self.current_user.username or self.current_user.email,
         )
         mail_html = self.render_to_string("admin/mail/pro_balance.html", mail_title=mail_title, **data)
         sendMail.delay("*****@*****.**", admin_emails, mail_title, mail_html)
     else:
         tmpl = self.render_to_string("admin/guide/_step_3_balance.html", **data)
         self.add_message(u"负载均衡信息添加失败!(%s)(%s)" % (pro_loadbalance_res.return_code, pro_loadbalance_res.return_message), level="warning")
     messages_tmpl = self.render_to_string("admin/base/base_messages.html")
     return simplejson.dumps(self.success(data={"tmpl": tmpl, "messages_tmpl": messages_tmpl}))
Ejemplo n.º 3
0
 def post(self):
     svc = ApplyBackups(self)
     pro_backup_res = svc.do_backups()
     pro_id = self.args.get("pro_id")
     data = self.get_pro_data(pro_id=pro_id)
     # svc = ApplyLoadBalance(self)
     # loadbalance_res = svc.get_loadbalance()
     # svc = ApplyBackups(self)
     # backups_res = svc.get_backups()
     data.update(
         pro_backup_res=pro_backup_res
     )  # , loadbalance_res=loadbalance_res, backups_res=backups_res)
     logger.info(pro_backup_res)
     if pro_backup_res.return_code == 0:
         self.add_message(
             u"定期备份信息添加成功!%s" %
             STATUS_PRO_TABLES.get(pro_backup_res.data.status).todo_value,
             level="success")
         tmpl = self.render_to_string(
             "admin/guide/_step_3_backup_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
     else:
         tmpl = self.render_to_string("admin/guide/_step_3_backup.html",
                                      **data)
         self.add_message(
             u"定期备份信息添加失败!(%s)(%s)" %
             (pro_backup_res.return_code, pro_backup_res.return_message),
             level="warning")
     messages_tmpl = self.render_to_string("admin/base/base_messages.html")
     return simplejson.dumps(
         self.success(data={
             "tmpl": tmpl,
             "messages_tmpl": messages_tmpl
         }))
Ejemplo n.º 4
0
 def post(self, **kwargs):
     svc = ProResourceApplyService(self, kwargs)
     delete_res = svc.do_delete()
     pro_resource_applies_res = svc.get_list()
     svc = ProjectService(self)
     pro_list_res = svc.get_project_list()
     # svc = ProResourceApplyService(self)
     if pro_list_res.return_code < 0:
         raise SystemError(pro_list_res.return_code, pro_list_res.return_message)
     logger.info(pro_list_res)
     data = dict(
         pro_list_res = pro_list_res,
         page = self.getPage(pro_resource_applies_res.data)
     )
     if isinstance(delete_res, Exception):
         raise delete_res
     # data = self.get_pro_info_res(kwargs["pro_id"])
     if delete_res.return_code == 0:
         self.add_message("云资源[%s-%s]记录删除成功!"% (delete_res.data.project.name, delete_res.data.desc), level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message("云资源记录删除失败!(%s)%s"% (delete_res.return_code, delete_res.return_message), level="warning")
     # logger.info("\t [data]: %s" % data )
     # logger.info("\t [data pro_info_res]: %s" % data["pro_info_res"])
     tmpl = self.render_to_string("admin/apply/resource/index_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 5
0
 def post(self):
     id_list = self.get_arguments("id")
     svc = EventService(self, {"id_list": id_list})
     del_res = svc.do_del_pro_event()
     logger.info(del_res)
     if del_res.return_code == 0:
         self.add_message(u"事件信息删除成功!", level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"事件信息删除失败!(%s)(%s)" %
                          (del_res.return_code, del_res.return_message),
                          level="warning")
     svc = EventService(self, {"user_id": self.current_user.id})
     pro_events_res = svc.get_list()
     svc = ProjectService(self)
     pro_list_res = svc.get_project_list()
     if pro_list_res.return_code < 0:
         raise SystemError(pro_list_res.return_code,
                           pro_list_res.return_message)
     logger.info(pro_list_res)
     data = {
         "pro_list_res": pro_list_res,
         "pro_events_res": pro_events_res,
         "page": self.getPage(pro_events_res.data)
     }
     tmpl = self.render_to_string("admin/event/index_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 6
0
    def post(self):
        svc = ProUserService(self)
        pro_user_res = svc.do_pro_user()
        user_id = self.args.get("user_id")
        if user_id:
            message = u"修改"
        else:
            message = u"添加"
        data = {"pro_user_res": pro_user_res}
        if pro_user_res.return_code == 0:
            self.add_message(u"权限用户信息%s成功!" % message, level="success", post_action=True)
            tmpl = self.render_to_string("admin/guide/_step_3_user_detail.html", **data)
            publish_notice_checker.delay(self.current_user.id)
            mail_title = u"%s申请的权限用户信息%s成功!待受理" % (
                self.current_user.username or self.current_user.email,
                message
            )
            mail_html = self.render_to_string("admin/mail/pro_user.html", mail_title=mail_title, **data)
            sendMail.delay("*****@*****.**", admin_emails, mail_title, mail_html)
        else:
            pro_data = self.get_pro_data()
            data.update(pro_data)
            self.add_message(u"权限用户信息%s失败!(%s)(%s)" % (message, pro_user_res.return_code, pro_user_res.return_message), level="warning")
            tmpl = self.render_to_string("admin/guide/_step_3_user.html", **data)

        messages_tmpl = self.render_to_string("admin/base/base_messages.html")
        return simplejson.dumps(self.success(data={"tmpl": tmpl, "messages_tmpl": messages_tmpl}))
Ejemplo n.º 7
0
    def post(self):
        kw = {"user_id": self.current_user.id}
        svc = ProResourceApplyService(self, kw)
        # pro_svc = ProjectService(self, kw)
        # pro_info_res = pro_svc.get_project()
        if self.kwargs["name"] == "apply.resource.add":
            post_action = u"提交"
            pro_resource_apply_res = svc.do_apply()
        elif self.kwargs["name"] == "apply.resource.edit":
            post_action = u"重新提交"
            pro_resource_apply_res = svc.do_re_apply()
        elif self.kwargs["name"] == "apply.resource.revoke":
            post_action = u"撤销"
            pro_resource_apply_res = svc.do_revoke()
        elif self.kwargs["name"] == "apply.resource.pay":
            post_action = u"支付"
            pro_resource_apply_res = svc.do_pay()
        pro_info_data = self.get_pro_data(pro_id=self.args.get("pro_id"))
        data = {"pro_resource_apply_res": pro_resource_apply_res}
        svc = ProjectService(self)
        env_resource_value_res = svc.load_env_resource_values()
        env_internet_ip_types_res = svc.load_env_internet_ip_types()
        data.update(
            dict(
                env_internet_ip_types_res=env_internet_ip_types_res,
                env_resource_value_res=env_resource_value_res,
            ))

        data.update(pro_info_data)
        if pro_resource_apply_res.return_code == 0:
            self.add_message(u"申请项目[%s-%s]%s资源成功!" %
                             (pro_resource_apply_res.data.project.name,
                              pro_resource_apply_res.data.desc, post_action),
                             level="success",
                             post_action=True)
            publish_notice_checker.delay(self.current_user.id)
            if self.kwargs["name"] == "apply.resource.pay":
                tmpl = self.render_to_string(
                    "admin/guide/_step_2_pay_detail.html", **data)
            else:
                tmpl = self.render_to_string(
                    "admin/guide/_step_1_res_detail.html", **data)
        else:
            self.add_message(u"申请项目%s资源失败!(%s)%s" %
                             (post_action, pro_resource_apply_res.return_code,
                              pro_resource_apply_res.return_message),
                             level="warning")
            if self.kwargs["name"] == "apply.resource.pay":
                tmpl = self.render_to_string("admin/guide/_step_2_pay.html",
                                             **data)
            else:
                tmpl = self.render_to_string(
                    "admin/guide/_step_1_res_add.html", **data)
        messages_tmpl = self.render_to_string("admin/base/base_messages.html")
        return simplejson.dumps(
            self.success(data={
                "tmpl": tmpl,
                "messages_tmpl": messages_tmpl
            }))
Ejemplo n.º 8
0
 def post(self):
     svc = ApplyBackups(self)
     backups_res = svc.do_backups()
     if backups_res.return_code == 0:
         self.add_message(u"定期备份申请成功!%s" % STATUS_PRO_TABLES.get(backups_res.data.status).todo_value, level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"定期备份申请失败!(%s)(%s)" % (backups_res.return_code, backups_res.return_message), level="warning")
     pro_id = self.args.get("pro_id")
     svc = ApplyLoadBalance(self)
     loadbalance_res = svc.get_loadbalance()
     data = self.get_pro_data(pro_id=pro_id)
     data.update(backups_res=backups_res, loadbalance_res=loadbalance_res)
     logger.info(backups_res)
     tmpl = self.render_to_string("admin/apply/service/add_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 9
0
 def post(self):
     id_list = self.get_arguments("id")
     svc = ApplyBackups(self, {"id_list": id_list})
     del_res = svc.do_del_pro_backup()
     logger.info(del_res)
     if del_res.return_code == 0:
         self.add_message(u"定期备份信息删除成功!", level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"定期备份信息删除失败!(%s)(%s)" % (del_res.return_code, del_res.return_message), level="warning")
     data = self.get_pro_data()
     svc = ApplyBackups(self, {"user_id": self.current_user.id})
     pro_backups_res = svc.get_list()
     page = self.getPage(pro_backups_res.data)
     data.update(page=page)
     tmpl = self.render_to_string("admin/apply/backup/index_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 10
0
 def post(self):
     user_id_list = self.get_arguments("user_id")
     svc = ProUserService(self, {"user_id_list": user_id_list})
     del_res = svc.do_del_pro_user()
     logger.info(del_res)
     if del_res.return_code == 0:
         self.add_message(u"用户信息删除成功!", level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"用户信息删除失败!(%s)(%s)" % (del_res.return_code, del_res.return_message), level="warning")
     data = self.get_pro_data()
     svc = ProUserService(self, {"user_id": self.current_user.id})
     pro_users_res = svc.get_list()
     page = self.getPage(pro_users_res.data)
     data.update(page=page)
     tmpl = self.render_to_string("admin/apply/user/index_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 11
0
    def post(self):
        kw = {"user_id": self.current_user.id}
        svc = ProResourceApplyService(self, kw)
        # pro_svc = ProjectService(self, kw)
        # pro_info_res = pro_svc.get_project()
        if self.kwargs["name"] == "apply.resource.add":
            post_action = u"提交"
            pro_resource_apply_res = svc.do_apply()
        elif self.kwargs["name"] == "apply.resource.edit":
            post_action = u"重新提交"
            pro_resource_apply_res = svc.do_re_apply()
        elif self.kwargs["name"] == "apply.resource.revoke":
            post_action = u"撤销"
            pro_resource_apply_res = svc.do_revoke()
        elif self.kwargs["name"] == "apply.resource.pay":
            post_action = u"支付"
            pro_resource_apply_res = svc.do_pay()
        pro_info_data = self.get_pro_data(pro_id=self.args.get("pro_id"))
        data = {
            "pro_resource_apply_res": pro_resource_apply_res
        }
        svc = ProjectService(self)
        env_resource_value_res = svc.load_env_resource_values()
        env_internet_ip_types_res = svc.load_env_internet_ip_types()
        data.update(dict(
            env_internet_ip_types_res = env_internet_ip_types_res,
            env_resource_value_res = env_resource_value_res,
        ))

        data.update(pro_info_data)
        if pro_resource_apply_res.return_code == 0:
            self.add_message(u"申请项目[%s-%s]%s资源成功!" % (pro_resource_apply_res.data.project.name, pro_resource_apply_res.data.desc, post_action), level="success", post_action=True)
            publish_notice_checker.delay(self.current_user.id)
            if self.kwargs["name"] == "apply.resource.pay":
                tmpl = self.render_to_string("admin/guide/_step_2_pay_detail.html", **data)
            else:
                tmpl = self.render_to_string("admin/guide/_step_1_res_detail.html", **data)
        else:
            self.add_message(u"申请项目%s资源失败!(%s)%s" % (post_action, pro_resource_apply_res.return_code, pro_resource_apply_res.return_message), level="warning")
            if self.kwargs["name"] == "apply.resource.pay":
                tmpl = self.render_to_string("admin/guide/_step_2_pay.html", **data)
            else:
                tmpl = self.render_to_string("admin/guide/_step_1_res_add.html", **data)
        messages_tmpl = self.render_to_string("admin/base/base_messages.html")
        return simplejson.dumps(self.success(data={"tmpl": tmpl, "messages_tmpl": messages_tmpl}))
Ejemplo n.º 12
0
 def post(self):
     svc = ApplyBackups(self)
     pro_backup_res = svc.do_backups()
     pro_id = self.args.get("pro_id")
     data = self.get_pro_data(pro_id=pro_id)
     # svc = ApplyLoadBalance(self)
     # loadbalance_res = svc.get_loadbalance()
     # svc = ApplyBackups(self)
     # backups_res = svc.get_backups()
     data.update(pro_backup_res=pro_backup_res) # , loadbalance_res=loadbalance_res, backups_res=backups_res)
     logger.info(pro_backup_res)
     if pro_backup_res.return_code == 0:
         self.add_message(u"定期备份信息添加成功!%s" % STATUS_PRO_TABLES.get(pro_backup_res.data.status).todo_value, level="success")
         tmpl = self.render_to_string("admin/guide/_step_3_backup_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
     else:
         tmpl = self.render_to_string("admin/guide/_step_3_backup.html", **data)
         self.add_message(u"定期备份信息添加失败!(%s)(%s)" % (pro_backup_res.return_code, pro_backup_res.return_message), level="warning")
     messages_tmpl = self.render_to_string("admin/base/base_messages.html")
     return simplejson.dumps(self.success(data={"tmpl": tmpl, "messages_tmpl": messages_tmpl}))
Ejemplo n.º 13
0
 def reply(self, template=""):
     svc = EventService(self)
     pro_event_res = svc.do_reply()
     logger.info(pro_event_res)
     # if pro_event_detail_res.return_code < 0:
     #     self.add_message(u"回复事件失败!(%s)%s" % (pro_event_detail_res.return_code, pro_event_detail_res.return_message), level="warning")
     # else:
     #     self.add_message(u"回复事件成功!", level="success")
     pro_event_res = svc.get_info()
     svc = ProjectService(self)
     pro_list_res = svc.get_project_list()
     logger.info(pro_event_res)
     data = {
         "pro_event_res": pro_event_res,
         "pro_list_res": pro_list_res,
     }
     if self.current_user.imchecker:
         publish_notice_user.delay(pro_event_res.data.user.id)
     else:
         publish_notice_checker.delay(self.current_user.id)
     tmpl = self.render_to_string(template, **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 14
0
 def reply(self, template=""):
     svc = EventService(self)
     pro_event_res = svc.do_reply()
     logger.info(pro_event_res)
     # if pro_event_detail_res.return_code < 0:
     #     self.add_message(u"回复事件失败!(%s)%s" % (pro_event_detail_res.return_code, pro_event_detail_res.return_message), level="warning")
     # else:
     #     self.add_message(u"回复事件成功!", level="success")
     pro_event_res = svc.get_info()
     svc = ProjectService(self)
     pro_list_res = svc.get_project_list()
     logger.info(pro_event_res)
     data = {
         "pro_event_res": pro_event_res,
         "pro_list_res": pro_list_res,
     }
     if self.current_user.imchecker:
         publish_notice_user.delay(pro_event_res.data.user.id)
     else:
         publish_notice_checker.delay(self.current_user.id)
     tmpl = self.render_to_string(template, **data)
     return simplejson.dumps(self.success(data=tmpl))
Ejemplo n.º 15
0
 def post(self):
     svc = ApplyLoadBalance(self)
     pro_loadbalance_res = svc.do_loadbalance()
     pro_id = self.args.get("pro_id")
     data = self.get_pro_data(pro_id=pro_id)
     # svc = ApplyLoadBalance(self)
     # loadbalance_res = svc.get_loadbalance()
     # svc = ApplyBackups(self)
     # backups_res = svc.get_backups()
     data.update(pro_loadbalance_res=pro_loadbalance_res)
     logger.info(pro_loadbalance_res)
     if pro_loadbalance_res.return_code == 0:
         self.add_message(u"负载均衡信息添加成功!%s" % STATUS_PRO_TABLES.get(
             pro_loadbalance_res.data.status).todo_value,
                          level="success")
         tmpl = self.render_to_string(
             "admin/guide/_step_3_balance_detail.html", **data)
         publish_notice_checker.delay(self.current_user.id)
         mail_title = u"%s申请的负载均衡信息添加成功!待受理" % (
             self.current_user.username or self.current_user.email, )
         mail_html = self.render_to_string("admin/mail/pro_balance.html",
                                           mail_title=mail_title,
                                           **data)
         sendMail.delay("*****@*****.**", admin_emails, mail_title,
                        mail_html)
     else:
         tmpl = self.render_to_string("admin/guide/_step_3_balance.html",
                                      **data)
         self.add_message(u"负载均衡信息添加失败!(%s)(%s)" %
                          (pro_loadbalance_res.return_code,
                           pro_loadbalance_res.return_message),
                          level="warning")
     messages_tmpl = self.render_to_string("admin/base/base_messages.html")
     return simplejson.dumps(
         self.success(data={
             "tmpl": tmpl,
             "messages_tmpl": messages_tmpl
         }))
Ejemplo n.º 16
0
 def post(self):
     id_list = self.get_arguments("id")
     svc = EventService(self, {"id_list": id_list})
     del_res = svc.do_del_pro_event()
     logger.info(del_res)
     if del_res.return_code == 0:
         self.add_message(u"事件信息删除成功!", level="success")
         publish_notice_checker.delay(self.current_user.id)
     else:
         self.add_message(u"事件信息删除失败!(%s)(%s)" % (del_res.return_code, del_res.return_message), level="warning")
     svc = EventService(self, {"user_id": self.current_user.id})
     pro_events_res = svc.get_list()
     svc = ProjectService(self)
     pro_list_res = svc.get_project_list()
     if pro_list_res.return_code < 0:
         raise SystemError(pro_list_res.return_code, pro_list_res.return_message)
     logger.info(pro_list_res)
     data = {
         "pro_list_res": pro_list_res,
         "pro_events_res": pro_events_res,
         "page": self.getPage(pro_events_res.data)
     }
     tmpl = self.render_to_string("admin/event/index_pjax.html", **data)
     return simplejson.dumps(self.success(data=tmpl))