mirror of https://github.com/apache/cloudstack.git
bug 8861: introduced optional zoneId parameter to listNetworkOfferings command
status 8861: resolved fixed
This commit is contained in:
parent
851c3344fc
commit
df3704e360
|
|
@ -27,6 +27,7 @@ import com.cloud.api.ApiConstants;
|
|||
import com.cloud.api.BaseListCmd;
|
||||
import com.cloud.api.Implementation;
|
||||
import com.cloud.api.Parameter;
|
||||
import com.cloud.api.BaseCmd.CommandType;
|
||||
import com.cloud.api.response.ListResponse;
|
||||
import com.cloud.api.response.NetworkOfferingResponse;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
|
|
@ -64,9 +65,11 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
|||
@Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required")
|
||||
private String availability;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.GUEST_IP_TYPE, type=CommandType.STRING, description="the guest ip type for the network offering, supported types are Direct and Virtual.")
|
||||
private String guestIpType;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="list netowrk offerings available for network creation in specific zone")
|
||||
private Long zoneId;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -108,6 +111,10 @@ public class ListNetworkOfferingsCmd extends BaseListCmd {
|
|||
return guestIpType;
|
||||
}
|
||||
|
||||
public Long getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -2513,6 +2513,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
Object isShared = cmd.getIsShared();
|
||||
Object availability = cmd.getAvailability();
|
||||
Object guestIpType = cmd.getGuestIpType();
|
||||
Long zoneId = cmd.getZoneId();
|
||||
DataCenter zone = null;
|
||||
|
||||
if (zoneId != null) {
|
||||
zone = getZone(zoneId);
|
||||
}
|
||||
|
||||
Object keyword = cmd.getKeyword();
|
||||
|
||||
|
|
@ -2559,6 +2565,15 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
sc.addAnd("availability", SearchCriteria.Op.EQ, availability);
|
||||
}
|
||||
|
||||
if (zone != null) {
|
||||
if (zone.getNetworkType() == NetworkType.Basic) {
|
||||
//return empty list as we don't allow to create networks in basic zone, and shouldn't display networkOfferings
|
||||
return new ArrayList<NetworkOffering>();
|
||||
} else if (zone.isSecurityGroupEnabled()){
|
||||
sc.addAnd("guestType", SearchCriteria.Op.EQ, GuestIpType.Direct);
|
||||
}
|
||||
}
|
||||
|
||||
//Don't return system network offerings to the user
|
||||
sc.addAnd("systemOnly", SearchCriteria.Op.EQ, false);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue