Skip to content

Commit 0926e5c

Browse files
committed
Merge remote-tracking branch 'apache/4.19'
2 parents 8f6721e + 2a56c61 commit 0926e5c

27 files changed

+1377
-166
lines changed

Diff for: api/src/main/java/org/apache/cloudstack/api/command/admin/vlan/DeleteVlanIpRangeCmd.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import com.cloud.user.Account;
3030

31-
@APICommand(name = "deleteVlanIpRange", description = "Creates a VLAN IP range.", responseObject = SuccessResponse.class,
31+
@APICommand(name = "deleteVlanIpRange", description = "Deletes a VLAN IP range.", responseObject = SuccessResponse.class,
3232
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
3333
public class DeleteVlanIpRangeCmd extends BaseCmd {
3434

Diff for: engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@
212212
import com.cloud.service.dao.ServiceOfferingDao;
213213
import com.cloud.storage.DiskOfferingVO;
214214
import com.cloud.storage.ScopeType;
215-
import com.cloud.storage.Storage.ImageFormat;
216215
import com.cloud.storage.Storage;
216+
import com.cloud.storage.Storage.ImageFormat;
217217
import com.cloud.storage.StorageManager;
218218
import com.cloud.storage.StoragePool;
219219
import com.cloud.storage.VMTemplateVO;
@@ -2206,6 +2206,8 @@ private void advanceStop(final VMInstanceVO vm, final boolean cleanUpEvenIfUnabl
22062206

22072207
boolean result = stateTransitTo(vm, Event.OperationSucceeded, null);
22082208
if (result) {
2209+
vm.setPowerState(PowerState.PowerOff);
2210+
_vmDao.update(vm.getId(), vm);
22092211
if (VirtualMachine.Type.User.equals(vm.type) && ResourceCountRunningVMsonly.value()) {
22102212
ServiceOfferingVO offering = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
22112213
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
@@ -2760,6 +2762,7 @@ protected void migrate(final VMInstanceVO vm, final long srcHostId, final Deploy
27602762
}
27612763

27622764
vm.setLastHostId(srcHostId);
2765+
_vmDao.resetVmPowerStateTracking(vm.getId());
27632766
try {
27642767
if (vm.getHostId() == null || vm.getHostId() != srcHostId || !changeState(vm, Event.MigrationRequested, dstHostId, work, Step.Migrating)) {
27652768
_networkMgr.rollbackNicForMigration(vmSrc, profile);

Diff for: engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

+18-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
@Component
6565
public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implements VMInstanceDao {
6666

67-
private static final int MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT = 3;
67+
static final int MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT = 3;
6868

6969
protected SearchBuilder<VMInstanceVO> VMClusterSearch;
7070
protected SearchBuilder<VMInstanceVO> LHVMClusterSearch;
@@ -895,17 +895,19 @@ public List<VMInstanceVO> listStartingWithNoHostId() {
895895

896896
@Override
897897
public boolean updatePowerState(final long instanceId, final long powerHostId, final VirtualMachine.PowerState powerState, Date wisdomEra) {
898-
return Transaction.execute(new TransactionCallback<Boolean>() {
898+
return Transaction.execute(new TransactionCallback<>() {
899899
@Override
900900
public Boolean doInTransaction(TransactionStatus status) {
901901
boolean needToUpdate = false;
902902
VMInstanceVO instance = findById(instanceId);
903903
if (instance != null
904-
&& (null == instance.getPowerStateUpdateTime()
904+
&& (null == instance.getPowerStateUpdateTime()
905905
|| instance.getPowerStateUpdateTime().before(wisdomEra))) {
906906
Long savedPowerHostId = instance.getPowerHostId();
907-
if (instance.getPowerState() != powerState || savedPowerHostId == null
908-
|| savedPowerHostId.longValue() != powerHostId) {
907+
if (instance.getPowerState() != powerState
908+
|| savedPowerHostId == null
909+
|| savedPowerHostId != powerHostId
910+
|| !isPowerStateInSyncWithInstanceState(powerState, powerHostId, instance)) {
909911
instance.setPowerState(powerState);
910912
instance.setPowerHostId(powerHostId);
911913
instance.setPowerStateUpdateCount(1);
@@ -927,6 +929,17 @@ public Boolean doInTransaction(TransactionStatus status) {
927929
});
928930
}
929931

932+
private boolean isPowerStateInSyncWithInstanceState(final VirtualMachine.PowerState powerState, final long powerHostId, final VMInstanceVO instance) {
933+
State instanceState = instance.getState();
934+
if ((powerState == VirtualMachine.PowerState.PowerOff && instanceState == State.Running)
935+
|| (powerState == VirtualMachine.PowerState.PowerOn && instanceState == State.Stopped)) {
936+
logger.debug(String.format("VM id: %d on host id: %d and power host id: %d is in %s state, but power state is %s",
937+
instance.getId(), instance.getHostId(), powerHostId, instanceState, powerState));
938+
return false;
939+
}
940+
return true;
941+
}
942+
930943
@Override
931944
public boolean isPowerStateUpToDate(final long instanceId) {
932945
VMInstanceVO instance = findById(instanceId);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
-- cloud.account_netstats_view source
19+
20+
21+
DROP VIEW IF EXISTS `cloud`.`account_netstats_view`;
22+
23+
CREATE VIEW `cloud`.`account_netstats_view` AS
24+
select
25+
`user_statistics`.`account_id` AS `account_id`,
26+
(sum(`user_statistics`.`net_bytes_received`) + sum(`user_statistics`.`current_bytes_received`)) AS `bytesReceived`,
27+
(sum(`user_statistics`.`net_bytes_sent`) + sum(`user_statistics`.`current_bytes_sent`)) AS `bytesSent`
28+
from
29+
`user_statistics`
30+
group by
31+
`user_statistics`.`account_id`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
-- cloud.account_vmstats_view source
19+
20+
21+
DROP VIEW IF EXISTS `cloud`.`account_vmstats_view`;
22+
23+
CREATE VIEW `cloud`.`account_vmstats_view` AS
24+
select
25+
`vm_instance`.`account_id` AS `account_id`,
26+
`vm_instance`.`state` AS `state`,
27+
count(0) AS `vmcount`
28+
from
29+
`vm_instance`
30+
where
31+
((`vm_instance`.`vm_type` = 'User')
32+
and (`vm_instance`.`removed` is null))
33+
group by
34+
`vm_instance`.`account_id`,
35+
`vm_instance`.`state`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
-- cloud.affinity_group_view source
19+
20+
21+
DROP VIEW IF EXISTS `cloud`.`affinity_group_view`;
22+
23+
CREATE VIEW `cloud`.`affinity_group_view` AS
24+
select
25+
`affinity_group`.`id` AS `id`,
26+
`affinity_group`.`name` AS `name`,
27+
`affinity_group`.`type` AS `type`,
28+
`affinity_group`.`description` AS `description`,
29+
`affinity_group`.`uuid` AS `uuid`,
30+
`affinity_group`.`acl_type` AS `acl_type`,
31+
`account`.`id` AS `account_id`,
32+
`account`.`uuid` AS `account_uuid`,
33+
`account`.`account_name` AS `account_name`,
34+
`account`.`type` AS `account_type`,
35+
`domain`.`id` AS `domain_id`,
36+
`domain`.`uuid` AS `domain_uuid`,
37+
`domain`.`name` AS `domain_name`,
38+
`domain`.`path` AS `domain_path`,
39+
`projects`.`id` AS `project_id`,
40+
`projects`.`uuid` AS `project_uuid`,
41+
`projects`.`name` AS `project_name`,
42+
`vm_instance`.`id` AS `vm_id`,
43+
`vm_instance`.`uuid` AS `vm_uuid`,
44+
`vm_instance`.`name` AS `vm_name`,
45+
`vm_instance`.`state` AS `vm_state`,
46+
`user_vm`.`display_name` AS `vm_display_name`
47+
from
48+
((((((`affinity_group`
49+
join `account` on
50+
((`affinity_group`.`account_id` = `account`.`id`)))
51+
join `domain` on
52+
((`affinity_group`.`domain_id` = `domain`.`id`)))
53+
left join `projects` on
54+
((`projects`.`project_account_id` = `account`.`id`)))
55+
left join `affinity_group_vm_map` on
56+
((`affinity_group`.`id` = `affinity_group_vm_map`.`affinity_group_id`)))
57+
left join `vm_instance` on
58+
((`vm_instance`.`id` = `affinity_group_vm_map`.`instance_id`)))
59+
left join `user_vm` on
60+
((`user_vm`.`id` = `vm_instance`.`id`)));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
-- cloud.event_view source
19+
20+
21+
DROP VIEW IF EXISTS `cloud`.`event_view`;
22+
23+
CREATE VIEW `cloud`.`event_view` AS
24+
select
25+
`event`.`id` AS `id`,
26+
`event`.`uuid` AS `uuid`,
27+
`event`.`type` AS `type`,
28+
`event`.`state` AS `state`,
29+
`event`.`description` AS `description`,
30+
`event`.`resource_id` AS `resource_id`,
31+
`event`.`resource_type` AS `resource_type`,
32+
`event`.`created` AS `created`,
33+
`event`.`level` AS `level`,
34+
`event`.`parameters` AS `parameters`,
35+
`event`.`start_id` AS `start_id`,
36+
`eve`.`uuid` AS `start_uuid`,
37+
`event`.`user_id` AS `user_id`,
38+
`event`.`archived` AS `archived`,
39+
`event`.`display` AS `display`,
40+
`user`.`username` AS `user_name`,
41+
`account`.`id` AS `account_id`,
42+
`account`.`uuid` AS `account_uuid`,
43+
`account`.`account_name` AS `account_name`,
44+
`account`.`type` AS `account_type`,
45+
`domain`.`id` AS `domain_id`,
46+
`domain`.`uuid` AS `domain_uuid`,
47+
`domain`.`name` AS `domain_name`,
48+
`domain`.`path` AS `domain_path`,
49+
`projects`.`id` AS `project_id`,
50+
`projects`.`uuid` AS `project_uuid`,
51+
`projects`.`name` AS `project_name`
52+
from
53+
(((((`event`
54+
join `account` on
55+
((`event`.`account_id` = `account`.`id`)))
56+
join `domain` on
57+
((`event`.`domain_id` = `domain`.`id`)))
58+
join `user` on
59+
((`event`.`user_id` = `user`.`id`)))
60+
left join `projects` on
61+
((`projects`.`project_account_id` = `event`.`account_id`)))
62+
left join `event` `eve` on
63+
((`event`.`start_id` = `eve`.`id`)));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
-- cloud.free_ip_view source
19+
20+
21+
DROP VIEW IF EXISTS `cloud`.`free_ip_view`;
22+
23+
CREATE VIEW `cloud`.`free_ip_view` AS
24+
select
25+
count(`user_ip_address`.`id`) AS `free_ip`
26+
from
27+
(`user_ip_address`
28+
join `vlan` on
29+
(((`vlan`.`id` = `user_ip_address`.`vlan_db_id`)
30+
and (`vlan`.`vlan_type` = 'VirtualNetwork'))))
31+
where
32+
(`user_ip_address`.`state` = 'Free');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
-- cloud.image_store_view source
19+
20+
21+
DROP VIEW IF EXISTS `cloud`.`image_store_view`;
22+
23+
CREATE VIEW `cloud`.`image_store_view` AS
24+
select
25+
`image_store`.`id` AS `id`,
26+
`image_store`.`uuid` AS `uuid`,
27+
`image_store`.`name` AS `name`,
28+
`image_store`.`image_provider_name` AS `image_provider_name`,
29+
`image_store`.`protocol` AS `protocol`,
30+
`image_store`.`url` AS `url`,
31+
`image_store`.`scope` AS `scope`,
32+
`image_store`.`role` AS `role`,
33+
`image_store`.`readonly` AS `readonly`,
34+
`image_store`.`removed` AS `removed`,
35+
`data_center`.`id` AS `data_center_id`,
36+
`data_center`.`uuid` AS `data_center_uuid`,
37+
`data_center`.`name` AS `data_center_name`,
38+
`image_store_details`.`name` AS `detail_name`,
39+
`image_store_details`.`value` AS `detail_value`
40+
from
41+
((`image_store`
42+
left join `data_center` on
43+
((`image_store`.`data_center_id` = `data_center`.`id`)))
44+
left join `image_store_details` on
45+
((`image_store_details`.`store_id` = `image_store`.`id`)));

0 commit comments

Comments
 (0)