Pearl1594 commented on a change in pull request #3976: Enable sending hypervior host name via metadata - VR and Config Drive URL: https://github.com/apache/cloudstack/pull/3976#discussion_r399346077
########## File path: server/src/main/java/com/cloud/network/router/CommandSetupHelper.java ########## @@ -177,23 +180,30 @@ private VlanDao _vlanDao; @Inject private IPAddressDao _ipAddressDao; - @Inject private RouterControlHelper _routerControlHelper; + @Inject + private HostDao _hostDao; @Autowired @Qualifier("networkHelper") protected NetworkHelper _networkHelper; public void createVmDataCommand(final VirtualRouter router, final UserVm vm, final NicVO nic, final String publicKey, final Commands cmds) { - final String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId()).getDisplayText(); - final String zoneName = _dcDao.findById(router.getDataCenterId()).getName(); - final IPAddressVO staticNatIp = _ipAddressDao.findByVmIdAndNetworkId(nic.getNetworkId(), vm.getId()); - cmds.addCommand( - "vmdata", - generateVmDataCommand(router, nic.getIPv4Address(), vm.getUserData(), serviceOffering, zoneName, - staticNatIp == null || staticNatIp.getState() != IpAddress.State.Allocated ? null : staticNatIp.getAddress().addr(), vm.getHostName(), vm.getInstanceName(), - vm.getId(), vm.getUuid(), publicKey, nic.getNetworkId())); + if (vm != null && router != null && nic != null) { Review comment: I put this check because I noticed a NPE during migration of Routers after adding my changes, as I'm calling "saveUserDataToRouter" ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services