WIP : extract NetworkService

WIP : move stuff between network manager and network service.
      at this point there is about 700 lines of duplicated code
WIP: Leave creation of default offerings to NetworkManager init
WIP: clean up imports

Signed-off-by: Chiradeep Vittal <chiradeep@apache.org>
This commit is contained in:
Chiradeep Vittal 2013-01-07 11:10:48 -08:00
parent a64b386714
commit f4da21998c
5 changed files with 3150 additions and 2475 deletions

View File

@ -17,8 +17,6 @@
package com.cloud.network;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.cloud.api.commands.CreateNetworkCmd;
import com.cloud.api.commands.ListNetworksCmd;
@ -29,8 +27,6 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.TrafficType;
import com.cloud.user.Account;
@ -63,22 +59,12 @@ public interface NetworkService {
IpAddress getIp(long id);
NetworkProfile convertNetworkToNetworkProfile(long networkId);
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
boolean isNetworkAvailableInDomain(long networkId, long domainId);
Long getDedicatedNetworkDomain(long networkId);
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
String domainSuffix, Long networkOfferingId, Boolean changeCidr);
Integer getNetworkRate(long networkId, Long vmId);
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
@ -93,8 +79,6 @@ public interface NetworkService {
List<? extends Service> listNetworkServices(String providerName);
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName,
Long destinationPhysicalNetworkId, List<String> enabledServices);
@ -126,7 +110,6 @@ public interface NetworkService {
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId);
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Network getExclusiveGuestNetwork(long zoneId);
@ -134,9 +117,7 @@ public interface NetworkService {
List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
List<? extends Network> listNetworksByVpc(long vpcId);
boolean isVmPartOfNetwork(long vmId, long ntwkId);
/**
* @param networkId
@ -169,9 +150,5 @@ public interface NetworkService {
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId)
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
/**
* @param network
* @return
*/
boolean canUseForDeploy(Network network);
}

View File

@ -109,6 +109,7 @@ import com.cloud.network.Network.GuestType;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.NetworkManager;
import com.cloud.network.NetworkService;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
@ -210,6 +211,8 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
@Inject
NetworkManager _networkMgr;
@Inject
NetworkService _networkSvc;
@Inject
ClusterDao _clusterDao;
@Inject
AlertManager _alertMgr;
@ -1535,7 +1538,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
_networkMgr.getDefaultPhysicalNetworkByZoneAndTrafficType(zoneId, TrafficType.Storage);
} catch (InvalidParameterValueException noStorage) {
PhysicalNetworkTrafficTypeVO mgmtTraffic = _trafficTypeDao.findBy(mgmtPhyNetwork.getId(), TrafficType.Management);
_networkMgr.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(),
_networkSvc.addTrafficTypeToPhysicalNetwork(mgmtPhyNetwork.getId(), TrafficType.Storage.toString(), mgmtTraffic.getXenNetworkLabel(), mgmtTraffic.getKvmNetworkLabel(),
mgmtTraffic.getVmwareNetworkLabel(), mgmtTraffic.getSimulatorNetworkLabel(), mgmtTraffic.getVlan());
s_logger.info("No storage traffic type was specified by admin, create default storage traffic on physical network " + mgmtPhyNetwork.getId() + " with same configure of management traffic type");
}

View File

@ -48,6 +48,7 @@ import com.cloud.network.rules.StaticNat;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.utils.Pair;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
@ -61,7 +62,7 @@ import com.cloud.vm.VirtualMachineProfileImpl;
* NetworkManager manages the network for the different end users.
*
*/
public interface NetworkManager extends NetworkService {
public interface NetworkManager {
/**
* Assigns a new public ip address.
*
@ -192,6 +193,8 @@ public interface NetworkManager extends NetworkService {
Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service);
boolean applyIpAssociations(Network network, boolean continueOnError) throws ResourceUnavailableException;
boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError, List<PublicIp> publicIps) throws ResourceUnavailableException;
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
@ -472,10 +475,72 @@ public interface NetworkManager extends NetworkService {
*/
PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat) throws ConcurrentOperationException, InsufficientAddressCapacityException;
NetworkProfile convertNetworkToNetworkProfile(long networkId);
/**
* @return
*/
int getNetworkLockTimeout();
boolean cleanupIpResources(long addrId, long userId, Account caller);
boolean restartNetwork(Long networkId, Account callerAccount,
User callerUser, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
boolean shutdownNetworkElementsAndResources(ReservationContext context,
boolean b, NetworkVO network);
void implementNetworkElementsAndResources(DeployDestination dest,
ReservationContext context, NetworkVO network,
NetworkOfferingVO findById) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException;
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Long getDedicatedNetworkDomain(long networkId);
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
List<? extends Network> listNetworksByVpc(long vpcId);
boolean canUseForDeploy(Network network);
Network getExclusiveGuestNetwork(long zoneId);
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
Integer getNetworkRate(long networkId, Long vmId);
boolean isVmPartOfNetwork(long vmId, long ntwkId);
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Network getNetwork(long networkId);
IpAddress getIp(long sourceIpAddressId);
IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller,
DataCenter zone) throws ConcurrentOperationException, ResourceAllocationException, InsufficientAddressCapacityException;
Map<String, String> finalizeServicesAndProvidersForNetwork(NetworkOffering offering,
Long physicalNetworkId);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff