1) In Advance zone allow ipAssoc only to the Isolated network with the source nat service enabled

2) Added zoneName parameter to the listNetworks response
This commit is contained in:
Alena Prokharchyk 2011-12-06 13:31:06 -08:00
parent b7b31591e3
commit 9092765183
18 changed files with 37 additions and 15 deletions

View File

@ -206,6 +206,7 @@ public class ApiConstants {
public static final String VNET = "vnet";
public static final String VOLUME_ID = "volumeid";
public static final String ZONE_ID = "zoneid";
public static final String ZONE_NAME = "zonename";
public static final String NETWORK_TYPE = "networktype";
public static final String PAGE = "page";
public static final String PAGE_SIZE = "pagesize";

View File

@ -94,7 +94,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
return UserContext.current().getCaller().getDomainId();
}
private long getZoneId() {
private Long getZoneId() {
return zoneId;
}

View File

@ -29,7 +29,7 @@ public class CapacityResponse extends BaseResponse {
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name")
private String zoneName;
@SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID")

View File

@ -43,7 +43,7 @@ public class ClusterResponse extends BaseResponse {
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID of the cluster")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name of the cluster")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the cluster")
private String zoneName;
@SerializedName("hypervisortype") @Param(description="the hypervisor type of the cluster")

View File

@ -33,7 +33,7 @@ public class DomainRouterResponse extends BaseResponse implements ControlledEnti
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID for the router")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name for the router")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name for the router")
private String zoneName;
@SerializedName(ApiConstants.DNS1) @Param(description="the first DNS for the router")

View File

@ -61,7 +61,7 @@ public class ExtractResponse extends BaseResponse {
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone ID the object was extracted from")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="zone name the object was extracted from")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="zone name the object was extracted from")
private String zoneName;
@SerializedName("extractMode") @Param(description="the mode of extraction - upload or download")

View File

@ -55,7 +55,7 @@ public class HostResponse extends BaseResponse {
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the Zone ID of the host")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name of the host")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the host")
private String zoneName;
@SerializedName(ApiConstants.POD_ID) @Param(description="the Pod ID of the host")

View File

@ -38,7 +38,7 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the zone the public IP address belongs to")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the name of the zone the public IP address belongs to")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the zone the public IP address belongs to")
private String zoneName;
@SerializedName("issourcenat") @Param(description="true if the IP address is a source nat address, false otherwise")

View File

@ -58,6 +58,9 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the network")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the zone the network belongs to")
private String zoneName;
@SerializedName("networkofferingid") @Param(description="network offering id the network is created from")
private IdentityProxy networkOfferingId = new IdentityProxy("network_offerings");
@ -260,4 +263,8 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
public void setSubdomainAccess(Boolean subdomainAccess) {
this.subdomainAccess = subdomainAccess;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
}

View File

@ -19,6 +19,7 @@ package com.cloud.api.response;
import java.util.List;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@ -33,7 +34,7 @@ public class PodResponse extends BaseResponse {
@SerializedName("zoneid") @Param(description="the Zone ID of the Pod")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name of the Pod")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the Pod")
private String zoneName;
@SerializedName("gateway") @Param(description="the gateway of the Pod")

View File

@ -32,7 +32,7 @@ public class StoragePoolResponse extends BaseResponse {
@SerializedName("zoneid") @Param(description="the Zone ID of the storage pool")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name of the storage pool")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name of the storage pool")
private String zoneName;
@SerializedName("podid") @Param(description="the Pod ID of the storage pool")

View File

@ -40,7 +40,7 @@ public class SystemVmResponse extends BaseResponse {
@SerializedName("zoneid") @Param(description="the Zone ID for the system VM")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the Zone name for the system VM")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the Zone name for the system VM")
private String zoneName;
@SerializedName("dns1") @Param(description="the first DNS for the system VM")

View File

@ -81,7 +81,7 @@ public class TemplateResponse extends BaseResponse implements ControlledEntityRe
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the zone for this template")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the name of the zone for this template")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the zone for this template")
private String zoneName;
@SerializedName(ApiConstants.STATUS) @Param(description="the status of the template")

View File

@ -19,6 +19,7 @@ package com.cloud.api.response;
import java.util.Date;
import com.cloud.api.ApiConstants;
import com.cloud.api.IdentityProxy;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@ -253,7 +254,7 @@ public class UpgradeVmResponse extends BaseResponse {
@SerializedName("displayname") @Param(description="user generated name. The name of the virtual machine is returned if no displayname exists.")
private String displayName;
@SerializedName("zonename") @Param(description="the name of the availability zone for the virtual machine")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the availability zone for the virtual machine")
private String zoneName;
@SerializedName("hostid") @Param(description="the ID of the host for the virtual machine")

View File

@ -69,7 +69,7 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the availablility zone for the virtual machine")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename") @Param(description="the name of the availability zone for the virtual machine")
@SerializedName(ApiConstants.ZONE_NAME) @Param(description="the name of the availability zone for the virtual machine")
private String zoneName;
@SerializedName(ApiConstants.HOST_ID) @Param(description="the ID of the host for the virtual machine")

View File

@ -38,7 +38,7 @@ public class VolumeResponse extends BaseResponse implements ControlledEntityResp
@Param(description = "ID of the availability zone")
private IdentityProxy zoneId = new IdentityProxy("data_center");
@SerializedName("zonename")
@SerializedName(ApiConstants.ZONE_NAME)
@Param(description = "name of the availability zone")
private String zoneName;

View File

@ -2662,8 +2662,10 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setNetmask(singleVlan.getVlanNetmask());
response.setVlan(singleVlan.getVlanTag());
}
DataCenter zone = ApiDBUtils.findZoneById(network.getDataCenterId());
response.setZoneId(network.getDataCenterId());
response.setZoneName(zone.getName());
response.setPhysicalNetworkId(network.getPhysicalNetworkId());
// populate network offering information

View File

@ -647,6 +647,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
//allow associating IP addresses to guest network only
if (network.getTrafficType() != TrafficType.Guest) {
throw new InvalidParameterValueException("Ip address can be associated to the network with trafficType " + TrafficType.Guest);
}
//In Advance zone only allow to do IP assoc for Isolated networks with source nat service enabled
if (zone.getNetworkType() == NetworkType.Advanced && !(network.getGuestType() == GuestType.Isolated && areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) {
throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced + " ip address can be associated only to the network of guest type " + GuestType.Isolated + " with the " + Service.SourceNat.getName() + " enabled");
}
// Check that network belongs to IP owner - skip this check for Basic zone as there is just one guest network, and it
// belongs to the system