@Override public void run(KVMStartVmAddonExtensionPoint extp) { if (spec.getVmInventory().getType().equals(extp.getVmTypeForAddonExtension().toString())) { extp.addAddon(host, spec, cmd); } } });
@Override public void addAddon(KVMHostInventory host, VmInstanceSpec spec, KVMAgentCommands.StartVmCmd cmd) { if (!spec.getVmInventory().getType().equals(ApplianceVmConstant.APPLIANCE_VM_TYPE)) { return; } KVMAddons.Channel chan = new KVMAddons.Channel(); chan.setSocketPath(makeChannelSocketPath(spec.getVmInventory().getUuid())); chan.setTargetName(String.format("applianceVm.vport")); cmd.getAddons().put(chan.NAME, chan); logger.debug(String.format("make kvm channel device[path:%s, target:%s]", chan.getSocketPath(), chan.getTargetName())); }
final VmInstanceInventory vm = spec.getVmInventory(); if (!VmInstanceConstant.USER_VM_TYPE.equals(vm.getType())) { trigger.next(); return;
@Override public void releaseResourceOnDetachingNic(VmInstanceSpec spec, VmNicInventory nic, NoErrorCompletion completion) { // Todo(WeiW): Need to check router rather than not only user vm if (spec.getVmInventory().getType().equals(VmInstanceConstant.USER_VM_TYPE)) { completion.done(); return; } /* FIXME shixin: nic.getL3NetworkUuid() should be change to nic.getUesedIp for appliancevm */ logger.debug(String.format("check detaching nic[uuid:%s] in peer l3 of vip", nic.getUuid())); List<VipPeerL3NetworkRefVO> refVOS = Q.New(VipPeerL3NetworkRefVO.class).eq(VipPeerL3NetworkRefVO_.l3NetworkUuid, nic.getL3NetworkUuid()).list(); if (refVOS == null || refVOS.isEmpty()) { completion.done(); return; } Set<String> refUuids = refVOS.stream().map(r -> r.getVipUuid()).collect(Collectors.toSet()); logger.debug(String.format("release peer l3[uuid:%s] from vips[uuid:%s] for detaching nic[uuid:%s]", nic.getL3NetworkUuid(), refUuids, nic.getUuid())); List<VipVO> vipVOS = Q.New(VipVO.class).in(VipVO_.uuid, refUuids).list(); for (VipVO vipVO : vipVOS) { VipBase v = new VipBase(vipVO); v.deletePeerL3NetworkUuid(nic.getL3NetworkUuid()); } completion.done(); }
private void releaseNetworkServices(final VmInstanceSpec spec, NetworkServiceExtensionPosition position, final NoErrorCompletion completion) { if (!spec.getVmInventory().getType().equals(VmInstanceConstant.USER_VM_TYPE)) { completion.done(); return;
private void applyNetworkServices(final VmInstanceSpec spec, NetworkServiceExtensionPosition position, final Completion completion) { if (!spec.getVmInventory().getType().equals(VmInstanceConstant.USER_VM_TYPE)) { completion.success(); return;
private void checkManagementIp(VmInstanceSpec spec, boolean isNewCreated) { if (CoreGlobalProperty.UNIT_TEST_ON) { return; } if (!ApplianceVmConstant.APPLIANCE_VM_TYPE.equals(spec.getVmInventory().getType())) { return; } VmNicInventory mgmtNic; if (isNewCreated) { final ApplianceVmSpec aspec = spec.getExtensionData(ApplianceVmConstant.Params.applianceVmSpec.toString(), ApplianceVmSpec.class); mgmtNic = CollectionUtils.find(spec.getDestNics(), new Function<VmNicInventory, VmNicInventory>() { @Override public VmNicInventory call(VmNicInventory arg) { return arg.getL3NetworkUuid().equals(aspec.getManagementNic().getL3NetworkUuid()) ? arg : null; } }); } else { ApplianceVmInventory apvm = ApplianceVmInventory.valueOf(dbf.findByUuid(spec.getVmInventory().getUuid(), ApplianceVmVO.class)); mgmtNic = apvm.getManagementNic(); } DebugUtils.Assert(mgmtNic!=null, String.format("cannot find management nic of appliance vm[uuid:%s, newCreated: %s]", spec.getVmInventory().getUuid(), isNewCreated)); ShellResult ret = ShellUtils.runAndReturn(String.format("ping -c 1 -W 1 %s", mgmtNic.getIp())); if (ret.isReturnCode(0)) { throw new OperationFailureException(err(ApplianceVmErrors.MANAGEMENT_IP_OCCUPIED, "the management nic IP[%s] has been occupied by another device in the data center, we can ping it", mgmtNic.getIp() )); } }
if (!VmInstanceConstant.USER_VM_TYPE.equals(vm.getType())) { trigger.next(); return;
if (VmInstanceConstant.USER_VM_TYPE.equals(spec.getVmInventory().getType())) { VmInstanceDeletionPolicy deletionPolicy = getDeletionPolicy(spec, data); if (deletionPolicy == VmInstanceDeletionPolicy.Direct) {
cmd.setEmulateHyperV(VmGlobalConfig.EMULATE_HYPERV.value(Boolean.class)); cmd.setAdditionalQmp(VmGlobalConfig.ADDITIONAL_QMP.value(Boolean.class)); cmd.setApplianceVm(spec.getVmInventory().getType().equals("ApplianceVm")); cmd.setSystemSerialNumber(makeAndSaveVmSystemSerialNumber(spec.getVmInventory().getUuid()));
public VmInstanceInventory(VmInstanceInventory origin) { VmInstanceInventory inv; try { inv = (VmInstanceInventory) origin.clone(); } catch (CloneNotSupportedException e) { throw new CloudRuntimeException(e); } this.setClusterUuid(inv.getClusterUuid()); this.setCreateDate(inv.getCreateDate()); this.setDescription(inv.getDescription()); this.setHostUuid(inv.getHostUuid()); this.setHypervisorType(inv.getHypervisorType()); this.setImageUuid(inv.getImageUuid()); this.setInstanceOfferingUuid(inv.getInstanceOfferingUuid()); this.setLastHostUuid(inv.getLastHostUuid()); this.setLastOpDate(inv.getLastOpDate()); this.setName(inv.getName()); this.setRootVolumeUuid(inv.getRootVolumeUuid()); this.setState(inv.getState()); this.setType(inv.getType()); this.setUuid(inv.getUuid()); this.setZoneUuid(inv.getZoneUuid()); this.setAllVolumes(inv.getAllVolumes()); this.setVmNics(inv.getVmNics()); this.setInternalId(inv.getInternalId()); this.setCpuNum(inv.getCpuNum()); this.setCpuSpeed(inv.getCpuSpeed()); this.setMemorySize(inv.getMemorySize()); this.setAllocatorStrategy(inv.getAllocatorStrategy()); }