public static APICreateL3NetworkMsg __example__() { APICreateL3NetworkMsg msg = new APICreateL3NetworkMsg(); msg.setName("Test-L3Network"); msg.setL2NetworkUuid(uuid()); msg.setCategory(L3NetworkCategory.Private.toString()); return msg; }
public static APICreateL3NetworkEvent __example__() { APICreateL3NetworkEvent event = new APICreateL3NetworkEvent(); L3NetworkInventory l3 = new L3NetworkInventory(); l3.setName("Test-L3Network"); l3.setL2NetworkUuid(uuid()); l3.setCategory(L3NetworkCategory.Private.toString()); event.setInventory(l3); return event; }
private void validate(APICreateL3NetworkMsg msg) { if (!L3NetworkType.hasType(msg.getType())) { throw new ApiMessageInterceptionException(argerr("unsupported l3network type[%s]", msg.getType())); } if (msg.getDnsDomain() != null) { DomainValidator validator = DomainValidator.getInstance(); if (!validator.isValid(msg.getDnsDomain())) { throw new ApiMessageInterceptionException(argerr("%s is not a valid domain name", msg.getDnsDomain())); } } List<L3NetworkCategory> validNetworkCategory = Arrays.asList(L3NetworkCategory.values()); for (L3NetworkCategory category : validNetworkCategory) { if (category.toString().equalsIgnoreCase(msg.getCategory())) { msg.setCategory(category.toString()); break; } } if (L3NetworkCategory.checkSystemAndCategory(msg.isSystem(), L3NetworkCategory.valueOf(msg.getCategory()))) { return; } else { throw new ApiMessageInterceptionException(argerr("not valid combination of system and category," + "only %s are valid", L3NetworkCategory.validCombination)); } }
private void validate(APIUpdateL3NetworkMsg msg) { if (msg.getCategory() == null && msg.getSystem() == null) { return; } Boolean currentSystem = Q.New(L3NetworkVO.class) .select(L3NetworkVO_.system) .eq(L3NetworkVO_.uuid, msg.getL3NetworkUuid()) .findValue(); if (msg.getSystem() != null && msg.getCategory() == null && !msg.getSystem().equals(currentSystem)) { throw new ApiMessageInterceptionException(argerr("you must update system and category both")); } List<L3NetworkCategory> validNetworkCategory = Arrays.asList(L3NetworkCategory.values()); for (L3NetworkCategory category : validNetworkCategory) { if (category.toString().equalsIgnoreCase(msg.getCategory())) { msg.setCategory(category.toString()); break; } } if (msg.getSystem() == null) { msg.setSystem(currentSystem); } if (msg.getCategory() != null) { if (L3NetworkCategory.checkSystemAndCategory(msg.getSystem(), L3NetworkCategory.valueOf(msg.getCategory()))) { return; } else { throw new ApiMessageInterceptionException(argerr("not valid combination of system and category," + "only %s are valid", L3NetworkCategory.validCombination)); } } }
public static L3NetworkInventory valueOf(L3NetworkVO vo) { L3NetworkInventory inv = new L3NetworkInventory(); inv.setUuid(vo.getUuid()); inv.setCreateDate(vo.getCreateDate()); inv.setDescription(vo.getDescription()); inv.setL2NetworkUuid(vo.getL2NetworkUuid()); inv.setName(vo.getName()); inv.setType(vo.getType()); inv.setDnsDomain(vo.getDnsDomain()); inv.setZoneUuid(vo.getZoneUuid()); inv.setState(vo.getState().toString()); vo.getDns().stream().sorted(Comparator.comparingLong(L3NetworkDnsVO::getId)).collect(Collectors.toList()) .forEach(dnsVo -> inv.getDns().add(dnsVo.getDns())); inv.setSystem(vo.isSystem()); inv.setIpRanges(IpRangeInventory.valueOf(vo.getIpRanges())); inv.setLastOpDate(vo.getLastOpDate()); inv.setNetworkServices(NetworkServiceL3NetworkRefInventory.valueOf(vo.getNetworkServices())); inv.setCategory(vo.getCategory().toString()); inv.setHostRoute(L3NetworkHostRouteInventory.valueOf(vo.getHostRoutes())); inv.setIpVersion(vo.getIpVersion()); return inv; }
L2NetworkVO l2NetworkVO = Q.New(L2NetworkVO.class).eq(L2NetworkVO_.uuid, l3NetworkVO.getL2NetworkUuid()).find(); mto.setCategory(l3NetworkVO.getCategory().toString()); mto.setL2type(l2NetworkVO.getType()); mto.setPhysicalInterface(l2NetworkVO.getPhysicalInterface()); l2NetworkVO = Q.New(L2NetworkVO.class).eq(L2NetworkVO_.uuid, l3NetworkVO.getL2NetworkUuid()).find(); t.setCategory(l3NetworkVO.getCategory().toString()); t.setL2type(l2NetworkVO.getType()); t.setVni(l2NetworkGetVniExtensionPointMap.get(l2NetworkVO.getType()).getL2NetworkVni(l2NetworkVO.getUuid())); l2NetworkVO = Q.New(L2NetworkVO.class).eq(L2NetworkVO_.uuid, l3NetworkVO.getL2NetworkUuid()).find(); nto.setCategory(l3NetworkVO.getCategory().toString()); nto.setL2type(l2NetworkVO.getType()); nto.setVni(l2NetworkGetVniExtensionPointMap.get(l2NetworkVO.getType()).getL2NetworkVni(l2NetworkVO.getUuid()));
info.setCategory(l3NetworkVO.getCategory().toString()); info.setL2type(l2NetworkVO.getType()); info.setPhysicalInterface(l2NetworkVO.getPhysicalInterface());