Added NicTO to setupGuestNetworkCommand constructor - we need this info for 
guest network configuraiton


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

Branch: refs/heads/vpc
Commit: 31b8f07bb5989d807a8d7eee2044208dc25a9bcd
Parents: daf1aa4
Author: Alena Prokharchyk <[email protected]>
Authored: Tue Jun 5 16:10:20 2012 -0700
Committer: Alena Prokharchyk <[email protected]>
Committed: Fri Jun 15 14:22:40 2012 -0700

----------------------------------------------------------------------
 .../cloud/agent/api/SetupGuestNetworkCommand.java  |    5 +++-
 api/src/com/cloud/vm/NicProfile.java               |    3 +-
 server/src/com/cloud/network/NetworkManager.java   |    3 ++
 .../router/VirtualNetworkApplianceManagerImpl.java |    6 ++++-
 server/src/com/cloud/vm/UserVmManagerImpl.java     |    3 +-
 server/src/com/cloud/vm/VirtualMachineManager.java |    8 +++++++
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |   16 +++++++++++---
 wscript                                            |    2 +-
 8 files changed, 37 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java 
b/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java
index a1507c2..c2ca11b 100644
--- a/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java
+++ b/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java
@@ -13,6 +13,7 @@
 package com.cloud.agent.api;
 
 import com.cloud.agent.api.routing.NetworkElementCommand;
+import com.cloud.agent.api.to.NicTO;
 
 /**
  * @author Alena Prokharchyk
@@ -25,6 +26,7 @@ public class SetupGuestNetworkCommand extends 
NetworkElementCommand{
     boolean isRedundant = false;
     Integer priority;
     boolean add = true;
+    NicTO nic;
     
     @Override
     public boolean executeInSequence() {
@@ -36,7 +38,7 @@ public class SetupGuestNetworkCommand extends 
NetworkElementCommand{
     
     
     public SetupGuestNetworkCommand(String dhcpRange, String networkDomain, 
boolean isRedundant, Integer priority, 
-            String defaultDns1, String defaultDns2, boolean add) {
+            String defaultDns1, String defaultDns2, boolean add, NicTO nic) {
         this.dhcpRange = dhcpRange;
         this.networkDomain = networkDomain;
         this.defaultDns1 = defaultDns1;
@@ -44,5 +46,6 @@ public class SetupGuestNetworkCommand extends 
NetworkElementCommand{
         this.isRedundant = isRedundant;
         this.priority = priority;
         this.add = add;
+        this.nic = nic;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/api/src/com/cloud/vm/NicProfile.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/vm/NicProfile.java 
b/api/src/com/cloud/vm/NicProfile.java
index 354b84b..67753c6 100644
--- a/api/src/com/cloud/vm/NicProfile.java
+++ b/api/src/com/cloud/vm/NicProfile.java
@@ -207,7 +207,8 @@ public class NicProfile {
         return strategy;
     }
 
-    public NicProfile(Nic nic, Network network, URI broadcastUri, URI 
isolationUri, Integer networkRate, boolean isSecurityGroupEnabled, String name) 
{
+    public NicProfile(Nic nic, Network network, URI broadcastUri, URI 
isolationUri, Integer networkRate, 
+            boolean isSecurityGroupEnabled, String name) {
         this.id = nic.getId();
         this.networkId = network.getId();
         this.gateway = nic.getGateway();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/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 6ab1200..5873115 100755
--- a/server/src/com/cloud/network/NetworkManager.java
+++ b/server/src/com/cloud/network/NetworkManager.java
@@ -18,6 +18,7 @@ import java.util.Map;
 import java.util.Set;
 
 import com.cloud.acl.ControlledEntity.ACLType;
+import com.cloud.agent.api.to.NicTO;
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.Vlan;
 import com.cloud.dc.Vlan.VlanType;
@@ -49,6 +50,7 @@ import com.cloud.user.Account;
 import com.cloud.utils.Pair;
 import com.cloud.vm.Nic;
 import com.cloud.vm.NicProfile;
+import com.cloud.vm.NicVO;
 import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
@@ -421,5 +423,6 @@ public interface NetworkManager extends NetworkService {
      * @return
      */
     NicProfile getNicProfile(VirtualMachine vm, long networkId);
+    
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/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 1ec4936..b28e193 100755
--- 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -3049,9 +3049,13 @@ public class VirtualNetworkApplianceManagerImpl 
implements VirtualNetworkApplian
             defaultDns1 = guestNic.getDns1();
             defaultDns2 = guestNic.getDns2();
         }
+        
+        NicVO nic = _nicDao.findByInstanceIdAndNetworkId(network.getId(), 
router.getId());
+        NicProfile nicProfile = new NicProfile(nic, network, 
nic.getBroadcastUri(), nic.getIsolationUri(), null, 
+                _networkMgr.isSecurityGroupSupportedInNetwork(network), 
_networkMgr.getNetworkTag(router.getHypervisorType(), network));
 
         SetupGuestNetworkCommand setupCmd = new 
SetupGuestNetworkCommand(dhcpRange, networkDomain, isRedundant, priority, 
-                defaultDns1, defaultDns2, add);
+                defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, 
router.getHypervisorType()));
         setupCmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, 
getRouterControlIp(router.getId()));
         setupCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, 
getRouterIpInNetwork(network.getId(), router.getId()));
         setupCmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, 
String.valueOf(guestVlanTag));

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java 
b/server/src/com/cloud/vm/UserVmManagerImpl.java
index b756d9f..705107a 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -426,7 +426,8 @@ public class UserVmManagerImpl implements UserVmManager, 
UserVmService, Manager
 
             Network defaultNetwork = 
_networkDao.findById(defaultNic.getNetworkId());
             NicProfile defaultNicProfile = new NicProfile(defaultNic, 
defaultNetwork, null, null, null, 
-                    
_networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork), 
_networkMgr.getNetworkTag(template.getHypervisorType(), defaultNetwork));
+                    
_networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork), 
+                    _networkMgr.getNetworkTag(template.getHypervisorType(), 
defaultNetwork));
             VirtualMachineProfile<VMInstanceVO> vmProfile = new 
VirtualMachineProfileImpl<VMInstanceVO>(vmInstance);
             vmProfile.setParameter(VirtualMachineProfile.Param.VmPassword, 
password);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/server/src/com/cloud/vm/VirtualMachineManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManager.java 
b/server/src/com/cloud/vm/VirtualMachineManager.java
index 485edb4..0cde9fb 100644
--- a/server/src/com/cloud/vm/VirtualMachineManager.java
+++ b/server/src/com/cloud/vm/VirtualMachineManager.java
@@ -15,6 +15,7 @@ package com.cloud.vm;
 import java.util.List;
 import java.util.Map;
 
+import com.cloud.agent.api.to.NicTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.deploy.DeploymentPlan;
@@ -154,4 +155,11 @@ public interface VirtualMachineManager extends Manager {
      */
     boolean removeVmFromNetwork(VirtualMachine vm, Network network) throws 
ConcurrentOperationException, ResourceUnavailableException;
 
+    /**
+     * @param nic
+     * @param hypervisorType
+     * @return
+     */
+    NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType);
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java 
b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 0d1d8a3..5dee3d1 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2131,7 +2131,8 @@ public class VirtualMachineManagerImpl implements 
VirtualMachineManager, Listene
         List<NicVO> nics = _nicsDao.listByVmId(profile.getId());
         for (NicVO nic : nics) {
             Network network = _networkMgr.getNetwork(nic.getNetworkId());
-            NicProfile nicProfile = new NicProfile(nic, network, 
nic.getBroadcastUri(), nic.getIsolationUri(), null, 
_networkMgr.isSecurityGroupSupportedInNetwork(network), 
_networkMgr.getNetworkTag(profile.getHypervisorType(), network));
+            NicProfile nicProfile = new NicProfile(nic, network, 
nic.getBroadcastUri(), nic.getIsolationUri(), null, 
+                    _networkMgr.isSecurityGroupSupportedInNetwork(network), 
_networkMgr.getNetworkTag(profile.getHypervisorType(), network));
             profile.addNic(nicProfile);
         }
 
@@ -2469,7 +2470,7 @@ public class VirtualMachineManagerImpl implements 
VirtualMachineManager, Listene
         VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
         
         //4) Convert nicProfile to NicTO
-        NicTO nicTO = hvGuru.toNicTO(nic);
+        NicTO nicTO = toNicTO(nic, 
vmProfile.getVirtualMachine().getHypervisorType());
         
         //5) plug the nic to the vm
         VirtualMachineGuru<VMInstanceVO> vmGuru = getVmGuru(vmVO);
@@ -2483,6 +2484,14 @@ public class VirtualMachineManagerImpl implements 
VirtualMachineManager, Listene
         }
         
     }
+
+    @Override
+    public NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType) {
+        HypervisorGuru hvGuru = _hvGuruMgr.getGuru(hypervisorType);
+        
+        NicTO nicTO = hvGuru.toNicTO(nic);
+        return nicTO;
+    }
     
     @Override
     public boolean removeVmFromNetwork(VirtualMachine vm, Network network) 
throws ConcurrentOperationException, ResourceUnavailableException {
@@ -2506,8 +2515,7 @@ public class VirtualMachineManagerImpl implements 
VirtualMachineManager, Listene
         HypervisorGuru hvGuru = 
_hvGuruMgr.getGuru(vmProfile.getVirtualMachine().getHypervisorType());
         VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
         
-        //3) Convert nicProfile to NicTO
-        NicTO nicTO = hvGuru.toNicTO(nic);
+        NicTO nicTO = toNicTO(nic, 
vmProfile.getVirtualMachine().getHypervisorType());
         
         boolean result = vmGuru.unplugNic(network, nicTO, vmTO, context, dest);
         //4) Unplug the nic

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/31b8f07b/wscript
----------------------------------------------------------------------
diff --git a/wscript b/wscript
index e41b860..f1c27f7 100644
--- a/wscript
+++ b/wscript
@@ -4,7 +4,7 @@
 # the following two variables are used by the target "waf dist"
 # if you change 'em here, you need to change it also in cloud.spec, add a 
%changelog entry there, and add an entry in debian/changelog
 
-VERSION = '3.0.3.2012-06-05T22:35:08Z'
+VERSION = '3.0.3.2012-06-05T23:07:27Z'
 APPNAME = 'cloud'
 
 import shutil,os

Reply via email to