@Override public String getHostUuid() { return getSrcHostUuid(); }
private MigrateStruct buildMigrateStuct(final MigrateVmOnHypervisorMsg msg){ MigrateStruct s = new MigrateStruct(); s.vmUuid = msg.getVmInventory().getUuid(); s.srcHostUuid = msg.getSrcHostUuid(); s.dstHostUuid = msg.getDestHostInventory().getUuid(); s.storageMigrationPolicy = msg.getStorageMigrationPolicy(); s.migrateFromDestition = msg.isMigrateFromDestination(); MigrateNetworkExtensionPoint.MigrateInfo migrateIpInfo = null; for (MigrateNetworkExtensionPoint ext: pluginRgty.getExtensionList(MigrateNetworkExtensionPoint.class)) { MigrateNetworkExtensionPoint.MigrateInfo r = ext.getMigrationAddressForVM(s.srcHostUuid, s.dstHostUuid); if (r == null) { continue; } migrateIpInfo = r; } s.dstHostMnIp = msg.getDestHostInventory().getManagementIp(); s.dstHostMigrateIp = migrateIpInfo == null ? s.dstHostMnIp : migrateIpInfo.dstMigrationAddress; s.srcHostMnIp = Q.New(HostVO.class).eq(HostVO_.uuid, msg.getSrcHostUuid()).select(HostVO_.managementIp).findValue(); s.srcHostMigrateIp = migrateIpInfo == null ? s.srcHostMnIp : migrateIpInfo.srcMigrationAddress; return s; }
private void handle(MigrateVmOnHypervisorMsg msg) { MigrateVmOnHypervisorReply reply = new MigrateVmOnHypervisorReply(); if (!config.migrateSuccess) { reply.setError(operr("on purpose")); } else { logger.debug(String.format("Successfully migrate vm[uuid:%s] on simulator host[uuid:%s] to host[uuid:%s]", msg.getVmInventory().getUuid(), self.getUuid(), msg.getDestHostInventory().getUuid())); config.removeVm(msg.getSrcHostUuid(), msg.getVmInventory().getUuid()); config.putVm(msg.getDestHostInventory().getUuid(), msg.getVmInventory().getUuid(), VmInstanceState.Running); } bus.reply(msg, reply); }
@Override public void run(final FlowTrigger chain, Map data) { final VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); boolean migrateFromDest = false; if (spec.getMessage() instanceof MigrateVmMessage) { migrateFromDest = ((MigrateVmMessage)spec.getMessage()).isMigrateFromDestination(); } MigrateVmOnHypervisorMsg msg = new MigrateVmOnHypervisorMsg(); msg.setVmInventory(spec.getVmInventory()); msg.setDestHostInventory(spec.getDestHost()); msg.setSrcHostUuid(spec.getVmInventory().getHostUuid()); msg.setMigrateFromDestination(migrateFromDest); bus.makeTargetServiceIdByResourceUuid(msg, HostConstant.SERVICE_ID, spec.getDestHost().getUuid()); bus.send(msg, new CloudBusCallBack(chain) { @Override public void run(MessageReply reply) { if (reply.isSuccess()) { chain.next(); } else { chain.fail(reply.getError()); } } }); }