@Override public String getVmInstanceUuid() { return getVmInstanceInventory().getUuid(); }
public static InstantiateVmFromNewCreatedStruct fromMessage(InstantiateNewCreatedVmInstanceMsg msg) { InstantiateVmFromNewCreatedStruct struct = new InstantiateVmFromNewCreatedStruct(); struct.setDataDiskOfferingUuids(msg.getDataDiskOfferingUuids()); struct.setL3NetworkUuids(msg.getL3NetworkUuids()); struct.setRootDiskOfferingUuid(msg.getRootDiskOfferingUuid()); struct.setPrimaryStorageUuidForRootVolume(msg.getPrimaryStorageUuidForRootVolume()); struct.setPrimaryStorageUuidForDataVolume(msg.getPrimaryStorageUuidForDataVolume()); struct.strategy = VmCreationStrategy.valueOf(msg.getStrategy()); struct.setRootVolumeSystemTags(msg.getRootVolumeSystemTags()); struct.setDataVolumeSystemTags(msg.getDataVolumeSystemTags()); return struct; }
InstantiateNewCreatedVmInstanceMsg smsg = new InstantiateNewCreatedVmInstanceMsg(); if (VmCreationStrategy.JustCreate == VmCreationStrategy.valueOf(msg.getStrategy())) { VmInstanceInventory inv = VmInstanceInventory.valueOf(vo); smsg.setDataDiskOfferingUuids(msg.getDataDiskOfferingUuids()); smsg.setL3NetworkUuids(msg.getL3NetworkUuids()); smsg.setRootDiskOfferingUuid(msg.getRootDiskOfferingUuid()); smsg.setVmInstanceInventory(VmInstanceInventory.valueOf(vo)); smsg.setPrimaryStorageUuidForRootVolume(msg.getPrimaryStorageUuidForRootVolume()); smsg.setPrimaryStorageUuidForDataVolume(msg.getPrimaryStorageUuidForDataVolume()); smsg.setStrategy(msg.getStrategy()); smsg.setTimeout(msg.getTimeout()); smsg.setRootVolumeSystemTags(msg.getRootVolumeSystemTags()); smsg.setDataVolumeSystemTags(msg.getDataVolumeSystemTags()); bus.makeTargetServiceIdByResourceUuid(smsg, VmInstanceConstant.SERVICE_ID, vo.getUuid()); bus.send(smsg, new CloudBusCallBack(smsg) {
ErrorCode preCreated = extEmitter.preStartNewCreatedVm(msg.getVmInstanceInventory()); if (preCreated != null) { bus.replyErrorByMessageType(msg, preCreated); spec.setVmInventory(msg.getVmInstanceInventory()); List<VmNicSpec> nicSpecs = new ArrayList<>(); if (msg.getL3NetworkUuids() != null && !msg.getL3NetworkUuids().isEmpty()) { SimpleQuery<L3NetworkVO> nwquery = dbf.createQuery(L3NetworkVO.class); nwquery.add(L3NetworkVO_.uuid, SimpleQuery.Op.IN, VmNicSpec.getL3UuidsOfSpec(msg.getL3NetworkUuids())); List<L3NetworkVO> vos = nwquery.list(); for (L3NetworkVO vo :vos) { if (msg.getDataDiskOfferingUuids() != null && !msg.getDataDiskOfferingUuids().isEmpty()) { SimpleQuery<DiskOfferingVO> dquery = dbf.createQuery(DiskOfferingVO.class); dquery.add(DiskOfferingVO_.uuid, SimpleQuery.Op.IN, msg.getDataDiskOfferingUuids()); List<DiskOfferingVO> vos = dquery.list(); for (final String duuid : msg.getDataDiskOfferingUuids()) { DiskOfferingVO dvo = CollectionUtils.find(vos, new Function<DiskOfferingVO, DiskOfferingVO>() { @Override spec.putExtensionData(ApplianceVmConstant.Params.timeout.toString(), msg.getTimeout()); spec.putExtensionData(ApplianceVmConstant.Params.applianceVmSpec.toString(), aspec); spec.setCurrentVmOperation(VmInstanceConstant.VmOperation.NewCreate); chain.setName(String.format("create-appliancevm-%s", msg.getVmInstanceUuid())); chain.getData().put(VmInstanceConstant.Params.VmInstanceSpec.toString(), spec); chain.getData().put(ApplianceVmConstant.Params.applianceVmFirewallRules.toString(), aspec.getFirewallRules());
protected void instantiateVmFromNewCreate(final InstantiateNewCreatedVmInstanceMsg msg, final SyncTaskChain taskChain) { refreshVO(); ErrorCode error = validateOperationByState(msg, self.getState(), SysErrors.OPERATION_ERROR); if (error != null) { throw new OperationFailureException(error); } error = extEmitter.preStartNewCreatedVm(msg.getVmInstanceInventory()); if (error != null) { throw new OperationFailureException(error); } InstantiateNewCreatedVmInstanceReply reply = new InstantiateNewCreatedVmInstanceReply(); instantiateVmFromNewCreate(InstantiateVmFromNewCreatedStruct.fromMessage(msg), new Completion(msg, taskChain) { @Override public void success() { self = dbf.reload(self); reply.setVmInventory(getSelfInventory()); bus.reply(msg, reply); taskChain.next(); } @Override public void fail(ErrorCode errorCode) { reply.setError(errorCode); bus.reply(msg, reply); taskChain.next(); } }); }