bug 13903: return vm's hostName as a displayName when displayName is null in bunch of api responses

status 13903: resolved fixed
Reviewed-by: Kelven Yang
This commit is contained in:
Alena Prokharchyk 2012-02-21 10:38:40 -08:00
parent 11e4ded985
commit 12b79da6c2
4 changed files with 34 additions and 153 deletions

View File

@ -84,11 +84,12 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
@Parameter(name=ApiConstants.SOURCE_NAT_SUPPORTED, type=CommandType.BOOLEAN, description="true if need to list only netwok offerings where source nat is supported, false otherwise")
private Boolean sourceNatSupported;
@Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if need to list only network offerings which support specifying ip ranges")
private Boolean specifyIpRanges;
@Parameter(name=ApiConstants.TAGS, type=CommandType.STRING, description="list network offerings by tags", length=4096)
private String tags;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -149,7 +150,11 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
return specifyIpRanges;
}
/////////////////////////////////////////////////////
public String getTags() {
return tags;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override

View File

@ -1,146 +0,0 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.api.response;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class IsoVmResponse extends BaseResponse {
@SerializedName("id") @Param(description="the ISO ID")
private IdentityProxy id = new IdentityProxy("vm_template");
@SerializedName("name") @Param(description="the ISO name")
private String name;
@SerializedName("displaytext") @Param(description="the ISO display text")
private String displayText;
@SerializedName("bootable") @Param(description="true if the ISO is bootable, false otherwise")
private Boolean bootable;
@SerializedName("isfeatured") @Param(description="true if this template is a featured template, false otherwise")
private Boolean featured;
@SerializedName("ostypeid") @Param(description="the ID of the OS type for this template.")
private IdentityProxy osTypeId = new IdentityProxy("guest_os");
@SerializedName("ostypename") @Param(description="the name of the OS type for this template.")
private String osTypeName;
@SerializedName("virtualmachineid") @Param(description="id of the virtual machine")
private IdentityProxy virtualMachineId = new IdentityProxy("vm_instance");
@SerializedName("vmname") @Param(description="name of the virtual machine")
private String virtualMachineName;
@SerializedName("vmdisplayname") @Param(description="display name of the virtual machine")
private String virtualMachineDisplayName;
@SerializedName("vmstate") @Param(description="state of the virtual machine")
private String virtualMachineState;
public Long getOsTypeId() {
return osTypeId.getValue();
}
public void setOsTypeId(Long osTypeId) {
this.osTypeId.setValue(osTypeId);
}
public String getOsTypeName() {
return osTypeName;
}
public void setOsTypeName(String osTypeName) {
this.osTypeName = osTypeName;
}
public Long getId() {
return id.getValue();
}
public void setId(Long id) {
this.id.setValue(id);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplayText() {
return displayText;
}
public void setDisplayText(String displayText) {
this.displayText = displayText;
}
public Boolean isBootable() {
return bootable;
}
public void setBootable(Boolean bootable) {
this.bootable = bootable;
}
public Boolean isFeatured() {
return featured;
}
public void setFeatured(Boolean featured) {
this.featured = featured;
}
public Long getVirtualMachineId() {
return virtualMachineId.getValue();
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId.setValue(virtualMachineId);
}
public String getVirtualMachineName() {
return virtualMachineName;
}
public void setVirtualMachineName(String virtualMachineName) {
this.virtualMachineName = virtualMachineName;
}
public String getVirtualMachineDisplayName() {
return virtualMachineDisplayName;
}
public void setVirtualMachineDisplayName(String virtualMachineDisplayName) {
this.virtualMachineDisplayName = virtualMachineDisplayName;
}
public String getVirtualMachineState() {
return virtualMachineState;
}
public void setVirtualMachineState(String virtualMachineState) {
this.virtualMachineState = virtualMachineState;
}
}

View File

@ -727,7 +727,11 @@ public class ApiResponseHelper implements ResponseGenerator {
UserVm vm = ApiDBUtils.findUserVmById(ipAddress.getAssociatedWithVmId());
ipResponse.setVirtualMachineId(vm.getId());
ipResponse.setVirtualMachineName(vm.getHostName());
ipResponse.setVirtualMachineDisplayName(vm.getDisplayName());
if (vm.getDisplayName() != null) {
ipResponse.setVirtualMachineDisplayName(vm.getDisplayName());
} else {
ipResponse.setVirtualMachineDisplayName(vm.getHostName());
}
}
ipResponse.setAssociatedNetworkId(ipAddress.getAssociatedWithNetworkId());
@ -972,7 +976,11 @@ public class ApiResponseHelper implements ResponseGenerator {
volResponse.setVirtualMachineName(vm.getHostName());
UserVm userVm = ApiDBUtils.findUserVmById(vm.getId());
if (userVm != null) {
volResponse.setVirtualMachineDisplayName(userVm.getDisplayName());
if (userVm.getDisplayName() != null) {
volResponse.setVirtualMachineDisplayName(userVm.getDisplayName());
} else {
volResponse.setVirtualMachineDisplayName(userVm.getHostName());
}
volResponse.setVirtualMachineState(vm.getState().toString());
} else {
s_logger.error("User Vm with Id: " + instanceId + " does not exist for volume " + volume.getId());
@ -1175,7 +1183,12 @@ public class ApiResponseHelper implements ResponseGenerator {
if (vm != null) {
response.setVirtualMachineId(vm.getId());
response.setVirtualMachineName(vm.getHostName());
response.setVirtualMachineDisplayName(vm.getDisplayName());
if (vm.getDisplayName() != null) {
response.setVirtualMachineDisplayName(vm.getDisplayName());
} else {
response.setVirtualMachineDisplayName(vm.getHostName());
}
}
}
FirewallRule.State state = fwRule.getState();
@ -1203,7 +1216,11 @@ public class ApiResponseHelper implements ResponseGenerator {
if (vm != null) {// vm might be destroyed
response.setVirtualMachineId(vm.getId());
response.setVirtualMachineName(vm.getHostName());
response.setVirtualMachineDisplayName(vm.getDisplayName());
if (vm.getDisplayName() != null) {
response.setVirtualMachineDisplayName(vm.getDisplayName());
} else {
response.setVirtualMachineDisplayName(vm.getHostName());
}
}
}
FirewallRule.State state = fwRule.getState();

View File

@ -3391,6 +3391,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
String guestIpType = cmd.getGuestIpType();
List<String> supportedServicesStr = cmd.getSupportedServices();
Object specifyIpRanges = cmd.getSpecifyIpRanges();
String tags = cmd.getTags();
if (zoneId != null) {
zone = getZone(zoneId);
@ -3483,6 +3484,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (id != null) {
sc.addAnd("id", SearchCriteria.Op.EQ, id);
}
if (tags != null) {
sc.addAnd("tags", SearchCriteria.Op.EQ, tags);
}
List<NetworkOfferingVO> offerings = _networkOfferingDao.search(sc, searchFilter);
Boolean sourceNatSupported = cmd.getSourceNatSupported();