use of com.cloud.vm.NicExtraDhcpOptionVO in project cloudstack by apache.
the class NetworkOrchestrator method saveExtraDhcpOptions.
@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()) {
// check if code is supported or not.
Dhcp.DhcpOptionCode.valueOfInt(code);
NicExtraDhcpOptionVO nicExtraDhcpOptionVO = new NicExtraDhcpOptionVO(nicId, code, extraDhcpOption.get(code));
nicExtraDhcpOptionList.add(nicExtraDhcpOptionVO);
}
_nicExtraDhcpOptionDao.saveExtraDhcpOptions(nicExtraDhcpOptionList);
}
}
}
use of com.cloud.vm.NicExtraDhcpOptionVO in project cloudstack by apache.
the class ApiResponseHelper method createNicResponse.
/**
* The resulting Response attempts to be in line with what is returned from
* @see com.cloud.api.query.dao.UserVmJoinDaoImpl#setUserVmResponse(ResponseView, UserVmResponse, UserVmJoinVO)
*/
@Override
public NicResponse createNicResponse(Nic result) {
NicResponse response = new NicResponse();
NetworkVO network = _entityMgr.findById(NetworkVO.class, result.getNetworkId());
VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, result.getInstanceId());
List<NicExtraDhcpOptionVO> nicExtraDhcpOptionVOs = _nicExtraDhcpOptionDao.listByNicId(result.getId());
// The numbered comments are to keep track of the data returned from here and UserVmJoinDaoImpl.setUserVmResponse()
// the data can't be identical but some tidying up/unifying might be possible
/*1: nicUuid*/
response.setId(result.getUuid());
/*2: networkUuid*/
response.setNetworkid(network.getUuid());
/*3: vmId*/
if (vm != null) {
response.setVmId(vm.getUuid());
}
if (network.getTrafficType() != null) {
/*4: trafficType*/
response.setTrafficType(network.getTrafficType().toString());
}
if (network.getGuestType() != null) {
/*5: guestType*/
response.setType(network.getGuestType().toString());
}
/*6: ipAddress*/
response.setIpaddress(result.getIPv4Address());
/*7: gateway*/
response.setGateway(result.getIPv4Gateway());
/*8: netmask*/
response.setNetmask(result.getIPv4Netmask());
/*9: networkName*/
response.setNetworkName(network.getName());
/*10: macAddress*/
response.setMacAddress(result.getMacAddress());
/*11: IPv6Address*/
if (result.getIPv6Address() != null) {
response.setIp6Address(result.getIPv6Address());
}
/*12: IPv6Gateway*/
if (result.getIPv6Gateway() != null) {
response.setIp6Gateway(result.getIPv6Gateway());
}
/*13: IPv6Cidr*/
if (result.getIPv6Cidr() != null) {
response.setIp6Cidr(result.getIPv6Cidr());
}
/*14: deviceId*/
response.setDeviceId(String.valueOf(result.getDeviceId()));
/*15: broadcastURI*/
if (result.getBroadcastUri() != null) {
response.setBroadcastUri(result.getBroadcastUri().toString());
}
/*16: isolationURI*/
if (result.getIsolationUri() != null) {
response.setIsolationUri(result.getIsolationUri().toString());
}
/*17: default*/
response.setIsDefault(result.isDefaultNic());
if (result.getSecondaryIp()) {
List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(result.getId());
if (secondaryIps != null) {
List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
for (NicSecondaryIpVO ip : secondaryIps) {
NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
ipRes.setId(ip.getUuid());
setResponseIpAddress(ip, ipRes);
ipList.add(ipRes);
}
response.setSecondaryIps(ipList);
}
}
/*18: extra dhcp options */
List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses = nicExtraDhcpOptionVOs.stream().map(vo -> new NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(), vo.getCode(), vo.getValue())).collect(Collectors.toList());
response.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
if (result instanceof NicVO) {
if (((NicVO) result).getNsxLogicalSwitchUuid() != null) {
response.setNsxLogicalSwitch(((NicVO) result).getNsxLogicalSwitchUuid());
}
if (((NicVO) result).getNsxLogicalSwitchPortUuid() != null) {
response.setNsxLogicalSwitchPort(((NicVO) result).getNsxLogicalSwitchPortUuid());
}
}
return response;
}
Aggregations