Skip to content

Commit 4f21f81

Browse files
Pearl1594dhslove
authored andcommitted
Support XenServer 8.4 / XCP 8.3 - make scripts python3 compatible (apache#10684)
1 parent fc93089 commit 4f21f81

File tree

24 files changed

+6524
-14
lines changed

24 files changed

+6524
-14
lines changed

engine/schema/src/main/resources/META-INF/db/schema-42000to42010.sql

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,59 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.storage_pool', 'used_iops', 'bigint
5454
-- Add reason column for op_ha_work
5555
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.op_ha_work', 'reason', 'varchar(32) DEFAULT NULL COMMENT "Reason for the HA work"');
5656

57+
-- Support for XCP-ng 8.3.0 and XenServer 8.4 by adding hypervisor capabilities
58+
-- https://docs.xenserver.com/en-us/xenserver/8/system-requirements/configuration-limits.html
59+
-- https://docs.xenserver.com/en-us/citrix-hypervisor/system-requirements/configuration-limits.html
60+
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported) VALUES (UUID(), 'XenServer', '8.3.0', 1000, 254, 64, 1);
61+
INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, max_data_volumes_limit, max_hosts_per_cluster, storage_motion_supported) VALUES (UUID(), 'XenServer', '8.4.0', 1000, 240, 64, 1);
62+
63+
-- Add missing and new Guest OS mappings
64+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (2, 'Debian GNU/Linux 10 (64-bit)', 'XenServer', '8.2.1', 'Debian Buster 10');
65+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (5, 'SUSE Linux Enterprise Server 15 (64-bit)', 'XenServer', '8.2.1', 'SUSE Linux Enterprise 15 (64-bit)');
66+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2022 (64-bit)', 'XenServer', '8.2.1', 'Windows Server 2022 (64-bit)');
67+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows 11 (64-bit)', 'XenServer', '8.2.1', 'Windows 11');
68+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (10, 'Ubuntu 20.04 LTS', 'XenServer', '8.2.1', 'Ubuntu Focal Fossa 20.04');
69+
70+
-- Copy XS 8.2.1 hypervisor guest OS mappings to XS 8.3 and 8.3 mappings to 8.4
71+
INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) SELECT UUID(),'Xenserver', '8.3.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='Xenserver' AND hypervisor_version='8.2.1';
72+
73+
-- Add new and missing guest os mappings for XS 8.3
74+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (1, 'Rocky Linux 9', 'XenServer', '8.3.0', 'Rocky Linux 9');
75+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (1, 'Rocky Linux 8', 'XenServer', '8.3.0', 'Rocky Linux 8');
76+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (1, 'AlmaLinux 9', 'XenServer', '8.3.0', 'AlmaLinux 9');
77+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (1, 'AlmaLinux 8', 'XenServer', '8.3.0', 'AlmaLinux 8');
78+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (2, 'Debian GNU/Linux 12 (64-bit)', 'XenServer', '8.3.0', 'Debian Bookworm 12');
79+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (3, 'Oracle Linux 9', 'XenServer', '8.3.0', 'Oracle Linux 9');
80+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (3, 'Oracle Linux 8', 'XenServer', '8.3.0', 'Oracle Linux 8');
81+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (4, 'Red Hat Enterprise Linux 8.0', 'XenServer', '8.3.0', 'Red Hat Enterprise Linux 8');
82+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (4, 'Red Hat Enterprise Linux 9.0', 'XenServer', '8.3.0', 'Red Hat Enterprise Linux 9');
83+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (10, 'Ubuntu 22.04 LTS', 'XenServer', '8.3.0', 'Ubuntu Jammy Jellyfish 22.04');
84+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (5, 'SUSE Linux Enterprise Server 12 SP5 (64-bit)', 'XenServer', '8.3.0', 'SUSE Linux Enterprise Server 12 SP5 (64-bit');
85+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (4, 'NeoKylin Linux Server 7', 'XenServer', '8.3.0', 'NeoKylin Linux Server 7');
86+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (1, 'CentOS Stream 9', 'XenServer', '8.3.0', 'CentOS Stream 9');
87+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (4, 'Scientific Linux 7', 'XenServer', '8.3.0', 'Scientific Linux 7');
88+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (7, 'Generic Linux UEFI', 'XenServer', '8.3.0', 'Generic Linux UEFI');
89+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (7, 'Generic Linux BIOS', 'XenServer', '8.3.0', 'Generic Linux BIOS');
90+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (2, 'Gooroom Platform 2.0', 'XenServer', '8.3.0', 'Gooroom Platform 2.0');
91+
92+
INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) SELECT UUID(),'Xenserver', '8.4.0', guest_os_name, guest_os_id, utc_timestamp(), 0 FROM `cloud`.`guest_os_hypervisor` WHERE hypervisor_type='Xenserver' AND hypervisor_version='8.3.0';
93+
94+
-- Add new guest os mappings for XS 8.4 and KVM
95+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2025', 'XenServer', '8.4.0', 'Windows Server 2025');
96+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (10, 'Ubuntu 24.04 LTS', 'XenServer', '8.4.0', 'Ubuntu Noble Numbat 24.04');
97+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (2, 'Debian GNU/Linux 10 (64-bit)', 'KVM', 'default', 'Debian GNU/Linux 10 (64-bit)');
98+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (2, 'Debian GNU/Linux 11 (64-bit)', 'KVM', 'default', 'Debian GNU/Linux 11 (64-bit)');
99+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (2, 'Debian GNU/Linux 12 (64-bit)', 'KVM', 'default', 'Debian GNU/Linux 12 (64-bit)');
100+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows 11 (64-bit)', 'KVM', 'default', 'Windows 11');
101+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (6, 'Windows Server 2025', 'KVM', 'default', 'Windows Server 2025');
102+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (10, 'Ubuntu 24.04 LTS', 'KVM', 'default', 'Ubuntu 24.04 LTS');
103+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (1, 'CentOS Stream 10 (preview)', 'XenServer', '8.4.0', 'CentOS Stream 10 (preview)');
104+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (1, 'CentOS Stream 9', 'XenServer', '8.4.0', 'CentOS Stream 9');
105+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (4, 'Scientific Linux 7', 'XenServer', '8.4.0', 'Scientific Linux 7');
106+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (4, 'NeoKylin Linux Server 7', 'XenServer', '8.4.0', 'NeoKylin Linux Server 7');
107+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (5, 'SUSE Linux Enterprise Server 12 SP5 (64-bit)', 'XenServer', '8.4.0', 'SUSE Linux Enterprise Server 12 SP5 (64-bit');
108+
CALL ADD_GUEST_OS_AND_HYPERVISOR_MAPPING (2, 'Gooroom Platform 2.0', 'XenServer', '8.4.0', 'Gooroom Platform 2.0');
109+
57110
-- Grant access to 2FA APIs for the "Read-Only User - Default" role
58111

59112
CALL `cloud`.`IDEMPOTENT_UPDATE_API_PERMISSION`('Read-Only User - Default', 'setupUserTwoFactorAuthentication', 'ALLOW');

plugins/hypervisors/ovm/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</parent>
3030
<dependencies>
3131
<dependency>
32-
<groupId>net.java.dev.vcc.thirdparty</groupId>
32+
<groupId>com.citrix.hypervisor</groupId>
3333
<artifactId>xen-api</artifactId>
3434
<version>${cs.xapi.version}</version>
3535
</dependency>

plugins/hypervisors/xenserver/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<scope>compile</scope>
4545
</dependency>
4646
<dependency>
47-
<groupId>net.java.dev.vcc.thirdparty</groupId>
47+
<groupId>com.citrix.hypervisor</groupId>
4848
<artifactId>xen-api</artifactId>
4949
<version>${cs.xapi.version}</version>
5050
</dependency>

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/discoverer/XcpServerDiscoverer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import javax.naming.ConfigurationException;
3131
import javax.persistence.EntityExistsException;
3232

33+
import com.cloud.hypervisor.xenserver.resource.XcpServer83Resource;
34+
import com.cloud.hypervisor.xenserver.resource.Xenserver84Resource;
3335
import org.apache.cloudstack.hypervisor.xenserver.XenserverConfigs;
3436
import org.apache.commons.collections.CollectionUtils;
3537
import org.apache.commons.lang3.StringUtils;
@@ -265,7 +267,6 @@ protected boolean poolHasHotFix(Connection conn, String hostIp, String hotFixUui
265267
} catch (Exception e) {
266268
logger.debug("Caught exception during logout", e);
267269
}
268-
conn.dispose();
269270
conn = null;
270271
}
271272

@@ -435,6 +436,10 @@ else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) {
435436
}
436437
} else if (prodBrand.equals("XCP_Kronos")) {
437438
return new XcpOssResource();
439+
} else if (prodBrand.equals("XenServer") && prodVersion.equals("8.4.0")) {
440+
return new Xenserver84Resource();
441+
} else if (prodBrand.equals("XCP-ng") && (prodVersion.equals("8.3.0"))) {
442+
return new XcpServer83Resource();
438443
} else if (prodBrand.equals("XenServer") || prodBrand.equals("XCP-ng") || prodBrand.equals("Citrix Hypervisor")) {
439444
final String[] items = prodVersion.split("\\.");
440445
if ((Integer.parseInt(items[0]) > 6) ||

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,7 @@ protected Network enableVlanNetwork(final Connection conn, final long tag, final
17151715
nwr.nameLabel = newName;
17161716
nwr.tags = new HashSet<String>();
17171717
nwr.tags.add(generateTimeStamp());
1718+
nwr.managed = true;
17181719
vlanNetwork = Network.create(conn, nwr);
17191720
vlanNic = getNetworkByName(conn, newName);
17201721
if (vlanNic == null) { // Still vlanNic is null means we could not
@@ -2020,6 +2021,7 @@ public synchronized Network findOrCreateTunnelNetwork(final Connection conn, fin
20202021
// started
20212022
otherConfig.put("assume_network_is_shared", "true");
20222023
rec.otherConfig = otherConfig;
2024+
rec.managed = true;
20232025
nw = Network.create(conn, rec);
20242026
logger.debug("### XenServer network for tunnels created:" + nwName);
20252027
} else {
@@ -4891,6 +4893,7 @@ public void setupLinkLocalNetwork(final Connection conn) {
48914893
configs.put("netmask", NetUtils.getLinkLocalNetMask());
48924894
configs.put("vswitch-disable-in-band", "true");
48934895
rec.otherConfig = configs;
4896+
rec.managed = true;
48944897
linkLocal = Network.create(conn, rec);
48954898
} else {
48964899
linkLocal = networks.iterator().next();
@@ -5082,6 +5085,7 @@ public synchronized Network setupvSwitchNetwork(final Connection conn) {
50825085
if (networks.size() == 0) {
50835086
rec.nameDescription = "vswitch network for " + nwName;
50845087
rec.nameLabel = nwName;
5088+
rec.managed = true;
50855089
vswitchNw = Network.create(conn, rec);
50865090
} else {
50875091
vswitchNw = networks.iterator().next();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.hypervisor.xenserver.resource;
18+
19+
public class XcpServer83Resource extends XenServer650Resource {
20+
21+
@Override
22+
protected String getPatchFilePath() {
23+
return "scripts/vm/hypervisor/xenserver/xcpserver83/patch";
24+
}
25+
}

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/XenServerConnectionPool.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.cloud.utils.exception.CloudRuntimeException;
2222
import com.xensource.xenapi.APIVersion;
2323
import com.xensource.xenapi.Connection;
24+
import com.xensource.xenapi.ConnectionNew;
2425
import com.xensource.xenapi.Host;
2526
import com.xensource.xenapi.Pool;
2627
import com.xensource.xenapi.Session;
@@ -150,12 +151,12 @@ static void forceSleep(long sec) {
150151
}
151152

152153
public Connection getConnect(String ip, String username, Queue<String> password) {
153-
Connection conn = new Connection(getURL(ip), 10, _connWait);
154+
Connection conn = new ConnectionNew(getURL(ip), 10, _connWait);
154155
try {
155156
loginWithPassword(conn, username, password, APIVersion.latest().toString());
156157
} catch (Types.HostIsSlave e) {
157158
String maddress = e.masterIPAddress;
158-
conn = new Connection(getURL(maddress), 10, _connWait);
159+
conn = new ConnectionNew(getURL(maddress), 10, _connWait);
159160
try {
160161
loginWithPassword(conn, username, password, APIVersion.latest().toString());
161162
} catch (Exception e1) {
@@ -221,7 +222,7 @@ public Connection connect(String hostUuid, String poolUuid, String ipAddress,
221222

222223
if ( mConn == null ) {
223224
try {
224-
Connection conn = new Connection(getURL(ipAddress), 5, _connWait);
225+
Connection conn = new ConnectionNew(getURL(ipAddress), 5, _connWait);
225226
Session sess = loginWithPassword(conn, username, password, APIVersion.latest().toString());
226227
Host host = sess.getThisHost(conn);
227228
Boolean hostenabled = host.getEnabled(conn);
@@ -231,7 +232,6 @@ public Connection connect(String hostUuid, String poolUuid, String ipAddress,
231232
} catch (Exception e) {
232233
LOGGER.debug("Caught exception during logout", e);
233234
}
234-
conn.dispose();
235235
}
236236
if (!hostenabled) {
237237
String msg = "Unable to create master connection, due to master Host " + ipAddress + " is not enabled";
@@ -412,7 +412,7 @@ public static XenServerConnectionPool getInstance() {
412412
return s_instance;
413413
}
414414

415-
public class XenServerConnection extends Connection {
415+
public class XenServerConnection extends ConnectionNew {
416416
long _interval;
417417
int _retries;
418418
String _ip;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.hypervisor.xenserver.resource;
18+
19+
public class Xenserver84Resource extends XenServer650Resource {
20+
@Override
21+
protected String getPatchFilePath() {
22+
return "scripts/vm/hypervisor/xenserver/xenserver84/patch";
23+
}
24+
}

plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixStartCommandWrapper.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,15 @@ public Answer execute(final StartCommand command, final CitrixResourceBase citri
9696
citrixResourceBase.createVGPU(conn, command, vm, gpuDevice);
9797
}
9898

99-
if (vmSpec.getType() != VirtualMachine.Type.User) {
99+
Host.Record record = host.getRecord(conn);
100+
String xenBrand = record.softwareVersion.get("product_brand");
101+
String xenVersion = record.softwareVersion.get("product_version");
102+
boolean requiresGuestTools = true;
103+
if (xenBrand.equals("XenServer") && isVersionGreaterThanOrEqual(xenVersion, "8.2.0")) {
104+
requiresGuestTools = false;
105+
}
106+
107+
if (vmSpec.getType() != VirtualMachine.Type.User && requiresGuestTools) {
100108
citrixResourceBase.createPatchVbd(conn, vmName, vm);
101109
}
102110

@@ -263,4 +271,19 @@ private void prepareDisks(VirtualMachineTO vmSpec, CitrixResourceBase citrixReso
263271
}
264272
}
265273
}
274+
275+
public static boolean isVersionGreaterThanOrEqual(String v1, String v2) {
276+
String[] parts1 = v1.split("\\.");
277+
String[] parts2 = v2.split("\\.");
278+
279+
int length = Math.max(parts1.length, parts2.length);
280+
for (int i = 0; i < length; i++) {
281+
int num1 = i < parts1.length ? Integer.parseInt(parts1[i]) : 0;
282+
int num2 = i < parts2.length ? Integer.parseInt(parts2[i]) : 0;
283+
284+
if (num1 > num2) return true;
285+
if (num1 < num2) return false;
286+
}
287+
return true; // versions are equal
288+
}
266289
}

0 commit comments

Comments
 (0)