public static List<VipInventory> valueOf(Collection<VipVO> vos) { List<VipInventory> invs = new ArrayList<VipInventory>(vos.size()); for (VipVO vo : vos) { invs.add(VipInventory.valueOf(vo)); } return invs; }
protected VipInventory getSelfInventory() { return VipInventory.valueOf(getSelf()); }
@Override public void run(AfterAcquireVipExtensionPoint ext) { logger.debug(String.format("execute after acquire vip extension point %s", ext)); ext.afterAcquireVip(VipInventory.valueOf(getSelf())); } });
@Override public void run(BeforeReleaseVipExtensionPoint ext) { logger.debug(String.format("execute before release vip extension point %s", ext)); ext.beforeReleaseVip(VipInventory.valueOf(getSelf())); } });
@Transactional private EipStruct eipVOtoEipStruct(EipVO vo) { String sql = "select nic from VmNicVO nic where nic.uuid = :uuid"; TypedQuery<VmNicVO> q = dbf.getEntityManager().createQuery(sql, VmNicVO.class); q.setParameter("uuid", vo.getVmNicUuid()); VmNicVO nicvo = q.getSingleResult(); sql = "select vip from VipVO vip where vip.uuid = :uuid"; TypedQuery<VipVO> vq = dbf.getEntityManager().createQuery(sql, VipVO.class); vq.setParameter("uuid", vo.getVipUuid()); VipVO vipvo = vq.getSingleResult(); UsedIpInventory guestIp = eipMgr.getEipGuestIp(vo.getUuid()); EipStruct struct = eipMgr.generateEipStruct(VmNicInventory.valueOf(nicvo), VipInventory.valueOf(vipvo), EipInventory.valueOf(vo), guestIp); struct.setSnatInboundTraffic(EipGlobalConfig.SNAT_INBOUND_TRAFFIC.value(Boolean.class)); return struct; }
@Transactional(readOnly = true) private List<VmNicInventory> getEipAttachableVmNics(APIGetEipAttachableVmNicsMsg msg){ VipVO vipvo = msg.getEipUuid() == null ? Q.New(VipVO.class).eq(VipVO_.uuid, msg.getVipUuid()).find() : SQL.New("select vip" + " from VipVO vip, EipVO eip" + " where eip.uuid = :eipUuid" + " and eip.vipUuid = vip.uuid") .param("eipUuid", msg.getEipUuid()) .find(); VipInventory vipInv = VipInventory.valueOf(vipvo); List<VmNicInventory> nics = getAttachableVmNicForEip(vipInv); if (nics == null || nics.isEmpty()) { return nics; } logger.debug(String.format("get eip[uuid:%s] attachable vm nics[%s] before filter extension point", msg.getEipUuid(), nics.stream().map(VmNicInventory::getUuid).collect(Collectors.toList()))); nics = filterVmNicsForEipInVirtualRouterExtensionPoint(vipInv, nics); if (nics != null && !nics.isEmpty()) { logger.debug(String.format("get eip[uuid:%s] attachable vm nics[%s] after filter extension point", msg.getEipUuid(), nics.stream().map(VmNicInventory::getUuid).collect(Collectors.toList()))); } return nics; }
List<VipVO> vipVOs = q.list(); return VipInventory.valueOf(vipVOs); } else if (IpRangeVO.class.getSimpleName().equals(action.getParentIssuer())) { List<String> iprUuids = CollectionUtils.transformToList((List<IpRangeInventory>) action.getParentIssuerContext(), new Function<String, IpRangeInventory>() { List<VipVO> vipVOs = q.list(); return VipInventory.valueOf(vipVOs); } else if (VipVO.class.getSimpleName().equals(action.getParentIssuer())) { return action.getParentIssuerContext(); return VipInventory.valueOf(vos);
.map(uuid -> (VipVO)Q.New(VipVO.class).eq(VipVO_.uuid, uuid).find()) .collect(Collectors.toList()); List<VipInventory> invs = VipInventory.valueOf(vips); vipExt.createVipOnVirtualRouterVm(vr, invs, new Completion(chain) { @Override
List<VipInventory> invs = VipInventory.valueOf(vips); vipExt.createVipOnVirtualRouterVm(vr, invs, new Completion(chain) { @Override
protected void handle(APIChangeVipStateMsg msg) { VipVO vip = dbf.findByUuid(msg.getUuid(), VipVO.class); VipStateEvent sevt = VipStateEvent.valueOf(msg.getStateEvent()); vip.setState(vip.getState().nextState(sevt)); vip = dbf.updateAndRefresh(vip); APIChangeVipStateEvent evt = new APIChangeVipStateEvent(msg.getId()); evt.setInventory(VipInventory.valueOf(vip)); bus.publish(evt); }
protected void handle(VipDeletionMsg msg) { VipDeletionReply reply = new VipDeletionReply(); VipInventory inventory = VipInventory.valueOf(self); String accountUuid = Q.New(AccountResourceRefVO.class) .select(AccountResourceRefVO_.accountUuid)
struct.setVip(VipInventory.valueOf(vipvo)); struct.setGuestIp(nic.getIp()); struct.setGuestMac(nic.getMac());
private void handle(final APICreateLoadBalancerMsg msg) { final APICreateLoadBalancerEvent evt = new APICreateLoadBalancerEvent(msg.getId()); final VipInventory vip = VipInventory.valueOf(dbf.findByUuid(msg.getVipUuid(), VipVO.class)); FlowChain chain = FlowChainBuilder.newShareFlowChain(); chain.setName(String.format("create-lb-%s", msg.getName()));
final List<VipInventory> ctx = Arrays.asList(VipInventory.valueOf(self)); FlowChain chain = FlowChainBuilder.newShareFlowChain(); chain.setName(String.format("delete-vip-%s", self.getUuid()));
protected void handle(APIUpdateVipMsg msg) { VipVO vo = dbf.findByUuid(msg.getUuid(), VipVO.class); boolean update = false; if (msg.getName() != null) { vo.setName(msg.getName()); update = true; } if (msg.getDescription() != null) { vo.setDescription(msg.getDescription()); update = true; } if (update) { vo = dbf.updateAndRefresh(vo); } APIUpdateVipEvent evt = new APIUpdateVipEvent(msg.getId()); evt.setInventory(VipInventory.valueOf(vo)); bus.publish(evt); }
private PortForwardingStruct makePortForwardingStruct(PortForwardingRuleInventory rule) { VipVO vipvo = dbf.findByUuid(rule.getVipUuid(), VipVO.class); L3NetworkVO vipL3vo = dbf.findByUuid(vipvo.getL3NetworkUuid(), L3NetworkVO.class); VmNicVO nic = dbf.findByUuid(rule.getVmNicUuid(), VmNicVO.class); L3NetworkVO guestL3vo = dbf.findByUuid(nic.getL3NetworkUuid(), L3NetworkVO.class); PortForwardingStruct struct = new PortForwardingStruct(); struct.setRule(rule); struct.setVip(VipInventory.valueOf(vipvo)); struct.setGuestIp(nic.getIp()); struct.setGuestMac(nic.getMac()); struct.setGuestL3Network(L3NetworkInventory.valueOf(guestL3vo)); struct.setSnatInboundTraffic(PortForwardingGlobalConfig.SNAT_INBOUND_TRAFFIC.value(Boolean.class)); struct.setVipL3Network(L3NetworkInventory.valueOf(vipL3vo)); return struct; }
final VipInventory vip = VipInventory.valueOf(dbf.findByUuid(struct.getLb().getVipUuid(), VipVO.class));
private void handle(APIDetachEipMsg msg) { final APIDetachEipEvent evt = new APIDetachEipEvent(msg.getId()); final EipVO vo = dbf.findByUuid(msg.getUuid(), EipVO.class); VmNicVO nicvo = dbf.findByUuid(vo.getVmNicUuid(), VmNicVO.class); VmNicInventory nicInventory = VmNicInventory.valueOf(nicvo); VipVO vipvo = dbf.findByUuid(vo.getVipUuid(), VipVO.class); VipInventory vipInventory = VipInventory.valueOf(vipvo); EipInventory eip = EipInventory.valueOf(vo); String l3NetworkUuid = getEipL3Network(nicInventory, eip); NetworkServiceProviderType providerType = nwServiceMgr. getTypeOfNetworkServiceProviderForService(l3NetworkUuid, EipConstant.EIP_TYPE); UsedIpInventory guestIp = getEipGuestIp(eip.getUuid()); EipStruct struct = generateEipStruct(nicInventory, vipInventory, eip, guestIp); struct.setSnatInboundTraffic(EipGlobalConfig.SNAT_INBOUND_TRAFFIC.value(Boolean.class)); detachEipAndUpdateDb(struct, providerType.toString(), new Completion(msg) { @Override public void success() { evt.setInventory(EipInventory.valueOf(dbf.reload(vo))); bus.publish(evt); } @Override public void fail(ErrorCode errorCode) { evt.setError(errorCode); bus.publish(evt); } }); }
private void deleteEip(String eipUuid, Completion completion) { final EipVO vo = dbf.findByUuid(eipUuid, EipVO.class); VipVO vipvo = dbf.findByUuid(vo.getVipUuid(), VipVO.class); VipInventory vipInventory = VipInventory.valueOf(vipvo);
final VmNicInventory nicInventory = VmNicInventory.valueOf(nicvo); VipVO vipvo = dbf.findByUuid(vo.getVipUuid(), VipVO.class); VipInventory vipInventory = VipInventory.valueOf(vipvo); UsedIpVO guestIp = dbf.findByUuid(msg.getUsedIpUuid(), UsedIpVO.class);