Package com.cloud.agent.api

Examples of com.cloud.agent.api.StopAnswer


            if (vmName.startsWith("s-")) {
                _mockAgentMgr.handleSystemVMStop(vm.getId());
            }
            txn.commit();
            return new StopAnswer(cmd, null, true);
        } catch (Exception ex) {
            txn.rollback();
            throw new CloudRuntimeException("unable to stop vm " + cmd.getVmName(), ex);
        } finally {
            txn.close();
View Full Code Here


  }
 
  protected synchronized StopAnswer execute(StopCommand cmd) {

    StopAnswer answer = null;
    String vmName = cmd.getVmName();

    State state = null;
    synchronized (_vms) {
      state = _vms.get(vmName);
      _vms.put(vmName, State.Stopping);
    }
    try {
        Answer result = _simMgr.simulate(cmd, hostGuid);
       
        if (!result.getResult()) {
            return new StopAnswer(cmd, result.getDetails(), false);
        }
       
      answer = new StopAnswer(cmd, null, 0, true);
      Pair<Long, Long> data = _runningVms.get(vmName);
      if (data != null) {
        this.usedCpu -= data.first();
        this.usedMem -= data.second();
      }
View Full Code Here

      return answer;
    }
   
    @Override
    public StopAnswer execute(StopCommand cmd) {
      StopAnswer answer = super.execute(cmd);
      String vmName = cmd.getVmName();
      if (vmName.startsWith("v-")) {
        Connection conn = getConnection();
        callHostPlugin(conn, "vmops", "setDNATRule", "add", "false");
      }
View Full Code Here

          OvmVm.Details vm = null;
          try {
            vm = OvmVm.getDetails(_conn, vmName);  
          } catch (XmlRpcException e) {
            s_logger.debug("Unable to get details of vm: " + vmName + ", treating it as stopped", e);
            return new StopAnswer(cmd, "success", 0, true);
          }
         
          deleteAllNetworkRulesForVm(vmName);   
          OvmVm.stop(_conn, vmName);
          cleanup(vm);
         
          state = State.Stopped;
          return new StopAnswer(cmd, "success", 0, true);
        } catch (Exception e) {
          s_logger.debug("Stop " + vmName + "failed", e);
          return new StopAnswer(cmd, e.getMessage(), false);
        } finally {
          synchronized(_vms) {
                if (state != null) {
                    _vms.put(vmName, state);
                } else {
View Full Code Here

      if (vmName.startsWith("s-")) {
        _mockAgentMgr.handleSystemVMStop(vm.getId());
      }
      txn.commit();
      return new StopAnswer(cmd, null, new Integer(0), true);
    } catch (Exception ex) {
      txn.rollback();
      throw new CloudRuntimeException("unable to stop vm " + cmd.getVmName(), ex);
    } finally {
      txn.close();
View Full Code Here

            }
                       
            count++;
        }
           
    return success ? new StopAnswer(cmd, "Success", null, true) : new StopAnswer(cmd, "IPMI power off failed", false);
  }
View Full Code Here

            if (result != null && result2 != null) {
                result = result2 + result;
            }
            state = State.Stopped;
            return new StopAnswer(cmd, result, 0, true);
        } catch (LibvirtException e) {
            return new StopAnswer(cmd, e.getMessage(), false);
        } finally {
            synchronized (_vms) {
                if (state != null) {
                    _vms.put(vmName, state);
                } else {
View Full Code Here

        }
    }

    @Override
    public StopAnswer execute(StopCommand cmd) {
      StopAnswer answer = super.execute(cmd);
      String vmName = cmd.getVmName();
      if (vmName.startsWith("v-")) {
        Connection conn = getConnection();
        callHostPlugin(conn, "vmops", "setDNATRule", "add", "false");
      }
View Full Code Here

            if (result != null && result2 != null) {
                result = result2 + result;
            }
            state = State.Stopped;
            return new StopAnswer(cmd, result, 0, true);
        } catch (LibvirtException e) {
            return new StopAnswer(cmd, e.getMessage(), false);
        } finally {
            synchronized (_vms) {
                if (state != null) {
                    _vms.put(vmName, state);
                } else {
View Full Code Here

                        // disk chain be collapsed
                        s_logger.info("Remove all snapshot before stopping VM " + cmd.getVmName());
                        vmMo.removeAllSnapshots();
                        if (vmMo.safePowerOff(_shutdown_waitMs)) {
                            state = State.Stopped;
                            return new StopAnswer(cmd, "Stop VM " + cmd.getVmName() + " Succeed", 0, true);
                        } else {
                            String msg = "Have problem in powering off VM " + cmd.getVmName() + ", let the process continue";
                            s_logger.warn(msg);
                            return new StopAnswer(cmd, msg, 0, true);
                        }
                    } else {
                        state = State.Stopped;
                    }

                    String msg = "VM " + cmd.getVmName() + " is already in stopped state";
                    s_logger.info(msg);
                    return new StopAnswer(cmd, msg, 0, true);
                } finally {
                    synchronized (_vms) {
                        _vms.put(cmd.getVmName(), state);
                    }
                }
            } else {
                synchronized (_vms) {
                    _vms.remove(cmd.getVmName());
                }

                String msg = "VM " + cmd.getVmName() + " is no longer in vSphere";
                s_logger.info(msg);
                return new StopAnswer(cmd, msg, 0, true);
            }
        } catch (Exception e) {
            if (e instanceof RemoteException) {
                s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
                invalidateServiceContext();
            }

            String msg = "StopCommand failed due to " + VmwareHelper.getExceptionMessage(e);
            s_logger.error(msg);
            return new StopAnswer(cmd, msg, false);
        }
    }
View Full Code Here

TOP

Related Classes of com.cloud.agent.api.StopAnswer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.