|
17 | 17 |
|
18 | 18 | package org.apache.cloudstack.veeam.api.dto; |
19 | 19 |
|
| 20 | +import org.apache.commons.lang3.StringUtils; |
| 21 | + |
20 | 22 | import com.fasterxml.jackson.annotation.JsonInclude; |
21 | 23 |
|
22 | 24 | @JsonInclude(JsonInclude.Include.NON_NULL) |
@@ -52,4 +54,61 @@ public void setDevices(NamedList<String> devices) { |
52 | 54 | this.devices = devices; |
53 | 55 | } |
54 | 56 | } |
| 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 | + } |
55 | 114 | } |
0 commit comments