public Map<String, Map<Integer, String>> getDhcpOptionsMap() { Map<String, Map<Integer, String>> dhcpOptionsMap = new HashMap<>(); if (dhcpOptionsNetworkList != null && !dhcpOptionsNetworkList.isEmpty()) { Collection<Map<String, String>> paramsCollection = this.dhcpOptionsNetworkList.values(); for (Map<String, String> dhcpNetworkOptions : paramsCollection) { String networkId = dhcpNetworkOptions.get(ApiConstants.NETWORK_ID); if (networkId == null) { throw new IllegalArgumentException("No networkid specified when providing extra dhcp options."); } Map<Integer, String> dhcpOptionsForNetwork = new HashMap<>(); dhcpOptionsMap.put(networkId, dhcpOptionsForNetwork); for (String key : dhcpNetworkOptions.keySet()) { if (key.startsWith(ApiConstants.DHCP_PREFIX)) { int dhcpOptionValue = Integer.parseInt(key.replaceFirst(ApiConstants.DHCP_PREFIX, "")); dhcpOptionsForNetwork.put(dhcpOptionValue, dhcpNetworkOptions.get(key)); } else if (!key.equals(ApiConstants.NETWORK_ID)) { Dhcp.DhcpOptionCode dhcpOptionEnum = Dhcp.DhcpOptionCode.valueOfString(key); dhcpOptionsForNetwork.put(dhcpOptionEnum.getCode(), dhcpNetworkOptions.get(key)); } } } } return dhcpOptionsMap; }
@Override public void saveExtraDhcpOptions(final String networkUuid, final Long nicId, final Map<String, Map<Integer, String>> extraDhcpOptionMap) { if(extraDhcpOptionMap != null) { Map<Integer, String> extraDhcpOption = extraDhcpOptionMap.get(networkUuid); if(extraDhcpOption != null) { List<NicExtraDhcpOptionVO> nicExtraDhcpOptionList = new LinkedList<>(); for (Integer code : extraDhcpOption.keySet()) { Dhcp.DhcpOptionCode.valueOfInt(code); //check if code is supported or not. NicExtraDhcpOptionVO nicExtraDhcpOptionVO = new NicExtraDhcpOptionVO(nicId, code, extraDhcpOption.get(code)); nicExtraDhcpOptionList.add(nicExtraDhcpOptionVO); } _nicExtraDhcpOptionDao.saveExtraDhcpOptions(nicExtraDhcpOptionList); } } }
.map(vo -> new NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(), vo.getCode(), vo.getValue())) .collect(Collectors.toList()); nicResponse.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses = _nicExtraDhcpOptionDao.listByNicId(nic_id) .stream() .map(vo -> new NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(), vo.getCode(), vo.getValue())) .collect(Collectors.toList()); nicResponse.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
.map(vo -> new NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(), vo.getCode(), vo.getValue())) .collect(Collectors.toList());
public Map<String, Map<Integer, String>> getDhcpOptionsMap() { Map<String, Map<Integer, String>> dhcpOptionsMap = new HashMap<>(); if (dhcpOptionsNetworkList != null && !dhcpOptionsNetworkList.isEmpty()) { Collection<Map<String, String>> paramsCollection = this.dhcpOptionsNetworkList.values(); for(Map<String, String> dhcpNetworkOptions : paramsCollection) { String networkId = dhcpNetworkOptions.get(ApiConstants.NETWORK_ID); if(networkId == null) { throw new IllegalArgumentException("No networkid specified when providing extra dhcp options."); } Map<Integer, String> dhcpOptionsForNetwork = new HashMap<>(); dhcpOptionsMap.put(networkId, dhcpOptionsForNetwork); for (String key : dhcpNetworkOptions.keySet()) { if (key.startsWith(ApiConstants.DHCP_PREFIX)) { int dhcpOptionValue = Integer.parseInt(key.replaceFirst(ApiConstants.DHCP_PREFIX, "")); dhcpOptionsForNetwork.put(dhcpOptionValue, dhcpNetworkOptions.get(key)); } else if (!key.equals(ApiConstants.NETWORK_ID)) { Dhcp.DhcpOptionCode dhcpOptionEnum = Dhcp.DhcpOptionCode.valueOfString(key); dhcpOptionsForNetwork.put(dhcpOptionEnum.getCode(), dhcpNetworkOptions.get(key)); } } } } return dhcpOptionsMap; }
public Map<Integer, String> getDhcpOptionsMap() { Map<Integer, String> dhcpOptionsMap = new HashMap<>(); if (dhcpOptions != null && !dhcpOptions.isEmpty()) { Collection<Map<String, String>> paramsCollection = this.dhcpOptions.values(); for(Map<String, String> dhcpNetworkOptions : paramsCollection) { for (String key : dhcpNetworkOptions.keySet()) { if (key.startsWith(ApiConstants.DHCP_PREFIX)) { int dhcpOptionValue = Integer.parseInt(key.replaceFirst(ApiConstants.DHCP_PREFIX, "")); dhcpOptionsMap.put(dhcpOptionValue, dhcpNetworkOptions.get(key)); } else { Dhcp.DhcpOptionCode dhcpOptionEnum = Dhcp.DhcpOptionCode.valueOfString(key); dhcpOptionsMap.put(dhcpOptionEnum.getCode(), dhcpNetworkOptions.get(key)); } } } } return dhcpOptionsMap; }