Skip to content

Commit 1db7277

Browse files
authored
Merge branch 'master' into ovfprops-full
2 parents 222a9a4 + 6d6e402 commit 1db7277

12 files changed

Lines changed: 63 additions & 21 deletions

File tree

agent/conf/agent.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,8 @@ hypervisor.type=kvm
258258
# timer.
259259
# For all actions refer to the libvirt documentation.
260260
# Recommended values are: none, reset and poweroff.
261+
#
262+
iscsi.session.cleanup.enabled=false
263+
# Automatically clean up iscsi sessions not attached to any VM.
264+
# Should be enabled for users using managed storage for example solidfire.
265+
# Should be disabled for users with unmanaged iscsi connections on their hosts

api/src/main/java/org/apache/cloudstack/api/response/UsageRecordResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ public class UsageRecordResponse extends BaseResponseWithTagInformation implemen
8888
@Param(description = "template ID")
8989
private String templateId;
9090

91+
@SerializedName(ApiConstants.OS_TYPE_ID)
92+
@Param(description = "virtual machine os type id")
93+
private Long osTypeId;
94+
9195
@SerializedName("usageid")
9296
@Param(description = "id of the resource")
9397
private String usageId;
@@ -198,6 +202,10 @@ public void setTemplateId(String templateId) {
198202
this.templateId = templateId;
199203
}
200204

205+
public void setOsTypeId(Long osTypeId) {
206+
this.osTypeId = osTypeId;
207+
}
208+
201209
public void setUsageId(String usageId) {
202210
this.usageId = usageId;
203211
}

api/src/main/java/org/apache/cloudstack/api/response/VMSnapshotResponse.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.LinkedHashSet;
2222
import java.util.Set;
2323

24+
import com.cloud.hypervisor.Hypervisor;
2425
import org.apache.cloudstack.api.ApiConstants;
2526
import org.apache.cloudstack.api.BaseResponseWithTagInformation;
2627
import org.apache.cloudstack.api.EntityReference;
@@ -100,6 +101,10 @@ public class VMSnapshotResponse extends BaseResponseWithTagInformation implement
100101
@Param(description = "the domain associated with the disk volume")
101102
private String domainName;
102103

104+
@SerializedName(ApiConstants.HYPERVISOR)
105+
@Param(description = "the type of hypervisor on which snapshot is stored")
106+
private Hypervisor.HypervisorType hypervisor;
107+
103108
public VMSnapshotResponse() {
104109
tags = new LinkedHashSet<ResourceTagResponse>();
105110
}
@@ -236,4 +241,12 @@ public void setDomainName(String domainName) {
236241
public void setTags(Set<ResourceTagResponse> tags) {
237242
this.tags = tags;
238243
}
244+
245+
public Hypervisor.HypervisorType getHypervisor() {
246+
return hypervisor;
247+
}
248+
249+
public void setHypervisor(Hypervisor.HypervisorType hypervisor) {
250+
this.hypervisor = hypervisor;
251+
}
239252
}

debian/cloudstack-usage.postinst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ case "$1" in
2424

2525
# Linking usage server db.properties to management server db.properties
2626
if [ -f "/etc/cloudstack/management/db.properties" ]; then
27+
echo Replacing usage server's db.properties with a link to the management server's db.properties
2728
rm -f /etc/cloudstack/usage/db.properties
2829
ln -s /etc/cloudstack/management/db.properties /etc/cloudstack/usage/db.properties
2930
fi
@@ -35,6 +36,7 @@ case "$1" in
3536

3637
# Replacing key with management server key
3738
if [ -f "/etc/cloudstack/management/key" ]; then
39+
echo Replacing usage server's key with a link to the management server's key
3840
rm -f /etc/cloudstack/usage/key
3941
ln -s /etc/cloudstack/management/key /etc/cloudstack/usage/key
4042
fi

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,14 +2663,14 @@ public Network doInTransaction(final TransactionStatus status) {
26632663
return network;
26642664
}
26652665

2666-
/**
2667-
* Checks bypass VLAN id/range overlap check during network creation for guest networks
2668-
* @param bypassVlanOverlapCheck bypass VLAN id/range overlap check
2669-
* @param ntwkOff network offering
2670-
*/
2671-
private boolean hasGuestBypassVlanOverlapCheck(final boolean bypassVlanOverlapCheck, final NetworkOfferingVO ntwkOff, final boolean isPrivateNetwork) {
2672-
return bypassVlanOverlapCheck && (ntwkOff.getGuestType() == GuestType.Shared || isPrivateNetwork);
2673-
}
2666+
/**
2667+
* Checks bypass VLAN id/range overlap check during network creation for guest networks
2668+
* @param bypassVlanOverlapCheck bypass VLAN id/range overlap check
2669+
* @param ntwkOff network offering
2670+
*/
2671+
private boolean hasGuestBypassVlanOverlapCheck(final boolean bypassVlanOverlapCheck, final NetworkOfferingVO ntwkOff, final boolean isPrivateNetwork) {
2672+
return bypassVlanOverlapCheck && (ntwkOff.getGuestType() != GuestType.Isolated || isPrivateNetwork);
2673+
}
26742674

26752675
/**
26762676
* Checks for L2 network offering services. Only 2 cases allowed:

packaging/centos7/cloud.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,14 @@ fi
465465

466466
%post usage
467467
if [ -f "%{_sysconfdir}/%{name}/management/db.properties" ]; then
468-
echo Replacing db.properties with management server db.properties
468+
echo Replacing usage server's db.properties with a link to the management server's db.properties
469469
rm -f %{_sysconfdir}/%{name}/usage/db.properties
470470
ln -s %{_sysconfdir}/%{name}/management/db.properties %{_sysconfdir}/%{name}/usage/db.properties
471471
/usr/bin/systemctl enable cloudstack-usage > /dev/null 2>&1 || true
472472
fi
473473

474474
if [ -f "%{_sysconfdir}/%{name}/management/key" ]; then
475-
echo Replacing key with management server key
475+
echo Replacing usage server's key with a link to the management server's key
476476
rm -f %{_sysconfdir}/%{name}/usage/key
477477
ln -s %{_sysconfdir}/%{name}/management/key %{_sysconfdir}/%{name}/usage/key
478478
fi

packaging/centos8/cloud.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,14 +462,14 @@ fi
462462

463463
%post usage
464464
if [ -f "%{_sysconfdir}/%{name}/management/db.properties" ]; then
465-
echo Replacing db.properties with management server db.properties
465+
echo Replacing usage server's db.properties with a link to the management server's db.properties
466466
rm -f %{_sysconfdir}/%{name}/usage/db.properties
467467
ln -s %{_sysconfdir}/%{name}/management/db.properties %{_sysconfdir}/%{name}/usage/db.properties
468468
/usr/bin/systemctl enable cloudstack-usage > /dev/null 2>&1 || true
469469
fi
470470

471471
if [ -f "%{_sysconfdir}/%{name}/management/key" ]; then
472-
echo Replacing key with management server key
472+
echo Replacing usage server's key with a link to the management server's key
473473
rm -f %{_sysconfdir}/%{name}/usage/key
474474
ln -s %{_sysconfdir}/%{name}/management/key %{_sysconfdir}/%{name}/usage/key
475475
fi

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import org.apache.commons.collections.MapUtils;
6262
import org.apache.commons.io.FileUtils;
6363
import org.apache.commons.lang.ArrayUtils;
64+
import org.apache.commons.lang.BooleanUtils;
6465
import org.apache.commons.lang.math.NumberUtils;
6566
import org.apache.log4j.Logger;
6667
import org.joda.time.Duration;
@@ -1156,9 +1157,15 @@ public boolean configure(final String name, final Map<String, Object> params) th
11561157
storageProcessor.configure(name, params);
11571158
storageHandler = new StorageSubsystemCommandHandlerBase(storageProcessor);
11581159

1159-
IscsiStorageCleanupMonitor isciCleanupMonitor = new IscsiStorageCleanupMonitor();
1160-
final Thread cleanupMonitor = new Thread(isciCleanupMonitor);
1161-
cleanupMonitor.start();
1160+
Boolean _iscsiCleanUpEnabled = Boolean.parseBoolean((String)params.get("iscsi.session.cleanup.enabled"));
1161+
1162+
if (BooleanUtils.isTrue(_iscsiCleanUpEnabled)) {
1163+
IscsiStorageCleanupMonitor isciCleanupMonitor = new IscsiStorageCleanupMonitor();
1164+
final Thread cleanupMonitor = new Thread(isciCleanupMonitor);
1165+
cleanupMonitor.start();
1166+
} else {
1167+
s_logger.info("iscsi session clean up is disabled");
1168+
}
11621169

11631170
return true;
11641171
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/IscsiStorageCleanupMonitor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public class IscsiStorageCleanupMonitor implements Runnable{
3838
private static final String ISCSI_PATH_PREFIX = "/dev/disk/by-path";
3939
private static final String KEYWORD_ISCSI = "iscsi";
4040
private static final String KEYWORD_IQN = "iqn";
41+
private static final String REGEX_PART = "\\S+part\\d+$";
4142

4243
private IscsiAdmStorageAdaptor iscsiStorageAdaptor;
4344

@@ -114,7 +115,7 @@ private void updateDiskStatusMapWithInactiveIscsiSessions(Connect conn){
114115

115116
//check the volume map. If an entry exists change the status to True
116117
for (final LibvirtVMDef.DiskDef disk : disks) {
117-
if (diskStatusMap.containsKey(disk.getDiskPath())) {
118+
if (diskStatusMap.containsKey(disk.getDiskPath())&&!disk.getDiskPath().matches(REGEX_PART)) {
118119
diskStatusMap.put(disk.getDiskPath(), true);
119120
s_logger.debug("active disk found by cleanup thread" + disk.getDiskPath());
120121
}

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ public VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot) {
622622
UserVm vm = ApiDBUtils.findUserVmById(vmSnapshot.getVmId());
623623
if (vm != null) {
624624
vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
625+
vmSnapshotResponse.setHypervisor(vm.getHypervisorType());
625626
DataCenterVO datacenter = ApiDBUtils.findZoneById(vm.getDataCenterId());
626627
if (datacenter != null) {
627628
vmSnapshotResponse.setZoneId(datacenter.getUuid());
@@ -3386,6 +3387,7 @@ public UsageRecordResponse createUsageResponse(Usage usageRecord, Map<String, Se
33863387
resourceType = ResourceTag.ResourceObjectType.UserVm;
33873388
usageRecResponse.setUsageId(vm.getUuid());
33883389
resourceId = vm.getId();
3390+
usageRecResponse.setOsTypeId(vm.getGuestOSId());
33893391
}
33903392
//Hypervisor Type
33913393
usageRecResponse.setType(usageRecord.getType());

0 commit comments

Comments
 (0)