Skip to content

Commit 1ae4276

Browse files
committed
Merge branch '4.20' of https://github.com/apache/cloudstack into support-xen84-py3
2 parents 84ea6ce + f6d0590 commit 1ae4276

File tree

21 files changed

+351
-38
lines changed

21 files changed

+351
-38
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ jobs:
236236
237237
- name: Install Python dependencies
238238
run: |
239-
python3 -m pip install --user --upgrade urllib3 lxml paramiko nose texttable ipmisim pyopenssl pycrypto mock flask netaddr pylint pycodestyle six astroid pynose
239+
python3 -m pip install --user --upgrade urllib3 lxml paramiko nose texttable ipmisim pyopenssl pycryptodome mock flask netaddr pylint pycodestyle six astroid pynose
240240
241241
- name: Install jacoco dependencies
242242
run: |

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
181181
thawAnswer = (FreezeThawVMAnswer) agentMgr.send(hostId, thawCmd);
182182
if (thawAnswer != null && thawAnswer.getResult()) {
183183
logger.info(String.format(
184-
"Virtual machne is thawed. The freeze of virtual machine took %s milliseconds.",
184+
"Virtual machine is thawed. The freeze of virtual machine took %s milliseconds.",
185185
TimeUnit.MILLISECONDS.convert(elapsedTime(startFreeze), TimeUnit.NANOSECONDS)));
186186
}
187187
} else {
@@ -427,9 +427,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
427427
String snapshotName = vmSnapshot.getId() + "_" + vol.getUuid();
428428
SnapshotVO snapshot = new SnapshotVO(vol.getDataCenterId(), vol.getAccountId(), vol.getDomainId(), vol.getId(), vol.getDiskOfferingId(),
429429
snapshotName, (short) Snapshot.Type.GROUP.ordinal(), Snapshot.Type.GROUP.name(), vol.getSize(), vol.getMinIops(), vol.getMaxIops(), Hypervisor.HypervisorType.KVM, null);
430+
VMSnapshotOptions options = ((VMSnapshotVO) vmSnapshot).getOptions();
431+
boolean quiescevm = false;
432+
if (options != null) {
433+
quiescevm = options.needQuiesceVM();
434+
}
430435

431436
snapshot = snapshotDao.persist(snapshot);
432-
vol.addPayload(setPayload(vol, snapshot));
437+
vol.addPayload(setPayload(vol, snapshot, quiescevm));
433438
SnapshotInfo snapshotInfo = snapshotDataFactory.getSnapshot(snapshot.getId(), vol.getDataStore());
434439
snapshotInfo.addPayload(vol.getpayload());
435440
SnapshotStrategy snapshotStrategy = storageStrategyFactory.getSnapshotStrategy(snapshotInfo, SnapshotOperation.TAKE);
@@ -447,14 +452,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
447452
return snapshotInfo;
448453
}
449454

450-
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate) {
455+
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate, boolean quiescevm) {
451456
CreateSnapshotPayload payload = new CreateSnapshotPayload();
452457
payload.setSnapshotId(snapshotCreate.getId());
453458
payload.setSnapshotPolicyId(SnapshotVO.MANUAL_POLICY_ID);
454459
payload.setLocationType(snapshotCreate.getLocationType());
455460
payload.setAccount(accountService.getAccount(vol.getAccountId()));
456461
payload.setAsyncBackup(false);
457-
payload.setQuiescevm(false);
462+
payload.setQuiescevm(quiescevm);
458463
return payload;
459464
}
460465
}

engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
3838
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation;
3939
import org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory;
40+
import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
4041
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
4142
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
4243
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@@ -151,7 +152,7 @@ public void setUp() throws Exception {
151152

152153
@Test
153154
public void testCreateDiskSnapshotBasedOnStrategy() throws Exception {
154-
VMSnapshot vmSnapshot = Mockito.mock(VMSnapshot.class);
155+
VMSnapshotVO vmSnapshot = Mockito.mock(VMSnapshotVO.class);
155156
List<SnapshotInfo> forRollback = new ArrayList<>();
156157
VolumeInfo vol = Mockito.mock(VolumeInfo.class);
157158
SnapshotInfo snapshotInfo = Mockito.mock(SnapshotInfo.class);
@@ -162,6 +163,7 @@ public void testCreateDiskSnapshotBasedOnStrategy() throws Exception {
162163
SnapshotVO snapshot = new SnapshotVO(vol.getDataCenterId(), vol.getAccountId(), vol.getDomainId(),
163164
vol.getId(),vol.getDiskOfferingId(), vmUuid + "_" + volUuid,(short) SnapshotVO.MANUAL_POLICY_ID,
164165
"MANUAL",vol.getSize(),vol.getMinIops(),vol.getMaxIops(), Hypervisor.HypervisorType.KVM, null);
166+
when(vmSnapshot.getOptions()).thenReturn(new VMSnapshotOptions(true));
165167
when(vmSnapshot.getUuid()).thenReturn(vmUuid);
166168
when(vol.getUuid()).thenReturn(volUuid);
167169
when(_snapshotDao.persist(any())).thenReturn(snapshot);

plugins/storage/object/ceph/src/main/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImpl.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ public Bucket createBucket(Bucket bucket, boolean objectLock) {
9595
AmazonS3 s3client = getS3Client(storeId, accountId);
9696

9797
try {
98-
if (s3client.getBucketAcl(bucketName) != null) {
99-
throw new CloudRuntimeException("Bucket already exists with name " + bucketName);
98+
if (s3client.doesBucketExistV2(bucketName)) {
99+
throw new CloudRuntimeException("Bucket already exists with the name: " + bucketName);
100100
}
101101
} catch (AmazonS3Exception e) {
102102
if (e.getStatusCode() != 404) {
@@ -221,9 +221,11 @@ public boolean createUser(long accountId, long storeId) {
221221
if (user.isPresent()) {
222222
logger.info("User already exists in Ceph RGW: " + username);
223223
return true;
224+
} else {
225+
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
224226
}
225227
} catch (Exception e) {
226-
logger.debug("User does not exist. Creating user in Ceph RGW: " + username);
228+
logger.debug("Get user info failed for user {} with exception {}. Proceeding with user creation.", username, e.getMessage());
227229
}
228230

229231
try {
@@ -348,7 +350,7 @@ protected AmazonS3 getS3Client(String url, String accessKey, String secretKey) {
348350
new AWSStaticCredentialsProvider(
349351
new BasicAWSCredentials(accessKey, secretKey)))
350352
.withEndpointConfiguration(
351-
new AwsClientBuilder.EndpointConfiguration(url, "auto"))
353+
new AwsClientBuilder.EndpointConfiguration(url, null))
352354
.build();
353355

354356
if (client == null) {

plugins/storage/object/ceph/src/test/java/org/apache/cloudstack/storage/datastore/driver/CephObjectStoreDriverImplTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void testCreateBucket() throws Exception {
9696
when(bucketDao.findById(anyLong())).thenReturn(new BucketVO(bucket.getName()));
9797
Bucket bucketRet = cephObjectStoreDriverImpl.createBucket(bucket, false);
9898
assertEquals(bucketRet.getName(), bucket.getName());
99-
verify(rgwClient, times(1)).getBucketAcl(anyString());
99+
verify(rgwClient, times(1)).doesBucketExistV2(anyString());
100100
verify(rgwClient, times(1)).createBucket(anyString());
101101
}
102102

python/lib/cloudutils/networkConfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def listNetworks():
4141
return devs
4242
@staticmethod
4343
def getDefaultNetwork():
44-
cmd = bash("route -n|awk \'/^0.0.0.0/ {print $2,$8}\'")
44+
cmd = bash("ip route show default | awk \'{print $3,$5}\'")
4545
if not cmd.isSuccess():
4646
logging.debug("Failed to get default route")
4747
raise CloudRuntimeException("Failed to get default route")

server/src/main/java/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,6 @@ public boolean associatePublicIP(final Network network, final List<? extends Pub
229229
public boolean applyNetworkACLs(final Network network, final List<? extends NetworkACLItem> rules, final VirtualRouter router, final boolean isPrivateGateway)
230230
throws ResourceUnavailableException {
231231

232-
if (rules == null || rules.isEmpty()) {
233-
logger.debug("No network ACLs to be applied for network {}", network);
234-
return true;
235-
}
236-
237232
logger.debug("APPLYING NETWORK ACLs RULES");
238233

239234
final String typeString = "network acls";

server/src/test/java/org/apache/cloudstack/resource/ResourceCleanupServiceImplTest.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
package org.apache.cloudstack.resource;
1818

1919
import java.lang.reflect.Field;
20+
import java.time.Duration;
21+
import java.time.Instant;
22+
import java.time.ZoneId;
23+
import java.time.ZonedDateTime;
24+
import java.time.zone.ZoneRules;
2025
import java.util.ArrayList;
2126
import java.util.Calendar;
2227
import java.util.Date;
@@ -629,9 +634,23 @@ public void testCalculatePastDateFromConfig() {
629634
Date result = resourceCleanupService.calculatePastDateFromConfig(
630635
ResourceCleanupService.ExpungedResourcesPurgeKeepPastDays.key(),
631636
days);
632-
Date today = new Date();
633-
long diff = today.getTime() - result.getTime();
634-
Assert.assertEquals(days, TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS));
637+
Instant resultInstant = result.toInstant();
638+
ZoneId systemZone = ZoneId.systemDefault();
639+
ZoneRules rules = systemZone.getRules();
640+
ZonedDateTime resultDateTime = resultInstant.atZone(systemZone);
641+
boolean isDSTInResultDateTime = rules.isDaylightSavings(resultDateTime.toInstant());
642+
643+
ZonedDateTime todayDateTime = ZonedDateTime.now(systemZone);
644+
boolean isDSTInTodayDateTime = rules.isDaylightSavings(todayDateTime.toInstant());
645+
646+
Duration duration = Duration.between(resultDateTime, todayDateTime);
647+
long actualDays = TimeUnit.DAYS.convert(duration.toMillis(), TimeUnit.MILLISECONDS);
648+
649+
if (!isDSTInResultDateTime && isDSTInTodayDateTime) {
650+
Assert.assertEquals(days - 1, actualDays);
651+
} else {
652+
Assert.assertEquals(days, actualDays);
653+
}
635654
}
636655

637656
@Test

test/integration/smoke/test_vm_strict_host_tags.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def test_06_deploy_vm_on_any_host_with_strict_tags_failure(self):
190190
self.cleanup.append(vm)
191191
self.fail("VM should not be deployed")
192192
except Exception as e:
193-
self.assertTrue("No suitable host found for vm " in str(e))
193+
self.assertTrue("No destination found for a deployment for VM instance" in str(e))
194194

195195

196196
class TestScaleVMStrictTags(cloudstackTestCase):
@@ -310,7 +310,7 @@ def test_02_scale_vm_strict_tags_failure(self):
310310
vm.start(self.apiclient)
311311
self.fail("VM should not be be able scale and start")
312312
except Exception as e:
313-
self.assertTrue("No suitable host found for vm " in str(e))
313+
self.assertTrue("Unable to orchestrate the start of VM instance" in str(e))
314314

315315

316316
class TestRestoreVMStrictTags(cloudstackTestCase):
@@ -423,7 +423,7 @@ def test_02_restore_vm_strict_tags_failure(self):
423423
vm.restore(self.apiclient, templateid=self.template_t2.id, expunge=True)
424424
self.fail("VM should not be restored")
425425
except Exception as e:
426-
self.assertTrue("No suitable host found for vm " in str(e))
426+
self.assertTrue("Unable to start VM with specified id" in str(e))
427427

428428

429429
class TestMigrateVMStrictTags(cloudstackTestCase):

ui/public/locales/en.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"message.delete.account.not.disabled": "Please disable the account before attempting to delete it.",
23
"alert.service.domainrouter": "Domain router",
34
"error.dedicate.bgp.peer.failed":"Failed to dedicate BGP peer",
45
"error.dedicate.cluster.failed": "Failed to dedicate cluster.",
@@ -929,6 +930,7 @@
929930
"label.endipv6": "IPv6 end IP",
930931
"label.endpoint": "Endpoint",
931932
"label.endport": "End port",
933+
"label.enter.account.name": "Enter the account name",
932934
"label.enter.code": "Enter 2FA code to verify",
933935
"label.enter.static.pin": "Enter static PIN to verify",
934936
"label.enter.token": "Enter token",
@@ -2951,7 +2953,11 @@
29512953
"message.dedicating.host": "Dedicating host...",
29522954
"message.dedicating.pod": "Dedicating pod...",
29532955
"message.dedicating.zone": "Dedicating zone...",
2954-
"message.delete.account": "Please confirm that you want to delete this Account.",
2956+
"message.delete.account.confirm": "Please confirm that you want to delete this account by entering the name of the account below.",
2957+
"message.delete.account.failed": "Delete account failed",
2958+
"message.delete.account.processing": "Deleting account",
2959+
"message.delete.account.success": "Successfully deleted account",
2960+
"message.delete.account.warning": "Deleting this account will delete all of the instances, volumes and snapshots associated with the account.",
29552961
"message.delete.acl.processing": "Removing ACL rule...",
29562962
"message.delete.acl.rule": "Remove ACL rule",
29572963
"message.delete.acl.rule.failed": "Failed to remove ACL rule.",
@@ -3044,6 +3050,7 @@
30443050
"message.enabling.security.group.provider": "Enabling security group provider",
30453051
"message.enter.valid.nic.ip": "Please enter a valid IP address for NIC",
30463052
"message.error.access.key": "Please enter access key.",
3053+
"message.error.account.delete.name.mismatch": "Name entered doesn't match the account name.",
30473054
"message.error.add.guest.network": "Either IPv4 fields or IPv6 fields need to be filled when adding a guest Network.",
30483055
"message.error.add.interface.static.route": "Adding interface Static Route failed",
30493056
"message.error.add.logical.router": "Adding Logical Router failed",

0 commit comments

Comments
 (0)