diff --git a/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java b/api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java index a1507c28ab4..c2ca11b741b 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; } } diff --git a/api/src/com/cloud/vm/NicProfile.java b/api/src/com/cloud/vm/NicProfile.java index 354b84b56e1..67753c61660 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(); diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index 6ab1200792c..5873115f1c5 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); + } diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 1ec4936e28a..b28e193b6b0 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)); diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index b756d9ff3c7..705107ab45a 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 vmProfile = new VirtualMachineProfileImpl(vmInstance); vmProfile.setParameter(VirtualMachineProfile.Param.VmPassword, password); diff --git a/server/src/com/cloud/vm/VirtualMachineManager.java b/server/src/com/cloud/vm/VirtualMachineManager.java index 485edb4a77d..0cde9fb2364 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); + } diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java index 0d1d8a3c42f..5dee3d1e9ee 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 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 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 diff --git a/wscript b/wscript index e41b86035e5..f1c27f7cd4b 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