mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Bug 12777 - Add storage network configuration into CloudStack
new API: ListTafficTypeImplementors
This commit is contained in:
parent
51dc4aff80
commit
ec7c22f5c7
@ -320,6 +320,7 @@ public class ApiConstants {
|
|||||||
public static final String RESTART_REQUIRED = "restartrequired";
|
public static final String RESTART_REQUIRED = "restartrequired";
|
||||||
public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects";
|
public static final String ALLOW_USER_CREATE_PROJECTS = "allowusercreateprojects";
|
||||||
public static final String CONSERVE_MODE = "conservemode";
|
public static final String CONSERVE_MODE = "conservemode";
|
||||||
|
public static final String TRAFFIC_TYPE_IMPLEMENTOR = "traffictypeimplementor";
|
||||||
|
|
||||||
public enum HostDetails {
|
public enum HostDetails {
|
||||||
all, capacity, events, stats, min;
|
all, capacity, events, stats, min;
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.response.TrafficTypeImplementorResponse;
|
||||||
import com.cloud.configuration.ConfigurationService;
|
import com.cloud.configuration.ConfigurationService;
|
||||||
import com.cloud.consoleproxy.ConsoleProxyService;
|
import com.cloud.consoleproxy.ConsoleProxyService;
|
||||||
import com.cloud.dao.EntityManager;
|
import com.cloud.dao.EntityManager;
|
||||||
|
|||||||
69
api/src/com/cloud/api/commands/ListTafficTypeImplementorsCmd.java
Executable file
69
api/src/com/cloud/api/commands/ListTafficTypeImplementorsCmd.java
Executable file
@ -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<Pair<TrafficType, String>> results = _networkService.listTrafficTypeImplementor(this);
|
||||||
|
ListResponse<TrafficTypeImplementorResponse> response = new ListResponse<TrafficTypeImplementorResponse>();
|
||||||
|
List<TrafficTypeImplementorResponse> responses= new ArrayList<TrafficTypeImplementorResponse>();
|
||||||
|
for (Pair<TrafficType, String> 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
api/src/com/cloud/api/commands/ListTrafficTypesCmd.java
Normal file → Executable file
2
api/src/com/cloud/api/commands/ListTrafficTypesCmd.java
Normal file → Executable file
@ -86,6 +86,4 @@ public class ListTrafficTypesCmd extends BaseListCmd {
|
|||||||
response.setResponseName(getCommandName());
|
response.setResponseName(getCommandName());
|
||||||
this.setResponseObject(response);
|
this.setResponseObject(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,17 +6,15 @@ import java.util.List;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.api.ApiConstants;
|
import com.cloud.api.ApiConstants;
|
||||||
import com.cloud.api.BaseAsyncCmd;
|
|
||||||
import com.cloud.api.BaseCmd;
|
import com.cloud.api.BaseCmd;
|
||||||
|
import com.cloud.api.BaseListCmd;
|
||||||
import com.cloud.api.IdentityMapper;
|
import com.cloud.api.IdentityMapper;
|
||||||
import com.cloud.api.Implementation;
|
import com.cloud.api.Implementation;
|
||||||
import com.cloud.api.Parameter;
|
import com.cloud.api.Parameter;
|
||||||
import com.cloud.api.ServerApiException;
|
import com.cloud.api.ServerApiException;
|
||||||
import com.cloud.api.BaseCmd.CommandType;
|
|
||||||
import com.cloud.api.response.ListResponse;
|
import com.cloud.api.response.ListResponse;
|
||||||
import com.cloud.api.response.StorageNetworkIpRangeResponse;
|
import com.cloud.api.response.StorageNetworkIpRangeResponse;
|
||||||
import com.cloud.dc.StorageNetworkIpRange;
|
import com.cloud.dc.StorageNetworkIpRange;
|
||||||
import com.cloud.event.EventTypes;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
import com.cloud.exception.InsufficientCapacityException;
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
import com.cloud.exception.ResourceAllocationException;
|
||||||
@ -24,7 +22,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
|
||||||
@Implementation(description="List a storage network IP range.", responseObject=StorageNetworkIpRangeResponse.class)
|
@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);
|
public static final Logger s_logger = Logger.getLogger(listStorageNetworkIpRangeCmd.class);
|
||||||
|
|
||||||
String s_name = "liststoragenetworkiprangeresponse";
|
String s_name = "liststoragenetworkiprangeresponse";
|
||||||
@ -61,16 +59,6 @@ public class listStorageNetworkIpRangeCmd extends BaseAsyncCmd {
|
|||||||
return zoneId;
|
return zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType() {
|
|
||||||
return EventTypes.EVENT_STORAGE_IP_RANGE_LIST;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventDescription() {
|
|
||||||
return "List storage network IP range";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||||
ResourceAllocationException {
|
ResourceAllocationException {
|
||||||
|
|||||||
21
api/src/com/cloud/api/response/TrafficTypeImplementorResponse.java
Executable file
21
api/src/com/cloud/api/response/TrafficTypeImplementorResponse.java
Executable file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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_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_DELETE = "STORAGE.IP.RANGE.DELETE";
|
||||||
public static final String EVENT_STORAGE_IP_RANGE_LIST = "STORAGE.IP.RANGE.LIST";
|
|
||||||
|
|
||||||
// Configuration Table
|
// Configuration Table
|
||||||
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
|
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
|
||||||
|
|||||||
4
api/src/com/cloud/network/NetworkService.java
Normal file → Executable file
4
api/src/com/cloud/network/NetworkService.java
Normal file → Executable file
@ -24,6 +24,7 @@ import java.util.Set;
|
|||||||
import com.cloud.api.commands.AssociateIPAddrCmd;
|
import com.cloud.api.commands.AssociateIPAddrCmd;
|
||||||
import com.cloud.api.commands.CreateNetworkCmd;
|
import com.cloud.api.commands.CreateNetworkCmd;
|
||||||
import com.cloud.api.commands.ListNetworksCmd;
|
import com.cloud.api.commands.ListNetworksCmd;
|
||||||
|
import com.cloud.api.commands.ListTafficTypeImplementorsCmd;
|
||||||
import com.cloud.api.commands.RestartNetworkCmd;
|
import com.cloud.api.commands.RestartNetworkCmd;
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
import com.cloud.exception.ConcurrentOperationException;
|
||||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||||
@ -36,6 +37,7 @@ import com.cloud.network.Network.Service;
|
|||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.user.User;
|
import com.cloud.user.User;
|
||||||
|
import com.cloud.utils.Pair;
|
||||||
|
|
||||||
public interface NetworkService {
|
public interface NetworkService {
|
||||||
|
|
||||||
@ -129,4 +131,6 @@ public interface NetworkService {
|
|||||||
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
|
||||||
|
|
||||||
Network getExclusiveGuestNetwork(long zoneId);
|
Network getExclusiveGuestNetwork(long zoneId);
|
||||||
|
|
||||||
|
List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTafficTypeImplementorsCmd cmd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,6 +99,7 @@ public class Networks {
|
|||||||
* Different types of network traffic in the data center.
|
* Different types of network traffic in the data center.
|
||||||
*/
|
*/
|
||||||
public enum TrafficType {
|
public enum TrafficType {
|
||||||
|
None,
|
||||||
Public,
|
Public,
|
||||||
Guest,
|
Guest,
|
||||||
Storage,
|
Storage,
|
||||||
@ -115,6 +116,23 @@ public class Networks {
|
|||||||
return false;
|
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 {
|
public enum IsolationType {
|
||||||
|
|||||||
5
api/src/com/cloud/network/guru/NetworkGuru.java
Normal file → Executable file
5
api/src/com/cloud/network/guru/NetworkGuru.java
Normal file → Executable file
@ -28,6 +28,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
|||||||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||||
import com.cloud.network.Network;
|
import com.cloud.network.Network;
|
||||||
import com.cloud.network.NetworkProfile;
|
import com.cloud.network.NetworkProfile;
|
||||||
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
import com.cloud.utils.component.Adapter;
|
import com.cloud.utils.component.Adapter;
|
||||||
@ -229,4 +230,8 @@ public interface NetworkGuru extends Adapter {
|
|||||||
boolean trash(Network network, NetworkOffering offering, Account owner);
|
boolean trash(Network network, NetworkOffering offering, Account owner);
|
||||||
|
|
||||||
void updateNetworkProfile(NetworkProfile networkProfile);
|
void updateNetworkProfile(NetworkProfile networkProfile);
|
||||||
|
|
||||||
|
TrafficType[] getSupportedTrafficType();
|
||||||
|
|
||||||
|
boolean isMyTrafficType(TrafficType type);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ import com.cloud.alert.AlertManager;
|
|||||||
import com.cloud.api.commands.AssociateIPAddrCmd;
|
import com.cloud.api.commands.AssociateIPAddrCmd;
|
||||||
import com.cloud.api.commands.CreateNetworkCmd;
|
import com.cloud.api.commands.CreateNetworkCmd;
|
||||||
import com.cloud.api.commands.ListNetworksCmd;
|
import com.cloud.api.commands.ListNetworksCmd;
|
||||||
|
import com.cloud.api.commands.ListTafficTypeImplementorsCmd;
|
||||||
import com.cloud.api.commands.RestartNetworkCmd;
|
import com.cloud.api.commands.RestartNetworkCmd;
|
||||||
import com.cloud.capacity.dao.CapacityDao;
|
import com.cloud.capacity.dao.CapacityDao;
|
||||||
import com.cloud.configuration.Config;
|
import com.cloud.configuration.Config;
|
||||||
@ -5646,4 +5647,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||||||
}
|
}
|
||||||
return canIpUsedForConserveService(publicIp, service);
|
return canIpUsedForConserveService(publicIp, service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTafficTypeImplementorsCmd cmd) {
|
||||||
|
String type = cmd.getTrafficType();
|
||||||
|
List<Pair<TrafficType, String>> results = new ArrayList<Pair<TrafficType, String>>();
|
||||||
|
if (type != null) {
|
||||||
|
for (NetworkGuru guru : _networkGurus) {
|
||||||
|
if (guru.isMyTrafficType(TrafficType.getTrafficType(type))) {
|
||||||
|
results.add(new Pair<TrafficType, String>(TrafficType.getTrafficType(type), guru.getName()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (NetworkGuru guru : _networkGurus) {
|
||||||
|
results.add(new Pair<TrafficType, String>(TrafficType.getTrafficType(type), guru.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
server/src/com/cloud/network/guru/ControlNetworkGuru.java
Normal file → Executable file
21
server/src/com/cloud/network/guru/ControlNetworkGuru.java
Normal file → Executable file
@ -41,10 +41,12 @@ import com.cloud.network.NetworkProfile;
|
|||||||
import com.cloud.network.NetworkVO;
|
import com.cloud.network.NetworkVO;
|
||||||
import com.cloud.network.Networks.AddressFormat;
|
import com.cloud.network.Networks.AddressFormat;
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
import com.cloud.network.Networks.BroadcastDomainType;
|
||||||
|
import com.cloud.network.Networks.IsolationType;
|
||||||
import com.cloud.network.Networks.Mode;
|
import com.cloud.network.Networks.Mode;
|
||||||
import com.cloud.network.Networks.TrafficType;
|
import com.cloud.network.Networks.TrafficType;
|
||||||
import com.cloud.offering.NetworkOffering;
|
import com.cloud.offering.NetworkOffering;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.ComponentLocator;
|
import com.cloud.utils.component.ComponentLocator;
|
||||||
import com.cloud.utils.component.Inject;
|
import com.cloud.utils.component.Inject;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
@ -63,8 +65,25 @@ public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGu
|
|||||||
String _cidr;
|
String _cidr;
|
||||||
String _gateway;
|
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) {
|
protected boolean canHandle(NetworkOffering offering) {
|
||||||
if (offering.isSystemOnly() && offering.getTrafficType() == TrafficType.Control) {
|
if (offering.isSystemOnly() && isMyTrafficType(offering.getTrafficType())) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
s_logger.trace("We only care about System only Control network");
|
s_logger.trace("We only care about System only Control network");
|
||||||
|
|||||||
19
server/src/com/cloud/network/guru/DirectNetworkGuru.java
Normal file → Executable file
19
server/src/com/cloud/network/guru/DirectNetworkGuru.java
Normal file → Executable file
@ -75,9 +75,26 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
@Inject
|
@Inject
|
||||||
NetworkOfferingDao _networkOfferingDao;
|
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) {
|
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||||
// this guru handles only Guest networks in Advance zone with source nat service disabled
|
// 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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
s_logger.trace("We only take care of Guest Direct networks");
|
s_logger.trace("We only take care of Guest Direct networks");
|
||||||
|
|||||||
2
server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
Normal file → Executable file
2
server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
Normal file → Executable file
@ -79,7 +79,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||||
// this guru handles system Direct pod based network
|
// 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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
s_logger.trace("We only take care of Guest Direct Pod based networks");
|
s_logger.trace("We only take care of Guest Direct Pod based networks");
|
||||||
|
|||||||
@ -78,6 +78,8 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
protected NetworkDao _networkDao;
|
protected NetworkDao _networkDao;
|
||||||
Random _rand = new Random(System.currentTimeMillis());
|
Random _rand = new Random(System.currentTimeMillis());
|
||||||
|
|
||||||
|
private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
|
||||||
|
|
||||||
String _defaultGateway;
|
String _defaultGateway;
|
||||||
String _defaultCidr;
|
String _defaultCidr;
|
||||||
|
|
||||||
@ -85,9 +87,24 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
super();
|
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) {
|
protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
|
||||||
// This guru handles only Guest Isolated network that supports Source nat service
|
// 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;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
s_logger.trace("We only take care of Guest networks with service " + Service.SourceNat + " enabled in zone of type " + NetworkType.Advanced);
|
s_logger.trace("We only take care of Guest networks with service " + Service.SourceNat + " enabled in zone of type " + NetworkType.Advanced);
|
||||||
|
|||||||
@ -62,11 +62,28 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
@Inject StorageNetworkManager _sNwMgr;
|
@Inject StorageNetworkManager _sNwMgr;
|
||||||
Random _rand = new Random(System.currentTimeMillis());
|
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
|
@Override
|
||||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||||
TrafficType type = offering.getTrafficType();
|
TrafficType type = offering.getTrafficType();
|
||||||
|
|
||||||
if (type != TrafficType.Management && type != TrafficType.Storage) {
|
if (!isMyTrafficType(type)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
19
server/src/com/cloud/network/guru/PublicNetworkGuru.java
Normal file → Executable file
19
server/src/com/cloud/network/guru/PublicNetworkGuru.java
Normal file → Executable file
@ -74,8 +74,25 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
@Inject
|
@Inject
|
||||||
IPAddressDao _ipAddressDao;
|
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) {
|
protected boolean canHandle(NetworkOffering offering) {
|
||||||
return offering.getTrafficType() == TrafficType.Public && offering.isSystemOnly();
|
return isMyTrafficType(offering.getTrafficType()) && offering.isSystemOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -40,8 +40,25 @@ public class StorageNetworkGuru extends AdapterBase implements NetworkGuru {
|
|||||||
super();
|
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) {
|
protected boolean canHandle(NetworkOffering offering) {
|
||||||
if (offering.getTrafficType() == TrafficType.Storage && offering.isSystemOnly()) {
|
if (isMyTrafficType(offering.getTrafficType()) && offering.isSystemOnly()) {
|
||||||
if (_sNwMgr.isStorageIpRangeAvailable()) {
|
if (_sNwMgr.isStorageIpRangeAvailable()) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user