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

This commit is contained in:
Alena Prokharchyk 2012-06-05 16:10:20 -07:00
parent daf1aa4b92
commit 31b8f07bb5
8 changed files with 37 additions and 9 deletions

View File

@ -13,6 +13,7 @@
package com.cloud.agent.api; package com.cloud.agent.api;
import com.cloud.agent.api.routing.NetworkElementCommand; import com.cloud.agent.api.routing.NetworkElementCommand;
import com.cloud.agent.api.to.NicTO;
/** /**
* @author Alena Prokharchyk * @author Alena Prokharchyk
@ -25,6 +26,7 @@ public class SetupGuestNetworkCommand extends NetworkElementCommand{
boolean isRedundant = false; boolean isRedundant = false;
Integer priority; Integer priority;
boolean add = true; boolean add = true;
NicTO nic;
@Override @Override
public boolean executeInSequence() { public boolean executeInSequence() {
@ -36,7 +38,7 @@ public class SetupGuestNetworkCommand extends NetworkElementCommand{
public SetupGuestNetworkCommand(String dhcpRange, String networkDomain, boolean isRedundant, Integer priority, 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.dhcpRange = dhcpRange;
this.networkDomain = networkDomain; this.networkDomain = networkDomain;
this.defaultDns1 = defaultDns1; this.defaultDns1 = defaultDns1;
@ -44,5 +46,6 @@ public class SetupGuestNetworkCommand extends NetworkElementCommand{
this.isRedundant = isRedundant; this.isRedundant = isRedundant;
this.priority = priority; this.priority = priority;
this.add = add; this.add = add;
this.nic = nic;
} }
} }

View File

@ -207,7 +207,8 @@ public class NicProfile {
return strategy; 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.id = nic.getId();
this.networkId = network.getId(); this.networkId = network.getId();
this.gateway = nic.getGateway(); this.gateway = nic.getGateway();

View File

@ -18,6 +18,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import com.cloud.acl.ControlledEntity.ACLType; import com.cloud.acl.ControlledEntity.ACLType;
import com.cloud.agent.api.to.NicTO;
import com.cloud.dc.DataCenter; import com.cloud.dc.DataCenter;
import com.cloud.dc.Vlan; import com.cloud.dc.Vlan;
import com.cloud.dc.Vlan.VlanType; import com.cloud.dc.Vlan.VlanType;
@ -49,6 +50,7 @@ import com.cloud.user.Account;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
import com.cloud.vm.Nic; import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile; import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.ReservationContext; import com.cloud.vm.ReservationContext;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
@ -421,5 +423,6 @@ public interface NetworkManager extends NetworkService {
* @return * @return
*/ */
NicProfile getNicProfile(VirtualMachine vm, long networkId); NicProfile getNicProfile(VirtualMachine vm, long networkId);
} }

View File

@ -3049,9 +3049,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
defaultDns1 = guestNic.getDns1(); defaultDns1 = guestNic.getDns1();
defaultDns2 = guestNic.getDns2(); 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, 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_IP, getRouterControlIp(router.getId()));
setupCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(network.getId(), router.getId())); setupCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(network.getId(), router.getId()));
setupCmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag)); setupCmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag));

View File

@ -426,7 +426,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
Network defaultNetwork = _networkDao.findById(defaultNic.getNetworkId()); Network defaultNetwork = _networkDao.findById(defaultNic.getNetworkId());
NicProfile defaultNicProfile = new NicProfile(defaultNic, defaultNetwork, null, null, null, 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); VirtualMachineProfile<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vmInstance);
vmProfile.setParameter(VirtualMachineProfile.Param.VmPassword, password); vmProfile.setParameter(VirtualMachineProfile.Param.VmPassword, password);

View File

@ -15,6 +15,7 @@ package com.cloud.vm;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlan;
@ -154,4 +155,11 @@ public interface VirtualMachineManager extends Manager {
*/ */
boolean removeVmFromNetwork(VirtualMachine vm, Network network) throws ConcurrentOperationException, ResourceUnavailableException; boolean removeVmFromNetwork(VirtualMachine vm, Network network) throws ConcurrentOperationException, ResourceUnavailableException;
/**
* @param nic
* @param hypervisorType
* @return
*/
NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType);
} }

View File

@ -2131,7 +2131,8 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
List<NicVO> nics = _nicsDao.listByVmId(profile.getId()); List<NicVO> nics = _nicsDao.listByVmId(profile.getId());
for (NicVO nic : nics) { for (NicVO nic : nics) {
Network network = _networkMgr.getNetwork(nic.getNetworkId()); 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); profile.addNic(nicProfile);
} }
@ -2469,7 +2470,7 @@ public class VirtualMachineManagerImpl implements VirtualMachineManager, Listene
VirtualMachineTO vmTO = hvGuru.implement(vmProfile); VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
//4) Convert nicProfile to NicTO //4) Convert nicProfile to NicTO
NicTO nicTO = hvGuru.toNicTO(nic); NicTO nicTO = toNicTO(nic, vmProfile.getVirtualMachine().getHypervisorType());
//5) plug the nic to the vm //5) plug the nic to the vm
VirtualMachineGuru<VMInstanceVO> vmGuru = getVmGuru(vmVO); 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 @Override
public boolean removeVmFromNetwork(VirtualMachine vm, Network network) throws ConcurrentOperationException, ResourceUnavailableException { 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()); HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vmProfile.getVirtualMachine().getHypervisorType());
VirtualMachineTO vmTO = hvGuru.implement(vmProfile); VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
//3) Convert nicProfile to NicTO NicTO nicTO = toNicTO(nic, vmProfile.getVirtualMachine().getHypervisorType());
NicTO nicTO = hvGuru.toNicTO(nic);
boolean result = vmGuru.unplugNic(network, nicTO, vmTO, context, dest); boolean result = vmGuru.unplugNic(network, nicTO, vmTO, context, dest);
//4) Unplug the nic //4) Unplug the nic

View File

@ -4,7 +4,7 @@
# the following two variables are used by the target "waf dist" # 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 # 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' APPNAME = 'cloud'
import shutil,os import shutil,os