From cabb02f9447b0e979d83e27735e063ee5787e4e3 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 6 Dec 2011 14:43:56 -0800 Subject: [PATCH] Removed unused values from the networkOffering response --- .../cloud/api/commands/CreateNetworkCmd.java | 2 +- .../commands/CreateNetworkOfferingCmd.java | 6 ++--- .../api/response/NetworkOfferingResponse.java | 21 ------------------ .../src/com/cloud/api/ApiResponseHelper.java | 17 +++++++------- .../com/cloud/network/NetworkManagerImpl.java | 22 ++++++++++++++----- 5 files changed, 29 insertions(+), 39 deletions(-) diff --git a/api/src/com/cloud/api/commands/CreateNetworkCmd.java b/api/src/com/cloud/api/commands/CreateNetworkCmd.java index c8acd4e539f..c7ff560c50c 100644 --- a/api/src/com/cloud/api/commands/CreateNetworkCmd.java +++ b/api/src/com/cloud/api/commands/CreateNetworkCmd.java @@ -81,7 +81,7 @@ public class CreateNetworkCmd extends BaseCmd { @Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain") private String networkDomain; - @Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values are account and domain. If not specified, defaulted to Account in Adavnce zone, and to Domain in Basic zone. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network") + @Parameter(name=ApiConstants.ACL_TYPE, type=CommandType.STRING, description="Access control type; supported values are account and domain. In 3.0 all shared networks should have aclType=Domain, and all Isolated networks - Account. Account means that only the account owner can use the network, domain - all accouns in the domain can use the network") private String aclType; @Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the network") diff --git a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java index 919c65e85ad..44157205901 100644 --- a/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java +++ b/api/src/com/cloud/api/commands/CreateNetworkOfferingCmd.java @@ -88,7 +88,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd { private Map serviceProviderList; @Parameter(name = ApiConstants.SERVICE_CAPABILITY_LIST, type = CommandType.MAP, description = "desired service capabilities as part of network offering") - private Map serviceCapabilistList; + private Map serviceCapabilitystList; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -173,9 +173,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd { public Map getServiceCapabilities(Service service) { Map capabilityMap = null; - if (serviceCapabilistList != null && !serviceCapabilistList.isEmpty()) { + if (serviceCapabilitystList != null && !serviceCapabilitystList.isEmpty()) { capabilityMap = new HashMap (); - Collection serviceCapabilityCollection = serviceCapabilistList.values(); + Collection serviceCapabilityCollection = serviceCapabilitystList.values(); Iterator iter = serviceCapabilityCollection.iterator(); while (iter.hasNext()) { HashMap svcCapabilityMap = (HashMap) iter.next(); diff --git a/api/src/com/cloud/api/response/NetworkOfferingResponse.java b/api/src/com/cloud/api/response/NetworkOfferingResponse.java index 1aa0a4b9624..1e4407a4a7f 100644 --- a/api/src/com/cloud/api/response/NetworkOfferingResponse.java +++ b/api/src/com/cloud/api/response/NetworkOfferingResponse.java @@ -73,15 +73,6 @@ public class NetworkOfferingResponse extends BaseResponse{ @SerializedName(ApiConstants.SERVICE) @Param(description="the list of supported services", responseObject = ServiceResponse.class) private List services; - @SerializedName(ApiConstants.IS_LB_SHARED) @Param(description="true if load balncer service offered is shared by multiple networks", responseObject = ServiceResponse.class) - private Boolean isLbShared; - - @SerializedName(ApiConstants.IS_SOURCE_NAT_SHARED) @Param(description="true if soruce NAT service offered is shared by multiple networks", responseObject = ServiceResponse.class) - private Boolean isSourceNatShared; - - @SerializedName(ApiConstants.REDUNDANT_ROUTER) @Param(description="true if gateway service offered redundant router", responseObject = ServiceResponse.class) - private Boolean isRedundantRouter; - public void setId(Long id) { this.id.setValue(id); } @@ -142,18 +133,6 @@ public class NetworkOfferingResponse extends BaseResponse{ this.guestIpType = type; } - public void setIsLBShared(boolean isLbSared) { - this.isLbShared = isLbSared; - } - - public void setIsSourceNatShared(boolean isSourceNatShared) { - this.isSourceNatShared = isSourceNatShared; - } - - public void setIsRedundantRouter(Boolean isRedundantRouter) { - this.isRedundantRouter = isRedundantRouter; - } - public void setServiceOfferingId(Long serviceOfferingId) { this.serviceOfferingId.setValue(serviceOfferingId); } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 50836dcdbdb..dcf7b9d0752 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -2604,21 +2604,20 @@ public class ApiResponseHelper implements ResponseGenerator { lbIsoaltion.setValue(offering.getDedicatedLB()?"dedicated":"shared"); lbCapResponse.add(lbIsoaltion); svcRsp.setCapabilities(lbCapResponse); - } else if (Service.Firewall.getName().equalsIgnoreCase(service)) { - List fwCapResponse = new ArrayList(); + } else if (Service.SourceNat.getName().equalsIgnoreCase(service)) { + List capabilities = new ArrayList(); CapabilityResponse sharedSourceNat = new CapabilityResponse(); sharedSourceNat.setName(Capability.SupportedSourceNatTypes.getName()); sharedSourceNat.setValue(offering.getSharedSourceNat()?"perzone":"peraccount"); - fwCapResponse.add(sharedSourceNat); - svcRsp.setCapabilities(fwCapResponse); - } else if (Service.Gateway.getName().equalsIgnoreCase(service)) { - List gatewayCapResponse = new ArrayList(); + capabilities.add(sharedSourceNat); + CapabilityResponse redundantRouter = new CapabilityResponse(); redundantRouter.setName(Capability.RedundantRouter.getName()); redundantRouter.setValue(offering.getRedundantRouter()?"true":"false"); - gatewayCapResponse.add(redundantRouter); - svcRsp.setCapabilities(gatewayCapResponse); - } + capabilities.add(redundantRouter); + + svcRsp.setCapabilities(capabilities); + } serviceResponses.add(svcRsp); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 2633c38feb7..04d3495834b 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -1765,11 +1765,23 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } else { throw new InvalidParameterValueException("Incorrect aclType specified. Check the API documentation for supported types"); } - } else if (zone.getNetworkType() == NetworkType.Advanced){ - aclType = ACLType.Account; - } else if (zone.getNetworkType() == NetworkType.Basic){ - aclType = ACLType.Domain; - } + //In 3.0 all Shared networks should have aclType == Domain, all Isolated networks aclType==Account + if (networkOffering.getGuestType() == GuestType.Isolated) { + if (aclType != ACLType.Account) { + throw new InvalidParameterValueException("AclType should be " + ACLType.Account + " for network of type " + Network.GuestType.Isolated); + } + } else if (networkOffering.getGuestType() == GuestType.Shared) { + if (aclType != ACLType.Domain) { + throw new InvalidParameterValueException("AclType should be " + ACLType.Domain + " for network of type " + Network.GuestType.Shared); + } + } + } else { + if (networkOffering.getGuestType() == GuestType.Isolated) { + aclType = ACLType.Account; + } else if (networkOffering.getGuestType() == GuestType.Shared) { + aclType = ACLType.Domain; + } + } // Check if the network is domain specific if (aclType == ACLType.Domain) {