DaanHoogland 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_r399328454
 
 

 ##########
 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) {
+            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());
+
+            Host host = _hostDao.findById(vm.getHostId());
+            final Account caller = CallContext.current().getCallingAccount();
+            String destHostname = 
(VirtualMachineManager.AllowExposeHypervisorHostname.value() && 
VirtualMachineManager.AllowExposeHypervisorHostnameAccountLevel.valueIn(caller.getId()))
 ? host.getName() : null;
 
 Review comment:
   fifth

----------------------------------------------------------------
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

Reply via email to