Skip to content

Commit f9af997

Browse files
author
gitlab
committed
Merge branch 'fix/ZSTAC-82118' into '5.5.6'
fix(flatNetwork): ZSTAC-82118 fallback metadata hostname for VMs with userdata See merge request zstackio/zstack!9144
2 parents d29dde5 + 7d3d429 commit f9af997

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

plugin/flatNetworkProvider/src/main/java/org/zstack/network/service/flat/FlatUserdataBackend.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ private List<UserdataTO> getUserData() {
310310
continue;
311311
}
312312

313+
if (mto.vmHostname == null) {
314+
mto.vmHostname = l.vmIp.replaceAll("\\.", "-");
315+
}
316+
313317
if (bridgeNames.get(l.l3Uuid) == null) {
314318
continue;
315319
}
@@ -780,6 +784,9 @@ public void run(final FlowTrigger trigger, Map data) {
780784
MetadataTO to = new MetadataTO();
781785
to.vmUuid = struct.getVmUuid();
782786
to.vmHostname = VmSystemTags.HOSTNAME.getTokenByResourceUuid(struct.getVmUuid(), VmSystemTags.HOSTNAME_TOKEN);
787+
if (to.vmHostname == null) {
788+
to.vmHostname = ipv4.getIp().replaceAll("\\.", "-");
789+
}
783790
to.regionName = getZoneNameByVmInstanceUuid(struct.getVmUuid());
784791
to.mac = destNic.getMac();
785792
to.dnsServersIp = getDnsServersIpFromVm(struct.getVmUuid());

0 commit comments

Comments
 (0)