@Override public void success() { logger.debug(String.format("successfully released vip[uuid:%s, name:%s, ip:%s] on service[%s]", self.getUuid(), self.getName(), self.getIp(), self.getServiceProvider())); VipUseForList useForList = new VipUseForList(self.getUseFor()); self.setUseFor(null); clearPeerL3Network(); self.setServiceProvider(null); dbf.update(self); completion.success(); }
if (vipVO.getUseFor().contains(SNAT_NETWORK_SERVICE_TYPE)) { l3Uuids = sql("select l3.uuid" + " from L3NetworkVO l3, VipVO vip, NetworkServiceL3NetworkRefVO ref, " +
protected boolean releaseCheckModifyVipAttributeStruct( ModifyVipAttributesStruct s) { VipUseForList useForList = new VipUseForList(self.getUseFor()); if (s.isUserFor() && s.getUseFor().equals(NetworkServiceType.SNAT.toString())) { useForList.del(s.getUseFor()); if (useForList.getUseForList().isEmpty()){ /* snat is bound to router public interface, it is created automatically, * so it should be deleted automatically, but don't need to remove from backend */ dbf.remove(self); } else { self.setUseFor(useForList.toString()); dbf.update(self); } return false; } for (VipGetServiceReferencePoint ext : pluginRgty.getExtensionList(VipGetServiceReferencePoint.class)) { VipGetServiceReferencePoint.ServiceReference service = ext.getServiceReference(self.getUuid()); if (service.useFor.equals(s.getUseFor()) && service.count <= 1){ useForList.del(s.getUseFor()); self.setUseFor(useForList.toString()); dbf.update(self); } } if (useForList.getUseForList().isEmpty()){ return true; } else { return false; } }
@Override public void success() { logger.debug(String.format("successfully acquired vip[uuid:%s, name:%s, ip:%s] on service[%s]", self.getUuid(), self.getName(), self.getIp(), s.getServiceProvider())); VipUseForList useForList = new VipUseForList(self.getUseFor()); useForList.add(s.getUseFor()); VipVO vo = Q.New(VipVO.class).eq(VipVO_.uuid, self.getUuid()).find(); vo.setUseFor(useForList.toString()); dbf.updateAndRefresh(vo); addPeerL3NetworkUuid(s.getPeerL3NetworkUuid()); completion.success(); }
VipUseForList useForList = new VipUseForList(self.getUseFor()); if(useForList.isIncluded(VipUseForList.SNAT_NETWORK_SERVICE_TYPE)){ evt.setError(operr("Vip [uuid %s, ip %s] of router public interface can not be deleted", self.getUuid(), self.getIp()));
protected void deleteVip(Completion completion) { refresh(); if (self.getUseFor() == null) { dbf.remove(self); returnVip(completion);
public static VipInventory valueOf(VipVO vo) { VipInventory inv = new VipInventory(); inv.setName(vo.getName()); inv.setDescription(vo.getDescription()); inv.setCreateDate(vo.getCreateDate()); inv.setGateway(vo.getGateway()); inv.setIp(vo.getIp()); inv.setIpRangeUuid(vo.getIpRangeUuid()); inv.setServiceProvider(vo.getServiceProvider()); inv.setL3NetworkUuid(vo.getL3NetworkUuid()); inv.setLastOpDate(vo.getLastOpDate()); inv.setNetmask(vo.getNetmask()); inv.setPrefixLen(vo.getPrefixLen()); inv.setUseFor(vo.getUseFor()); inv.setUuid(vo.getUuid()); inv.setState(vo.getState().toString()); inv.setUsedIpUuid(vo.getUsedIpUuid()); if (vo.getPeerL3NetworkRefs() != null && !vo.getPeerL3NetworkRefs().isEmpty()) { inv.setPeerL3NetworkUuids(vo.getPeerL3NetworkRefs().stream() .map(ref -> ref.getL3NetworkUuid()) .collect(Collectors.toList())); } return inv; }
private void validate(APICreateEipMsg msg) { VipVO vip = dbf.findByUuid(msg.getVipUuid(), VipVO.class); if (vip.getUseFor() != null) { VipUseForList useForList = new VipUseForList(vip.getUseFor()); if(!useForList.validateNewAdded(EipConstant.EIP_NETWORK_SERVICE_TYPE)) { throw new ApiMessageInterceptionException(operr("vip[uuid:%s] has been occupied other network service entity[%s]", msg.getVipUuid(), vip.getUseFor())); } } if (vip.getState() != VipState.Enabled) { throw new ApiMessageInterceptionException(operr("vip[uuid:%s] is not in state[%s], current state is %s", msg.getVipUuid(), VipState.Enabled, vip.getState())); } if (msg.getVmNicUuid() != null) { SimpleQuery<VmNicVO> nicq = dbf.createQuery(VmNicVO.class); nicq.add(VmNicVO_.uuid, Op.EQ, msg.getVmNicUuid()); VmNicVO nic = nicq.find(); if (VmNicHelper.getL3Uuids(nic).contains(vip.getL3NetworkUuid())) { throw new ApiMessageInterceptionException(argerr("guest l3Network of vm nic[uuid:%s] and vip l3Network of vip[uuid: %s] are the same network", msg.getVmNicUuid(), msg.getVipUuid())); } if (msg.getUsedIpUuid() == null) { msg.setUsedIpUuid(nic.getUsedIpUuid()); } else { validateEipGuestIpUuid(msg.getVmNicUuid(), msg.getUsedIpUuid()); } // check if the vm already has a network where the vip comes checkIfVmAlreadyHasVipNetwork(nic.getVmInstanceUuid(), vip); } if (msg.getUsedIpUuid() != null) { isVipInVmNicSubnet(msg.getVipUuid(), msg.getUsedIpUuid()); } }
protected boolean acquireCheckModifyVipAttributeStruct(ModifyVipAttributesStruct s) { if (s.isUserFor()) { VipUseForList useForList = new VipUseForList(self.getUseFor()); useForList.add(s.getUseFor()); self.setUseFor(useForList.toString()); } if (s.isServiceProvider()) { if (self.getServiceProvider() != null && s.getServiceProvider() != null && !s.getServiceProvider().equals(self.getServiceProvider())) { throw new OperationFailureException(operr("service provider of the vip[uuid:%s, name:%s, ip: %s] has been set to %s", self.getUuid(), self.getName(), self.getIp(), self.getServiceProvider())); } self.setServiceProvider(s.getServiceProvider()); } if (s.isPeerL3NetworkUuid()) { try { if (s.isServiceProvider()) { addPeerL3NetworkUuid(s.getPeerL3NetworkUuid()); } } catch (CloudRuntimeException e) { throw new OperationFailureException(operr(e.getMessage())); } } self = dbf.updateAndRefresh(self); /* snat service is bound the router interface, don't need to bound to backend */ if (s.getUseFor().equals(NetworkServiceType.SNAT.toString())) { return false; } return s.isPeerL3NetworkUuid() && s.isServiceProvider(); }
VipUseForList useForList = new VipUseForList(vipVO.getUseFor()); boolean isTcpProto = msg.getProtocol().equals(LoadBalancerConstants.LB_PROTOCOL_TCP) || msg.getProtocol().equals(LoadBalancerConstants.LB_PROTOCOL_HTTP)