コード例 #1
0
ファイル: OpsAction.java プロジェクト: RexG/hscloud-3.0.x
 /**
  * <发送重启虚拟机命令>
  *
  * @return
  * @see [类、类#方法、类#成员]
  */
 public String rebootVM() {
   long beginRunTime = 0;
   if (logger.isDebugEnabled()) {
     beginRunTime = System.currentTimeMillis();
     logger.debug("enter rebootVM method.");
   }
   String result = null;
   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 + "]";
   try {
     result = facade.rebootVmByVmId(vmId, controlPanelUser, LogOperatorType.CP.getName());
     facade.insertOperationLog(
         controlPanelUser, "发送重启虚拟机命令成功", "发送重启虚拟机命令", Constants.RESULT_SUCESS, operateObject);
   } catch (HsCloudException e) {
     facade.insertOperationLog(
         controlPanelUser,
         "发送重启虚拟机命令出现错误:" + e.getMessage(),
         "发送重启虚拟机命令",
         Constants.RESULT_FAILURE,
         operateObject);
     dealThrow(new HsCloudException(Constants.VM_REBOOT_ERROR, "rebootVM异常", logger, e), "000");
     return null;
   }
   if (result != null) {
     logger.info("ERROR:" + result);
     super.fillActionResult(Constants.VM_REBOOT_ERROR);
   } else {
     super.fillActionResult(Constants.OPTIONS_SUCCESS);
   }
   if (logger.isDebugEnabled()) {
     long takeTime = System.currentTimeMillis() - beginRunTime;
     logger.debug("exit rebootVM method.takeTime:" + takeTime + "ms");
   }
   return null;
 }