Ejemplo n.º 1
0
 /**
  * <启动虚拟机>
  *
  * @return
  * @see [类、类#方法、类#成员]
  */
 public String startVM() {
   long beginRunTime = 0;
   if (logger.isDebugEnabled()) {
     beginRunTime = System.currentTimeMillis();
     logger.debug("enter startVM method.");
   }
   boolean result = false;
   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.startVmByVmId(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_START_ERROR, "startVM异常", logger, e), "000");
     return null;
   }
   if (result) {
     super.fillActionResult(Constants.OPTIONS_SUCCESS);
   } else {
     logger.error("ERROR:" + result);
     super.fillActionResult(Constants.VM_START_ERROR);
   }
   if (logger.isDebugEnabled()) {
     long takeTime = System.currentTimeMillis() - beginRunTime;
     logger.debug("exit startVM method.takeTime:" + takeTime + "ms");
   }
   return null;
 }