From ec7c22f5c7ab757538a9b7c0fb06abe094caea1c Mon Sep 17 00:00:00 2001 From: frank Date: Thu, 5 Jan 2012 16:12:02 -0800 Subject: [PATCH] Bug 12777 - Add storage network configuration into CloudStack new API: ListTafficTypeImplementors --- api/src/com/cloud/api/ApiConstants.java | 1 + api/src/com/cloud/api/BaseCmd.java | 1 + .../ListTafficTypeImplementorsCmd.java | 69 +++++++++++++++++++ .../api/commands/ListTrafficTypesCmd.java | 2 - .../listStorageNetworkIpRangeCmd.java | 16 +---- .../TrafficTypeImplementorResponse.java | 21 ++++++ api/src/com/cloud/event/EventTypes.java | 1 - api/src/com/cloud/network/NetworkService.java | 4 ++ api/src/com/cloud/network/Networks.java | 18 +++++ .../com/cloud/network/guru/NetworkGuru.java | 5 ++ .../com/cloud/network/NetworkManagerImpl.java | 21 ++++++ .../network/guru/ControlNetworkGuru.java | 21 +++++- .../cloud/network/guru/DirectNetworkGuru.java | 19 ++++- .../guru/DirectPodBasedNetworkGuru.java | 2 +- .../cloud/network/guru/GuestNetworkGuru.java | 19 ++++- .../network/guru/PodBasedNetworkGuru.java | 19 ++++- .../cloud/network/guru/PublicNetworkGuru.java | 19 ++++- .../network/guru/StorageNetworkGuru.java | 19 ++++- 18 files changed, 253 insertions(+), 24 deletions(-) create mode 100755 api/src/com/cloud/api/commands/ListTafficTypeImplementorsCmd.java mode change 100644 => 100755 api/src/com/cloud/api/commands/ListTrafficTypesCmd.java create mode 100755 api/src/com/cloud/api/response/TrafficTypeImplementorResponse.java mode change 100644 => 100755 api/src/com/cloud/network/NetworkService.java mode change 100644 => 100755 api/src/com/cloud/network/guru/NetworkGuru.java mode change 100644 => 100755 server/src/com/cloud/network/guru/ControlNetworkGuru.java mode change 100644 => 100755 server/src/com/cloud/network/guru/DirectNetworkGuru.java mode change 100644 => 100755 server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java mode change 100644 => 100755 server/src/com/cloud/network/guru/PublicNetworkGuru.java diff --git a/api/src/com/cloud/api/ApiConstants.java b/api/src/com/cloud/api/ApiConstants.java index 3337089fdd6..3566b6da3c6 100755 --- a/api/src/com/cloud/api/ApiConstants.java +++ b/api/src/com/cloud/api/ApiConstants.java @@ -320,6 +320,7 @@ public class ApiConstants { public static final String RESTART_REQUIRED = "restartrequired"; public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects"; public static final String CONSERVE_MODE = "conservemode"; + public static final String TRAFFIC_TYPE_IMPLEMENTOR = "traffictypeimplementor"; public enum HostDetails { all, capacity, events, stats, min; diff --git a/api/src/com/cloud/api/BaseCmd.java b/api/src/com/cloud/api/BaseCmd.java index 398aeebd68d..09a5dfd7f8f 100755 --- a/api/src/com/cloud/api/BaseCmd.java +++ b/api/src/com/cloud/api/BaseCmd.java @@ -28,6 +28,7 @@ import java.util.regex.Pattern; import org.apache.log4j.Logger; +import com.cloud.api.response.TrafficTypeImplementorResponse; import com.cloud.configuration.ConfigurationService; import com.cloud.consoleproxy.ConsoleProxyService; import com.cloud.dao.EntityManager; diff --git a/api/src/com/cloud/api/commands/ListTafficTypeImplementorsCmd.java b/api/src/com/cloud/api/commands/ListTafficTypeImplementorsCmd.java new file mode 100755 index 00000000000..a561ca434c2 --- /dev/null +++ b/api/src/com/cloud/api/commands/ListTafficTypeImplementorsCmd.java @@ -0,0 +1,69 @@ +package com.cloud.api.commands; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import com.cloud.api.ApiConstants; +import com.cloud.api.BaseListCmd; +import com.cloud.api.Implementation; +import com.cloud.api.Parameter; +import com.cloud.api.ServerApiException; +import com.cloud.api.response.ListResponse; +import com.cloud.api.response.TrafficTypeImplementorResponse; +import com.cloud.exception.ConcurrentOperationException; +import com.cloud.exception.InsufficientCapacityException; +import com.cloud.exception.ResourceAllocationException; +import com.cloud.exception.ResourceUnavailableException; +import com.cloud.network.Networks.TrafficType; +import com.cloud.user.Account; +import com.cloud.utils.Pair; + +@Implementation(description="Lists implementors of implementor of a network traffic type or implementors of all network traffic types", responseObject=TrafficTypeImplementorResponse.class) +public class ListTafficTypeImplementorsCmd extends BaseListCmd { + public static final Logger s_logger = Logger.getLogger(ListTafficTypeImplementorsCmd.class); + private static final String _name = "listtraffictypeimplementorsresponse"; + + ///////////////////////////////////////////////////// + //////////////// API parameters ///////////////////// + ///////////////////////////////////////////////////// + @Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="Optional. The network traffic type, if specified, return its implementor. Otherwise, return all traffic types with their implementor") + private String trafficType; + + ///////////////////////////////////////////////////// + /////////////////// Accessors /////////////////////// + ///////////////////////////////////////////////////// + + public String getTrafficType() { + return trafficType; + } + + @Override + public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, + ResourceAllocationException { + List> results = _networkService.listTrafficTypeImplementor(this); + ListResponse response = new ListResponse(); + List responses= new ArrayList(); + for (Pair r : results) { + TrafficTypeImplementorResponse p = new TrafficTypeImplementorResponse(); + p.setTrafficType(r.first().toString()); + p.setImplementor(r.second()); + responses.add(p); + } + + response.setResponses(responses); + response.setResponseName(getCommandName()); + this.setResponseObject(response); + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public String getCommandName() { + return _name; + } +} diff --git a/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java b/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java old mode 100644 new mode 100755 index 4b163aa3a0e..a21ee5412d9 --- a/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java +++ b/api/src/com/cloud/api/commands/ListTrafficTypesCmd.java @@ -86,6 +86,4 @@ public class ListTrafficTypesCmd extends BaseListCmd { response.setResponseName(getCommandName()); this.setResponseObject(response); } - - } diff --git a/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java b/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java index af0984433d6..943f0737d91 100755 --- a/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java +++ b/api/src/com/cloud/api/commands/listStorageNetworkIpRangeCmd.java @@ -6,17 +6,15 @@ import java.util.List; import org.apache.log4j.Logger; import com.cloud.api.ApiConstants; -import com.cloud.api.BaseAsyncCmd; import com.cloud.api.BaseCmd; +import com.cloud.api.BaseListCmd; import com.cloud.api.IdentityMapper; import com.cloud.api.Implementation; import com.cloud.api.Parameter; import com.cloud.api.ServerApiException; -import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.ListResponse; import com.cloud.api.response.StorageNetworkIpRangeResponse; import com.cloud.dc.StorageNetworkIpRange; -import com.cloud.event.EventTypes; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceAllocationException; @@ -24,7 +22,7 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.user.Account; @Implementation(description="List a storage network IP range.", responseObject=StorageNetworkIpRangeResponse.class) -public class listStorageNetworkIpRangeCmd extends BaseAsyncCmd { +public class listStorageNetworkIpRangeCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(listStorageNetworkIpRangeCmd.class); String s_name = "liststoragenetworkiprangeresponse"; @@ -60,16 +58,6 @@ public class listStorageNetworkIpRangeCmd extends BaseAsyncCmd { public Long getZoneId() { return zoneId; } - - @Override - public String getEventType() { - return EventTypes.EVENT_STORAGE_IP_RANGE_LIST; - } - - @Override - public String getEventDescription() { - return "List storage network IP range"; - } @Override public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, diff --git a/api/src/com/cloud/api/response/TrafficTypeImplementorResponse.java b/api/src/com/cloud/api/response/TrafficTypeImplementorResponse.java new file mode 100755 index 00000000000..36f93af778e --- /dev/null +++ b/api/src/com/cloud/api/response/TrafficTypeImplementorResponse.java @@ -0,0 +1,21 @@ +package com.cloud.api.response; + +import com.cloud.api.ApiConstants; +import com.cloud.serializer.Param; +import com.google.gson.annotations.SerializedName; + +public class TrafficTypeImplementorResponse extends BaseResponse { + @SerializedName(ApiConstants.TRAFFIC_TYPE) @Param(description="network traffic type") + private String trafficType; + + @SerializedName(ApiConstants.TRAFFIC_TYPE_IMPLEMENTOR) @Param(description="implementor of network traffic type") + private String implementor; + + public void setTrafficType(String type) { + this.trafficType = type; + } + + public void setImplementor(String impl) { + this.implementor = impl; + } +} diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 3bd3f5f54c0..3c6c6d0e77c 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -172,7 +172,6 @@ public class EventTypes { public static final String EVENT_STORAGE_IP_RANGE_CREATE = "STORAGE.IP.RANGE.CREATE"; public static final String EVENT_STORAGE_IP_RANGE_DELETE = "STORAGE.IP.RANGE.DELETE"; - public static final String EVENT_STORAGE_IP_RANGE_LIST = "STORAGE.IP.RANGE.LIST"; // Configuration Table public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT"; diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java old mode 100644 new mode 100755 index ed451e51492..84220cace6b --- a/api/src/com/cloud/network/NetworkService.java +++ b/api/src/com/cloud/network/NetworkService.java @@ -24,6 +24,7 @@ import java.util.Set; import com.cloud.api.commands.AssociateIPAddrCmd; import com.cloud.api.commands.CreateNetworkCmd; import com.cloud.api.commands.ListNetworksCmd; +import com.cloud.api.commands.ListTafficTypeImplementorsCmd; import com.cloud.api.commands.RestartNetworkCmd; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientAddressCapacityException; @@ -36,6 +37,7 @@ import com.cloud.network.Network.Service; import com.cloud.network.Networks.TrafficType; import com.cloud.user.Account; import com.cloud.user.User; +import com.cloud.utils.Pair; public interface NetworkService { @@ -129,4 +131,6 @@ public interface NetworkService { PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType); Network getExclusiveGuestNetwork(long zoneId); + + List> listTrafficTypeImplementor(ListTafficTypeImplementorsCmd cmd); } diff --git a/api/src/com/cloud/network/Networks.java b/api/src/com/cloud/network/Networks.java index 3ad532c4583..ed88d9c7cd4 100755 --- a/api/src/com/cloud/network/Networks.java +++ b/api/src/com/cloud/network/Networks.java @@ -99,6 +99,7 @@ public class Networks { * Different types of network traffic in the data center. */ public enum TrafficType { + None, Public, Guest, Storage, @@ -115,6 +116,23 @@ public class Networks { return false; } + public static TrafficType getTrafficType(String type) { + if (type.equals("Public")) { + return Public; + } else if (type.endsWith("Guest")) { + return Guest; + } else if (type.endsWith("Storage")) { + return Storage; + } else if (type.endsWith("Management")) { + return Management; + } else if (type.endsWith("Control")) { + return Control; + } else if (type.endsWith("Vpn")) { + return Vpn; + } else { + return None; + } + } }; public enum IsolationType { diff --git a/api/src/com/cloud/network/guru/NetworkGuru.java b/api/src/com/cloud/network/guru/NetworkGuru.java old mode 100644 new mode 100755 index e50b8192611..dd444c5b9c3 --- a/api/src/com/cloud/network/guru/NetworkGuru.java +++ b/api/src/com/cloud/network/guru/NetworkGuru.java @@ -28,6 +28,7 @@ import com.cloud.exception.InsufficientAddressCapacityException; import com.cloud.exception.InsufficientVirtualNetworkCapcityException; import com.cloud.network.Network; import com.cloud.network.NetworkProfile; +import com.cloud.network.Networks.TrafficType; import com.cloud.offering.NetworkOffering; import com.cloud.user.Account; import com.cloud.utils.component.Adapter; @@ -229,4 +230,8 @@ public interface NetworkGuru extends Adapter { boolean trash(Network network, NetworkOffering offering, Account owner); void updateNetworkProfile(NetworkProfile networkProfile); + + TrafficType[] getSupportedTrafficType(); + + boolean isMyTrafficType(TrafficType type); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index b4a444ca4b5..909857f8e60 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -58,6 +58,7 @@ import com.cloud.alert.AlertManager; import com.cloud.api.commands.AssociateIPAddrCmd; import com.cloud.api.commands.CreateNetworkCmd; import com.cloud.api.commands.ListNetworksCmd; +import com.cloud.api.commands.ListTafficTypeImplementorsCmd; import com.cloud.api.commands.RestartNetworkCmd; import com.cloud.capacity.dao.CapacityDao; import com.cloud.configuration.Config; @@ -5646,4 +5647,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } return canIpUsedForConserveService(publicIp, service); } + + @Override + public List> listTrafficTypeImplementor(ListTafficTypeImplementorsCmd cmd) { + String type = cmd.getTrafficType(); + List> results = new ArrayList>(); + if (type != null) { + for (NetworkGuru guru : _networkGurus) { + if (guru.isMyTrafficType(TrafficType.getTrafficType(type))) { + results.add(new Pair(TrafficType.getTrafficType(type), guru.getName())); + break; + } + } + } else { + for (NetworkGuru guru : _networkGurus) { + results.add(new Pair(TrafficType.getTrafficType(type), guru.getName())); + } + } + + return results; + } } diff --git a/server/src/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/com/cloud/network/guru/ControlNetworkGuru.java old mode 100644 new mode 100755 index 85391bac3be..b2194c01df3 --- a/server/src/com/cloud/network/guru/ControlNetworkGuru.java +++ b/server/src/com/cloud/network/guru/ControlNetworkGuru.java @@ -41,10 +41,12 @@ import com.cloud.network.NetworkProfile; import com.cloud.network.NetworkVO; import com.cloud.network.Networks.AddressFormat; import com.cloud.network.Networks.BroadcastDomainType; +import com.cloud.network.Networks.IsolationType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; import com.cloud.offering.NetworkOffering; import com.cloud.user.Account; +import com.cloud.utils.Pair; import com.cloud.utils.component.ComponentLocator; import com.cloud.utils.component.Inject; import com.cloud.utils.exception.CloudRuntimeException; @@ -63,8 +65,25 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu String _cidr; String _gateway; + private static final TrafficType[] _trafficTypes = {TrafficType.Control}; + + @Override + public boolean isMyTrafficType(TrafficType type) { + for (TrafficType t : _trafficTypes) { + if (t == type) { + return true; + } + } + return false; + } + + @Override + public TrafficType[] getSupportedTrafficType() { + return _trafficTypes; + } + protected boolean canHandle(NetworkOffering offering) { - if (offering.isSystemOnly() && offering.getTrafficType() == TrafficType.Control) { + if (offering.isSystemOnly() && isMyTrafficType(offering.getTrafficType())) { return true; } else { s_logger.trace("We only care about System only Control network"); diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java old mode 100644 new mode 100755 index e615bc31273..6c337239267 --- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java +++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java @@ -74,10 +74,27 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru { IPAddressDao _ipAddressDao; @Inject NetworkOfferingDao _networkOfferingDao; + + private static final TrafficType[] _trafficTypes = {TrafficType.Guest}; + + @Override + public boolean isMyTrafficType(TrafficType type) { + for (TrafficType t : _trafficTypes) { + if (t == type) { + return true; + } + } + return false; + } + @Override + public TrafficType[] getSupportedTrafficType() { + return _trafficTypes; + } + protected boolean canHandle(NetworkOffering offering, DataCenter dc) { // this guru handles only Guest networks in Advance zone with source nat service disabled - if (dc.getNetworkType() == NetworkType.Advanced && !_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)&& offering.getTrafficType() == TrafficType.Guest) { + if (dc.getNetworkType() == NetworkType.Advanced && !_networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)&& isMyTrafficType(offering.getTrafficType())) { return true; } else { s_logger.trace("We only take care of Guest Direct networks"); diff --git a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java old mode 100644 new mode 100755 index fd41f81e62b..9b02126cd7f --- a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java +++ b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java @@ -79,7 +79,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru { @Override protected boolean canHandle(NetworkOffering offering, DataCenter dc) { // this guru handles system Direct pod based network - if (dc.getNetworkType() == NetworkType.Basic && offering.getTrafficType() == TrafficType.Guest) { + if (dc.getNetworkType() == NetworkType.Basic && isMyTrafficType(offering.getTrafficType())) { return true; } else { s_logger.trace("We only take care of Guest Direct Pod based networks"); diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java index fb00f50f94e..49aa78ce29c 100755 --- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java +++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java @@ -78,16 +78,33 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru { protected NetworkDao _networkDao; Random _rand = new Random(System.currentTimeMillis()); + private static final TrafficType[] _trafficTypes = {TrafficType.Guest}; + String _defaultGateway; String _defaultCidr; protected GuestNetworkGuru() { super(); } + + @Override + public boolean isMyTrafficType(TrafficType type) { + for (TrafficType t : _trafficTypes) { + if (t == type) { + return true; + } + } + return false; + } + @Override + public TrafficType[] getSupportedTrafficType() { + return _trafficTypes; + } + protected boolean canHandle(NetworkOffering offering, DataCenter dc) { // This guru handles only Guest Isolated network that supports Source nat service - if (dc.getNetworkType() == NetworkType.Advanced && offering.getTrafficType() == TrafficType.Guest && offering.getGuestType() == Network.GuestType.Isolated && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)) { + if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == Network.GuestType.Isolated && _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SourceNat)) { return true; } else { s_logger.trace("We only take care of Guest networks with service " + Service.SourceNat + " enabled in zone of type " + NetworkType.Advanced); diff --git a/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java b/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java index 851507f98c9..490605466a1 100755 --- a/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java +++ b/server/src/com/cloud/network/guru/PodBasedNetworkGuru.java @@ -61,12 +61,29 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru { @Inject DataCenterDao _dcDao; @Inject StorageNetworkManager _sNwMgr; Random _rand = new Random(System.currentTimeMillis()); + + private static final TrafficType[] _trafficTypes = {TrafficType.Management, TrafficType.Storage}; + + @Override + public boolean isMyTrafficType(TrafficType type) { + for (TrafficType t : _trafficTypes) { + if (t == type) { + return true; + } + } + return false; + } + @Override + public TrafficType[] getSupportedTrafficType() { + return _trafficTypes; + } + @Override public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) { TrafficType type = offering.getTrafficType(); - if (type != TrafficType.Management && type != TrafficType.Storage) { + if (!isMyTrafficType(type)) { return null; } diff --git a/server/src/com/cloud/network/guru/PublicNetworkGuru.java b/server/src/com/cloud/network/guru/PublicNetworkGuru.java old mode 100644 new mode 100755 index 3f98adb09a0..835127eb340 --- a/server/src/com/cloud/network/guru/PublicNetworkGuru.java +++ b/server/src/com/cloud/network/guru/PublicNetworkGuru.java @@ -74,8 +74,25 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru { @Inject IPAddressDao _ipAddressDao; + private static final TrafficType[] _trafficTypes = {TrafficType.Public}; + + @Override + public boolean isMyTrafficType(TrafficType type) { + for (TrafficType t : _trafficTypes) { + if (t == type) { + return true; + } + } + return false; + } + + @Override + public TrafficType[] getSupportedTrafficType() { + return _trafficTypes; + } + protected boolean canHandle(NetworkOffering offering) { - return offering.getTrafficType() == TrafficType.Public && offering.isSystemOnly(); + return isMyTrafficType(offering.getTrafficType()) && offering.isSystemOnly(); } @Override diff --git a/server/src/com/cloud/network/guru/StorageNetworkGuru.java b/server/src/com/cloud/network/guru/StorageNetworkGuru.java index d6eae133dd7..f6710ca6d90 100755 --- a/server/src/com/cloud/network/guru/StorageNetworkGuru.java +++ b/server/src/com/cloud/network/guru/StorageNetworkGuru.java @@ -40,8 +40,25 @@ public class StorageNetworkGuru extends AdapterBase implements NetworkGuru { super(); } + private static final TrafficType[] _trafficTypes = {TrafficType.Storage}; + + @Override + public boolean isMyTrafficType(TrafficType type) { + for (TrafficType t : _trafficTypes) { + if (t == type) { + return true; + } + } + return false; + } + + @Override + public TrafficType[] getSupportedTrafficType() { + return _trafficTypes; + } + protected boolean canHandle(NetworkOffering offering) { - if (offering.getTrafficType() == TrafficType.Storage && offering.isSystemOnly()) { + if (isMyTrafficType(offering.getTrafficType()) && offering.isSystemOnly()) { if (_sNwMgr.isStorageIpRangeAvailable()) { return true; } else {