Skip to content

Commit 7bc5f2a

Browse files
committed
Include view changes in schema upgrade files and use feature in various UI elements
1 parent 0cf2fe8 commit 7bc5f2a

5 files changed

Lines changed: 339 additions & 12 deletions

File tree

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 312 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,315 @@ WHERE rp.rule = 'quotaStatement'
3737
AND NOT EXISTS(SELECT 1 FROM cloud.role_permissions rp_ WHERE rp.role_id = rp_.role_id AND rp_.rule = 'quotaCreditsList');
3838

3939
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.host', 'last_mgmt_server_id', 'bigint unsigned DEFAULT NULL COMMENT "last management server this host is connected to" AFTER `mgmt_server_id`');
40+
41+
-- Add column lease_duration and lease_expiry_action to service_offering_view
42+
DROP VIEW IF EXISTS `cloud`.`service_offering_view`;
43+
44+
CREATE VIEW `cloud`.`service_offering_view` AS
45+
SELECT
46+
`service_offering`.`id` AS `id`,
47+
`service_offering`.`uuid` AS `uuid`,
48+
`service_offering`.`name` AS `name`,
49+
`service_offering`.`state` AS `state`,
50+
`service_offering`.`display_text` AS `display_text`,
51+
`disk_offering`.`provisioning_type` AS `provisioning_type`,
52+
`service_offering`.`created` AS `created`,
53+
`disk_offering`.`tags` AS `tags`,
54+
`service_offering`.`removed` AS `removed`,
55+
`disk_offering`.`use_local_storage` AS `use_local_storage`,
56+
`service_offering`.`system_use` AS `system_use`,
57+
`disk_offering`.`id` AS `disk_offering_id`,
58+
`disk_offering`.`name` AS `disk_offering_name`,
59+
`disk_offering`.`uuid` AS `disk_offering_uuid`,
60+
`disk_offering`.`display_text` AS `disk_offering_display_text`,
61+
`disk_offering`.`customized_iops` AS `customized_iops`,
62+
`disk_offering`.`min_iops` AS `min_iops`,
63+
`disk_offering`.`max_iops` AS `max_iops`,
64+
`disk_offering`.`hv_ss_reserve` AS `hv_ss_reserve`,
65+
`disk_offering`.`bytes_read_rate` AS `bytes_read_rate`,
66+
`disk_offering`.`bytes_read_rate_max` AS `bytes_read_rate_max`,
67+
`disk_offering`.`bytes_read_rate_max_length` AS `bytes_read_rate_max_length`,
68+
`disk_offering`.`bytes_write_rate` AS `bytes_write_rate`,
69+
`disk_offering`.`bytes_write_rate_max` AS `bytes_write_rate_max`,
70+
`disk_offering`.`bytes_write_rate_max_length` AS `bytes_write_rate_max_length`,
71+
`disk_offering`.`iops_read_rate` AS `iops_read_rate`,
72+
`disk_offering`.`iops_read_rate_max` AS `iops_read_rate_max`,
73+
`disk_offering`.`iops_read_rate_max_length` AS `iops_read_rate_max_length`,
74+
`disk_offering`.`iops_write_rate` AS `iops_write_rate`,
75+
`disk_offering`.`iops_write_rate_max` AS `iops_write_rate_max`,
76+
`disk_offering`.`iops_write_rate_max_length` AS `iops_write_rate_max_length`,
77+
`disk_offering`.`cache_mode` AS `cache_mode`,
78+
`disk_offering`.`disk_size` AS `root_disk_size`,
79+
`disk_offering`.`encrypt` AS `encrypt_root`,
80+
`service_offering`.`cpu` AS `cpu`,
81+
`service_offering`.`speed` AS `speed`,
82+
`service_offering`.`ram_size` AS `ram_size`,
83+
`service_offering`.`nw_rate` AS `nw_rate`,
84+
`service_offering`.`mc_rate` AS `mc_rate`,
85+
`service_offering`.`ha_enabled` AS `ha_enabled`,
86+
`service_offering`.`limit_cpu_use` AS `limit_cpu_use`,
87+
`service_offering`.`host_tag` AS `host_tag`,
88+
`service_offering`.`default_use` AS `default_use`,
89+
`service_offering`.`vm_type` AS `vm_type`,
90+
`service_offering`.`sort_key` AS `sort_key`,
91+
`service_offering`.`is_volatile` AS `is_volatile`,
92+
`service_offering`.`deployment_planner` AS `deployment_planner`,
93+
`service_offering`.`dynamic_scaling_enabled` AS `dynamic_scaling_enabled`,
94+
`service_offering`.`disk_offering_strictness` AS `disk_offering_strictness`,
95+
`vsphere_storage_policy`.`value` AS `vsphere_storage_policy`,
96+
`lease_duration_details`.`value` AS `lease_duration`,
97+
`lease_expiry_action_details`.`value` AS `lease_expiry_action`,
98+
GROUP_CONCAT(DISTINCT(domain.id)) AS domain_id,
99+
GROUP_CONCAT(DISTINCT(domain.uuid)) AS domain_uuid,
100+
GROUP_CONCAT(DISTINCT(domain.name)) AS domain_name,
101+
GROUP_CONCAT(DISTINCT(domain.path)) AS domain_path,
102+
GROUP_CONCAT(DISTINCT(zone.id)) AS zone_id,
103+
GROUP_CONCAT(DISTINCT(zone.uuid)) AS zone_uuid,
104+
GROUP_CONCAT(DISTINCT(zone.name)) AS zone_name,
105+
IFNULL(`min_compute_details`.`value`, `cpu`) AS min_cpu,
106+
IFNULL(`max_compute_details`.`value`, `cpu`) AS max_cpu,
107+
IFNULL(`min_memory_details`.`value`, `ram_size`) AS min_memory,
108+
IFNULL(`max_memory_details`.`value`, `ram_size`) AS max_memory
109+
FROM
110+
`cloud`.`service_offering`
111+
INNER JOIN
112+
`cloud`.`disk_offering` ON service_offering.disk_offering_id = disk_offering.id
113+
LEFT JOIN
114+
`cloud`.`service_offering_details` AS `domain_details` ON `domain_details`.`service_offering_id` = `service_offering`.`id` AND `domain_details`.`name`='domainid'
115+
LEFT JOIN
116+
`cloud`.`domain` AS `domain` ON FIND_IN_SET(`domain`.`id`, `domain_details`.`value`)
117+
LEFT JOIN
118+
`cloud`.`service_offering_details` AS `zone_details` ON `zone_details`.`service_offering_id` = `service_offering`.`id` AND `zone_details`.`name`='zoneid'
119+
LEFT JOIN
120+
`cloud`.`data_center` AS `zone` ON FIND_IN_SET(`zone`.`id`, `zone_details`.`value`)
121+
LEFT JOIN
122+
`cloud`.`service_offering_details` AS `min_compute_details` ON `min_compute_details`.`service_offering_id` = `service_offering`.`id`
123+
AND `min_compute_details`.`name` = 'mincpunumber'
124+
LEFT JOIN
125+
`cloud`.`service_offering_details` AS `max_compute_details` ON `max_compute_details`.`service_offering_id` = `service_offering`.`id`
126+
AND `max_compute_details`.`name` = 'maxcpunumber'
127+
LEFT JOIN
128+
`cloud`.`service_offering_details` AS `min_memory_details` ON `min_memory_details`.`service_offering_id` = `service_offering`.`id`
129+
AND `min_memory_details`.`name` = 'minmemory'
130+
LEFT JOIN
131+
`cloud`.`service_offering_details` AS `max_memory_details` ON `max_memory_details`.`service_offering_id` = `service_offering`.`id`
132+
AND `max_memory_details`.`name` = 'maxmemory'
133+
LEFT JOIN
134+
`cloud`.`service_offering_details` AS `vsphere_storage_policy` ON `vsphere_storage_policy`.`service_offering_id` = `service_offering`.`id`
135+
AND `vsphere_storage_policy`.`name` = 'storagepolicy'
136+
LEFT JOIN
137+
`cloud`.`service_offering_details` AS `lease_duration_details` ON `lease_duration_details`.`service_offering_id` = `service_offering`.`id`
138+
AND `lease_duration_details`.`name` = 'leaseduration'
139+
LEFT JOIN
140+
`cloud`.`service_offering_details` AS `lease_expiry_action_details` ON `lease_expiry_action_details`.`service_offering_id` = `service_offering`.`id`
141+
AND `lease_expiry_action_details`.`name` = 'leaseexpiryaction'
142+
GROUP BY
143+
`service_offering`.`id`;
144+
145+
-- Add lease_expiry_date and lease_expiry_action to user_vm_view
146+
147+
DROP VIEW IF EXISTS `cloud`.`user_vm_view`;
148+
149+
CREATE VIEW `user_vm_view` AS
150+
SELECT
151+
`vm_instance`.`id` AS `id`,
152+
`vm_instance`.`name` AS `name`,
153+
`user_vm`.`display_name` AS `display_name`,
154+
`user_vm`.`user_data` AS `user_data`,
155+
`user_vm`.`user_vm_type` AS `user_vm_type`,
156+
`account`.`id` AS `account_id`,
157+
`account`.`uuid` AS `account_uuid`,
158+
`account`.`account_name` AS `account_name`,
159+
`account`.`type` AS `account_type`,
160+
`domain`.`id` AS `domain_id`,
161+
`domain`.`uuid` AS `domain_uuid`,
162+
`domain`.`name` AS `domain_name`,
163+
`domain`.`path` AS `domain_path`,
164+
`projects`.`id` AS `project_id`,
165+
`projects`.`uuid` AS `project_uuid`,
166+
`projects`.`name` AS `project_name`,
167+
`instance_group`.`id` AS `instance_group_id`,
168+
`instance_group`.`uuid` AS `instance_group_uuid`,
169+
`instance_group`.`name` AS `instance_group_name`,
170+
`vm_instance`.`uuid` AS `uuid`,
171+
`vm_instance`.`user_id` AS `user_id`,
172+
`vm_instance`.`last_host_id` AS `last_host_id`,
173+
`vm_instance`.`vm_type` AS `type`,
174+
`vm_instance`.`limit_cpu_use` AS `limit_cpu_use`,
175+
`vm_instance`.`created` AS `created`,
176+
`vm_instance`.`state` AS `state`,
177+
`vm_instance`.`update_time` AS `update_time`,
178+
`vm_instance`.`removed` AS `removed`,
179+
`vm_instance`.`ha_enabled` AS `ha_enabled`,
180+
`vm_instance`.`hypervisor_type` AS `hypervisor_type`,
181+
`vm_instance`.`instance_name` AS `instance_name`,
182+
`vm_instance`.`guest_os_id` AS `guest_os_id`,
183+
`vm_instance`.`display_vm` AS `display_vm`,
184+
`vm_instance`.`delete_protection` AS `delete_protection`,
185+
`guest_os`.`uuid` AS `guest_os_uuid`,
186+
`vm_instance`.`pod_id` AS `pod_id`,
187+
`host_pod_ref`.`uuid` AS `pod_uuid`,
188+
`vm_instance`.`private_ip_address` AS `private_ip_address`,
189+
`vm_instance`.`private_mac_address` AS `private_mac_address`,
190+
`vm_instance`.`vm_type` AS `vm_type`,
191+
`data_center`.`id` AS `data_center_id`,
192+
`data_center`.`uuid` AS `data_center_uuid`,
193+
`data_center`.`name` AS `data_center_name`,
194+
`data_center`.`is_security_group_enabled` AS `security_group_enabled`,
195+
`data_center`.`networktype` AS `data_center_network_type`,
196+
`host`.`id` AS `host_id`,
197+
`host`.`uuid` AS `host_uuid`,
198+
`host`.`name` AS `host_name`,
199+
`host`.`cluster_id` AS `cluster_id`,
200+
`host`.`status` AS `host_status`,
201+
`host`.`resource_state` AS `host_resource_state`,
202+
`vm_template`.`id` AS `template_id`,
203+
`vm_template`.`uuid` AS `template_uuid`,
204+
`vm_template`.`name` AS `template_name`,
205+
`vm_template`.`type` AS `template_type`,
206+
`vm_template`.`format` AS `template_format`,
207+
`vm_template`.`display_text` AS `template_display_text`,
208+
`vm_template`.`enable_password` AS `password_enabled`,
209+
`iso`.`id` AS `iso_id`,
210+
`iso`.`uuid` AS `iso_uuid`,
211+
`iso`.`name` AS `iso_name`,
212+
`iso`.`display_text` AS `iso_display_text`,
213+
`service_offering`.`id` AS `service_offering_id`,
214+
`service_offering`.`uuid` AS `service_offering_uuid`,
215+
`disk_offering`.`uuid` AS `disk_offering_uuid`,
216+
`disk_offering`.`id` AS `disk_offering_id`,
217+
(CASE
218+
WHEN ISNULL(`service_offering`.`cpu`) THEN `custom_cpu`.`value`
219+
ELSE `service_offering`.`cpu`
220+
END) AS `cpu`,
221+
(CASE
222+
WHEN ISNULL(`service_offering`.`speed`) THEN `custom_speed`.`value`
223+
ELSE `service_offering`.`speed`
224+
END) AS `speed`,
225+
(CASE
226+
WHEN ISNULL(`service_offering`.`ram_size`) THEN `custom_ram_size`.`value`
227+
ELSE `service_offering`.`ram_size`
228+
END) AS `ram_size`,
229+
`backup_offering`.`uuid` AS `backup_offering_uuid`,
230+
`backup_offering`.`id` AS `backup_offering_id`,
231+
`service_offering`.`name` AS `service_offering_name`,
232+
`disk_offering`.`name` AS `disk_offering_name`,
233+
`backup_offering`.`name` AS `backup_offering_name`,
234+
`storage_pool`.`id` AS `pool_id`,
235+
`storage_pool`.`uuid` AS `pool_uuid`,
236+
`storage_pool`.`pool_type` AS `pool_type`,
237+
`volumes`.`id` AS `volume_id`,
238+
`volumes`.`uuid` AS `volume_uuid`,
239+
`volumes`.`device_id` AS `volume_device_id`,
240+
`volumes`.`volume_type` AS `volume_type`,
241+
`security_group`.`id` AS `security_group_id`,
242+
`security_group`.`uuid` AS `security_group_uuid`,
243+
`security_group`.`name` AS `security_group_name`,
244+
`security_group`.`description` AS `security_group_description`,
245+
`nics`.`id` AS `nic_id`,
246+
`nics`.`uuid` AS `nic_uuid`,
247+
`nics`.`device_id` AS `nic_device_id`,
248+
`nics`.`network_id` AS `network_id`,
249+
`nics`.`ip4_address` AS `ip_address`,
250+
`nics`.`ip6_address` AS `ip6_address`,
251+
`nics`.`ip6_gateway` AS `ip6_gateway`,
252+
`nics`.`ip6_cidr` AS `ip6_cidr`,
253+
`nics`.`default_nic` AS `is_default_nic`,
254+
`nics`.`gateway` AS `gateway`,
255+
`nics`.`netmask` AS `netmask`,
256+
`nics`.`mac_address` AS `mac_address`,
257+
`nics`.`broadcast_uri` AS `broadcast_uri`,
258+
`nics`.`isolation_uri` AS `isolation_uri`,
259+
`vpc`.`id` AS `vpc_id`,
260+
`vpc`.`uuid` AS `vpc_uuid`,
261+
`networks`.`uuid` AS `network_uuid`,
262+
`networks`.`name` AS `network_name`,
263+
`networks`.`traffic_type` AS `traffic_type`,
264+
`networks`.`guest_type` AS `guest_type`,
265+
`user_ip_address`.`id` AS `public_ip_id`,
266+
`user_ip_address`.`uuid` AS `public_ip_uuid`,
267+
`user_ip_address`.`public_ip_address` AS `public_ip_address`,
268+
`ssh_details`.`value` AS `keypair_names`,
269+
`resource_tags`.`id` AS `tag_id`,
270+
`resource_tags`.`uuid` AS `tag_uuid`,
271+
`resource_tags`.`key` AS `tag_key`,
272+
`resource_tags`.`value` AS `tag_value`,
273+
`resource_tags`.`domain_id` AS `tag_domain_id`,
274+
`domain`.`uuid` AS `tag_domain_uuid`,
275+
`domain`.`name` AS `tag_domain_name`,
276+
`resource_tags`.`account_id` AS `tag_account_id`,
277+
`account`.`account_name` AS `tag_account_name`,
278+
`resource_tags`.`resource_id` AS `tag_resource_id`,
279+
`resource_tags`.`resource_uuid` AS `tag_resource_uuid`,
280+
`resource_tags`.`resource_type` AS `tag_resource_type`,
281+
`resource_tags`.`customer` AS `tag_customer`,
282+
`async_job`.`id` AS `job_id`,
283+
`async_job`.`uuid` AS `job_uuid`,
284+
`async_job`.`job_status` AS `job_status`,
285+
`async_job`.`account_id` AS `job_account_id`,
286+
`affinity_group`.`id` AS `affinity_group_id`,
287+
`affinity_group`.`uuid` AS `affinity_group_uuid`,
288+
`affinity_group`.`name` AS `affinity_group_name`,
289+
`affinity_group`.`description` AS `affinity_group_description`,
290+
`autoscale_vmgroups`.`id` AS `autoscale_vmgroup_id`,
291+
`autoscale_vmgroups`.`uuid` AS `autoscale_vmgroup_uuid`,
292+
`autoscale_vmgroups`.`name` AS `autoscale_vmgroup_name`,
293+
`vm_instance`.`dynamically_scalable` AS `dynamically_scalable`,
294+
`user_data`.`id` AS `user_data_id`,
295+
`user_data`.`uuid` AS `user_data_uuid`,
296+
`user_data`.`name` AS `user_data_name`,
297+
`user_vm`.`user_data_details` AS `user_data_details`,
298+
`vm_template`.`user_data_link_policy` AS `user_data_policy`,
299+
`lease_expiry_date`.`value` AS `lease_expiry_date`,
300+
`lease_expiry_action`.`value` AS `lease_expiry_action`
301+
FROM
302+
(((((((((((((((((((((((((((((((((((`user_vm`
303+
JOIN `vm_instance` ON (((`vm_instance`.`id` = `user_vm`.`id`)
304+
AND ISNULL(`vm_instance`.`removed`))))
305+
JOIN `account` ON ((`vm_instance`.`account_id` = `account`.`id`)))
306+
JOIN `domain` ON ((`vm_instance`.`domain_id` = `domain`.`id`)))
307+
LEFT JOIN `guest_os` ON ((`vm_instance`.`guest_os_id` = `guest_os`.`id`)))
308+
LEFT JOIN `host_pod_ref` ON ((`vm_instance`.`pod_id` = `host_pod_ref`.`id`)))
309+
LEFT JOIN `projects` ON ((`projects`.`project_account_id` = `account`.`id`)))
310+
LEFT JOIN `instance_group_vm_map` ON ((`vm_instance`.`id` = `instance_group_vm_map`.`instance_id`)))
311+
LEFT JOIN `instance_group` ON ((`instance_group_vm_map`.`group_id` = `instance_group`.`id`)))
312+
LEFT JOIN `data_center` ON ((`vm_instance`.`data_center_id` = `data_center`.`id`)))
313+
LEFT JOIN `host` ON ((`vm_instance`.`host_id` = `host`.`id`)))
314+
LEFT JOIN `vm_template` ON ((`vm_instance`.`vm_template_id` = `vm_template`.`id`)))
315+
LEFT JOIN `vm_template` `iso` ON ((`iso`.`id` = `user_vm`.`iso_id`)))
316+
LEFT JOIN `volumes` ON ((`vm_instance`.`id` = `volumes`.`instance_id`)))
317+
LEFT JOIN `service_offering` ON ((`vm_instance`.`service_offering_id` = `service_offering`.`id`)))
318+
LEFT JOIN `disk_offering` `svc_disk_offering` ON ((`volumes`.`disk_offering_id` = `svc_disk_offering`.`id`)))
319+
LEFT JOIN `disk_offering` ON ((`volumes`.`disk_offering_id` = `disk_offering`.`id`)))
320+
LEFT JOIN `backup_offering` ON ((`vm_instance`.`backup_offering_id` = `backup_offering`.`id`)))
321+
LEFT JOIN `storage_pool` ON ((`volumes`.`pool_id` = `storage_pool`.`id`)))
322+
LEFT JOIN `security_group_vm_map` ON ((`vm_instance`.`id` = `security_group_vm_map`.`instance_id`)))
323+
LEFT JOIN `security_group` ON ((`security_group_vm_map`.`security_group_id` = `security_group`.`id`)))
324+
LEFT JOIN `user_data` ON ((`user_data`.`id` = `user_vm`.`user_data_id`)))
325+
LEFT JOIN `nics` ON (((`vm_instance`.`id` = `nics`.`instance_id`)
326+
AND ISNULL(`nics`.`removed`))))
327+
LEFT JOIN `networks` ON ((`nics`.`network_id` = `networks`.`id`)))
328+
LEFT JOIN `vpc` ON (((`networks`.`vpc_id` = `vpc`.`id`)
329+
AND ISNULL(`vpc`.`removed`))))
330+
LEFT JOIN `user_ip_address` FORCE INDEX(`fk_user_ip_address__vm_id`) ON ((`user_ip_address`.`vm_id` = `vm_instance`.`id`)))
331+
LEFT JOIN `user_vm_details` `ssh_details` ON (((`ssh_details`.`vm_id` = `vm_instance`.`id`)
332+
AND (`ssh_details`.`name` = 'SSH.KeyPairNames'))))
333+
LEFT JOIN `resource_tags` ON (((`resource_tags`.`resource_id` = `vm_instance`.`id`)
334+
AND (`resource_tags`.`resource_type` = 'UserVm'))))
335+
LEFT JOIN `async_job` ON (((`async_job`.`instance_id` = `vm_instance`.`id`)
336+
AND (`async_job`.`instance_type` = 'VirtualMachine')
337+
AND (`async_job`.`job_status` = 0))))
338+
LEFT JOIN `affinity_group_vm_map` ON ((`vm_instance`.`id` = `affinity_group_vm_map`.`instance_id`)))
339+
LEFT JOIN `affinity_group` ON ((`affinity_group_vm_map`.`affinity_group_id` = `affinity_group`.`id`)))
340+
LEFT JOIN `autoscale_vmgroup_vm_map` ON ((`autoscale_vmgroup_vm_map`.`instance_id` = `vm_instance`.`id`)))
341+
LEFT JOIN `autoscale_vmgroups` ON ((`autoscale_vmgroup_vm_map`.`vmgroup_id` = `autoscale_vmgroups`.`id`)))
342+
LEFT JOIN `user_vm_details` `custom_cpu` ON (((`custom_cpu`.`vm_id` = `vm_instance`.`id`)
343+
AND (`custom_cpu`.`name` = 'CpuNumber'))))
344+
LEFT JOIN `user_vm_details` `custom_speed` ON (((`custom_speed`.`vm_id` = `vm_instance`.`id`)
345+
AND (`custom_speed`.`name` = 'CpuSpeed'))))
346+
LEFT JOIN `user_vm_details` `custom_ram_size` ON (((`custom_ram_size`.`vm_id` = `vm_instance`.`id`)
347+
AND (`custom_ram_size`.`name` = 'memory')))
348+
LEFT JOIN `user_vm_details` `lease_expiry_date` ON ((`lease_expiry_date`.`vm_id` = `vm_instance`.`id`)
349+
AND (`lease_expiry_date`.`name` = 'leaseexpirydate'))
350+
LEFT JOIN `user_vm_details` `lease_expiry_action` ON (((`lease_expiry_action`.`vm_id` = `vm_instance`.`id`)
351+
AND (`lease_expiry_action`.`name` = 'leaseexpiryaction'))));

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
163163
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
164164
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
165+
import org.apache.cloudstack.vm.lease.VMLeaseManagerImpl;
165166
import org.apache.commons.collections.CollectionUtils;
166167
import org.apache.commons.collections.MapUtils;
167168
import org.apache.commons.lang3.EnumUtils;
@@ -1477,7 +1478,7 @@ private Pair<List<Long>, Integer> searchForUserVMIdsAndCount(ListVMsCmd cmd) {
14771478
userVmSearchBuilder.join("tags", resourceTagSearch, resourceTagSearch.entity().getResourceId(), userVmSearchBuilder.entity().getId(), JoinBuilder.JoinType.INNER);
14781479
}
14791480

1480-
if (cmd.getOnlyLeasedInstances() != null && cmd.getOnlyLeasedInstances()) {
1481+
if (VMLeaseManagerImpl.InstanceLeaseEnabled.value() && cmd.getOnlyLeasedInstances() != null && cmd.getOnlyLeasedInstances()) {
14811482
SearchBuilder<UserVmDetailVO> leasedInstancesSearch = userVmDetailsDao.createSearchBuilder();
14821483
leasedInstancesSearch.and(VmDetailConstants.INSTANCE_LEASE_EXPIRY_DATE, leasedInstancesSearch.entity().getName(), SearchCriteria.Op.NNULL);
14831484
userVmSearchBuilder.join("userVmToLeased", leasedInstancesSearch, leasedInstancesSearch.entity().getResourceId(), userVmSearchBuilder.entity().getId(), JoinBuilder.JoinType.INNER);

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
3434
import org.apache.cloudstack.context.CallContext;
3535
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
36+
import org.apache.cloudstack.vm.lease.VMLeaseManagerImpl;
3637
import org.apache.commons.lang3.StringUtils;
3738
import org.springframework.stereotype.Component;
3839

@@ -176,7 +177,7 @@ public ServiceOfferingResponse newServiceOfferingResponse(ServiceOfferingJoinVO
176177
}
177178
}
178179

179-
if (offering.getLeaseDuration() != null && offering.getLeaseDuration() != -1L) {
180+
if (VMLeaseManagerImpl.InstanceLeaseEnabled.value() && offering.getLeaseDuration() != null && offering.getLeaseDuration() != -1L) {
180181
offeringResponse.setLeaseDuration(offering.getLeaseDuration());
181182
offeringResponse.setLeaseExpiryAction(offering.getLeaseExpiryAction());
182183
}

0 commit comments

Comments
 (0)