Remove IdentityProxy from OfferingResponse, FirewallResponse,

FirewallRuleResponse, HypervisorCapabilitiesResponse, IPAddressResponse.

Signed-off-by: Min Chen <min.chen@citrix.com>
This commit is contained in:
Min Chen 2012-12-18 12:02:08 -08:00
parent 1aa30f03e7
commit 16be94e9d7
22 changed files with 324 additions and 233 deletions

View File

@ -28,6 +28,8 @@ public interface HypervisorCapabilities {
*/
long getId();
String getUuid();
/**
* @return type of hypervisor
*/

View File

@ -72,6 +72,8 @@ public interface IpAddress extends ControlledEntity {
*/
long getId();
String getUuid();
void setState(IpAddress.State state);
Long getAllocatedToAccountId();

View File

@ -255,6 +255,8 @@ public interface Network extends ControlledEntity {
*/
long getId();
String getUuid();
String getName();
Mode getMode();

View File

@ -24,6 +24,7 @@ import com.cloud.network.Networks.TrafficType;
public class NetworkProfile implements Network {
private long id;
private String uuid;
private long dataCenterId;
private long ownerId;
private long domainId;
@ -51,6 +52,7 @@ public class NetworkProfile implements Network {
public NetworkProfile(Network network) {
this.id = network.getId();
this.uuid = network.getUuid();
this.broadcastUri = network.getBroadcastUri();
this.dataCenterId = network.getDataCenterId();
this.ownerId = network.getAccountId();
@ -105,6 +107,12 @@ public class NetworkProfile implements Network {
return id;
}
@Override
public String getUuid() {
return uuid;
}
@Override
public long getDataCenterId() {
return dataCenterId;

View File

@ -52,6 +52,12 @@ public interface FirewallRule extends ControlledEntity {
*/
long getId();
/**
*
* @return uuid
*/
String getUuid();
/**
* @return external id.
*/

View File

@ -153,6 +153,13 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
return null;
}
@Override
public String getUuid() {
// TODO Auto-generated method stub
return null;
}
@Override
public Long getSourceIpAddressId() {
return ipAddressId;

View File

@ -208,6 +208,13 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
return null;
}
@Override
public String getUuid() {
// TODO Auto-generated method stub
return null;
}
@Override
public Long getSourceIpAddressId() {
return ipAddressId;

View File

@ -255,6 +255,13 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
return null;
}
@Override
public String getUuid() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getSyncObjType() {
return BaseAsyncCmd.networkSyncObject;

View File

@ -184,6 +184,13 @@ public class CreateNetworkACLCmd extends BaseAsyncCreateCmd implements FirewallR
return null;
}
@Override
public String getUuid() {
// TODO Auto-generated method stub
return null;
}
@Override
public Long getSourceIpAddressId() {
return null;

View File

@ -19,17 +19,16 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.utils.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
public class DiskOfferingResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="unique ID of the disk offering")
private IdentityProxy id = new IdentityProxy("disk_offering");
private String id;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID this disk offering belongs to. Ignore this information as it is not currently applicable.")
private IdentityProxy domainId = new IdentityProxy("domain");
private String domainId;
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name this disk offering belongs to. Ignore this information as it is not currently applicable.")
private String domain;
@ -55,20 +54,20 @@ public class DiskOfferingResponse extends BaseResponse {
@SerializedName("storagetype") @Param(description="the storage type for this disk offering")
private String storageType;
public Long getId() {
return id.getValue();
public String getId() {
return id;
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public Long getDomainId() {
return domainId.getValue();
public String getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId.setValue(domainId);
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public String getDomain() {

View File

@ -20,14 +20,13 @@ import java.util.List;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.serializer.Param;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
@SuppressWarnings("unused")
public class FirewallResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the firewall rule")
private IdentityProxy id = new IdentityProxy("firewall_rules");
private String id;
@SerializedName(ApiConstants.PROTOCOL) @Param(description="the protocol of the firewall rule")
private String protocol;
@ -59,8 +58,8 @@ public class FirewallResponse extends BaseResponse {
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the rule", responseObject = ResourceTagResponse.class)
private List<ResourceTagResponse> tags;
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setProtocol(String protocol) {

View File

@ -20,14 +20,13 @@ import java.util.List;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.serializer.Param;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
@SuppressWarnings("unused")
public class FirewallRuleResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the port forwarding rule")
private IdentityProxy id = new IdentityProxy("firewall_rules");
private String id;
@SerializedName(ApiConstants.PRIVATE_START_PORT) @Param(description = "the starting port of port forwarding rule's private port range")
private String privateStartPort;
@ -45,7 +44,7 @@ public class FirewallRuleResponse extends BaseResponse {
private String publicEndPort;
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID) @Param(description="the VM ID for the port forwarding rule")
private IdentityProxy virtualMachineId = new IdentityProxy("vm_instance");
private String virtualMachineId;
@SerializedName("virtualmachinename") @Param(description="the VM name for the port forwarding rule")
private String virtualMachineName;
@ -54,7 +53,7 @@ public class FirewallRuleResponse extends BaseResponse {
private String virtualMachineDisplayName;
@SerializedName(ApiConstants.IP_ADDRESS_ID) @Param(description="the public ip address id for the port forwarding rule")
private IdentityProxy publicIpAddressId = new IdentityProxy("user_ip_address");
private String publicIpAddressId;
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the public ip address for the port forwarding rule")
private String publicIpAddress;
@ -68,12 +67,12 @@ public class FirewallRuleResponse extends BaseResponse {
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with the rule", responseObject = ResourceTagResponse.class)
private List<ResourceTagResponse> tags;
public Long getId() {
return id.getValue();
public String getId() {
return id;
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public String getPrivateStartPort() {
@ -116,12 +115,12 @@ public class FirewallRuleResponse extends BaseResponse {
this.publicEndPort = publicPort;
}
public Long getVirtualMachineId() {
return virtualMachineId.getValue();
public String getVirtualMachineId() {
return virtualMachineId;
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId.setValue(virtualMachineId);
public void setVirtualMachineId(String virtualMachineId) {
this.virtualMachineId = virtualMachineId;
}
public String getVirtualMachineName() {
@ -156,12 +155,12 @@ public class FirewallRuleResponse extends BaseResponse {
this.state = state;
}
public Long getPublicIpAddressId() {
return publicIpAddressId.getValue();
public String getPublicIpAddressId() {
return publicIpAddressId;
}
public void setPublicIpAddressId(Long publicIpAddressId) {
this.publicIpAddressId.setValue(publicIpAddressId);
public void setPublicIpAddressId(String publicIpAddressId) {
this.publicIpAddressId = publicIpAddressId;
}
public String getCidrList() {

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.response;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.utils.IdentityProxy;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@ -25,7 +24,7 @@ import org.apache.cloudstack.api.BaseResponse;
public class HypervisorCapabilitiesResponse extends BaseResponse {
@SerializedName(ApiConstants.ID) @Param(description="the ID of the hypervisor capabilities row")
private IdentityProxy id = new IdentityProxy("hypervisor_capabilities");
private String id;
@SerializedName(ApiConstants.HYPERVISOR_VERSION) @Param(description="the hypervisor version")
private String hypervisorVersion;
@ -39,17 +38,13 @@ public class HypervisorCapabilitiesResponse extends BaseResponse {
@SerializedName(ApiConstants.SECURITY_GROUP_EANBLED) @Param(description="true if security group is supported")
private boolean isSecurityGroupEnabled;
@Override
public Long getObjectId() {
return getId();
public String getId() {
return id;
}
public Long getId() {
return id.getValue();
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}

View File

@ -21,14 +21,13 @@ import java.util.List;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.serializer.Param;
import com.cloud.utils.IdentityProxy;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
@SuppressWarnings("unused")
public class IPAddressResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="public IP address id")
private IdentityProxy id = new IdentityProxy("user_ip_address");
private String id;
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="public IP address")
private String ipAddress;
@ -37,7 +36,7 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
private Date allocated;
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the zone the public IP address belongs to")
private IdentityProxy zoneId = new IdentityProxy("data_center");
private String zoneId;
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the zone the public IP address belongs to")
private String zoneName;
@ -65,7 +64,7 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
@SerializedName(ApiConstants.VLAN_ID) @Param(description="the ID of the VLAN associated with the IP address." +
" This parameter is visible to ROOT admins only")
private IdentityProxy vlanId = new IdentityProxy("vlan");
private String vlanId;
@SerializedName("vlanname") @Param(description="the VLAN associated with the IP address")
private String vlanName;
@ -77,7 +76,7 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
private Boolean isSystem;
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID) @Param(description="virutal machine id the ip address is assigned to (not null only for static nat Ip)")
private IdentityProxy virtualMachineId = new IdentityProxy("vm_instance");
private String virtualMachineId;
@SerializedName("virtualmachinename") @Param(description="virutal machine name the ip address is assigned to (not null only for static nat Ip)")
private String virtualMachineName;
@ -86,25 +85,25 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
private String virtualMachineDisplayName;
@SerializedName(ApiConstants.ASSOCIATED_NETWORK_ID) @Param(description="the ID of the Network associated with the IP address")
private IdentityProxy associatedNetworkId = new IdentityProxy("networks");
private String associatedNetworkId;
@SerializedName(ApiConstants.ASSOCIATED_NETWORK_NAME) @Param(description="the name of the Network associated with the IP address")
private String associatedNetworkName;
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="the ID of the Network where ip belongs to")
private IdentityProxy networkId = new IdentityProxy("networks");
private String networkId;
@SerializedName(ApiConstants.STATE) @Param(description="State of the ip address. Can be: Allocatin, Allocated and Releasing")
private String state;
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID) @Param(description="the physical network this belongs to")
private IdentityProxy physicalNetworkId = new IdentityProxy("physical_network");
private String physicalNetworkId;
@SerializedName(ApiConstants.PURPOSE) @Param(description="purpose of the IP address. In Acton this value is not null for Ips with isSystem=true, and can have either StaticNat or LB value")
private String purpose;
@SerializedName(ApiConstants.VPC_ID) @Param(description="VPC the ip belongs to")
private IdentityProxy vpcId = new IdentityProxy("vpc");
private String vpcId;
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with ip address", responseObject = ResourceTagResponse.class)
private List<ResourceTagResponse> tags;
@ -122,8 +121,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
this.allocated = allocated;
}
public void setZoneId(Long zoneId) {
this.zoneId.setValue(zoneId);
public void setZoneId(String zoneId) {
this.zoneId = zoneId;
}
public void setZoneName(String zoneName) {
@ -153,8 +152,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
this.forVirtualNetwork = forVirtualNetwork;
}
public void setVlanId(Long vlanId) {
this.vlanId.setValue(vlanId);
public void setVlanId(String vlanId) {
this.vlanId = vlanId;
}
public void setVlanName(String vlanName) {
@ -165,16 +164,16 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
this.staticNat = staticNat;
}
public void setAssociatedNetworkId(Long networkId) {
this.associatedNetworkId.setValue(networkId);
public void setAssociatedNetworkId(String networkId) {
this.associatedNetworkId = networkId;
}
public void setNetworkId(Long networkId) {
this.networkId.setValue(networkId);
public void setNetworkId(String networkId) {
this.networkId = networkId;
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId.setValue(virtualMachineId);
public void setVirtualMachineId(String virtualMachineId) {
this.virtualMachineId = virtualMachineId;
}
public void setVirtualMachineName(String virtualMachineName) {
@ -185,22 +184,18 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
this.virtualMachineDisplayName = virtualMachineDisplayName;
}
public Long getId() {
return id.getValue();
public String getId() {
return id;
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public void setState(String state) {
this.state = state;
}
@Override
public Long getObjectId() {
return getId();
}
@Override
public void setProjectId(String projectId) {
@ -212,8 +207,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
this.projectName = projectName;
}
public void setPhysicalNetworkId(long physicalNetworkId) {
this.physicalNetworkId.setValue(physicalNetworkId);
public void setPhysicalNetworkId(String physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId;
}
public void setIsSystem(Boolean isSystem) {
@ -224,8 +219,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
this.purpose = purpose;
}
public void setVpcId(Long vpcId) {
this.vpcId.setValue(vpcId);
public void setVpcId(String vpcId) {
this.vpcId = vpcId;
}
public void setTags(List<ResourceTagResponse> tags) {

View File

@ -19,14 +19,13 @@ package org.apache.cloudstack.api.response;
import java.util.Date;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.utils.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
import org.apache.cloudstack.api.BaseResponse;
public class ServiceOfferingResponse extends BaseResponse {
@SerializedName("id") @Param(description="the id of the service offering")
private IdentityProxy id = new IdentityProxy("disk_offering");
private String id;
@SerializedName("name") @Param(description="the name of the service offering")
private String name;
@ -59,7 +58,7 @@ public class ServiceOfferingResponse extends BaseResponse {
private String tags;
@SerializedName("domainid") @Param(description="the domain id of the service offering")
private IdentityProxy domainId = new IdentityProxy("domain");
private String domainId;
@SerializedName(ApiConstants.DOMAIN) @Param(description="Domain name for the offering")
private String domain;
@ -80,12 +79,12 @@ public class ServiceOfferingResponse extends BaseResponse {
private Integer networkRate;
public Long getId() {
return id.getValue();
public String getId() {
return id;
}
public void setId(Long id) {
this.id.setValue(id);
public void setId(String id) {
this.id = id;
}
public String getName() {
@ -195,12 +194,12 @@ public class ServiceOfferingResponse extends BaseResponse {
this.tags = tags;
}
public Long getDomainId() {
return domainId.getValue();
public String getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId.setValue(domainId);
public void setDomainId(String domainId) {
this.domainId = domainId;
}
public String getDomain() {

View File

@ -137,6 +137,7 @@ import com.cloud.network.security.dao.SecurityGroupDao;
import com.cloud.network.vpc.StaticRouteVO;
import com.cloud.network.vpc.VpcGatewayVO;
import com.cloud.network.vpc.VpcManager;
import com.cloud.network.vpc.VpcVO;
import com.cloud.network.vpc.dao.StaticRouteDao;
import com.cloud.network.vpc.dao.VpcGatewayDao;
import com.cloud.offering.NetworkOffering;
@ -218,6 +219,7 @@ import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.UserVmDao;
import com.cloud.vm.dao.UserVmDetailsDao;
import com.cloud.vm.dao.VMInstanceDao;
import com.cloud.network.vpc.dao.VpcDao;
public class ApiDBUtils {
private static ManagementServer _ms;
@ -302,6 +304,7 @@ public class ApiDBUtils {
private static FirewallRulesDao _firewallRuleDao;
private static StaticRouteDao _staticRouteDao;
private static VpcGatewayDao _vpcGatewayDao;
private static VpcDao _vpcDao;
static {
_ms = (ManagementServer) ComponentLocator.getComponent(ManagementServer.Name);
@ -385,6 +388,7 @@ public class ApiDBUtils {
_vpcGatewayDao = locator.getDao(VpcGatewayDao.class);
_asVmProfileDao = locator.getDao(AutoScaleVmProfileDao.class);
_asVmGroupDao = locator.getDao(AutoScaleVmGroupDao.class);
_vpcDao = locator.getDao(VpcDao.class);
// Note: stats collector should already have been initialized by this time, otherwise a null instance is returned
_statsCollector = StatsCollector.getInstance();
@ -1020,6 +1024,10 @@ public class ApiDBUtils {
public static GuestOSCategoryVO findGuestOsCategoryById(long catId){
return _guestOSCategoryDao.findById(catId);
}
public static VpcVO findVpcById(long vpcId){
return _vpcDao.findById(vpcId);
}
///////////////////////////////////////////////////////////////////////
// Newly Added Utility Methods for List API refactoring //
///////////////////////////////////////////////////////////////////////

View File

@ -156,6 +156,7 @@ import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PhysicalNetwork;
import com.cloud.network.PhysicalNetworkServiceProvider;
@ -196,6 +197,7 @@ import com.cloud.network.vpc.StaticRouteVO;
import com.cloud.network.vpc.Vpc;
import com.cloud.network.vpc.VpcGatewayVO;
import com.cloud.network.vpc.VpcOffering;
import com.cloud.network.vpc.VpcVO;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.ServiceOffering;
@ -451,14 +453,17 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public DiskOfferingResponse createDiskOfferingResponse(DiskOffering offering) {
DiskOfferingResponse diskOfferingResponse = new DiskOfferingResponse();
diskOfferingResponse.setId(offering.getId());
diskOfferingResponse.setId(offering.getUuid());
diskOfferingResponse.setName(offering.getName());
diskOfferingResponse.setDisplayText(offering.getDisplayText());
diskOfferingResponse.setCreated(offering.getCreated());
diskOfferingResponse.setDiskSize(offering.getDiskSize() / (1024 * 1024 * 1024));
if (offering.getDomainId() != null) {
diskOfferingResponse.setDomain(ApiDBUtils.findDomainById(offering.getDomainId()).getName());
diskOfferingResponse.setDomainId(offering.getDomainId());
Domain domain = ApiDBUtils.findDomainById(offering.getDomainId());
if (domain != null) {
diskOfferingResponse.setDomain(domain.getName());
diskOfferingResponse.setDomainId(domain.getUuid());
}
}
diskOfferingResponse.setTags(offering.getTags());
diskOfferingResponse.setCustomized(offering.isCustomized());
@ -507,7 +512,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public ServiceOfferingResponse createServiceOfferingResponse(ServiceOffering offering) {
ServiceOfferingResponse offeringResponse = new ServiceOfferingResponse();
offeringResponse.setId(offering.getId());
offeringResponse.setId(offering.getUuid());
offeringResponse.setName(offering.getName());
offeringResponse.setIsSystemOffering(offering.getSystemUse());
offeringResponse.setDefaultUse(offering.getDefaultUse());
@ -522,8 +527,11 @@ public class ApiResponseHelper implements ResponseGenerator {
offeringResponse.setLimitCpuUse(offering.getLimitCpuUse());
offeringResponse.setTags(offering.getTags());
if (offering.getDomainId() != null) {
offeringResponse.setDomain(ApiDBUtils.findDomainById(offering.getDomainId()).getName());
offeringResponse.setDomainId(offering.getDomainId());
Domain domain = ApiDBUtils.findDomainById(offering.getDomainId());
if (domain != null) {
offeringResponse.setDomain(domain.getName());
offeringResponse.setDomainId(domain.getUuid());
}
}
offeringResponse.setNetworkRate(offering.getRateMbps());
offeringResponse.setHostTag(offering.getHostTag());
@ -788,13 +796,16 @@ public class ApiResponseHelper implements ResponseGenerator {
long zoneId = ipAddr.getDataCenterId();
IPAddressResponse ipResponse = new IPAddressResponse();
ipResponse.setId(ipAddr.getId());
ipResponse.setId(ipAddr.getUuid());
ipResponse.setIpAddress(ipAddr.getAddress().toString());
if (ipAddr.getAllocatedTime() != null) {
ipResponse.setAllocated(ipAddr.getAllocatedTime());
}
ipResponse.setZoneId(zoneId);
ipResponse.setZoneName(ApiDBUtils.findZoneById(ipAddr.getDataCenterId()).getName());
DataCenterVO zone = ApiDBUtils.findZoneById(ipAddr.getDataCenterId());
if (zone != null) {
ipResponse.setZoneId(zone.getUuid());
ipResponse.setZoneName(zone.getName());
}
ipResponse.setSourceNat(ipAddr.isSourceNat());
ipResponse.setIsSystem(ipAddr.getSystem());
@ -808,24 +819,34 @@ public class ApiResponseHelper implements ResponseGenerator {
if (ipAddr.getAssociatedWithVmId() != null) {
UserVm vm = ApiDBUtils.findUserVmById(ipAddr.getAssociatedWithVmId());
ipResponse.setVirtualMachineId(vm.getId());
ipResponse.setVirtualMachineName(vm.getHostName());
if (vm.getDisplayName() != null) {
ipResponse.setVirtualMachineDisplayName(vm.getDisplayName());
} else {
ipResponse.setVirtualMachineDisplayName(vm.getHostName());
if (vm != null) {
ipResponse.setVirtualMachineId(vm.getUuid());
ipResponse.setVirtualMachineName(vm.getHostName());
if (vm.getDisplayName() != null) {
ipResponse.setVirtualMachineDisplayName(vm.getDisplayName());
} else {
ipResponse.setVirtualMachineDisplayName(vm.getHostName());
}
}
}
if (ipAddr.getAssociatedWithNetworkId() != null) {
Network ntwk = ApiDBUtils.findNetworkById(ipAddr.getAssociatedWithNetworkId());
ipResponse.setAssociatedNetworkId(ipAddr.getAssociatedWithNetworkId());
ipResponse.setAssociatedNetworkName(ntwk.getName());
if (ntwk != null) {
ipResponse.setAssociatedNetworkId(ntwk.getUuid());
ipResponse.setAssociatedNetworkName(ntwk.getName());
}
}
ipResponse.setVpcId(ipAddr.getVpcId());
if (ipAddr.getVpcId() != null) {
VpcVO vpc = ApiDBUtils.findVpcById(ipAddr.getVpcId());
if (vpc != null) {
ipResponse.setVpcId(vpc.getUuid());
}
}
// Network id the ip is associated with (if associated networkId is null, try to get this information from vlan)
// Network id the ip is associated with (if associated networkId is
// null, try to get this information from vlan)
Long vlanNetworkId = ApiDBUtils.getVlanNetworkId(ipAddr.getVlanId());
// Network id the ip belongs to
@ -836,15 +857,29 @@ public class ApiResponseHelper implements ResponseGenerator {
networkId = ApiDBUtils.getPublicNetworkIdByZone(zoneId);
}
ipResponse.setNetworkId(networkId);
if (networkId != null) {
NetworkVO nw = ApiDBUtils.findNetworkById(networkId);
if (nw != null) {
ipResponse.setNetworkId(nw.getUuid());
}
}
ipResponse.setState(ipAddr.getState().toString());
ipResponse.setPhysicalNetworkId(ipAddr.getPhysicalNetworkId());
if (ipAddr.getPhysicalNetworkId() != null) {
PhysicalNetworkVO pnw = ApiDBUtils.findPhysicalNetworkById(ipAddr.getPhysicalNetworkId());
if (pnw != null) {
ipResponse.setPhysicalNetworkId(pnw.getUuid());
}
}
// show this info to admin only
Account account = UserContext.current().getCaller();
if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
ipResponse.setVlanId(ipAddr.getVlanId());
ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddr.getVlanId()).getVlanTag());
VlanVO vl = ApiDBUtils.findVlanById(ipAddr.getVlanId());
if (vl != null) {
ipResponse.setVlanId(vl.getUuid());
ipResponse.setVlanName(vl.getVlanTag());
}
}
if (ipAddr.getSystem()) {
@ -1297,7 +1332,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public FirewallRuleResponse createPortForwardingRuleResponse(PortForwardingRule fwRule) {
FirewallRuleResponse response = new FirewallRuleResponse();
response.setId(fwRule.getId());
response.setId(fwRule.getUuid());
response.setPrivateStartPort(Integer.toString(fwRule.getDestinationPortStart()));
response.setPrivateEndPort(Integer.toString(fwRule.getDestinationPortEnd()));
response.setProtocol(fwRule.getProtocol());
@ -1307,13 +1342,13 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setCidrList(StringUtils.join(cidrs, ","));
IpAddress ip = ApiDBUtils.findIpAddressById(fwRule.getSourceIpAddressId());
response.setPublicIpAddressId(ip.getId());
response.setPublicIpAddressId(ip.getUuid());
response.setPublicIpAddress(ip.getAddress().addr());
if (ip != null && fwRule.getDestinationIpAddress() != null) {
UserVm vm = ApiDBUtils.findUserVmById(fwRule.getVirtualMachineId());
if (vm != null) {
response.setVirtualMachineId(vm.getId());
response.setVirtualMachineId(vm.getUuid());
response.setVirtualMachineName(vm.getHostName());
if (vm.getDisplayName() != null) {
@ -2758,7 +2793,7 @@ public class ApiResponseHelper implements ResponseGenerator {
public FirewallResponse createFirewallResponse(FirewallRule fwRule) {
FirewallResponse response = new FirewallResponse();
response.setId(fwRule.getId());
response.setId(fwRule.getUuid());
response.setProtocol(fwRule.getProtocol());
if (fwRule.getSourcePortStart() != null) {
response.setStartPort(Integer.toString(fwRule.getSourcePortStart()));
@ -2844,7 +2879,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public HypervisorCapabilitiesResponse createHypervisorCapabilitiesResponse(HypervisorCapabilities hpvCapabilities) {
HypervisorCapabilitiesResponse hpvCapabilitiesResponse = new HypervisorCapabilitiesResponse();
hpvCapabilitiesResponse.setId(hpvCapabilities.getId());
hpvCapabilitiesResponse.setId(hpvCapabilities.getUuid());
hpvCapabilitiesResponse.setHypervisor(hpvCapabilities.getHypervisorType());
hpvCapabilitiesResponse.setHypervisorVersion(hpvCapabilities.getHypervisorVersion());
hpvCapabilitiesResponse.setIsSecurityGroupEnabled(hpvCapabilities.isSecurityGroupEnabled());

View File

@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@ -40,12 +40,12 @@ import com.cloud.utils.net.Ip;
*/
@Entity
@Table(name=("user_ip_address"))
public class IPAddressVO implements IpAddress, Identity {
public class IPAddressVO implements IpAddress {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
long id;
@Column(name="account_id")
private Long allocatedToAccountId = null;
@ -59,59 +59,59 @@ public class IPAddressVO implements IpAddress, Identity {
@Column(name="data_center_id", updatable=false)
private long dataCenterId;
@Column(name="source_nat")
private boolean sourceNat;
@Column(name="allocated")
@Temporal(value=TemporalType.TIMESTAMP)
private Date allocatedTime;
@Column(name="vlan_db_id")
private long vlanId;
@Column(name="one_to_one_nat")
private boolean oneToOneNat;
@Column(name="vm_id")
private Long associatedWithVmId;
@Column(name="state")
private State state;
@Column(name="mac_address")
private long macAddress;
@Column(name="source_network_id")
private Long sourceNetworkId;
@Column(name="network_id")
private Long associatedWithNetworkId;
@Column(name="uuid")
private String uuid;
@Column(name="physical_network_id")
private Long physicalNetworkId;
@Column(name="is_system")
private boolean system;
@Column(name="account_id")
@Transient
private Long accountId = null;
@Transient
@Column(name="domain_id")
private Long domainId = null;
@Column(name="vpc_id")
private Long vpcId;
protected IPAddressVO() {
this.uuid = UUID.randomUUID().toString();
}
@Override
public boolean readyToUse() {
return state == State.Allocated;
@ -129,36 +129,36 @@ public class IPAddressVO implements IpAddress, Identity {
this.macAddress = macAddress;
this.uuid = UUID.randomUUID().toString();
}
public long getMacAddress() {
return macAddress;
}
@Override
public long getDataCenterId() {
return dataCenterId;
return dataCenterId;
}
@Override
public Ip getAddress() {
return address;
}
@Override
public Long getAllocatedToAccountId() {
return allocatedToAccountId;
}
@Override
public Long getAllocatedInDomainId() {
return allocatedInDomainId;
}
@Override
public Long getAssociatedWithNetworkId() {
return associatedWithNetworkId;
}
public void setAssociatedWithNetworkId(Long networkId) {
this.associatedWithNetworkId = networkId;
}
@ -171,7 +171,7 @@ public class IPAddressVO implements IpAddress, Identity {
public void setAssociatedWithVmId(Long associatedWithVmId) {
this.associatedWithVmId = associatedWithVmId;
}
@Override
public Date getAllocatedTime() {
return allocatedTime;
@ -188,7 +188,7 @@ public class IPAddressVO implements IpAddress, Identity {
public void setSourceNat(boolean sourceNat) {
this.sourceNat = sourceNat;
}
@Override
public boolean isSourceNat() {
return sourceNat;
@ -197,12 +197,12 @@ public class IPAddressVO implements IpAddress, Identity {
public void setAllocatedTime(Date allocated) {
this.allocatedTime = allocated;
}
@Override
public long getVlanId() {
return this.vlanId;
}
public void setVlanId(long vlanDbId) {
this.vlanId = vlanDbId;
}
@ -215,31 +215,31 @@ public class IPAddressVO implements IpAddress, Identity {
public void setOneToOneNat(boolean oneToOneNat) {
this.oneToOneNat = oneToOneNat;
}
@Override
public long getDomainId() {
return allocatedInDomainId == null ? -1 : allocatedInDomainId;
}
@Override
public long getAccountId() {
return allocatedToAccountId == null ? -1 : allocatedToAccountId;
}
@Override
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
@Override
public String toString() {
return new StringBuilder("Ip[").append(address).append("-").append(dataCenterId).append("]").toString();
}
@Override
public long getId() {
return id;
@ -252,12 +252,12 @@ public class IPAddressVO implements IpAddress, Identity {
public void setSourceNetworkId(Long sourceNetworkId) {
this.sourceNetworkId = sourceNetworkId;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@ -269,7 +269,7 @@ public class IPAddressVO implements IpAddress, Identity {
public void setPhysicalNetworkId(Long physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId;
}
@Override
public boolean getSystem() {
return system;

View File

@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@ -44,7 +44,7 @@ import com.cloud.utils.net.NetUtils;
*/
@Entity
@Table(name="networks")
public class NetworkVO implements Network, Identity {
public class NetworkVO implements Network {
@Id
@TableGenerator(name="networks_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="networks_seq", allocationSize=1)
@Column(name="id")
@ -79,13 +79,13 @@ public class NetworkVO implements Network, Identity {
@Column(name="network_offering_id")
long networkOfferingId;
@Column(name="vpc_id")
Long vpcId;
@Column(name="physical_network_id")
Long physicalNetworkId;
@Column(name="data_center_id")
long dataCenterId;
@ -132,24 +132,24 @@ public class NetworkVO implements Network, Identity {
@Column(name="reservation_id")
String reservationId;
@Column(name="uuid")
String uuid;
@Column(name="guest_type")
@Enumerated(value=EnumType.STRING)
Network.GuestType guestType;
@Column(name="acl_type")
@Enumerated(value=EnumType.STRING)
ControlledEntity.ACLType aclType;
@Column(name="restart_required")
boolean restartRequired = false;
@Column(name="specify_ip_ranges")
boolean specifyIpRanges = false;
public NetworkVO() {
this.uuid = UUID.randomUUID().toString();
}
@ -181,8 +181,8 @@ public class NetworkVO implements Network, Identity {
this.uuid = UUID.randomUUID().toString();
}
public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId,
long related, String name, String displayText, String networkDomain, GuestType guestType, long dcId,
public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId,
long related, String name, String displayText, String networkDomain, GuestType guestType, long dcId,
Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges, Long vpcId) {
this(id, that.getTrafficType(), that.getMode(), that.getBroadcastDomainType(), offeringId, domainId, accountId,
related, name, displayText, networkDomain, guestType, dcId, physicalNetworkId, aclType, specifyIpRanges, vpcId);
@ -215,8 +215,8 @@ public class NetworkVO implements Network, Identity {
* @param vpcId TODO
* @param dataCenterId
*/
public NetworkVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType,
long networkOfferingId, long domainId, long accountId, long related, String name, String displayText,
public NetworkVO(long id, TrafficType trafficType, Mode mode, BroadcastDomainType broadcastDomainType,
long networkOfferingId, long domainId, long accountId, long related, String name, String displayText,
String networkDomain, GuestType guestType, long dcId, Long physicalNetworkId, ACLType aclType, boolean specifyIpRanges, Long vpcId) {
this(trafficType, mode, broadcastDomainType, networkOfferingId, State.Allocated, dcId, physicalNetworkId);
this.domainId = domainId;
@ -368,7 +368,7 @@ public class NetworkVO implements Network, Identity {
public Long getPhysicalNetworkId() {
return physicalNetworkId;
}
@Override
public void setPhysicalNetworkId(Long physicalNetworkId) {
this.physicalNetworkId = physicalNetworkId;
@ -428,7 +428,7 @@ public class NetworkVO implements Network, Identity {
public void setCreated(Date created) {
this.created = created;
}
@Override
public Network.GuestType getGuestType() {
return guestType;
@ -465,7 +465,7 @@ public class NetworkVO implements Network, Identity {
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
@ -482,7 +482,7 @@ public class NetworkVO implements Network, Identity {
public boolean isRestartRequired() {
return restartRequired;
}
@Override
public boolean getSpecifyIpRanges() {
return specifyIpRanges;

View File

@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@ -36,52 +36,52 @@ public class PublicIp implements PublicIpAddress {
_vlan = vlan;
this.macAddress = NetUtils.long2Mac(macAddress);
}
@Override
public Ip getAddress() {
return _addr.getAddress();
}
@Override
public String getNetmask() {
return _vlan.getVlanNetmask();
}
@Override
public String getGateway() {
return _vlan.getVlanGateway();
}
@Override
public String getVlanTag() {
return _vlan.getVlanTag();
}
@Override
public long getDataCenterId() {
return _addr.getDataCenterId();
}
@Override
public boolean readyToUse() {
return _addr.getAllocatedTime() != null && _addr.getState() == State.Allocated;
}
@Override
public boolean isSourceNat() {
return _addr.isSourceNat();
}
@Override
public boolean isOneToOneNat() {
return _addr.isOneToOneNat();
}
@Override
public Long getAssociatedWithVmId() {
return _addr.getAssociatedWithVmId();
}
@Override
public Date getAllocatedTime() {
return _addr.getAllocatedTime();
@ -106,25 +106,25 @@ public class PublicIp implements PublicIpAddress {
public State getState() {
return _addr.getState();
}
public IPAddressVO ip() {
return _addr;
}
public VlanVO vlan() {
return _vlan;
}
@Override
public String getMacAddress() {
return macAddress;
}
@Override
public Long getAssociatedWithNetworkId() {
return _addr.getAssociatedWithNetworkId();
}
@Override
public Long getNetworkId() {
return _vlan.getNetworkId();
@ -149,12 +149,18 @@ public class PublicIp implements PublicIpAddress {
public VlanType getVlanType() {
return _vlan.getVlanType();
}
@Override
public long getId() {
return _addr.getId();
}
@Override
public String getUuid() {
return _addr.getUuid();
}
@Override
public String toString() {
return _addr.getAddress().toString();
@ -179,7 +185,7 @@ public class PublicIp implements PublicIpAddress {
public Long getAllocatedInDomainId() {
return _addr.getAllocatedInDomainId();
}
@Override
public boolean getSystem() {
return _addr.getSystem();

View File

@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@ -44,69 +44,69 @@ import com.cloud.utils.net.NetUtils;
@Table(name="firewall_rules")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorColumn(name="purpose", discriminatorType=DiscriminatorType.STRING, length=32)
public class FirewallRuleVO implements Identity, FirewallRule {
public class FirewallRuleVO implements FirewallRule {
protected final FirewallRulesCidrsDaoImpl _firewallRulesCidrsDao = ComponentLocator.inject(FirewallRulesCidrsDaoImpl.class);
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
long id;
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name=GenericDao.XID_COLUMN)
String xId;
@Column(name="domain_id", updatable=false)
long domainId;
@Column(name="account_id", updatable=false)
long accountId;
@Column(name="ip_address_id", updatable=false)
Long sourceIpAddressId;
@Column(name="start_port", updatable=false)
Integer sourcePortStart;
@Column(name="end_port", updatable=false)
Integer sourcePortEnd;
@Column(name="protocol", updatable=false)
String protocol = NetUtils.TCP_PROTO;
@Enumerated(value=EnumType.STRING)
@Column(name="purpose")
Purpose purpose;
@Enumerated(value=EnumType.STRING)
@Column(name="state")
State state;
@Column(name=GenericDao.CREATED_COLUMN)
Date created;
@Column(name="network_id")
long networkId;
@Column(name="icmp_code")
Integer icmpCode;
@Column(name="icmp_type")
Integer icmpType;
@Column(name="related")
Long related;
@Column(name="type")
@Enumerated(value=EnumType.STRING)
FirewallRuleType type;
@Column(name="traffic_type")
@Enumerated(value=EnumType.STRING)
TrafficType trafficType;
// This is a delayed load value. If the value is null,
// then this field has not been loaded yet.
// Call firewallrules dao to load it.
@ -124,7 +124,7 @@ public class FirewallRuleVO implements Identity, FirewallRule {
public List<String> getSourceCidrList() {
if (sourceCidrs == null && (purpose == Purpose.Firewall || purpose == Purpose.NetworkACL)) {
return _firewallRulesCidrsDao.getSourceCidrs(id);
}
}
return sourceCidrs;
}
@ -167,7 +167,7 @@ public class FirewallRuleVO implements Identity, FirewallRule {
public String getProtocol() {
return protocol;
}
public void setState(State state) {
this.state = state;
}
@ -176,17 +176,17 @@ public class FirewallRuleVO implements Identity, FirewallRule {
public Purpose getPurpose() {
return purpose;
}
@Override
public State getState() {
return state;
}
@Override
public long getNetworkId() {
return networkId;
}
@Override
public FirewallRuleType getType() {
return type;
@ -194,12 +194,12 @@ public class FirewallRuleVO implements Identity, FirewallRule {
public Date getCreated() {
return created;
}
protected FirewallRuleVO() {
this.uuid = UUID.randomUUID().toString();
}
public FirewallRuleVO(String xId, Long ipAddressId, Integer portStart, Integer portEnd, String protocol,
public FirewallRuleVO(String xId, Long ipAddressId, Integer portStart, Integer portEnd, String protocol,
long networkId, long accountId, long domainId, Purpose purpose, List<String> sourceCidrs, Integer icmpCode,
Integer icmpType, Long related, TrafficType trafficType) {
this.xId = xId;
@ -208,11 +208,11 @@ public class FirewallRuleVO implements Identity, FirewallRule {
}
this.accountId = accountId;
this.domainId = domainId;
if (ipAddressId == null) {
assert (purpose == Purpose.NetworkACL) : "ipAddressId can be null for " + Purpose.NetworkACL + " only";
}
this.sourceIpAddressId = ipAddressId;
this.sourcePortStart = portStart;
this.sourcePortEnd = portEnd;
@ -223,28 +223,28 @@ public class FirewallRuleVO implements Identity, FirewallRule {
this.icmpCode = icmpCode;
this.icmpType = icmpType;
this.sourceCidrs = sourceCidrs;
if (related != null) {
assert (purpose == Purpose.Firewall) : "related field can be set for rule of purpose " + Purpose.Firewall + " only";
}
this.related = related;
this.uuid = UUID.randomUUID().toString();
this.type = FirewallRuleType.User;
this.trafficType = trafficType;
}
public FirewallRuleVO(String xId, long ipAddressId, int port, String protocol, long networkId, long accountId,
public FirewallRuleVO(String xId, long ipAddressId, int port, String protocol, long networkId, long accountId,
long domainId, Purpose purpose, List<String> sourceCidrs, Integer icmpCode, Integer icmpType, Long related) {
this(xId, ipAddressId, port, port, protocol, networkId, accountId, domainId, purpose, sourceCidrs, icmpCode, icmpType, related, null);
}
@Override
public String toString() {
return new StringBuilder("Rule[").append(id).append("-").append(purpose).append("-").append(state).append("]").toString();
}
@Override
public Integer getIcmpCode() {
return icmpCode;
@ -259,16 +259,16 @@ public class FirewallRuleVO implements Identity, FirewallRule {
public Long getRelated() {
return related;
}
@Override
public String getUuid() {
return this.uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setType(FirewallRuleType type) {
this.type = type;
}

View File

@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@ -22,6 +22,7 @@ import java.util.List;
public class StaticNatRuleImpl implements StaticNatRule{
long id;
String xid;
String uuid;
String protocol;
int portStart;
int portEnd;
@ -32,9 +33,10 @@ public class StaticNatRuleImpl implements StaticNatRule{
long sourceIpAddressId;
String destIpAddress;
public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) {
public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) {
this.id = rule.getId();
this.xid = rule.getXid();
this.uuid = rule.getUuid();
this.protocol = rule.getProtocol();
this.portStart = rule.getSourcePortStart();
this.portEnd = rule.getSourcePortEnd();
@ -55,7 +57,7 @@ public class StaticNatRuleImpl implements StaticNatRule{
public Integer getSourcePortEnd() {
return portEnd;
}
@Override
public Purpose getPurpose() {
return Purpose.StaticNat;
@ -65,17 +67,17 @@ public class StaticNatRuleImpl implements StaticNatRule{
public State getState() {
return state;
}
@Override
public long getAccountId() {
return accountId;
}
@Override
public long getDomainId() {
return domainId;
}
@Override
public long getNetworkId() {
return networkId;
@ -105,12 +107,18 @@ public class StaticNatRuleImpl implements StaticNatRule{
public String getXid() {
return xid;
}
@Override
public String getUuid() {
return uuid;
}
@Override
public Integer getIcmpCode() {
return null;
}
@Override
public Integer getIcmpType() {
return null;
@ -130,7 +138,7 @@ public class StaticNatRuleImpl implements StaticNatRule{
public FirewallRuleType getType() {
return FirewallRuleType.User;
}
@Override
public TrafficType getTrafficType() {
return null;