public String getVmBackupPlan() { long beginRunTime = 0; if (logger.isDebugEnabled()) { beginRunTime = System.currentTimeMillis(); logger.debug("enter getVmBackupPlan method."); } ControlPanelUser controlPanelUser = (ControlPanelUser) super.getSession().getAttribute(Constants.LOGIN_CURRENTUSER); if (controlPanelUser == null) { super.fillActionResult(Constants.OPTIONS_TIMEOUT); return null; } String vmId = controlPanelUser.getVmId(); String operateObject = "VM[vmId:" + vmId + "]"; VmSnapShotPlanVO vsspVO = null; try { vsspVO = facade.getBackupVmPlanByVmId(vmId); } catch (Exception e) { dealThrow( new HsCloudException(Constants.VM_SNAPSHOT_GET_ERROR, "getVmBackupPlan异常", logger, e), "000"); return null; } super.fillActionResult(vsspVO); if (logger.isDebugEnabled()) { long takeTime = System.currentTimeMillis() - beginRunTime; logger.debug("exit getVmBackupPlan method.takeTime:" + takeTime + "ms"); } return null; }
/** * <创建备份计划> * * @return * @see [类、类#方法、类#成员] */ public String createBackupVmPlan() { long beginRunTime = 0; if (logger.isDebugEnabled()) { beginRunTime = System.currentTimeMillis(); logger.debug("enter createBackupVmPlan method."); } java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("HH:mm"); ControlPanelUser controlPanelUser = (ControlPanelUser) super.getSession().getAttribute(Constants.LOGIN_CURRENTUSER); if (controlPanelUser == null) { super.fillActionResult(Constants.OPTIONS_TIMEOUT); return null; } String result = null; String vmId = controlPanelUser.getVmId(); String operateObject = "VM[vmId:" + vmId + "]"; try { vssp = Utils.strutsJson2Object(VmSnapShotPlan.class); Date dtime = sdf.parse(planTime); Time time = new Time(dtime.getTime()); vssp.setPlanTime(time); vssp.setModifyUser(controlPanelUser.getId()); vssp.setVmId(controlPanelUser.getVmId()); VmSnapShotPlanVO vsspVO = facade.getBackupVmPlanByVmId(vmId); if (vsspVO != null) { vssp.setId(vsspVO.getId()); if (0 == vssp.getPlanType()) { vssp.setPlanTime(vsspVO.getPlanTime()); vssp.setPlanDate(vsspVO.getPlanDate()); } } result = facade.createBackupVmPlanByVmId(vssp); facade.insertOperationLog( controlPanelUser, "创建备份计划成功", "创建备份计划", Constants.RESULT_SUCESS, operateObject); } catch (Exception e) { facade.insertOperationLog( controlPanelUser, "创建备份计划出现错误:" + e.getMessage(), "创建备份计划", Constants.RESULT_FAILURE, operateObject); dealThrow( new HsCloudException(Constants.VM_BACKUP_PLAN_ERROR, "createBackupVmPlan异常", logger, e), "000"); return null; } if (result != null) { super.fillActionResult(Constants.VM_BACKUP_PLAN_ERROR); } else { super.fillActionResult(Constants.OPTIONS_SUCCESS); } if (logger.isDebugEnabled()) { long takeTime = System.currentTimeMillis() - beginRunTime; logger.debug("exit createBackupVmPlan method.takeTime:" + takeTime + "ms"); } return null; }