Skip to content

Commit 6931d1b

Browse files
committed
Merge branch '4.19' of https://github.com/apache/cloudstack into go-sdk-response-obj
2 parents b5a0842 + 5c01cff commit 6931d1b

File tree

35 files changed

+192
-83
lines changed

35 files changed

+192
-83
lines changed

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public interface VmDetailConstants {
7373
String ENCRYPTED_PASSWORD = "Encrypted.Password";
7474

7575
String CONFIG_DRIVE_LOCATION = "configDriveLocation";
76+
String LAST_CONFIG_DRIVE_LOCATION = "lastConfigDriveLocation";
7677

7778
String SKIP_DRS = "skipFromDRS";
7879

engine/orchestration/src/main/java/com/cloud/agent/manager/AgentAttache.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.cloud.agent.api.Command;
4747
import com.cloud.agent.api.CreateStoragePoolCommand;
4848
import com.cloud.agent.api.DeleteStoragePoolCommand;
49+
import com.cloud.agent.api.HandleConfigDriveIsoCommand;
4950
import com.cloud.agent.api.MaintainCommand;
5051
import com.cloud.agent.api.MigrateCommand;
5152
import com.cloud.agent.api.ModifySshKeysCommand;
@@ -119,11 +120,10 @@ public int compare(final Object o1, final Object o2) {
119120

120121
public final static String[] s_commandsAllowedInMaintenanceMode = new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(),
121122
StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(),
122-
ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(),
123-
CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString(),
124-
ModifyTargetsCommand.class.toString(), ModifySshKeysCommand.class.toString(),
125-
CreateStoragePoolCommand.class.toString(), DeleteStoragePoolCommand.class.toString(), ModifyStoragePoolCommand.class.toString(),
126-
SetupMSListCommand.class.toString(), RollingMaintenanceCommand.class.toString(), CleanupPersistentNetworkResourceCommand.class.toString()};
123+
ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), CleanupNetworkRulesCmd.class.toString(),
124+
CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString(), CheckOnHostCommand.class.toString(), ModifyTargetsCommand.class.toString(),
125+
ModifySshKeysCommand.class.toString(), CreateStoragePoolCommand.class.toString(), DeleteStoragePoolCommand.class.toString(), ModifyStoragePoolCommand.class.toString(),
126+
SetupMSListCommand.class.toString(), RollingMaintenanceCommand.class.toString(), CleanupPersistentNetworkResourceCommand.class.toString(), HandleConfigDriveIsoCommand.class.toString()};
127127
protected final static String[] s_commandsNotAllowedInConnectingMode = new String[] { StartCommand.class.toString(), CreateCommand.class.toString() };
128128
static {
129129
Arrays.sort(s_commandsAllowedInMaintenanceMode);

packaging/centos7/cloud.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/lib
261261
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup
262262
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
263263
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management
264+
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/systemd/system/%{name}-management.service.d
264265
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/run
265266
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup/wheel
266267

@@ -309,6 +310,7 @@ install -D utils/target/cloud-utils-%{_maventag}-bundled.jar ${RPM_BUILD_ROOT}%{
309310

310311
install -D packaging/centos7/cloud-ipallocator.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-ipallocator
311312
install -D packaging/centos7/cloud.limits ${RPM_BUILD_ROOT}%{_sysconfdir}/security/limits.d/cloud
313+
install -D packaging/centos7/filelimit.conf ${RPM_BUILD_ROOT}%{_sysconfdir}/systemd/system/%{name}-management.service.d
312314
install -D packaging/systemd/cloudstack-management.service ${RPM_BUILD_ROOT}%{_unitdir}/%{name}-management.service
313315
install -D packaging/systemd/cloudstack-management.default ${RPM_BUILD_ROOT}%{_sysconfdir}/default/%{name}-management
314316
install -D server/target/conf/cloudstack-sudoers ${RPM_BUILD_ROOT}%{_sysconfdir}/sudoers.d/%{name}-management
@@ -591,6 +593,7 @@ pip3 install --upgrade urllib3
591593
%config(noreplace) %{_sysconfdir}/default/%{name}-management
592594
%config(noreplace) %{_sysconfdir}/sudoers.d/%{name}-management
593595
%config(noreplace) %{_sysconfdir}/security/limits.d/cloud
596+
%config(noreplace) %{_sysconfdir}/systemd/system/%{name}-management.service.d
594597
%config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/db.properties
595598
%config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/server.properties
596599
%config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/config.json

packaging/centos7/filelimit.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
18+
# should go in /etc/systemd/system/cloudstack-management.service.d/
19+
[Service]
20+
LimitNPROC=infinity

packaging/centos8/cloud.spec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/lib
243243
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup
244244
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
245245
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management
246+
mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/systemd/system/%{name}-management.service.d
246247
mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/run
247248
mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup/wheel
248249

@@ -291,6 +292,7 @@ install -D utils/target/cloud-utils-%{_maventag}-bundled.jar ${RPM_BUILD_ROOT}%{
291292

292293
install -D packaging/centos8/cloud-ipallocator.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-ipallocator
293294
install -D packaging/centos8/cloud.limits ${RPM_BUILD_ROOT}%{_sysconfdir}/security/limits.d/cloud
295+
install -D packaging/centos8/filelimit.conf ${RPM_BUILD_ROOT}%{_sysconfdir}/systemd/system/%{name}-management.service.d
294296
install -D packaging/systemd/cloudstack-management.service ${RPM_BUILD_ROOT}%{_unitdir}/%{name}-management.service
295297
install -D packaging/systemd/cloudstack-management.default ${RPM_BUILD_ROOT}%{_sysconfdir}/default/%{name}-management
296298
install -D server/target/conf/cloudstack-sudoers ${RPM_BUILD_ROOT}%{_sysconfdir}/sudoers.d/%{name}-management
@@ -570,6 +572,7 @@ pip install --upgrade /usr/share/cloudstack-marvin/Marvin-*.tar.gz
570572
%config(noreplace) %{_sysconfdir}/default/%{name}-management
571573
%config(noreplace) %{_sysconfdir}/sudoers.d/%{name}-management
572574
%config(noreplace) %{_sysconfdir}/security/limits.d/cloud
575+
%config(noreplace) %{_sysconfdir}/systemd/system/%{name}-management.service.d
573576
%config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/db.properties
574577
%config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/server.properties
575578
%config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/config.json

packaging/centos8/filelimit.conf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
18+
# should go in /etc/systemd/system/cloudstack-management.service.d/
19+
[Service]
20+
LimitNPROC=infinity

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,9 +2985,10 @@ public String getVolumePath(final Connect conn, final DiskTO volume, boolean dis
29852985

29862986
public static boolean useBLOCKDiskType(KVMPhysicalDisk physicalDisk) {
29872987
return physicalDisk != null &&
2988-
physicalDisk.getPool().getType() == StoragePoolType.Linstor &&
2988+
physicalDisk.getPool() != null &&
2989+
StoragePoolType.Linstor.equals(physicalDisk.getPool().getType()) &&
29892990
physicalDisk.getFormat() != null &&
2990-
physicalDisk.getFormat()== PhysicalDiskFormat.RAW;
2991+
PhysicalDiskFormat.RAW.equals(physicalDisk.getFormat());
29912992
}
29922993

29932994
public static DiskDef.DiskType getDiskType(KVMPhysicalDisk physicalDisk) {
@@ -3402,13 +3403,15 @@ public void detachAndAttachConfigDriveISO(final Connect conn, final String vmNam
34023403
}
34033404
if (configdrive != null) {
34043405
try {
3406+
s_logger.debug(String.format("Detaching ConfigDrive ISO of the VM %s, at path %s", vmName, configdrive.getDiskPath()));
34053407
String result = attachOrDetachISO(conn, vmName, configdrive.getDiskPath(), false, CONFIG_DRIVE_ISO_DEVICE_ID);
34063408
if (result != null) {
3407-
s_logger.warn("Detach ConfigDrive ISO with result: " + result);
3409+
s_logger.warn(String.format("Detach ConfigDrive ISO of the VM %s, at path %s with %s: ", vmName, configdrive.getDiskPath(), result));
34083410
}
3411+
s_logger.debug(String.format("Attaching ConfigDrive ISO of the VM %s, at path %s", vmName, configdrive.getDiskPath()));
34093412
result = attachOrDetachISO(conn, vmName, configdrive.getDiskPath(), true, CONFIG_DRIVE_ISO_DEVICE_ID);
34103413
if (result != null) {
3411-
s_logger.warn("Attach ConfigDrive ISO with result: " + result);
3414+
s_logger.warn(String.format("Attach ConfigDrive ISO of the VM %s, at path %s with %s: ", vmName, configdrive.getDiskPath(), result));
34123415
}
34133416
} catch (final LibvirtException | InternalErrorException | URISyntaxException e) {
34143417
final String msg = "Detach and attach ConfigDrive ISO failed due to " + e.toString();
@@ -3420,16 +3423,20 @@ public void detachAndAttachConfigDriveISO(final Connect conn, final String vmNam
34203423
public synchronized String attachOrDetachISO(final Connect conn, final String vmName, String isoPath, final boolean isAttach, final Integer diskSeq) throws LibvirtException, URISyntaxException,
34213424
InternalErrorException {
34223425
final DiskDef iso = new DiskDef();
3423-
if (isoPath != null && isAttach) {
3424-
final int index = isoPath.lastIndexOf("/");
3425-
final String path = isoPath.substring(0, index);
3426-
final String name = isoPath.substring(index + 1);
3427-
final KVMStoragePool secondaryPool = storagePoolManager.getStoragePoolByURI(path);
3428-
final KVMPhysicalDisk isoVol = secondaryPool.getPhysicalDisk(name);
3429-
final DiskDef.DiskType diskType = getDiskType(isoVol);
3430-
isoPath = isoVol.getPath();
3431-
3432-
iso.defISODisk(isoPath, diskSeq, diskType);
3426+
if (isAttach && StringUtils.isNotBlank(isoPath) && isoPath.lastIndexOf("/") > 0) {
3427+
if (isoPath.startsWith(getConfigPath() + "/" + ConfigDrive.CONFIGDRIVEDIR) && isoPath.contains(vmName)) {
3428+
iso.defISODisk(isoPath, diskSeq, DiskDef.DiskType.FILE);
3429+
} else {
3430+
final int index = isoPath.lastIndexOf("/");
3431+
final String path = isoPath.substring(0, index);
3432+
final String name = isoPath.substring(index + 1);
3433+
final KVMStoragePool storagePool = storagePoolManager.getStoragePoolByURI(path);
3434+
final KVMPhysicalDisk isoVol = storagePool.getPhysicalDisk(name);
3435+
final DiskDef.DiskType diskType = getDiskType(isoVol);
3436+
isoPath = isoVol.getPath();
3437+
3438+
iso.defISODisk(isoPath, diskSeq, diskType);
3439+
}
34333440
} else {
34343441
iso.defISODisk(null, diskSeq, DiskDef.DiskType.FILE);
34353442
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtGetVmIpAddressCommandWrapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public Answer execute(final GetVmIpAddressCommand command, final LibvirtComputin
4242
String ip = null;
4343
boolean result = false;
4444
String vmName = command.getVmName();
45+
if (!NetUtils.verifyDomainNameLabel(vmName, true)) {
46+
return new Answer(command, result, ip);
47+
}
4548
String sanitizedVmName = sanitizeBashCommandArgument(vmName);
4649
String networkCidr = command.getVmNetworkCidr();
4750
List<String[]> commands = new ArrayList<>();

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtPrepareForMigrationCommandWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public Answer execute(final PrepareForMigrationCommand command, final LibvirtCom
120120

121121
skipDisconnect = true;
122122

123-
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm)) {
123+
if (!storagePoolMgr.connectPhysicalDisksViaVmSpec(vm, true)) {
124124
return new PrepareForMigrationAnswer(command, "failed to connect physical disks to host");
125125
}
126126

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtSetupDirectDownloadCertificateCommandWrapper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import com.cloud.utils.FileUtil;
3838
import com.cloud.utils.PropertiesUtil;
3939
import com.cloud.utils.exception.CloudRuntimeException;
40+
import com.cloud.utils.net.NetUtils;
4041
import com.cloud.utils.script.Script;
4142

4243
@ResourceWrapper(handles = SetupDirectDownloadCertificateCommand.class)
@@ -132,6 +133,9 @@ protected void cleanupTemporaryFile(String temporaryFile) {
132133
public Answer execute(SetupDirectDownloadCertificateCommand cmd, LibvirtComputingResource serverResource) {
133134
String certificate = cmd.getCertificate();
134135
String certificateName = cmd.getCertificateName();
136+
if (!NetUtils.verifyDomainNameLabel(certificateName, false)) {
137+
return new Answer(cmd, false, "The provided certificate name is invalid");
138+
}
135139

136140
try {
137141
File agentFile = getAgentPropertiesFile();

0 commit comments

Comments
 (0)