cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [46/50] [abbrv] git commit: updated refs/heads/affinity_groups to ca1a794
Date Fri, 05 Apr 2013 21:03:41 GMT
CLOUDSTACK-1895: save placeholder nic with not null vmType='DomainRouter' when placeholder
is used for the VR ip address


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

Branch: refs/heads/affinity_groups
Commit: 42ffac3ae87ff2ac021b5591c9285e1da6122124
Parents: df48b65
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Thu Apr 4 11:28:14 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Thu Apr 4 13:29:17 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/network/NetworkModel.java        |    4 +-
 .../network/ExternalFirewallDeviceManagerImpl.java |    4 +-
 .../ExternalLoadBalancerDeviceManagerImpl.java     |   32 ++++++++-------
 server/src/com/cloud/network/NetworkManager.java   |    3 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |    6 ++-
 server/src/com/cloud/network/NetworkModelImpl.java |    9 ++--
 .../com/cloud/network/guru/DirectNetworkGuru.java  |    6 +-
 .../network/guru/DirectPodBasedNetworkGuru.java    |    9 ++--
 .../router/VirtualNetworkApplianceManagerImpl.java |   10 +----
 .../src/com/cloud/upgrade/dao/Upgrade410to420.java |    2 +-
 server/src/com/cloud/vm/NicVO.java                 |    6 ++-
 server/src/com/cloud/vm/dao/NicDao.java            |    1 +
 server/src/com/cloud/vm/dao/NicDaoImpl.java        |    9 ++++
 .../com/cloud/network/MockNetworkManagerImpl.java  |    3 +-
 .../com/cloud/network/MockNetworkModelImpl.java    |    8 ++--
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |    3 +-
 .../test/com/cloud/vpc/MockNetworkModelImpl.java   |    8 ++--
 17 files changed, 67 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/api/src/com/cloud/network/NetworkModel.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/network/NetworkModel.java b/api/src/com/cloud/network/NetworkModel.java
index c1f1674..4d7d714 100644
--- a/api/src/com/cloud/network/NetworkModel.java
+++ b/api/src/com/cloud/network/NetworkModel.java
@@ -260,7 +260,7 @@ public interface NetworkModel {
 
 	String getStartIpv6Address(long id);
 
-    Nic getPlaceholderNic(Network network, Long podId);
-
     boolean isProviderEnabledInZone(long zoneId, String provider);
+
+    Nic getPlaceholderNicForRouter(Network network, Long podId);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
index ae00bf2..1fc32d0 100644
--- a/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalFirewallDeviceManagerImpl.java
@@ -483,7 +483,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase
impl
 
         if (add && (!reservedIpAddressesForGuestNetwork.contains(network.getGateway())))
{
             // Insert a new NIC for this guest network to reserve the gateway address
-            _networkMgr.savePlaceholderNic(network,  network.getGateway());
+            _networkMgr.savePlaceholderNic(network,  network.getGateway(), null);
         }
         
         // Delete any mappings used for inline external load balancers in this network
@@ -501,7 +501,7 @@ public abstract class ExternalFirewallDeviceManagerImpl extends AdapterBase
impl
         if (!add) {
             List<NicVO> nics = _nicDao.listByNetworkId(network.getId());
             for (NicVO nic : nics) {
-                if (nic.getReservationStrategy().equals(ReservationStrategy.PlaceHolder)
&& nic.getIp4Address().equals(network.getGateway())) {
+                if (nic.getVmType() == null && nic.getReservationStrategy().equals(ReservationStrategy.PlaceHolder)
&& nic.getIp4Address().equals(network.getGateway())) {
                     s_logger.debug("Removing placeholder nic " + nic + " for the network
" + network);
                     _nicDao.remove(nic.getId());
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
index 4853256..7666397 100644
--- a/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
+++ b/server/src/com/cloud/network/ExternalLoadBalancerDeviceManagerImpl.java
@@ -111,7 +111,6 @@ import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserStatisticsDao;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.Transaction;
@@ -119,18 +118,10 @@ import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.utils.net.UrlUtil;
 import com.cloud.vm.Nic;
+import com.cloud.vm.Nic.ReservationStrategy;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
-import org.apache.cloudstack.api.ApiConstants;
-import org.apache.cloudstack.api.response.ExternalLoadBalancerResponse;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
-import org.apache.log4j.Logger;
-
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-import java.net.URI;
-import java.util.*;
 
 public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase implements
ExternalLoadBalancerDeviceManager, ResourceStateAdapter {
 
@@ -783,7 +774,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
                 // If a NIC doesn't exist for the load balancing IP address, create one
                 loadBalancingIpNic = _nicDao.findByIp4AddressAndNetworkId(loadBalancingIpAddress,
network.getId());
                 if (loadBalancingIpNic == null) {
-                    loadBalancingIpNic = _networkMgr.savePlaceholderNic(network, loadBalancingIpAddress);
+                    loadBalancingIpNic = _networkMgr.savePlaceholderNic(network, loadBalancingIpAddress,
null);
                 }
 
                 // Save a mapping between the source IP address and the load balancing IP
address NIC
@@ -992,7 +983,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
 
         if (add) {
 		    // on restart network, network could have already been implemented. If already implemented
then return
-            Nic selfipNic = _networkModel.getPlaceholderNic(guestConfig, null);
+            Nic selfipNic = getPlaceholderNic(guestConfig);
             if (selfipNic != null) {
 		    return true;
             }
@@ -1006,7 +997,7 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends AdapterBase
             }
         } else {
             // get the self-ip used by the load balancer
-            Nic selfipNic = _networkModel.getPlaceholderNic(guestConfig, null);
+            Nic selfipNic = getPlaceholderNic(guestConfig);
             if (selfipNic == null) {
                 s_logger.warn("Network shutdwon requested on external load balancer element,
which did not implement the network." +
                         " Either network implement failed half way through or already network
shutdown is completed. So just returning.");
@@ -1034,10 +1025,10 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends
AdapterBase
 
         if (add) {
             // Insert a new NIC for this guest network to reserve the self IP
-            _networkMgr.savePlaceholderNic(guestConfig, selfIp);
+            _networkMgr.savePlaceholderNic(guestConfig, selfIp, null);
         } else {
             // release the self-ip obtained from guest network
-            Nic selfipNic = _networkModel.getPlaceholderNic(guestConfig, null);
+            Nic selfipNic = getPlaceholderNic(guestConfig);
             _nicDao.remove(selfipNic.getId());
 
             // release the load balancer allocated for the network
@@ -1211,4 +1202,15 @@ public abstract class ExternalLoadBalancerDeviceManagerImpl extends
AdapterBase
         return answer.getLoadBalancers();
     }
 
+    private NicVO getPlaceholderNic(Network network) {
+        List<NicVO> guestIps = _nicDao.listByNetworkId(network.getId());
+        for (NicVO guestIp : guestIps) {
+            // only external firewall and external load balancer will create NicVO with PlaceHolder
reservation strategy
+            if (guestIp.getReservationStrategy().equals(ReservationStrategy.PlaceHolder)
&& guestIp.getVmType() == null
+                    && guestIp.getReserver() == null && !guestIp.getIp4Address().equals(network.getGateway()))
{
+                return guestIp;
+            }
+        }
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/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 851f7f5..4af716c 100755
--- a/server/src/com/cloud/network/NetworkManager.java
+++ b/server/src/com/cloud/network/NetworkManager.java
@@ -55,6 +55,7 @@ import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachine.Type;
 import com.cloud.vm.VirtualMachineProfile;
 
 /**
@@ -345,6 +346,6 @@ public interface NetworkManager  {
     String allocatePublicIpForGuestNic(Long networkId, DataCenter dc, Pod pod, Account caller,
String requestedIp) throws InsufficientAddressCapacityException;
     boolean removeVmSecondaryIpsOfNic(long nicId);
 
-    NicVO savePlaceholderNic(Network network, String ip4Address);
+    NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType);
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index a16288f..6296011 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -3488,6 +3488,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
     public void allocateDirectIp(NicProfile nic, DataCenter dc, VirtualMachineProfile<?
extends VirtualMachine> vm, Network network,
     							 String requestedIpv4, String requestedIpv6) throws InsufficientVirtualNetworkCapcityException,
             InsufficientAddressCapacityException {
+        //This method allocates direct ip for the Shared network in Advance zones
     	boolean ipv4 = false, ipv6 = false;
     	
     	Transaction txn = Transaction.currentTxn();
@@ -3500,7 +3501,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
     			
     			//Get ip address from the placeholder and don't allocate a new one
     			if (requestedIpv4 != null && vm.getType() == VirtualMachine.Type.DomainRouter)
{
-    			    Nic placeholderNic = _networkModel.getPlaceholderNic(network, null);
+    			    Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, null);
     			    if (placeholderNic != null) {
     			        IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(),
placeholderNic.getIp4Address());
                         ip = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
@@ -3756,11 +3757,12 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager,
L
         }
         
         @Override
-        public NicVO savePlaceholderNic(Network network, String ip4Address) {
+        public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType)
{
             NicVO nic = new NicVO(null, null, network.getId(), null); 
             nic.setIp4Address(ip4Address);
             nic.setReservationStrategy(ReservationStrategy.PlaceHolder);
             nic.setState(Nic.State.Reserved);
+            nic.setVmType(vmType);
             return _nicDao.persist(nic);
         }
         

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/network/NetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkModelImpl.java b/server/src/com/cloud/network/NetworkModelImpl.java
index d967f33..4c13c91 100644
--- a/server/src/com/cloud/network/NetworkModelImpl.java
+++ b/server/src/com/cloud/network/NetworkModelImpl.java
@@ -92,7 +92,6 @@ import com.cloud.user.Account;
 import com.cloud.user.DomainManager;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.component.AdapterBase;
-import com.cloud.utils.component.ComponentContext;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
 import com.cloud.utils.db.JoinBuilder;
@@ -2012,12 +2011,12 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel
{
     	}
 		return startIpv6;
 	}
-	
+    
     @Override
-    public NicVO getPlaceholderNic(Network network, Long podId) {
-        List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkId(network.getId());
+    public NicVO getPlaceholderNicForRouter(Network network, Long podId) {
+        List<NicVO> nics = _nicDao.listPlaceholderNicsByNetworkIdAndVmType(network.getId(),
VirtualMachine.Type.DomainRouter);
         for (NicVO nic : nics) {
-            if (nic.getVmType() == null && nic.getReserver() == null && nic.getIp4Address()
!= null && !nic.getIp4Address().equals(network.getGateway())) {
+            if (nic.getReserver() == null && nic.getIp4Address() != null) {
                 if (podId == null) {
                     return nic;
                 } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
index 2c8acbb..84008c0 100755
--- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
@@ -227,10 +227,10 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru
{
         _networkMgr.allocateDirectIp(nic, dc, vm, network, requestedIp4Addr, requestedIp6Addr);
         //save the placeholder nic if the vm is the Virtual router
         if (vm.getType() == VirtualMachine.Type.DomainRouter) {
-            Nic placeholderNic = _networkModel.getPlaceholderNic(network, null);
+            Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, null);
             if (placeholderNic == null) {
                 s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address()
+ " and ipv6 address " + requestedIp6Addr + " for the network " + network);
-                _networkMgr.savePlaceholderNic(network, nic.getIp4Address());
+                _networkMgr.savePlaceholderNic(network, nic.getIp4Address(), VirtualMachine.Type.DomainRouter);
             }
         }
         txn.commit();
@@ -259,7 +259,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru
{
                 txn.start();
                 
                 // if the ip address a part of placeholder, don't release it
-                Nic placeholderNic = _networkModel.getPlaceholderNic(network, null);
+                Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, null);
                 if (placeholderNic != null && placeholderNic.getIp4Address().equalsIgnoreCase(ip.getAddress().addr()))
{
                     s_logger.debug("Not releasing direct ip " + ip.getId() +" yet as its
ip is saved in the placeholder");
                 } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
index d74cd06..cf27986 100755
--- a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
@@ -1,3 +1,4 @@
+
 // Licensed to the Apache Software Foundation (ASF) under one
 // or more contributor license agreements.  See the NOTICE file
 // distributed with this work for additional information
@@ -173,7 +174,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
             }
             //Get ip address from the placeholder and don't allocate a new one
             if (vm.getType() == VirtualMachine.Type.DomainRouter) {
-                Nic placeholderNic = _networkModel.getPlaceholderNic(network, null);
+                Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, pod.getId());
                 if (placeholderNic != null) {
                     IPAddressVO userIp = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(),
placeholderNic.getIp4Address());
                     ip = PublicIp.createFromAddrAndVlan(userIp, _vlanDao.findById(userIp.getVlanId()));
@@ -199,10 +200,10 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
             
             //save the placeholder nic if the vm is the Virtual router
             if (vm.getType() == VirtualMachine.Type.DomainRouter) {
-                Nic placeholderNic = _networkModel.getPlaceholderNic(network, null);
+                Nic placeholderNic = _networkModel.getPlaceholderNicForRouter(network, pod.getId());
                 if (placeholderNic == null) {
-                    s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address()
+ " for the network " + network + " with the gateway " + podRangeGateway);
-                    _networkMgr.savePlaceholderNic(network, nic.getIp4Address());
+                    s_logger.debug("Saving placeholder nic with ip4 address " + nic.getIp4Address()
+ " for the network " + network);
+                    _networkMgr.savePlaceholderNic(network, nic.getIp4Address(), VirtualMachine.Type.DomainRouter);
                 }
             }
             txn.commit();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index afdbbca..ab91059 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1708,15 +1708,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase
implements V
             String defaultNetworkStartIp = null, defaultNetworkStartIpv6 = null;
             if (!setupPublicNetwork) {
             	if (guestNetwork.getCidr() != null) {
-            	    //Check the placeholder nic, and if it's ip address is not empty, allocate
it from there
-            	    String requestedGateway = null;
-            	    if (guestNetwork.getGateway() != null) {
-            	        requestedGateway = guestNetwork.getGateway();
-            	    } else if (plan != null && plan.getPodId() != null) {
-            	        Pod pod = _configMgr.getPod(plan.getPodId());
-            	        requestedGateway = pod.getGateway();
-            	    }
-            	    Nic placeholder = _networkModel.getPlaceholderNic(guestNetwork, null);
+            	    Nic placeholder = _networkModel.getPlaceholderNicForRouter(guestNetwork,
plan.getPodId());
             	    if (placeholder != null) {
             	        s_logger.debug("Requesting ip address " + placeholder.getIp4Address()
+ " stored in placeholder nic for the network " + guestNetwork);
             	        defaultNetworkStartIp = placeholder.getIp4Address();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 434430a..f39038f 100644
--- a/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/server/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -248,7 +248,7 @@ public class Upgrade410to420 implements DbUpgrade {
                     String ip = rs.getString(3);
                     String uuid = UUID.randomUUID().toString();
                     //Insert placeholder nic for each Domain router nic in Shared network
-                    pstmt = conn.prepareStatement("INSERT INTO `cloud`.`nics` (uuid, ip4_address,
gateway, network_id, state, strategy) VALUES (?, ?, ?, ?, 'Reserved', 'PlaceHolder')");
+                    pstmt = conn.prepareStatement("INSERT INTO `cloud`.`nics` (uuid, ip4_address,
gateway, network_id, state, strategy, vm_type) VALUES (?, ?, ?, ?, 'Reserved', 'PlaceHolder',
'DomainRouter')");
                     pstmt.setString(1, uuid);
                     pstmt.setString(2, ip);
                     pstmt.setString(3, gateway);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/vm/NicVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/NicVO.java b/server/src/com/cloud/vm/NicVO.java
index 987596c..833cec5 100644
--- a/server/src/com/cloud/vm/NicVO.java
+++ b/server/src/com/cloud/vm/NicVO.java
@@ -29,11 +29,9 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
-import org.apache.cloudstack.api.Identity;
 import com.cloud.network.Networks.AddressFormat;
 import com.cloud.network.Networks.Mode;
 import com.cloud.utils.db.GenericDao;
-import org.apache.cloudstack.api.InternalIdentity;
 
 @Entity
 @Table(name = "nics")
@@ -360,4 +358,8 @@ public class NicVO implements Nic {
     public void setSecondaryIp(boolean secondaryIp) {
         this.secondaryIp = secondaryIp;
     }
+
+    public void setVmType(VirtualMachine.Type vmType) {
+        this.vmType = vmType;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/vm/dao/NicDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/NicDao.java b/server/src/com/cloud/vm/dao/NicDao.java
index eb38a8d..67c1e07 100644
--- a/server/src/com/cloud/vm/dao/NicDao.java
+++ b/server/src/com/cloud/vm/dao/NicDao.java
@@ -65,4 +65,5 @@ public interface NicDao extends GenericDao<NicVO, Long> {
     
     List<NicVO> listPlaceholderNicsByNetworkId(long networkId);
     
+    List<NicVO> listPlaceholderNicsByNetworkIdAndVmType(long networkId, VirtualMachine.Type
vmType);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/src/com/cloud/vm/dao/NicDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/dao/NicDaoImpl.java b/server/src/com/cloud/vm/dao/NicDaoImpl.java
index b427d4e..c70d194 100644
--- a/server/src/com/cloud/vm/dao/NicDaoImpl.java
+++ b/server/src/com/cloud/vm/dao/NicDaoImpl.java
@@ -229,4 +229,13 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements
NicDao {
         return listBy(sc);
     }
 
+    @Override
+    public List<NicVO> listPlaceholderNicsByNetworkIdAndVmType(long networkId, VirtualMachine.Type
vmType) {
+        SearchCriteria<NicVO> sc = AllFieldsSearch.create();
+        sc.setParameters("network", networkId);
+        sc.setParameters("strategy", Nic.ReservationStrategy.PlaceHolder.toString());
+        sc.setParameters("vmType", vmType);
+        return listBy(sc);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/test/com/cloud/network/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkManagerImpl.java b/server/test/com/cloud/network/MockNetworkManagerImpl.java
index 6da48ec..18eae08 100755
--- a/server/test/com/cloud/network/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/network/MockNetworkManagerImpl.java
@@ -71,6 +71,7 @@ import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachine.Type;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.VirtualMachineProfileImpl;
 
@@ -884,7 +885,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
     }
 
     @Override
-    public NicVO savePlaceholderNic(Network network, String ip4Address) {
+    public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
         // TODO Auto-generated method stub
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/test/com/cloud/network/MockNetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/MockNetworkModelImpl.java b/server/test/com/cloud/network/MockNetworkModelImpl.java
index c578965..511249f 100644
--- a/server/test/com/cloud/network/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/network/MockNetworkModelImpl.java
@@ -840,14 +840,14 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
 	}
 
     @Override
-    public Nic getPlaceholderNic(Network network, Long podId) {
+    public boolean isProviderEnabledInZone(long zoneId, String provider) {
         // TODO Auto-generated method stub
-        return null;
+        return false;
     }
 
     @Override
-    public boolean isProviderEnabledInZone(long zoneId, String provider) {
+    public Nic getPlaceholderNicForRouter(Network network, Long podId) {
         // TODO Auto-generated method stub
-        return false;
+        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
index ead0051..bd4fd67 100644
--- a/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkManagerImpl.java
@@ -87,6 +87,7 @@ import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachine.Type;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.VirtualMachineProfileImpl;
 
@@ -1418,7 +1419,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
 
 
     @Override
-    public NicVO savePlaceholderNic(Network network, String ip4Address) {
+    public NicVO savePlaceholderNic(Network network, String ip4Address, Type vmType) {
         // TODO Auto-generated method stub
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42ffac3a/server/test/com/cloud/vpc/MockNetworkModelImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockNetworkModelImpl.java b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
index e1534cb..9857964 100644
--- a/server/test/com/cloud/vpc/MockNetworkModelImpl.java
+++ b/server/test/com/cloud/vpc/MockNetworkModelImpl.java
@@ -852,15 +852,15 @@ public class MockNetworkModelImpl extends ManagerBase implements NetworkModel
{
 	}
 
     @Override
-    public Nic getPlaceholderNic(Network network, Long podId) {
+    public boolean isProviderEnabledInZone(long zoneId, String provider) {
         // TODO Auto-generated method stub
-        return null;
+        return false;
     }
 
     @Override
-    public boolean isProviderEnabledInZone(long zoneId, String provider) {
+    public Nic getPlaceholderNicForRouter(Network network, Long podId) {
         // TODO Auto-generated method stub
-        return false;
+        return null;
     }
 
 }


Mime
View raw message