Skip to content

Commit 4d41b6b

Browse files
committed
Merge remote-tracking branch 'origin/4.17'
2 parents c4ab8ff + 2d0a2e3 commit 4d41b6b

File tree

16 files changed

+266
-103
lines changed

16 files changed

+266
-103
lines changed

.github/workflows/codecov.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
name: Coverage Check
19+
20+
on: [pull_request, push]
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
build:
27+
name: codecov
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v3
31+
32+
- name: Set up JDK11
33+
uses: actions/setup-java@v3
34+
with:
35+
distribution: 'temurin'
36+
java-version: '11'
37+
cache: 'maven'
38+
39+
- name: Build CloudStack with Quality Checks
40+
run: |
41+
git clone https://github.com/shapeblue/cloudstack-nonoss.git nonoss
42+
cd nonoss && bash -x install-non-oss.sh && cd ..
43+
mvn -P quality -Dsimulator -Dnoredist clean install
44+
45+
- uses: codecov/codecov-action@v3
46+
with:
47+
files: ./client/target/site/jacoco-aggregate/jacoco.xml
48+
fail_ci_if_error: true
49+
verbose: true
50+
name: codecov

engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,109 @@
2020
--;
2121

2222
UPDATE `cloud`.`configuration` SET `value` = 'false' WHERE `name` = 'network.disable.rpfilter' AND `value` != 'true';
23-
UPDATE `cloud`.`configuration` SET `value` = 'false' WHERE `name` = 'consoleproxy.disable.rpfilter' AND `value` != 'true';
23+
UPDATE `cloud`.`configuration` SET `value` = 'false' WHERE `name` = 'consoleproxy.disable.rpfilter' AND `value` != 'true';
24+
25+
-- Retrieve the hypervisor_type from vm_instance
26+
DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
27+
CREATE VIEW `cloud`.`domain_router_view` AS
28+
select
29+
vm_instance.id id,
30+
vm_instance.name name,
31+
account.id account_id,
32+
account.uuid account_uuid,
33+
account.account_name account_name,
34+
account.type account_type,
35+
domain.id domain_id,
36+
domain.uuid domain_uuid,
37+
domain.name domain_name,
38+
domain.path domain_path,
39+
projects.id project_id,
40+
projects.uuid project_uuid,
41+
projects.name project_name,
42+
vm_instance.uuid uuid,
43+
vm_instance.created created,
44+
vm_instance.state state,
45+
vm_instance.removed removed,
46+
vm_instance.pod_id pod_id,
47+
vm_instance.instance_name instance_name,
48+
vm_instance.hypervisor_type,
49+
host_pod_ref.uuid pod_uuid,
50+
data_center.id data_center_id,
51+
data_center.uuid data_center_uuid,
52+
data_center.name data_center_name,
53+
data_center.networktype data_center_type,
54+
data_center.dns1 dns1,
55+
data_center.dns2 dns2,
56+
data_center.ip6_dns1 ip6_dns1,
57+
data_center.ip6_dns2 ip6_dns2,
58+
host.id host_id,
59+
host.uuid host_uuid,
60+
host.name host_name,
61+
host.cluster_id cluster_id,
62+
vm_template.id template_id,
63+
vm_template.uuid template_uuid,
64+
service_offering.id service_offering_id,
65+
service_offering.uuid service_offering_uuid,
66+
service_offering.name service_offering_name,
67+
nics.id nic_id,
68+
nics.uuid nic_uuid,
69+
nics.network_id network_id,
70+
nics.ip4_address ip_address,
71+
nics.ip6_address ip6_address,
72+
nics.ip6_gateway ip6_gateway,
73+
nics.ip6_cidr ip6_cidr,
74+
nics.default_nic is_default_nic,
75+
nics.gateway gateway,
76+
nics.netmask netmask,
77+
nics.mac_address mac_address,
78+
nics.broadcast_uri broadcast_uri,
79+
nics.isolation_uri isolation_uri,
80+
vpc.id vpc_id,
81+
vpc.uuid vpc_uuid,
82+
vpc.name vpc_name,
83+
networks.uuid network_uuid,
84+
networks.name network_name,
85+
networks.network_domain network_domain,
86+
networks.traffic_type traffic_type,
87+
networks.guest_type guest_type,
88+
async_job.id job_id,
89+
async_job.uuid job_uuid,
90+
async_job.job_status job_status,
91+
async_job.account_id job_account_id,
92+
domain_router.template_version template_version,
93+
domain_router.scripts_version scripts_version,
94+
domain_router.is_redundant_router is_redundant_router,
95+
domain_router.redundant_state redundant_state,
96+
domain_router.stop_pending stop_pending,
97+
domain_router.role role,
98+
domain_router.software_version software_version
99+
from
100+
`cloud`.`domain_router`
101+
inner join
102+
`cloud`.`vm_instance` ON vm_instance.id = domain_router.id
103+
inner join
104+
`cloud`.`account` ON vm_instance.account_id = account.id
105+
inner join
106+
`cloud`.`domain` ON vm_instance.domain_id = domain.id
107+
left join
108+
`cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
109+
left join
110+
`cloud`.`projects` ON projects.project_account_id = account.id
111+
left join
112+
`cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
113+
left join
114+
`cloud`.`host` ON vm_instance.host_id = host.id
115+
left join
116+
`cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
117+
left join
118+
`cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
119+
left join
120+
`cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null
121+
left join
122+
`cloud`.`networks` ON nics.network_id = networks.id
123+
left join
124+
`cloud`.`vpc` ON domain_router.vpc_id = vpc.id and vpc.removed is null
125+
left join
126+
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
127+
and async_job.instance_type = 'DomainRouter'
128+
and async_job.job_status = 0;

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@
329329
import org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDao;
330330
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
331331
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
332-
import org.apache.commons.lang3.StringUtils;
333332

334333
import javax.annotation.PostConstruct;
335334
import javax.inject.Inject;
@@ -1795,17 +1794,7 @@ public static String findJobInstanceUuid(AsyncJob job) {
17951794
///////////////////////////////////////////////////////////////////////
17961795

17971796
public static DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO vr, Account caller) {
1798-
DomainRouterResponse response = s_domainRouterJoinDao.newDomainRouterResponse(vr, caller);
1799-
if (StringUtils.isBlank(response.getHypervisor())) {
1800-
VMInstanceVO vm = ApiDBUtils.findVMInstanceById(vr.getId());
1801-
if (vm.getLastHostId() != null) {
1802-
HostVO lastHost = ApiDBUtils.findHostById(vm.getLastHostId());
1803-
if (lastHost != null) {
1804-
response.setHypervisor(lastHost.getHypervisorType().toString());
1805-
}
1806-
}
1807-
}
1808-
return response;
1797+
return s_domainRouterJoinDao.newDomainRouterResponse(vr, caller);
18091798
}
18101799

18111800
public static DomainRouterResponse fillRouterDetails(DomainRouterResponse vrData, DomainRouterJoinVO vr) {

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,18 +1538,13 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
15381538
vmResponse.setTemplateName(template.getName());
15391539
}
15401540
vmResponse.setCreated(vm.getCreated());
1541+
vmResponse.setHypervisor(vm.getHypervisorType().toString());
15411542

15421543
if (vm.getHostId() != null) {
15431544
Host host = ApiDBUtils.findHostById(vm.getHostId());
15441545
if (host != null) {
15451546
vmResponse.setHostId(host.getUuid());
15461547
vmResponse.setHostName(host.getName());
1547-
vmResponse.setHypervisor(host.getHypervisorType().toString());
1548-
}
1549-
} else if (vm.getLastHostId() != null) {
1550-
Host lastHost = ApiDBUtils.findHostById(vm.getLastHostId());
1551-
if (lastHost != null) {
1552-
vmResponse.setHypervisor(lastHost.getHypervisorType().toString());
15531548
}
15541549
}
15551550

server/src/main/java/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A
118118
routerResponse.setRequiresUpgrade(true);
119119
}
120120

121+
routerResponse.setHypervisor(router.getHypervisorType().toString());
121122
routerResponse.setHasAnnotation(annotationDao.hasAnnotations(router.getUuid(), AnnotationService.EntityType.VR.name(),
122123
_accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
123124

@@ -126,7 +127,6 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A
126127
if (router.getHostId() != null) {
127128
routerResponse.setHostId(router.getHostUuid());
128129
routerResponse.setHostName(router.getHostName());
129-
routerResponse.setHypervisor(router.getHypervisorType().toString());
130130
}
131131
routerResponse.setPodId(router.getPodUuid());
132132
HostPodVO pod = ApiDBUtils.findPodById(router.getPodId());

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
630630
HypervisorType.Simulator
631631
));
632632

633+
private static final List<HypervisorType> HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS = Arrays.asList(HypervisorType.KVM, HypervisorType.VMware);
634+
633635
@Override
634636
public UserVmVO getVirtualMachine(long vmId) {
635637
return _vmDao.findById(vmId);
@@ -6093,16 +6095,18 @@ private VMInstanceVO preVmStorageMigrationCheck(Long vmId) {
60936095
throw ex;
60946096
}
60956097

6096-
if (vm.getType() != VirtualMachine.Type.User && !HypervisorType.VMware.equals(vm.getHypervisorType())) {
6097-
throw new InvalidParameterValueException("cannot do storage migration on non-user vm for hypervisor: " + vm.getHypervisorType().toString() + ", only supported for VMware");
6098+
HypervisorType hypervisorType = vm.getHypervisorType();
6099+
if (vm.getType() != VirtualMachine.Type.User && !HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS.contains(hypervisorType)) {
6100+
throw new InvalidParameterValueException(String.format("Unable to migrate storage of non-user VMs for hypervisor [%s]. Operation only supported for the following"
6101+
+ " hypervisors: [%s].", hypervisorType, HYPERVISORS_THAT_CAN_DO_STORAGE_MIGRATION_ON_NON_USER_VMS));
60986102
}
60996103

61006104
List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
61016105
if (vols.size() > 1) {
61026106
// OffLineVmwareMigration: data disks are not permitted, here!
61036107
if (vols.size() > 1 &&
61046108
// OffLineVmwareMigration: allow multiple disks for vmware
6105-
!HypervisorType.VMware.equals(vm.getHypervisorType())) {
6109+
!HypervisorType.VMware.equals(hypervisorType)) {
61066110
throw new InvalidParameterValueException("Data disks attached to the vm, can not migrate. Need to detach data disks first");
61076111
}
61086112
}

test/integration/smoke/test_attach_multiple_volumes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
DiskOffering,
2929
)
3030
from marvin.lib.common import (get_domain,
31-
get_zone,
32-
get_template,
33-
find_storage_pool_type)
31+
get_zone,
32+
get_suitable_test_template,
33+
find_storage_pool_type)
3434
from marvin.codes import (
3535
PASS,
3636
FAILED,
@@ -69,13 +69,13 @@ def setUpClass(cls):
6969
)
7070
cls._cleanup.append(cls.disk_offering)
7171

72-
template = get_template(
73-
cls.apiclient,
74-
cls.zone.id,
75-
cls.services["ostype"]
76-
)
72+
template = get_suitable_test_template(
73+
cls.apiclient,
74+
cls.zone.id,
75+
cls.services["ostype"],
76+
cls.hypervisor)
7777
if template == FAILED:
78-
assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
78+
assert False, "get_suitable_test_template() failed to return template with description %s" % cls.services["ostype"]
7979

8080
cls.services["domainid"] = cls.domain.id
8181
cls.services["zoneid"] = cls.zone.id

test/integration/smoke/test_network_permissions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
from marvin.lib.common import (get_domain,
4646
get_zone,
47-
get_template)
47+
get_suitable_test_template)
4848

4949
NETWORK_FILTER_ACCOUNT = 'account'
5050
NETWORK_FILTER_DOMAIN = 'domain'
@@ -66,7 +66,12 @@ def setUpClass(cls):
6666

6767
zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
6868
cls.zone = Zone(zone.__dict__)
69-
cls.template = get_template(cls.apiclient, cls.zone.id)
69+
cls.hypervisor = cls.testClient.getHypervisorInfo()
70+
cls.template = get_suitable_test_template(
71+
cls.apiclient,
72+
cls.zone.id,
73+
cls.services["ostype"],
74+
cls.hypervisor)
7075
cls._cleanup = []
7176

7277
cls.logger = logging.getLogger("TestNetworkPermissions")

0 commit comments

Comments
 (0)