Skip to content

Commit b9d834e

Browse files
committed
CLOUDSTACK-4200: listSystemVMs API and listRouters API should return hypervisor property since dynamic scaling is not enabled for all the hypervisors and that action can be showed only for the hypervisors that support it.
1 parent 129437c commit b9d834e

6 files changed

Lines changed: 139 additions & 0 deletions

File tree

api/src/org/apache/cloudstack/api/response/DomainRouterResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
8585
@Param(description = "the hostname for the router")
8686
private String hostName;
8787

88+
@SerializedName("hypervisor")
89+
@Param(description = "the hypervisor on which the template runs")
90+
private String hypervisor;
91+
8892
@SerializedName(ApiConstants.LINK_LOCAL_IP)
8993
@Param(description = "the link local IP address for the router")
9094
private String linkLocalIp;
@@ -262,6 +266,14 @@ public void setHostName(String hostName) {
262266
this.hostName = hostName;
263267
}
264268

269+
public String getHypervisor() {
270+
return hypervisor;
271+
}
272+
273+
public void setHypervisor(String hypervisor) {
274+
this.hypervisor = hypervisor;
275+
}
276+
265277
public void setPublicIp(String publicIp) {
266278
this.publicIp = publicIp;
267279
}

api/src/org/apache/cloudstack/api/response/SystemVmResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ public class SystemVmResponse extends BaseResponse {
8585
@Param(description = "the hostname for the system VM")
8686
private String hostName;
8787

88+
@SerializedName("hypervisor")
89+
@Param(description = "the hypervisor on which the template runs")
90+
private String hypervisor;
91+
8892
@SerializedName(ApiConstants.PRIVATE_IP)
8993
@Param(description = "the private IP address for the system VM")
9094
private String privateIp;
@@ -240,6 +244,14 @@ public void setHostName(String hostName) {
240244
this.hostName = hostName;
241245
}
242246

247+
public String getHypervisor() {
248+
return hypervisor;
249+
}
250+
251+
public void setHypervisor(String hypervisor) {
252+
this.hypervisor = hypervisor;
253+
}
254+
243255
public String getPrivateIp() {
244256
return privateIp;
245257
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,6 +1166,7 @@ public SystemVmResponse createSystemVmResponse(VirtualMachine vm) {
11661166
if (host != null) {
11671167
vmResponse.setHostId(host.getUuid());
11681168
vmResponse.setHostName(host.getName());
1169+
vmResponse.setHypervisor(host.getHypervisorType().toString());
11691170
}
11701171
}
11711172

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public DomainRouterResponse newDomainRouterResponse(DomainRouterJoinVO router, A
9494
if (router.getHostId() != null) {
9595
routerResponse.setHostId(router.getHostUuid());
9696
routerResponse.setHostName(router.getHostName());
97+
routerResponse.setHypervisor(router.getHypervisorType().toString());
9798
}
9899
routerResponse.setPodId(router.getPodUuid());
99100
long nic_id = router.getNicId();

server/src/com/cloud/api/query/vo/DomainRouterJoinVO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import javax.persistence.Id;
2727
import javax.persistence.Table;
2828

29+
import com.cloud.hypervisor.Hypervisor;
2930
import com.cloud.network.Network.GuestType;
3031
import com.cloud.network.Networks.TrafficType;
3132
import com.cloud.network.router.VirtualRouter;
@@ -126,6 +127,10 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
126127
@Column(name = "host_name", nullable = false)
127128
private String hostName;
128129

130+
@Column(name="hypervisor_type")
131+
@Enumerated(value=EnumType.STRING)
132+
private Hypervisor.HypervisorType hypervisorType;
133+
129134
@Column(name = "template_id", updatable = true, nullable = true, length = 17)
130135
private long templateId;
131136

@@ -338,6 +343,10 @@ public String getHostName() {
338343
return hostName;
339344
}
340345

346+
public Hypervisor.HypervisorType getHypervisorType() {
347+
return hypervisorType;
348+
}
349+
341350
public Long getClusterId() {
342351
return clusterId;
343352
}

setup/db/db/schema-441to450.sql

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,107 @@ CREATE VIEW `cloud`.`template_view` AS
432432

433433
UPDATE configuration SET value='KVM,XenServer,VMware,BareMetal,Ovm,LXC,Hyperv' WHERE name='hypervisor.list';
434434
UPDATE `cloud`.`configuration` SET description="If set to true, will set guest VM's name as it appears on the hypervisor, to its hostname. The flag is supported for VMware hypervisor only" WHERE name='vm.instancename.flag';
435+
DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
436+
CREATE VIEW `cloud`.`domain_router_view` AS
437+
select
438+
vm_instance.id id,
439+
vm_instance.name name,
440+
account.id account_id,
441+
account.uuid account_uuid,
442+
account.account_name account_name,
443+
account.type account_type,
444+
domain.id domain_id,
445+
domain.uuid domain_uuid,
446+
domain.name domain_name,
447+
domain.path domain_path,
448+
projects.id project_id,
449+
projects.uuid project_uuid,
450+
projects.name project_name,
451+
vm_instance.uuid uuid,
452+
vm_instance.created created,
453+
vm_instance.state state,
454+
vm_instance.removed removed,
455+
vm_instance.pod_id pod_id,
456+
vm_instance.instance_name instance_name,
457+
host_pod_ref.uuid pod_uuid,
458+
data_center.id data_center_id,
459+
data_center.uuid data_center_uuid,
460+
data_center.name data_center_name,
461+
data_center.networktype data_center_type,
462+
data_center.dns1 dns1,
463+
data_center.dns2 dns2,
464+
data_center.ip6_dns1 ip6_dns1,
465+
data_center.ip6_dns2 ip6_dns2,
466+
host.id host_id,
467+
host.uuid host_uuid,
468+
host.name host_name,
469+
host.hypervisor_type,
470+
host.cluster_id cluster_id,
471+
vm_template.id template_id,
472+
vm_template.uuid template_uuid,
473+
service_offering.id service_offering_id,
474+
disk_offering.uuid service_offering_uuid,
475+
disk_offering.name service_offering_name,
476+
nics.id nic_id,
477+
nics.uuid nic_uuid,
478+
nics.network_id network_id,
479+
nics.ip4_address ip_address,
480+
nics.ip6_address ip6_address,
481+
nics.ip6_gateway ip6_gateway,
482+
nics.ip6_cidr ip6_cidr,
483+
nics.default_nic is_default_nic,
484+
nics.gateway gateway,
485+
nics.netmask netmask,
486+
nics.mac_address mac_address,
487+
nics.broadcast_uri broadcast_uri,
488+
nics.isolation_uri isolation_uri,
489+
vpc.id vpc_id,
490+
vpc.uuid vpc_uuid,
491+
networks.uuid network_uuid,
492+
networks.name network_name,
493+
networks.network_domain network_domain,
494+
networks.traffic_type traffic_type,
495+
networks.guest_type guest_type,
496+
async_job.id job_id,
497+
async_job.uuid job_uuid,
498+
async_job.job_status job_status,
499+
async_job.account_id job_account_id,
500+
domain_router.template_version template_version,
501+
domain_router.scripts_version scripts_version,
502+
domain_router.is_redundant_router is_redundant_router,
503+
domain_router.redundant_state redundant_state,
504+
domain_router.stop_pending stop_pending,
505+
domain_router.role role
506+
from
507+
`cloud`.`domain_router`
508+
inner join
509+
`cloud`.`vm_instance` ON vm_instance.id = domain_router.id
510+
inner join
511+
`cloud`.`account` ON vm_instance.account_id = account.id
512+
inner join
513+
`cloud`.`domain` ON vm_instance.domain_id = domain.id
514+
left join
515+
`cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
516+
left join
517+
`cloud`.`projects` ON projects.project_account_id = account.id
518+
left join
519+
`cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
520+
left join
521+
`cloud`.`host` ON vm_instance.host_id = host.id
522+
left join
523+
`cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
524+
left join
525+
`cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
526+
left join
527+
`cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
528+
left join
529+
`cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null
530+
left join
531+
`cloud`.`networks` ON nics.network_id = networks.id
532+
left join
533+
`cloud`.`vpc` ON domain_router.vpc_id = vpc.id and vpc.removed is null
534+
left join
535+
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
536+
and async_job.instance_type = 'DomainRouter'
537+
and async_job.job_status = 0;
538+

0 commit comments

Comments
 (0)