You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ch...@apache.org on 2013/01/08 00:22:53 UTC

[3/7] git commit: 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 imp

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 <ch...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/f4da2199
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/f4da2199
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/f4da2199

Branch: refs/heads/network-refactor
Commit: f4da21998c3ea830cc222876ddafca5ff4e8d814
Parents: a64b386
Author: Chiradeep Vittal <ch...@apache.org>
Authored: Mon Jan 7 11:10:48 2013 -0800
Committer: Chiradeep Vittal <ch...@apache.org>
Committed: Mon Jan 7 14:25:03 2013 -0800

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkService.java      |   25 +-
 .../configuration/ConfigurationManagerImpl.java    |    5 +-
 server/src/com/cloud/network/NetworkManager.java   |   67 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  | 2792 ++-------------
 .../src/com/cloud/network/NetworkServiceImpl.java  | 2964 +++++++++++++++
 5 files changed, 3264 insertions(+), 2589 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f4da2199/api/src/com/cloud/network/NetworkService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkService.java b/api/src/com/cloud/network/NetworkService.java
index e7b6def..94a08d2 100755
--- a/api/src/com/cloud/network/NetworkService.java
+++ b/api/src/com/cloud/network/NetworkService.java
@@ -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);
+ 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f4da2199/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index c7a5d64..3bce619 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -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");
                     }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f4da2199/server/src/com/cloud/network/NetworkManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java
index 0d281aa..101d318 100755
--- a/server/src/com/cloud/network/NetworkManager.java
+++ b/server/src/com/cloud/network/NetworkManager.java
@@ -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);
+
+
 }