Bug 12777 - Add storage network configuration into CloudStack

Let StorageGuru inherit PodBaseNetworkGuru
This commit is contained in:
frank 2012-01-05 18:22:02 -08:00
parent cb6058906d
commit ea422af8a9
7 changed files with 60 additions and 23 deletions

View File

@ -117,17 +117,17 @@ public class Networks {
}
public static TrafficType getTrafficType(String type) {
if (type.equals("Public")) {
if ("Public".equals(type)) {
return Public;
} else if (type.endsWith("Guest")) {
} else if ("Guest".equals(type)) {
return Guest;
} else if (type.endsWith("Storage")) {
} else if ("Storage".equals(type)) {
return Storage;
} else if (type.endsWith("Management")) {
} else if ("Management".equals(type)) {
return Management;
} else if (type.endsWith("Control")) {
} else if ("Control".equals(type)) {
return Control;
} else if (type.endsWith("Vpn")) {
} else if ("Vpn".equals(type)) {
return Vpn;
} else {
return None;

View File

@ -52,14 +52,33 @@
<adapter name="Balance" class="com.cloud.consoleproxy.ConsoleProxyBalanceAllocator"/>
</adapters>
<adapters key="com.cloud.network.guru.NetworkGuru">
<!--
NOTE: The order of those gurus implicates priority of network traffic types the guru implements.
The upper the higher priority. It effects listTafficTypeImplementors API which returns impelmentor
of a specific network traffic.
A fair question is, if two gurus implement the same two network traffic types, but these traffic types
have cross priority, how to rank them? For example:
GuruA (TrafficTypeA, TrafficTypeB)
GuruB (TrafficTypeA, TrafficTypeB)
we want GuruB.TrafficTypeB > GuruA.TrafficTypeB and GuruB.TrafficTypeA < GuruA.TrafficTypeA. As the priority
implicated by order can not map to multiple traffic type, you have to do implement GuruC which inherits GuruB
for TrafficTypeB. Then ranking them in order of:
GuruC (TrafficTypeB)
GuruA (TrafficTypeA, TrafficTypeB)
GuruB (TrafficTypeA, TrafficTypeB)
now GuruC represents TrafficTypeB with highest priority while GuruA represents TrafficTypeA with highest pirority.
However, above case barely happens.
-->
<adapter name="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru"/>
<adapter name="ExternalGuestNetworkGuru" class="com.cloud.network.guru.ExternalGuestNetworkGuru"/>
<adapter name="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru"/>
<adapter name="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru"/>
<adapter name="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru"/>
<adapter name="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru"/>
<adapter name="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru"/>
<adapter name="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru"/>
<adapter name="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru"/>
<adapter name="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru"/>
</adapters>
<adapters key="com.cloud.cluster.ClusterServiceAdapter">
<adapter name="ClusterService" class="com.cloud.cluster.ClusterServiceServletAdapter"/>

View File

@ -235,8 +235,8 @@ public enum Config {
// XenServer
XenPublicNetwork("Network", ManagementServer.class, String.class, "xen.public.network.device", null, "[ONLY IF THE PUBLIC NETWORK IS ON A DEDICATED NIC]:The network name label of the physical device dedicated to the public network on a XenServer host", null),
XenStorageNetwork1("Network", ManagementServer.class, String.class, "xen.storage.network.device1", "cloud-stor1", "Specify when there are storage networks", null),
XenStorageNetwork2("Network", ManagementServer.class, String.class, "xen.storage.network.device2", "cloud-stor2", "Specify when there are storage networks", null),
XenStorageNetwork1("Network", ManagementServer.class, String.class, "xen.storage.network.device1", null, "Specify when there are storage networks", null),
XenStorageNetwork2("Network", ManagementServer.class, String.class, "xen.storage.network.device2", null, "Specify when there are storage networks", null),
XenPrivateNetwork("Network", ManagementServer.class, String.class, "xen.private.network.device", null, "Specify when the private network name is different", null),
NetworkGuestCidrLimit("Network", NetworkManager.class, Integer.class, "network.guest.cidr.limit", "22", "size limit for guest cidr; can't be less than this value", null),
XenSetupMultipath("Advanced", ManagementServer.class, String.class, "xen.setup.multipath", "false", "Setup the host to do multipath", null),

0
server/src/com/cloud/network/NetworkManager.java Normal file → Executable file
View File

View File

@ -5661,7 +5661,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
} else {
for (NetworkGuru guru : _networkGurus) {
results.add(new Pair<TrafficType, String>(TrafficType.getTrafficType(type), guru.getName()));
TrafficType[] allTypes = guru.getSupportedTrafficType();
for (TrafficType t : allTypes) {
results.add(new Pair<TrafficType, String>(t, guru.getName()));
}
}
}

View File

@ -36,11 +36,11 @@ import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkVO;
import com.cloud.network.StorageNetworkManager;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.StorageNetworkManager;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.utils.Pair;
@ -88,10 +88,10 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
}
if (type == TrafficType.Storage && _sNwMgr.isStorageIpRangeAvailable()) {
s_logger.debug("There is some storage ip available, let StorageNetworkGuru to handle storage traffic type, not me");
s_logger.debug("There is an storage network ip range, let StorageNetworkGuru to handle TrafficType.Storage");
return null;
}
NetworkVO config = new NetworkVO(type, Mode.Static, BroadcastDomainType.Native, offering.getId(), Network.State.Setup, plan.getDataCenterId(), plan.getPhysicalNetworkId());
return config;
}

View File

@ -32,7 +32,7 @@ import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.Nic.ReservationStrategy;
@Local(value = NetworkGuru.class)
public class StorageNetworkGuru extends AdapterBase implements NetworkGuru {
public class StorageNetworkGuru extends PodBasedNetworkGuru implements NetworkGuru {
private static final Logger s_logger = Logger.getLogger(StorageNetworkGuru.class);
@Inject StorageNetworkManager _sNwMgr;
@ -59,12 +59,7 @@ public class StorageNetworkGuru extends AdapterBase implements NetworkGuru {
protected boolean canHandle(NetworkOffering offering) {
if (isMyTrafficType(offering.getTrafficType()) && offering.isSystemOnly()) {
if (_sNwMgr.isStorageIpRangeAvailable()) {
return true;
} else {
s_logger.debug("No storage network ip range availabe, let PodBasedNetworkGuru to handle storage traffic type, not me");
return false;
}
return true;
} else {
s_logger.trace("It's not storage network offering, skip it.");
return false;
@ -77,6 +72,10 @@ public class StorageNetworkGuru extends AdapterBase implements NetworkGuru {
return null;
}
if (!_sNwMgr.isStorageIpRangeAvailable()) {
return super.design(offering, plan, userSpecified, owner);
}
NetworkVO config = new NetworkVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.Native, offering.getId(), Network.State.Setup,
plan.getDataCenterId(), plan.getPhysicalNetworkId());
return config;
@ -86,13 +85,20 @@ public class StorageNetworkGuru extends AdapterBase implements NetworkGuru {
public Network implement(Network network, NetworkOffering offering, DeployDestination destination, ReservationContext context)
throws InsufficientVirtualNetworkCapcityException {
assert network.getTrafficType() == TrafficType.Storage : "Why are you sending this configuration to me " + network;
if (!_sNwMgr.isStorageIpRangeAvailable()) {
return super.implement(network, offering, destination, context);
}
return network;
}
@Override
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
assert network.getTrafficType() == TrafficType.Storage : "Well, I can't take care of this config now can I? " + network;
if (!_sNwMgr.isStorageIpRangeAvailable()) {
return super.allocate(network, nic, vm);
}
return new NicProfile(ReservationStrategy.Start, null, null, null, null);
}
@ -110,7 +116,12 @@ public class StorageNetworkGuru extends AdapterBase implements NetworkGuru {
@Override
public void reserve(NicProfile nic, Network network, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context)
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException {
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
if (!_sNwMgr.isStorageIpRangeAvailable()) {
super.reserve(nic, network, vm, dest, context);
return;
}
Pod pod = dest.getPod();
Integer vlan = null;
@ -136,6 +147,10 @@ public class StorageNetworkGuru extends AdapterBase implements NetworkGuru {
@Override
public boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId) {
if (!_sNwMgr.isStorageIpRangeAvailable()) {
return super.release(nic, vm, reservationId);
}
_sNwMgr.releaseIpAddress(nic.getIp4Address());
s_logger.debug("Release an storage ip " + nic.getIp4Address());
nic.deallocate();