@Override public void rollback(FlowRollback chain, Map data) { try { VmInstanceSpec spec = (VmInstanceSpec) data.get(VmInstanceConstant.Params.VmInstanceSpec.toString()); List<VmNicInventory> nics = spec.getDestNics(); if (nics.isEmpty()) { return; } removeNicFromDb(nics); for (VmNicInventory nic : nics) { if (nic.getUsedIpUuid() == null) { continue; } ReturnIpMsg msg = new ReturnIpMsg(); msg.setL3NetworkUuid(nic.getL3NetworkUuid()); msg.setUsedIpUuid(nic.getUsedIpUuid()); bus.makeTargetServiceIdByResourceUuid(msg, L3NetworkConstant.SERVICE_ID, nic.getL3NetworkUuid()); bus.send(msg); } } finally { chain.rollback(); } } }
final List<VmNicInventory> usedIpNics = new ArrayList<VmNicInventory>(); for (VmNicInventory nic : vm.getVmNics()) { if (nic.getUsedIpUuid() == null) { nicsNeedNewIp.add(nic); } else {
vo.setMetaData(GUEST_NIC_MASK.toString()); UsedIpVO usedIpVO = Q.New(UsedIpVO.class).eq(UsedIpVO_.uuid, nicInventory.getUsedIpUuid()).find(); usedIpVO.setMetaData(GUEST_NIC_MASK.toString()); dbf.updateAndRefresh(usedIpVO);
private Vip getVipWithSnatService(VirtualRouterVmInventory vr, VmNicInventory nic){ String vipUuid = Q.New(VipVO.class).eq(VipVO_.usedIpUuid, vr.getPublicNic().getUsedIpUuid()).select(VipVO_.uuid).findValue(); if (vipUuid == null){ return null; } ModifyVipAttributesStruct struct = new ModifyVipAttributesStruct(); struct.setUseFor(NetworkServiceType.SNAT.toString()); Vip vip = new Vip(vipUuid); String l3NetworkUuuid = nic.getL3NetworkUuid(); try { NetworkServiceProviderType providerType = nwServiceMgr.getTypeOfNetworkServiceProviderForService(l3NetworkUuuid, NetworkServiceType.SNAT); struct.setPeerL3NetworkUuid(l3NetworkUuuid); struct.setServiceProvider(providerType.toString()); } catch (OperationFailureException e){ logger.debug(String.format("Get providerType exception %s", e.toString())); } vip.setStruct(struct); return vip; }
@Override protected void scripts() { String acntUuid = Account.getAccountUuidOfResource(spec.getVmInventory().getUuid()); spec.getDestNics().forEach(nic -> { VmNicVO nvo = new VmNicVO(); nvo.setUuid(nic.getUuid()); nvo.setDeviceId(nic.getDeviceId()); nvo.setIp(nic.getIp()); nvo.setL3NetworkUuid(nic.getL3NetworkUuid()); nvo.setMac(nic.getMac()); nvo.setHypervisorType(nic.getHypervisorType()); nvo.setUsedIpUuid(nic.getUsedIpUuid()); nvo.setGateway(nic.getGateway()); nvo.setNetmask(nic.getNetmask()); nvo.setVmInstanceUuid(nic.getVmInstanceUuid()); nvo.setMetaData(nic.getMetaData()); nvo.setInternalName(nic.getInternalName()); nvo.setAccountUuid(acntUuid); nvo.setIpVersion(nic.getIpVersion()); persist(nvo); if (nic.getUsedIpUuid() != null) { SQL.New(UsedIpVO.class).eq(UsedIpVO_.uuid, nic.getUsedIpUuid()).set(UsedIpVO_.vmNicUuid, nvo.getUuid()).update(); } }); ApplianceVmVO apvm = findByUuid(spec.getVmInventory().getUuid(), ApplianceVmVO.class); apvm.setManagementNetworkUuid(mgmtNic.getL3NetworkUuid()); merge(apvm); } }.execute();
vipvo.setL3NetworkUuid(nic.getL3NetworkUuid()); vipvo.setNetmask(nic.getNetmask()); vipvo.setUsedIpUuid(nic.getUsedIpUuid()); vipvo.setUseFor(VirtualRouterConstant.SNAT_NETWORK_SERVICE_TYPE); vipvo.setAccountUuid(accountUuid);