public boolean validateNewAdded(VipUseForList newList){ Iterator<String> it = newList.getUseForList().iterator(); while (it.hasNext()){ String useFor = it.next(); if(!validateNewAdded(useFor)){ return false; } } return true; }
private void validate(APICreateLoadBalancerMsg msg) { SimpleQuery<VipVO> q = dbf.createQuery(VipVO.class); q.select(VipVO_.useFor); q.add(VipVO_.uuid, Op.EQ, msg.getVipUuid()); String useFor = q.findValue(); if(useFor != null){ VipUseForList useForList = new VipUseForList(useFor); if(!useForList.validateNewAdded(LoadBalancerConstants.LB_NETWORK_SERVICE_TYPE_STRING)){ throw new ApiMessageInterceptionException(argerr("the vip[uuid:%s] has been occupied other network service entity[%s]", msg.getVipUuid(), useForList.toString())); } } }
private void validate(APICreateEipMsg msg) { String useFor = Q.New(VipVO.class).select(VipVO_.useFor).eq(VipVO_.uuid, msg.getVipUuid()).findValue(); VipUseForList vipUseForList; if (useFor != null){ vipUseForList = new VipUseForList(useFor); } else { vipUseForList = new VipUseForList(); } if(!vipUseForList.validateNewAdded(EipConstant.EIP_NETWORK_SERVICE_TYPE)){ throw new ApiMessageInterceptionException(operr("the vip[uuid:%s] already has bound to other service[%s]", msg.getVipUuid(), vipUseForList.toString())); } }
if(useFor != null){ VipUseForList useForList = new VipUseForList(useFor); if(!useForList.validateNewAdded(PortForwardingConstant.PORTFORWARDING_NETWORK_SERVICE_TYPE)){ throw new ApiMessageInterceptionException(argerr("the vip[uuid:%s] has been occupied other network service entity[%s]", msg.getVipUuid(), useForList.toString()));
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()); } }