@Override public String call(L3NetworkInventory arg) { return arg.getUuid(); } });
public static List<L3NetworkInventory> valueOf(Collection<L3NetworkVO> vos) { List<L3NetworkInventory> invs = new ArrayList<L3NetworkInventory>(vos.size()); for (L3NetworkVO vo : vos) { invs.add(valueOf(vo)); } return invs; }
public static APIRemoveHostRouteFromL3NetworkEvent __example__() { APIRemoveHostRouteFromL3NetworkEvent event = new APIRemoveHostRouteFromL3NetworkEvent(); L3NetworkInventory l3 = new L3NetworkInventory(); l3.setName("Test-L3Network"); l3.setL2NetworkUuid(uuid()); l3.setDns(Arrays.asList()); event.setInventory(l3); return event; }
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; }
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; }
public static APIGetInterdependentL3NetworkImageReply __example__() { APIGetInterdependentL3NetworkImageReply reply = new APIGetInterdependentL3NetworkImageReply(); L3NetworkInventory l3 = new L3NetworkInventory(); l3.setName("private L3"); l3.setUuid(l3Uuid); l3.setType(L3NetworkConstant.L3_BASIC_NETWORK_TYPE); l3.setState(L3NetworkState.Enabled.toString()); l3.setL2NetworkUuid(uuid()); l3.setZoneUuid(uuid()); l3.setCreateDate(time); l3.setLastOpDate(time); ipr.setCreateDate(time); ipr.setLastOpDate(time); l3.setIpRanges(asList(ipr)); refs.add(ref); l3.setNetworkServices(refs);
public static APIGetAttachablePublicL3ForVRouterReply __example__() { APIGetAttachablePublicL3ForVRouterReply reply = new APIGetAttachablePublicL3ForVRouterReply(); L3NetworkInventory inventory = new L3NetworkInventory(); inventory.setName("test-pub-l3"); inventory.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); inventory.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); inventory.setDescription("test pub l3"); inventory.setL2NetworkUuid(uuid()); inventory.setSystem(true); inventory.setUuid(uuid()); inventory.setZoneUuid(uuid()); IpRangeInventory ipRangeInventory = new IpRangeInventory(); ipRangeInventory.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); ipRangeInventory.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); ipRangeInventory.setStartIp("100.64.0.10"); ipRangeInventory.setEndIp("100.64.0.100"); ipRangeInventory.setName("test ip range"); ipRangeInventory.setNetworkCidr("100.64.0.0/24"); ipRangeInventory.setNetmask("255.255.255.0"); ipRangeInventory.setGateway("100.64.0.1"); ipRangeInventory.setL3NetworkUuid(uuid()); inventory.setIpRanges(Arrays.asList(ipRangeInventory)); reply.setInventories(Arrays.asList(inventory)); return reply; } }
s.setL3Network(L3NetworkInventory.valueOf(dbf.findByUuid(self.getPeerL3NetworkUuids().iterator().next(), L3NetworkVO.class))); throw new OperationFailureException(operr("found a virtual router offering[uuid:%s] for L3Network[uuid:%s] in zone[uuid:%s]; however, the network's public network[uuid:%s] is not the same to VIP[uuid:%s]'s; you may need to use system tag" + " guestL3Network::l3NetworkUuid to specify a particular virtual router offering for the L3Network", offering.getUuid(), s.getL3Network().getUuid(), s.getL3Network().getZoneUuid(), self.getL3NetworkUuid(), self.getUuid()));
protected List<PortForwardingStruct> makePortForwardingStruct(List<VmNicInventory> nics, boolean releaseVmNicInfo,L3NetworkInventory l3) { VmNicInventory nic = null; for (VmNicInventory inv : nics) { if (VmNicHelper.getL3Uuids(inv).contains(l3.getUuid())) { nic = inv; break; struct.setGuestL3Network(l3); struct.setSnatInboundTraffic(PortForwardingGlobalConfig.SNAT_INBOUND_TRAFFIC.value(Boolean.class)); struct.setVipL3Network(L3NetworkInventory.valueOf(l3vo)); struct.setReleaseVmNicInfoWhenDetaching(releaseVmNicInfo); struct.setReleaseVip(false);
@Override public void afterDeleteL3Network(L3NetworkInventory l3) { Optional<NetworkServiceL3NetworkRefInventory> o = l3.getNetworkServices().stream().filter(n -> n.getNetworkServiceType().equals(UserdataConstant.USERDATA_TYPE_STRING)).findAny(); if (!o.isPresent()) { return; cmd.bridgeName = new BridgeNameFinder().findByL3Uuid(l3.getUuid()); cmd.l3NetworkUuid = l3.getUuid();
private List<DhcpInfo> toDhcpInfo(List<DhcpStruct> structs) { final Map<String, String> l3Bridges = new HashMap<String, String>(); for (DhcpStruct s : structs) { if (!l3Bridges.containsKey(s.getL3Network().getUuid())) { l3Bridges.put(s.getL3Network().getUuid(), KVMSystemTags.L2_BRIDGE_NAME.getTokenByResourceUuid(s.getL3Network().getL2NetworkUuid(), KVMSystemTags.L2_BRIDGE_NAME_TOKEN));
@Override public void validate(VirtualRouterOfferingInventory offering) throws OperationFailureException { if (!offering.getPublicNetworkUuid().equals(struct.getVip().getL3NetworkUuid())) { throw new OperationFailureException(operr("found a virtual router offering[uuid:%s] for L3Network[uuid:%s] in zone[uuid:%s]; however, the network's public network[uuid:%s] is not the same to EIP[uuid:%s]'s; you may need to use system tag" + " guestL3Network::l3NetworkUuid to specify a particular virtual router offering for the L3Network", offering.getUuid(), l3inv.getUuid(), l3inv.getZoneUuid(), struct.getVip().getL3NetworkUuid(), struct.getEip().getUuid())); } } });
@Override public void beforeStartNewCreatedVm(VmInstanceSpec spec) { String providerUuid = new NetworkServiceProviderLookup().lookupUuidByType(FlatNetworkServiceConstant.FLAT_NETWORK_SERVICE_TYPE_STRING); // make sure the Flat DHCP acquired DHCP server IP before starting VMs, // otherwise it may not be able to get IP when lots of VMs start concurrently // because the logic of VM acquiring IP is ahead flat DHCP acquiring IP for (L3NetworkInventory l3 :VmNicSpec.getL3NetworkInventoryOfSpec(spec.getL3Networks())) { List<String> serviceTypes = l3.getNetworkServiceTypesFromProvider(providerUuid); if (serviceTypes.contains(NetworkServiceType.DHCP.toString())) { allocateDhcpIp(l3.getUuid()); } } }
@Override @Transactional(readOnly = true) public NetworkServiceProviderType getTypeOfNetworkServiceProviderForService(String l3NetworkUuid, NetworkServiceType serviceType) { L3NetworkVO l3vo = Q.New(L3NetworkVO.class).eq(L3NetworkVO_.uuid, l3NetworkUuid).find(); L3NetworkInventory l3inv = L3NetworkInventory.valueOf(l3vo); NetworkServiceL3NetworkRefInventory targetRef = null; for (NetworkServiceL3NetworkRefInventory ref : l3inv.getNetworkServices()) { if (ref.getNetworkServiceType().equals(serviceType.toString())) { targetRef = ref; break; } } if (targetRef == null) { throw new OperationFailureException(operr("L3Network[uuid:%s] doesn't have network service[type:%s] enabled or no provider provides this network service", l3NetworkUuid, serviceType)); } String providerType = Q.New(NetworkServiceProviderVO.class) .select(NetworkServiceProviderVO_.type) .eq(NetworkServiceProviderVO_.uuid, targetRef.getNetworkServiceProviderUuid()) .findValue(); return NetworkServiceProviderType.valueOf(providerType); }
public List<String> getNetworkServiceTypes() { List<String> nwTypes = new ArrayList<String>(); for (NetworkServiceL3NetworkRefInventory ref : getNetworkServices()) { nwTypes.add(ref.getNetworkServiceType()); } return nwTypes; }
public static APIQueryL3NetworkReply __example__() { APIQueryL3NetworkReply reply = new APIQueryL3NetworkReply(); L3NetworkInventory l3 = new L3NetworkInventory(); l3.setName("Test-L3Network"); l3.setL2NetworkUuid(uuid()); reply.setInventories(Arrays.asList(l3)); return reply; }
public static APIUpdateL3NetworkEvent __example__() { APIUpdateL3NetworkEvent event = new APIUpdateL3NetworkEvent(); L3NetworkInventory l3 = new L3NetworkInventory(); l3.setName("Test-L3Network"); l3.setUuid(uuid()); event.setInventory(l3); return event; }
public static APIDetachNetworkServiceFromL3NetworkEvent __example__() { APIDetachNetworkServiceFromL3NetworkEvent event = new APIDetachNetworkServiceFromL3NetworkEvent(); L3NetworkInventory l3 = new L3NetworkInventory(); NetworkServiceL3NetworkRefInventory ns = new NetworkServiceL3NetworkRefInventory(); l3.setUuid(uuid()); l3.setNetworkServices(Arrays.asList(ns)); return event; }
@Override @Transactional(readOnly = true) public List<String> call() { String sql = "select host.uuid from HostVO host, L2NetworkVO l2, L2NetworkClusterRefVO ref where l2.uuid = ref.l2NetworkUuid" + " and ref.clusterUuid = host.clusterUuid and l2.uuid = :uuid"; TypedQuery<String> q = dbf.getEntityManager().createQuery(sql, String.class); q.setParameter("uuid", inventory.getL2NetworkUuid()); return q.getResultList(); } }.call();