CLOUDSTACK-9129: list vpc routers by keyword in Infrastructure -> Virtual Routers

and two more changes:
(1) add network name/vpc name in the listRouters response
(2) add network name/vpc id, vpc name in the router details page
This commit is contained in:
Wei Zhou 2015-12-09 09:07:57 +01:00
parent 738b78886e
commit 24f1396ac1
6 changed files with 205 additions and 0 deletions

View File

@ -137,6 +137,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
@Param(description = "the ID of the corresponding guest network") @Param(description = "the ID of the corresponding guest network")
private String guestNetworkId; private String guestNetworkId;
@SerializedName("guestnetworkname")
@Param(description = "the name of the corresponding guest network")
private String guestNetworkName;
@SerializedName(ApiConstants.TEMPLATE_ID) @SerializedName(ApiConstants.TEMPLATE_ID)
@Param(description = "the template ID for the router") @Param(description = "the template ID for the router")
private String templateId; private String templateId;
@ -197,6 +201,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
@Param(description = "VPC the router belongs to") @Param(description = "VPC the router belongs to")
private String vpcId; private String vpcId;
@SerializedName("vpcname")
@Param(description = "the name of VPC the router belongs to")
private String vpcName;
@SerializedName(ApiConstants.ROLE) @SerializedName(ApiConstants.ROLE)
@Param(description = "role of the domain router") @Param(description = "role of the domain router")
private String role; private String role;
@ -333,6 +341,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
this.guestNetworkId = guestNetworkId; this.guestNetworkId = guestNetworkId;
} }
public void setGuestNetworkName(String guestNetworkName) {
this.guestNetworkName = guestNetworkName;
}
public void setLinkLocalIp(String linkLocalIp) { public void setLinkLocalIp(String linkLocalIp) {
this.linkLocalIp = linkLocalIp; this.linkLocalIp = linkLocalIp;
} }
@ -395,6 +407,10 @@ public class DomainRouterResponse extends BaseResponse implements ControlledView
this.vpcId = vpcId; this.vpcId = vpcId;
} }
public void setVpcName(String vpcName) {
this.vpcName = vpcName;
}
public void setNics(Set<NicResponse> nics) { public void setNics(Set<NicResponse> nics) {
this.nics = nics; this.nics = nics;
} }

View File

@ -1225,6 +1225,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService, Confi
ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("state", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("networkName", SearchCriteria.Op.LIKE, "%" + keyword + "%"); ssc.addOr("networkName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
ssc.addOr("vpcName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
sc.addAnd("instanceName", SearchCriteria.Op.SC, ssc); sc.addAnd("instanceName", SearchCriteria.Op.SC, ssc);
} }

View File

@ -116,6 +116,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
routerResponse.setGuestMacAddress(router.getMacAddress()); routerResponse.setGuestMacAddress(router.getMacAddress());
routerResponse.setGuestNetmask(router.getNetmask()); routerResponse.setGuestNetmask(router.getNetmask());
routerResponse.setGuestNetworkId(router.getNetworkUuid()); routerResponse.setGuestNetworkId(router.getNetworkUuid());
routerResponse.setGuestNetworkName(router.getNetworkName());
routerResponse.setNetworkDomain(router.getNetworkDomain()); routerResponse.setNetworkDomain(router.getNetworkDomain());
} }
} }
@ -166,6 +167,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
routerResponse.setIp6Dns2(router.getIp6Dns2()); routerResponse.setIp6Dns2(router.getIp6Dns2());
routerResponse.setVpcId(router.getVpcUuid()); routerResponse.setVpcId(router.getVpcUuid());
routerResponse.setVpcName(router.getVpcName());
routerResponse.setRole(router.getRole().toString()); routerResponse.setRole(router.getRole().toString());
@ -208,6 +210,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase<DomainRouterJoinVO,
vrData.setGuestMacAddress(vr.getMacAddress()); vrData.setGuestMacAddress(vr.getMacAddress());
vrData.setGuestNetmask(vr.getNetmask()); vrData.setGuestNetmask(vr.getNetmask());
vrData.setGuestNetworkId(vr.getNetworkUuid()); vrData.setGuestNetworkId(vr.getNetworkUuid());
vrData.setGuestNetworkName(vr.getNetworkName());
vrData.setNetworkDomain(vr.getNetworkDomain()); vrData.setNetworkDomain(vr.getNetworkDomain());
} }
} }

View File

@ -152,6 +152,9 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
@Column(name = "vpc_uuid") @Column(name = "vpc_uuid")
private String vpcUuid; private String vpcUuid;
@Column(name = "vpc_name")
private String vpcName;
@Column(name = "nic_id") @Column(name = "nic_id")
private long nicId; private long nicId;
@ -371,6 +374,10 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
return vpcId; return vpcId;
} }
public String getVpcName() {
return vpcName;
}
public long getNicId() { public long getNicId() {
return nicId; return nicId;
} }

View File

@ -140,3 +140,110 @@ INSERT IGNORE INTO `cloud_usage`.`quota_email_templates` (`template_name`, `temp
('QUOTA_UNLOCK_ACCOUNT', 'Quota credits added, account ${accountName} is unlocked now, if it was locked', 'Your account ${accountName} in the domain ${domainName} has enough quota credits now with the current balance of ${quotaBalance}.'), ('QUOTA_UNLOCK_ACCOUNT', 'Quota credits added, account ${accountName} is unlocked now, if it was locked', 'Your account ${accountName} in the domain ${domainName} has enough quota credits now with the current balance of ${quotaBalance}.'),
('QUOTA_STATEMENT', 'Quota Statement for your account ${accountName}', 'Monthly quota statement of your account ${accountName} in the domain ${domainName}:<br>Balance = ${quotaBalance}<br>Total Usage = ${quotaUsage}.'); ('QUOTA_STATEMENT', 'Quota Statement for your account ${accountName}', 'Monthly quota statement of your account ${accountName} in the domain ${domainName}:<br>Balance = ${quotaBalance}<br>Total Usage = ${quotaUsage}.');
UNLOCK TABLES; UNLOCK TABLES;
DROP VIEW IF EXISTS `cloud`.`domain_router_view`;
CREATE VIEW `cloud`.`domain_router_view` AS
select
vm_instance.id id,
vm_instance.name name,
account.id account_id,
account.uuid account_uuid,
account.account_name account_name,
account.type account_type,
domain.id domain_id,
domain.uuid domain_uuid,
domain.name domain_name,
domain.path domain_path,
projects.id project_id,
projects.uuid project_uuid,
projects.name project_name,
vm_instance.uuid uuid,
vm_instance.created created,
vm_instance.state state,
vm_instance.removed removed,
vm_instance.pod_id pod_id,
vm_instance.instance_name instance_name,
host_pod_ref.uuid pod_uuid,
data_center.id data_center_id,
data_center.uuid data_center_uuid,
data_center.name data_center_name,
data_center.networktype data_center_type,
data_center.dns1 dns1,
data_center.dns2 dns2,
data_center.ip6_dns1 ip6_dns1,
data_center.ip6_dns2 ip6_dns2,
host.id host_id,
host.uuid host_uuid,
host.name host_name,
host.hypervisor_type,
host.cluster_id cluster_id,
vm_template.id template_id,
vm_template.uuid template_uuid,
service_offering.id service_offering_id,
disk_offering.uuid service_offering_uuid,
disk_offering.name service_offering_name,
nics.id nic_id,
nics.uuid nic_uuid,
nics.network_id network_id,
nics.ip4_address ip_address,
nics.ip6_address ip6_address,
nics.ip6_gateway ip6_gateway,
nics.ip6_cidr ip6_cidr,
nics.default_nic is_default_nic,
nics.gateway gateway,
nics.netmask netmask,
nics.mac_address mac_address,
nics.broadcast_uri broadcast_uri,
nics.isolation_uri isolation_uri,
vpc.id vpc_id,
vpc.uuid vpc_uuid,
vpc.name vpc_name,
networks.uuid network_uuid,
networks.name network_name,
networks.network_domain network_domain,
networks.traffic_type traffic_type,
networks.guest_type guest_type,
async_job.id job_id,
async_job.uuid job_uuid,
async_job.job_status job_status,
async_job.account_id job_account_id,
domain_router.template_version template_version,
domain_router.scripts_version scripts_version,
domain_router.is_redundant_router is_redundant_router,
domain_router.redundant_state redundant_state,
domain_router.stop_pending stop_pending,
domain_router.role role
from
`cloud`.`domain_router`
inner join
`cloud`.`vm_instance` ON vm_instance.id = domain_router.id
inner join
`cloud`.`account` ON vm_instance.account_id = account.id
inner join
`cloud`.`domain` ON vm_instance.domain_id = domain.id
left join
`cloud`.`host_pod_ref` ON vm_instance.pod_id = host_pod_ref.id
left join
`cloud`.`projects` ON projects.project_account_id = account.id
left join
`cloud`.`data_center` ON vm_instance.data_center_id = data_center.id
left join
`cloud`.`host` ON vm_instance.host_id = host.id
left join
`cloud`.`vm_template` ON vm_instance.vm_template_id = vm_template.id
left join
`cloud`.`service_offering` ON vm_instance.service_offering_id = service_offering.id
left join
`cloud`.`disk_offering` ON vm_instance.service_offering_id = disk_offering.id
left join
`cloud`.`nics` ON vm_instance.id = nics.instance_id and nics.removed is null
left join
`cloud`.`networks` ON nics.network_id = networks.id
left join
`cloud`.`vpc` ON domain_router.vpc_id = vpc.id and vpc.removed is null
left join
`cloud`.`async_job` ON async_job.instance_id = vm_instance.id
and async_job.instance_type = 'DomainRouter'
and async_job.job_status = 0;

View File

@ -2721,6 +2721,15 @@
hiddenFields.push('publicip'); hiddenFields.push('publicip');
//In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API. //In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API.
} }
if ('routers' in args.context && args.context.routers[0].vpcid != undefined) {
hiddenFields.push('guestnetworkid');
hiddenFields.push('guestnetworkname');
} else if ('routers' in args.context && args.context.routers[0].guestnetworkid != undefined) {
hiddenFields.push('vpcid');
hiddenFields.push('vpcname');
}
return hiddenFields; return hiddenFields;
}, },
fields:[ { fields:[ {
@ -2744,6 +2753,15 @@
guestnetworkid: { guestnetworkid: {
label: 'label.network.id' label: 'label.network.id'
}, },
guestnetworkname: {
label: 'label.network.name'
},
vpcid: {
label: 'label.vpc.id'
},
vpcname: {
label: 'label.vpc'
},
publicip: { publicip: {
label: 'label.public.ip' label: 'label.public.ip'
}, },
@ -3247,6 +3265,15 @@
hiddenFields.push('publicip'); hiddenFields.push('publicip');
//In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API. //In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API.
} }
if ('routers' in args.context && args.context.routers[0].vpcid != undefined) {
hiddenFields.push('guestnetworkid');
hiddenFields.push('guestnetworkname');
} else if ('routers' in args.context && args.context.routers[0].guestnetworkid != undefined) {
hiddenFields.push('vpcid');
hiddenFields.push('vpcname');
}
return hiddenFields; return hiddenFields;
}, },
fields:[ { fields:[ {
@ -3270,6 +3297,15 @@
guestnetworkid: { guestnetworkid: {
label: 'label.network.id' label: 'label.network.id'
}, },
guestnetworkname: {
label: 'label.network.name'
},
vpcid: {
label: 'label.vpc.id'
},
vpcname: {
label: 'label.vpc'
},
publicip: { publicip: {
label: 'label.public.ip' label: 'label.public.ip'
}, },
@ -6771,6 +6807,15 @@
hiddenFields.push('publicip'); hiddenFields.push('publicip');
//In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API. //In Basic zone, guest IP is public IP. So, publicip is not returned by listRouters API. Only guestipaddress is returned by listRouters API.
} }
if ('routers' in args.context && args.context.routers[0].vpcid != undefined) {
hiddenFields.push('guestnetworkid');
hiddenFields.push('guestnetworkname');
} else if ('routers' in args.context && args.context.routers[0].guestnetworkid != undefined) {
hiddenFields.push('vpcid');
hiddenFields.push('vpcname');
}
return hiddenFields; return hiddenFields;
}, },
fields:[ { fields:[ {
@ -6794,6 +6839,15 @@
guestnetworkid: { guestnetworkid: {
label: 'label.network.id' label: 'label.network.id'
}, },
guestnetworkname: {
label: 'label.network.name'
},
vpcid: {
label: 'label.vpc.id'
},
vpcname: {
label: 'label.vpc'
},
publicip: { publicip: {
label: 'label.public.ip' label: 'label.public.ip'
}, },
@ -10042,6 +10096,14 @@
} }
}); });
if ('routers' in args.context && args.context.routers[0].vpcid != undefined) {
hiddenFields.push('guestnetworkid');
hiddenFields.push('guestnetworkname');
} else if ('routers' in args.context && args.context.routers[0].guestnetworkid != undefined) {
hiddenFields.push('vpcid');
hiddenFields.push('vpcname');
}
return hiddenFields; return hiddenFields;
}, },
fields:[ { fields:[ {
@ -10072,6 +10134,15 @@
guestnetworkid: { guestnetworkid: {
label: 'label.network.id' label: 'label.network.id'
}, },
guestnetworkname: {
label: 'label.network.name'
},
vpcid: {
label: 'label.vpc.id'
},
vpcname: {
label: 'label.vpc'
},
publicip: { publicip: {
label: 'label.public.ip' label: 'label.public.ip'
}, },