Skip to content

Commit db37691

Browse files
DaanHooglanddhslove
authored andcommitted
Merge branch '4.19' into 4.20.merge
1 parent c590379 commit db37691

File tree

11 files changed

+50
-35
lines changed

11 files changed

+50
-35
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,6 @@ public class ApiConstants {
493493
public static final String STORAGE_TAGS = "storagetags";
494494
public static final String SUCCESS = "success";
495495
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
496-
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
497496
public static final String TARGET_IQN = "targetiqn";
498497
public static final String TEMPLATE_FILTER = "templatefilter";
499498
public static final String TEMPLATE_ID = "templateid";

core/src/main/java/com/cloud/agent/api/ConvertInstanceAnswer.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
2929
this.temporaryConvertUuid = temporaryConvertUuid;
3030
}
3131

32+
public ConvertInstanceAnswer(Command command, String temporaryConvertUuid) {
33+
super(command, true, "");
34+
this.temporaryConvertUuid = temporaryConvertUuid;
35+
}
36+
3237
public String getTemporaryConvertUuid() {
3338
return temporaryConvertUuid;
3439
}
40+
41+
public UnmanagedInstanceTO getConvertedInstance() {
42+
return convertedInstance;
43+
}
3544
}

engine/schema/src/main/java/com/cloud/network/dao/FirewallRulesCidrsDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public List<String> getSourceCidrs(long firewallRuleId) {
4646
sc.setParameters("firewallRuleId", firewallRuleId);
4747

4848
List<FirewallRulesCidrsVO> results = search(sc, null);
49-
List<String> cidrs = new ArrayList<String>(results.size());
49+
List<String> cidrs = new ArrayList<>(results.size());
5050
for (FirewallRulesCidrsVO result : results) {
5151
cidrs.add(result.getCidr());
5252
}

engine/schema/src/main/java/com/cloud/network/rules/PortForwardingRuleVO.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ public PortForwardingRuleVO(String xId, long srcIpId, int srcPortStart, int srcP
6464
this.sourceCidrs = sourceCidrs;
6565
}
6666

67+
public PortForwardingRuleVO(String xId, long srcIpId, int srcPortStart, int srcPortEnd, Ip dstIp, int dstPortStart, int dstPortEnd, String protocol, long networkId,
68+
long accountId, long domainId, long instanceId) {
69+
this(xId, srcIpId, srcPortStart, srcPortEnd, dstIp, dstPortStart, dstPortEnd, protocol.toLowerCase(), networkId, accountId, domainId, instanceId, null);
70+
}
71+
72+
public PortForwardingRuleVO(String xId, long srcIpId, int srcPort, Ip dstIp, int dstPort, String protocol, long networkId, long accountId,
73+
long domainId, long instanceId) {
74+
this(xId, srcIpId, srcPort, srcPort, dstIp, dstPort, dstPort, protocol.toLowerCase(), networkId, accountId, domainId, instanceId, null);
75+
}
76+
6777
@Override
6878
public Ip getDestinationIpAddress() {
6979
return destinationIpAddress;

engine/schema/src/main/java/com/cloud/network/rules/dao/PortForwardingRulesDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,4 @@ public PortForwardingRuleVO findById(Long id) {
225225

226226
return rule;
227227
}
228-
}
228+
}

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

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.apache.commons.collections.CollectionUtils;
3535
import org.apache.commons.io.IOUtils;
3636
import org.apache.commons.lang3.StringUtils;
37-
import org.apache.log4j.Logger;
3837

3938
import com.cloud.agent.api.Answer;
4039
import com.cloud.agent.api.ImportConvertedInstanceAnswer;
@@ -60,8 +59,6 @@
6059
@ResourceWrapper(handles = ImportConvertedInstanceCommand.class)
6160
public class LibvirtImportConvertedInstanceCommandWrapper extends CommandWrapper<ImportConvertedInstanceCommand, Answer, LibvirtComputingResource> {
6261

63-
private static final Logger s_logger = Logger.getLogger(LibvirtImportConvertedInstanceCommandWrapper.class);
64-
6562
@Override
6663
public Answer execute(ImportConvertedInstanceCommand cmd, LibvirtComputingResource serverResource) {
6764
RemoteInstanceTO sourceInstance = cmd.getSourceInstance();
@@ -94,11 +91,11 @@ public Answer execute(ImportConvertedInstanceCommand cmd, LibvirtComputingResour
9491
} catch (Exception e) {
9592
String error = String.format("Error converting instance %s from %s, due to: %s",
9693
sourceInstanceName, sourceHypervisorType, e.getMessage());
97-
s_logger.error(error, e);
94+
logger.error(error, e);
9895
return new ImportConvertedInstanceAnswer(cmd, false, error);
9996
} finally {
10097
if (conversionTemporaryLocation instanceof NfsTO) {
101-
s_logger.debug("Cleaning up secondary storage temporary location");
98+
logger.debug("Cleaning up secondary storage temporary location");
10299
storagePoolMgr.deleteStoragePool(temporaryStoragePool.getType(), temporaryStoragePool.getUuid());
103100
}
104101
}
@@ -120,7 +117,7 @@ protected List<KVMPhysicalDisk> getTemporaryDisksFromParsedXml(KVMStoragePool po
120117
x.getDeviceType() == LibvirtVMDef.DiskDef.DeviceType.DISK).collect(Collectors.toList());
121118
if (CollectionUtils.isEmpty(disksDefs)) {
122119
String err = String.format("Cannot find any disk defined on the converted XML domain %s.xml", convertedBasePath);
123-
s_logger.error(err);
120+
logger.error(err);
124121
throw new CloudRuntimeException(err);
125122
}
126123
sanitizeDisksPath(disksDefs);
@@ -138,15 +135,15 @@ private List<KVMPhysicalDisk> getPhysicalDisksFromDefPaths(List<LibvirtVMDef.Dis
138135

139136
protected List<KVMPhysicalDisk> getTemporaryDisksWithPrefixFromTemporaryPool(KVMStoragePool pool, String path, String prefix) {
140137
String msg = String.format("Could not parse correctly the converted XML domain, checking for disks on %s with prefix %s", path, prefix);
141-
s_logger.info(msg);
138+
logger.info(msg);
142139
pool.refresh();
143140
List<KVMPhysicalDisk> disksWithPrefix = pool.listPhysicalDisks()
144141
.stream()
145142
.filter(x -> x.getName().startsWith(prefix) && !x.getName().endsWith(".xml"))
146143
.collect(Collectors.toList());
147144
if (CollectionUtils.isEmpty(disksWithPrefix)) {
148145
msg = String.format("Could not find any converted disk with prefix %s on temporary location %s", prefix, path);
149-
s_logger.error(msg);
146+
logger.error(msg);
150147
throw new CloudRuntimeException(msg);
151148
}
152149
return disksWithPrefix;
@@ -156,10 +153,10 @@ private void cleanupDisksAndDomainFromTemporaryLocation(List<KVMPhysicalDisk> di
156153
KVMStoragePool temporaryStoragePool,
157154
String temporaryConvertUuid) {
158155
for (KVMPhysicalDisk disk : disks) {
159-
s_logger.info(String.format("Cleaning up temporary disk %s after conversion from temporary location", disk.getName()));
156+
logger.info(String.format("Cleaning up temporary disk %s after conversion from temporary location", disk.getName()));
160157
temporaryStoragePool.deletePhysicalDisk(disk.getName(), Storage.ImageFormat.QCOW2);
161158
}
162-
s_logger.info(String.format("Cleaning up temporary domain %s after conversion from temporary location", temporaryConvertUuid));
159+
logger.info(String.format("Cleaning up temporary domain %s after conversion from temporary location", temporaryConvertUuid));
163160
FileUtil.deleteFiles(temporaryStoragePool.getLocalPath(), temporaryConvertUuid, ".xml");
164161
}
165162

@@ -178,26 +175,26 @@ protected List<KVMPhysicalDisk> moveTemporaryDisksToDestination(List<KVMPhysical
178175
if (temporaryDisks.size() != destinationStoragePools.size()) {
179176
String warn = String.format("Discrepancy between the converted instance disks (%s) " +
180177
"and the expected number of disks (%s)", temporaryDisks.size(), destinationStoragePools.size());
181-
s_logger.warn(warn);
178+
logger.warn(warn);
182179
}
183180
for (int i = 0; i < temporaryDisks.size(); i++) {
184181
String poolPath = destinationStoragePools.get(i);
185182
KVMStoragePool destinationPool = storagePoolMgr.getStoragePool(Storage.StoragePoolType.NetworkFilesystem, poolPath);
186183
if (destinationPool == null) {
187184
String err = String.format("Could not find a storage pool by URI: %s", poolPath);
188-
s_logger.error(err);
185+
logger.error(err);
189186
continue;
190187
}
191188
if (destinationPool.getType() != Storage.StoragePoolType.NetworkFilesystem) {
192189
String err = String.format("Storage pool by URI: %s is not an NFS storage", poolPath);
193-
s_logger.error(err);
190+
logger.error(err);
194191
continue;
195192
}
196193
KVMPhysicalDisk sourceDisk = temporaryDisks.get(i);
197-
if (s_logger.isDebugEnabled()) {
194+
if (logger.isDebugEnabled()) {
198195
String msg = String.format("Trying to copy converted instance disk number %s from the temporary location %s" +
199196
" to destination storage pool %s", i, sourceDisk.getPool().getLocalPath(), destinationPool.getUuid());
200-
s_logger.debug(msg);
197+
logger.debug(msg);
201198
}
202199

203200
String destinationName = UUID.randomUUID().toString();
@@ -267,7 +264,7 @@ protected Pair<String, String> getNfsStoragePoolHostAndPath(KVMStoragePool stora
267264
commands.add(new String[]{Script.getExecutableAbsolutePath("mount")});
268265
commands.add(new String[]{Script.getExecutableAbsolutePath("grep"), storagePool.getLocalPath()});
269266
String storagePoolMountPoint = Script.executePipedCommands(commands, 0).second();
270-
s_logger.debug(String.format("NFS Storage pool: %s - local path: %s, mount point: %s", storagePool.getUuid(), storagePool.getLocalPath(), storagePoolMountPoint));
267+
logger.debug(String.format("NFS Storage pool: %s - local path: %s, mount point: %s", storagePool.getUuid(), storagePool.getLocalPath(), storagePoolMountPoint));
271268
if (StringUtils.isNotEmpty(storagePoolMountPoint)) {
272269
String[] res = storagePoolMountPoint.strip().split(" ");
273270
res = res[0].split(":");
@@ -283,7 +280,7 @@ protected LibvirtDomainXMLParser parseMigratedVMXmlDomain(String installPath) th
283280
String xmlPath = String.format("%s.xml", installPath);
284281
if (!new File(xmlPath).exists()) {
285282
String err = String.format("Conversion failed. Unable to find the converted XML domain, expected %s", xmlPath);
286-
s_logger.error(err);
283+
logger.error(err);
287284
throw new CloudRuntimeException(err);
288285
}
289286
InputStream is = new BufferedInputStream(new FileInputStream(xmlPath));
@@ -294,8 +291,8 @@ protected LibvirtDomainXMLParser parseMigratedVMXmlDomain(String installPath) th
294291
return parser;
295292
} catch (RuntimeException e) {
296293
String err = String.format("Error parsing the converted instance XML domain at %s: %s", xmlPath, e.getMessage());
297-
s_logger.error(err, e);
298-
s_logger.debug(xml);
294+
logger.error(err, e);
295+
logger.debug(xml);
299296
return null;
300297
}
301298
}

plugins/hypervisors/kvm/src/test/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtImportConvertedInstanceCommandWrapperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void testSanitizeDisksPath() {
149149
@Test
150150
public void testMoveTemporaryDisksToDestination() {
151151
KVMPhysicalDisk sourceDisk = Mockito.mock(KVMPhysicalDisk.class);
152-
Mockito.when(sourceDisk.getPool()).thenReturn(temporaryPool);
152+
Mockito.lenient().when(sourceDisk.getPool()).thenReturn(temporaryPool);
153153
List<KVMPhysicalDisk> disks = List.of(sourceDisk);
154154
String destinationPoolUuid = UUID.randomUUID().toString();
155155
List<String> destinationPools = List.of(destinationPoolUuid);

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060

6161
import java.io.File;
6262

63-
@StorageAdaptorInfo(storagePoolType=Storage.StoragePoolType.Linstor)
6463
public class LinstorStorageAdaptor implements StorageAdaptor {
6564
private static final Logger s_logger = Logger.getLogger(LinstorStorageAdaptor.class);
6665
private static final Map<String, KVMStoragePool> MapStorageUuidToStoragePool = new HashMap<>();

server/src/main/java/com/cloud/network/firewall/FirewallManagerImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -498,38 +498,38 @@ protected boolean checkIfRulesHaveConflictingPortRanges(FirewallRule newRule, Fi
498498
String rulesAsString = String.format("[%s] and [%s]", rule, newRule);
499499

500500
if (oneOfRulesIsFirewall) {
501-
s_logger.debug(String.format("Only one of the rules (%s) is firewall; therefore, their port ranges will not conflict.",
501+
logger.debug(String.format("Only one of the rules (%s) is firewall; therefore, their port ranges will not conflict.",
502502
rulesAsString));
503503
return false;
504504
}
505505

506506
if ((bothRulesFirewall || bothRulesPortForwarding) && !duplicatedCidrs) {
507-
s_logger.debug(String.format("Both rules (%s) are firewall/port forwarding, but they do not have duplicated CIDRs; therefore, their port ranges will not conflict.",
507+
logger.debug(String.format("Both rules (%s) are firewall/port forwarding, but they do not have duplicated CIDRs; therefore, their port ranges will not conflict.",
508508
rulesAsString));
509509
return false;
510510
}
511511

512512
if (rule.getSourcePortStart() <= newRule.getSourcePortStart() && rule.getSourcePortEnd() >= newRule.getSourcePortStart()) {
513-
s_logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
513+
logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
514514
return true;
515515
}
516516

517517
if (rule.getSourcePortStart() <= newRule.getSourcePortEnd() && rule.getSourcePortEnd() >= newRule.getSourcePortEnd()) {
518-
s_logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
518+
logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
519519
return true;
520520
}
521521

522522
if (newRule.getSourcePortStart() <= rule.getSourcePortStart() && newRule.getSourcePortEnd() >= rule.getSourcePortStart()) {
523-
s_logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
523+
logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
524524
return true;
525525
}
526526

527527
if (newRule.getSourcePortStart() <= rule.getSourcePortEnd() && newRule.getSourcePortEnd() >= rule.getSourcePortEnd()) {
528-
s_logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
528+
logger.debug(String.format("Rules (%s) have conflicting port ranges.", rulesAsString));
529529
return true;
530530
}
531531

532-
s_logger.debug(String.format("Rules (%s) do not have conflicting port ranges.", rulesAsString));
532+
logger.debug(String.format("Rules (%s) do not have conflicting port ranges.", rulesAsString));
533533
return false;
534534
}
535535

server/src/main/java/org/apache/cloudstack/vm/UnmanagedVMsManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ protected UserVm importUnmanagedInstanceFromVmwareToKvm(DataCenter zone, Cluster
16481648

16491649
temporaryConvertLocation = selectInstanceConversionTemporaryLocation(
16501650
destinationCluster, convertHost, convertStoragePoolId);
1651-
DiskOffering diskOffering = diskOfferingDao.findById(serviceOffering.getDiskOfferingId());
1651+
DiskOffering diskOffering = diskOfferingDao.findById(serviceOffering.getDiskOfferingId());
16521652
List<StoragePoolVO> convertStoragePools = primaryDataStoreDao.findPoolsByTags(zone.getId(), destinationCluster.getPodId(), destinationCluster.getId(), diskOffering.getTagsArray(), true, VolumeApiServiceImpl.storageTagRuleExecutionTimeout.value());
16531653
long importStartTime = System.currentTimeMillis();
16541654
Pair<UnmanagedInstanceTO, Boolean> sourceInstanceDetails = getSourceVmwareUnmanagedInstance(vcenter, datacenterName, username, password, clusterName, sourceHostName, sourceVMName);

0 commit comments

Comments
 (0)