[ https://issues.apache.org/jira/browse/CLOUDSTACK-10288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444602#comment-16444602 ]
ASF GitHub Bot commented on CLOUDSTACK-10288: --------------------------------------------- nvazquez commented on a change in pull request #2566: ConfigDrive fixes: CLOUDSTACK-10288, CLOUDSTACK-10289 URL: https://github.com/apache/cloudstack/pull/2566#discussion_r182847446 ########## File path: server/src/com/cloud/network/NetworkModelImpl.java ########## @@ -2344,18 +2345,47 @@ public boolean getNetworkEgressDefaultPolicy(Long networkId) { } @Override - public List<String[]> generateVmData(String userData, String serviceOffering, String zoneName, - String vmName, long vmId, String publicKey, String password, Boolean isWindows) { + public List<String[]> generateVmData(String userData, String serviceOffering, long datacenterId, + String vmName, long vmId, String vmUuid, + String guestIpAddress, String publicKey, String password, Boolean isWindows) { + + DataCenterVO dcVo = _dcDao.findById(datacenterId); + final String zoneName = dcVo.getName(); + + IPAddressVO publicIp = _ipAddressDao.findByAssociatedVmId(vmId); + final List<String[]> vmData = new ArrayList<String[]>(); if (userData != null) { - vmData.add(new String[]{USERDATA_DIR, USERDATA_FILE, new String(Base64.decodeBase64(userData),StringUtils.getPreferredCharset())}); + vmData.add(new String[]{USERDATA_DIR, USERDATA_FILE, userData}); } vmData.add(new String[]{METATDATA_DIR, SERVICE_OFFERING_FILE, StringUtils.unicodeEscape(serviceOffering)}); vmData.add(new String[]{METATDATA_DIR, AVAILABILITY_ZONE_FILE, StringUtils.unicodeEscape(zoneName)}); vmData.add(new String[]{METATDATA_DIR, LOCAL_HOSTNAME_FILE, StringUtils.unicodeEscape(vmName)}); - vmData.add(new String[]{METATDATA_DIR, INSTANCE_ID_FILE, vmName}); - vmData.add(new String[]{METATDATA_DIR, VM_ID_FILE, String.valueOf(vmId)}); + vmData.add(new String[]{METATDATA_DIR, LOCAL_IPV4_FILE, guestIpAddress}); + + String publicIpAddress = guestIpAddress; + String publicHostName = StringUtils.unicodeEscape(vmName); + + if (dcVo.getNetworkType() != DataCenter.NetworkType.Basic) { + if (publicIp != null) { + publicIpAddress = publicIp.getAddress().addr(); + publicHostName = publicIp.getAddress().addr(); + } else { + publicHostName = null; + } + } + vmData.add(new String[]{METATDATA_DIR, PUBLIC_IPV4_FILE, publicIpAddress}); + vmData.add(new String[]{METATDATA_DIR, PUBLIC_HOSTNAME_FILE, publicHostName}); + + if (vmUuid == null) { + vmData.add(new String[]{METATDATA_DIR, INSTANCE_ID_FILE, vmName}); + vmData.add(new String[]{METATDATA_DIR, VM_ID_FILE, String.valueOf(vmId)}); + } else { + vmData.add(new String[]{METATDATA_DIR, INSTANCE_ID_FILE, vmUuid}); + vmData.add(new String[]{METATDATA_DIR, VM_ID_FILE, vmUuid}); + } + vmData.add(new String[]{METATDATA_DIR, PUBLIC_KEYS_FILE, publicKey}); Review comment: As `getSshKey(VirtualMachineProfile profile)` method on `ConfigDriveNetworkElement` could return null, shouldn't we check here if it is not null before adding it? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 > Config drive - Usedata corruption when gzipped > ----------------------------------------------- > > Key: CLOUDSTACK-10288 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-10288 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the > default.) > Affects Versions: 4.11.0.0 > Reporter: Rohit Yadav > Assignee: Frank Maximus > Priority: Major > > Should be able to create userdata via "echo hi | gzip | base64 -w0" and read > it back in VM via "mount -o loop /dev/sr1 /mnt/tmp; cat > /mnt/tmp/cloudstack/userdata/user_data.txt | gunzip" -- This message was sent by Atlassian JIRA (v7.6.3#76005)