GutoVeronezi commented on code in PR #6710:
URL: https://github.com/apache/cloudstack/pull/6710#discussion_r967108261


##########
server/src/main/java/com/cloud/network/NetworkModelImpl.java:
##########
@@ -2551,6 +2553,10 @@ public List<String[]> generateVmData(String userData, 
String serviceOffering, lo
         final String zoneName = dcVo.getName();
 
         IPAddressVO publicIp = _ipAddressDao.findByAssociatedVmId(vmId);
+        VirtualMachine vm = _vmDao.findById(vmId);
+        if (vm == null) {
+            throw new CloudRuntimeException("Cannot generate VM instance data, 
no VM exists by given ID");

Review Comment:
   We could add a log here and print the `vmId`.



##########
engine/api/src/main/java/com/cloud/vm/VirtualMachineManager.java:
##########
@@ -79,6 +79,9 @@ public interface VirtualMachineManager extends Manager {
     ConfigKey<Boolean> AllowExposeHypervisorHostname = new 
ConfigKey<Boolean>("Advanced", Boolean.class, 
"global.allow.expose.host.hostname",
             "false", "If set to true, it allows the hypervisor host name on 
which the VM is spawned on to be exposed to the VM", true, 
ConfigKey.Scope.Global);
 
+    ConfigKey<Boolean> AllowExposeDomainInMetadata = new 
ConfigKey<>("Advanced", Boolean.class, "metadata.allow.expose.domain",
+            "false", "If set to true, it allows the VM's domain to be seen in 
metadata", true, ConfigKey.Scope.Domain);

Review Comment:
   ```suggestion
               "false", "If set to true, it allows the VM's domain to be seen 
in metadata.", true, ConfigKey.Scope.Domain);
   ```



##########
server/src/main/java/com/cloud/network/router/CommandSetupHelper.java:
##########
@@ -210,11 +214,18 @@ public void createVmDataCommand(final VirtualRouter 
router, final UserVm vm, fin
 
             Host host = _hostDao.findById(vm.getHostId());
             String destHostname = 
VirtualMachineManager.getHypervisorHostname(host != null ? host.getName() : "");
-            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(), destHostname));
+            VmDataCommand vmDataCommand = 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(), 
destHostname);
+
+            Domain domain = domainDao.findById(vm.getDomainId());
+            if (domain != null && 
VirtualMachineManager.AllowExposeDomainInMetadata.valueIn(domain.getId())) {
+                s_logger.debug("Adding domain info to cloud metadata");

Review Comment:
   We could print the domain info being added to the metadata.



##########
server/src/main/java/com/cloud/network/NetworkModelImpl.java:
##########
@@ -2619,6 +2625,14 @@ public List<String[]> generateVmData(String userData, 
String serviceOffering, lo
             vmData.add(new String[]{PASSWORD_DIR, PASSWORD_FILE, password});
         }
         vmData.add(new String[]{METATDATA_DIR, HYPERVISOR_HOST_NAME_FILE, 
hostname});
+
+        Domain domain = _domainDao.findById(vm.getDomainId());
+        if (domain != null && 
VirtualMachineManager.AllowExposeDomainInMetadata.valueIn(domain.getId())) {
+            s_logger.debug("Adding domain info to cloud metadata");

Review Comment:
   We could print the domain info being added to the metadata.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to