Skip to content

Commit f794e5c

Browse files
committed
flr: fix windows vm os type
Fixes Windows instance file-level restore --------- Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent be61c04 commit f794e5c

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/converter/UserVmJoinVOToVmConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public static Vm toVm(final UserVmJoinVO src,
128128
cpu.setTopology(new Topology(src.getCpu(), 1, 1));
129129
dst.setCpu(cpu);
130130
Os os = new Os();
131-
os.setType(src.getGuestOsDisplayName());
131+
os.setType(Os.inferTypeFromOsName(src.getGuestOsDisplayName()));
132132
Os.Boot boot = new Os.Boot();
133133
boot.setDevices(NamedList.of("device", List.of("hd")));
134134
os.setBoot(boot);

plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/api/dto/Os.java

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.apache.cloudstack.veeam.api.dto;
1919

20+
import org.apache.commons.lang3.StringUtils;
21+
2022
import com.fasterxml.jackson.annotation.JsonInclude;
2123

2224
@JsonInclude(JsonInclude.Include.NON_NULL)
@@ -52,4 +54,61 @@ public void setDevices(NamedList<String> devices) {
5254
this.devices = devices;
5355
}
5456
}
57+
58+
/**
59+
* Infers the oVirt guest OS identifier expected by Veeam from the operating system name.
60+
* This allows Veeam to correctly recognize Windows virtual machines and enable features
61+
* such as file-level restore.
62+
*<p>
63+
* Identifier values are derived from the
64+
* <a href="https://github.com/oVirt/ovirt-engine/blob/master/packaging/conf/osinfo-defaults.properties">
65+
* oVirt OS defaults
66+
* </a>.
67+
*</p>
68+
*
69+
* @param name normalized operating system name
70+
* @return the matching oVirt Windows OS identifier
71+
*/
72+
public static String getWindowsOsKey(final String name) {
73+
if (name.contains("2025")) {
74+
return "windows_2025";
75+
}
76+
77+
if (name.contains("2022")) {
78+
return "windows_2022";
79+
}
80+
81+
if (name.contains("11")) {
82+
return "windows_11";
83+
}
84+
85+
if (name.contains("2019")) {
86+
return "windows_2019x64";
87+
}
88+
89+
if (name.contains("2016")) {
90+
return "windows_2016x64";
91+
}
92+
93+
if (name.contains("10") && name.contains("64")) {
94+
return "windows_10x64";
95+
}
96+
97+
return "windows_10";
98+
}
99+
100+
public static String inferTypeFromOsName(String name) {
101+
if (StringUtils.isBlank(name)) {
102+
return "other";
103+
}
104+
String normalized = name.trim().toLowerCase();
105+
if (normalized.contains("windows")) {
106+
return getWindowsOsKey(normalized);
107+
}
108+
if (normalized.contains("linux") || normalized.contains("ubuntu") || normalized.contains("debian") ||
109+
normalized.contains("centos") || normalized.contains("red hat") || normalized.contains("suse")) {
110+
return "linux";
111+
}
112+
return "other";
113+
}
55114
}

0 commit comments

Comments
 (0)