Examples of MigrateAnswer


Examples of com.cloud.agent.api.MigrateAnswer

            destroy_network_rules_for_vm(conn, vmName);
            cleanupVM(conn, vmName,
                    getVnetId(VirtualMachineName.getVnet(vmName)));
        }

        return new MigrateAnswer(cmd, result == null, result, null);
    }
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

            if (!vmMo.migrate(destHyperHost.getHyperHostOwnerResourcePool(), morTargetPhysicalHost)) {
                throw new Exception("Migration failed");
            }

            state = State.Stopping;
            return new MigrateAnswer(cmd, true, "migration succeeded", null);
        } catch (Throwable e) {
            if (e instanceof RemoteException) {
                s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
                invalidateServiceContext();
            }

            String msg = "MigrationCommand failed due to " + VmwareHelper.getExceptionMessage(e);
            s_logger.warn(msg, e);
            return new MigrateAnswer(cmd, false, msg, null);
        } finally {
            synchronized (_vms) {
                _vms.put(vmName, state);
            }
        }
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

            boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
            MigrateCommand mc = new MigrateCommand(vm.getInstanceName(), dest.getHost().getPrivateIpAddress(), isWindows);
            mc.setHostGuid(dest.getHost().getGuid());

            try {
                MigrateAnswer ma = (MigrateAnswer) _agentMgr.send(vm.getLastHostId(), mc);
                if (!ma.getResult()) {
                    s_logger.error("Unable to migrate due to " + ma.getDetails());
                    return null;
                }
            } catch (OperationTimedoutException e) {
                if (e.isActive()) {
                    s_logger.warn("Active migration command so scheduling a restart for " + vm);
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

            boolean isWindows = _guestOsCategoryDao.findById(_guestOsDao.findById(vm.getGuestOSId()).getCategoryId()).getName().equalsIgnoreCase("Windows");
            MigrateCommand mc = new MigrateCommand(vm.getInstanceName(), dest.getHost().getPrivateIpAddress(), isWindows);
            mc.setHostGuid(dest.getHost().getGuid());

            try {
                MigrateAnswer ma = (MigrateAnswer) _agentMgr.send(vm.getLastHostId(), mc);
                if (!ma.getResult()) {
                    s_logger.error("Unable to migrate due to " + ma.getDetails());
                    return null;
                }
            } catch (OperationTimedoutException e) {
                if (e.isActive()) {
                    s_logger.warn("Active migration command so scheduling a restart for " + vm);
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

            if (!vmMo.migrate(destHyperHost.getHyperHostOwnerResourcePool(), morTargetPhysicalHost)) {
                throw new Exception("Migration failed");
            }

            state = State.Stopping;
            return new MigrateAnswer(cmd, true, "migration succeeded", null);
        } catch (Throwable e) {
            if (e instanceof RemoteException) {
                s_logger.warn("Encounter remote exception to vCenter, invalidate VMware session context");
                invalidateServiceContext();
            }

            String msg = "MigrationCommand failed due to " + VmwareHelper.getExceptionMessage(e);
            s_logger.warn(msg, e);
            return new MigrateAnswer(cmd, false, msg, null);
        } finally {
            synchronized (_vms) {
                _vms.put(vmName, state);
            }
        }
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

            txn.start();
            String vmName = cmd.getVmName();
            String destGuid = cmd.getHostGuid();
            MockVMVO vm = _mockVmDao.findByVmNameAndHost(vmName, info.getHostUuid());
            if (vm == null) {
                return new MigrateAnswer(cmd, false, "can't find vm:" + vmName + " on host:" + info.getHostUuid(), null);
            } else {
                if (vm.getState() == State.Migrating) {
                    vm.setState(State.Running);
                }
            }

            MockHost destHost = _mockHostDao.findByGuid(destGuid);
            if (destHost == null) {
                return new MigrateAnswer(cmd, false, "can;t find host:" + info.getHostUuid(), null);
            }
            vm.setHostId(destHost.getId());
            _mockVmDao.update(vm.getId(), vm);
            txn.commit();
            return new MigrateAnswer(cmd, true, null, 0);
        } catch (Exception ex) {
            txn.rollback();
            throw new CloudRuntimeException("unable to migrate vm " + cmd.getVmName(), ex);
        } finally {
            txn.close();
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

                    vifDriver.unplug(iface);
                }
            }
        }

        return new MigrateAnswer(cmd, result == null, result, null);
    }
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

          OvmVm.Details vm = OvmVm.getDetails(_conn, vmName);
          String destIp = cmd.getDestinationIp();
          OvmVm.migrate(_conn, vmName, destIp);
            state = State.Stopping;
            cleanup(vm);
            return new MigrateAnswer(cmd, true, "migration succeeded", null);
        } catch (Exception e) {
            String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed due to " + e.toString();
            s_logger.debug(msg, e);
            return new MigrateAnswer(cmd, false, msg, null);
        } finally {
            synchronized (_vms) {
                _vms.put(vmName, state);
            }
        }
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

                }
            }
            if ( dsthost == null ) {
                String msg = "Migration failed due to unable to find host " + ipaddr + " in XenServer pool " + _host.pool;
                s_logger.warn(msg);
                return new MigrateAnswer(cmd, false, msg, null);
            }
            for (VM vm : vms) {
                Set<VBD> vbds = vm.getVBDs(conn);
                for( VBD vbd : vbds) {
                    VBD.Record vbdRec = vbd.getRecord(conn);
                    if( vbdRec.type.equals(Types.VbdType.CD.toString()) && !vbdRec.empty ) {
                        vbd.eject(conn);
                        break;
                    }
                }
                migrateVM(conn, dsthost, vm, vmName);
                vm.setAffinity(conn, dsthost);
                state = State.Stopping;
            }
            return new MigrateAnswer(cmd, true, "migration succeeded", null);
        } catch (Exception e) {
            String msg = "Catch Exception " + e.getClass().getName() + ": Migration failed due to " + e.toString();
            s_logger.warn(msg, e);
            return new MigrateAnswer(cmd, false, msg, null);
        } finally {
            synchronized (_cluster.intern()) {
                s_vms.put(_cluster, _name, vmName, state);
            }
            s_logger.debug("6. The VM " + vmName + " is in " + state + " state");
View Full Code Here

Examples of com.cloud.agent.api.MigrateAnswer

    return new PrepareForMigrationAnswer(cmd);
  }

  protected MigrateAnswer execute(MigrateCommand cmd) {
    if (!doScript(_powerOffCommand)) {
      return new MigrateAnswer(cmd, false, "IPMI power off failed", null);
    }
    return new MigrateAnswer(cmd, true, "success", null);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.