Skip to content

Commit 31b8f07

Browse files
author
Alena Prokharchyk
committed
Added NicTO to setupGuestNetworkCommand constructor - we need this info for guest network configuraiton
1 parent daf1aa4 commit 31b8f07

8 files changed

Lines changed: 37 additions & 9 deletions

File tree

‎api/src/com/cloud/agent/api/SetupGuestNetworkCommand.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
package com.cloud.agent.api;
1414

1515
import com.cloud.agent.api.routing.NetworkElementCommand;
16+
import com.cloud.agent.api.to.NicTO;
1617

1718
/**
1819
* @author Alena Prokharchyk
@@ -25,6 +26,7 @@ public class SetupGuestNetworkCommand extends NetworkElementCommand{
2526
boolean isRedundant = false;
2627
Integer priority;
2728
boolean add = true;
29+
NicTO nic;
2830

2931
@Override
3032
public boolean executeInSequence() {
@@ -36,13 +38,14 @@ protected SetupGuestNetworkCommand() {
3638

3739

3840
public SetupGuestNetworkCommand(String dhcpRange, String networkDomain, boolean isRedundant, Integer priority,
39-
String defaultDns1, String defaultDns2, boolean add) {
41+
String defaultDns1, String defaultDns2, boolean add, NicTO nic) {
4042
this.dhcpRange = dhcpRange;
4143
this.networkDomain = networkDomain;
4244
this.defaultDns1 = defaultDns1;
4345
this.defaultDns2 = defaultDns2;
4446
this.isRedundant = isRedundant;
4547
this.priority = priority;
4648
this.add = add;
49+
this.nic = nic;
4750
}
4851
}

‎api/src/com/cloud/vm/NicProfile.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ public ReservationStrategy getStrategy() {
207207
return strategy;
208208
}
209209

210-
public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate, boolean isSecurityGroupEnabled, String name) {
210+
public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri, Integer networkRate,
211+
boolean isSecurityGroupEnabled, String name) {
211212
this.id = nic.getId();
212213
this.networkId = network.getId();
213214
this.gateway = nic.getGateway();

‎server/src/com/cloud/network/NetworkManager.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Set;
1919

2020
import com.cloud.acl.ControlledEntity.ACLType;
21+
import com.cloud.agent.api.to.NicTO;
2122
import com.cloud.dc.DataCenter;
2223
import com.cloud.dc.Vlan;
2324
import com.cloud.dc.Vlan.VlanType;
@@ -49,6 +50,7 @@
4950
import com.cloud.utils.Pair;
5051
import com.cloud.vm.Nic;
5152
import com.cloud.vm.NicProfile;
53+
import com.cloud.vm.NicVO;
5254
import com.cloud.vm.ReservationContext;
5355
import com.cloud.vm.VMInstanceVO;
5456
import com.cloud.vm.VirtualMachine;
@@ -421,5 +423,6 @@ IpAddress associateIPToGuestNetwork(long ipAddrId, long networkId) throws Resour
421423
* @return
422424
*/
423425
NicProfile getNicProfile(VirtualMachine vm, long networkId);
426+
424427

425428
}

‎server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3049,9 +3049,13 @@ protected boolean setupGuestNetwork(Network network, VirtualRouter router, boole
30493049
defaultDns1 = guestNic.getDns1();
30503050
defaultDns2 = guestNic.getDns2();
30513051
}
3052+
3053+
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(network.getId(), router.getId());
3054+
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null,
3055+
_networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(router.getHypervisorType(), network));
30523056

30533057
SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, isRedundant, priority,
3054-
defaultDns1, defaultDns2, add);
3058+
defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
30553059
setupCmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, getRouterControlIp(router.getId()));
30563060
setupCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(network.getId(), router.getId()));
30573061
setupCmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag));

‎server/src/com/cloud/vm/UserVmManagerImpl.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,8 @@ private boolean resetVMPasswordInternal(ResetVMPasswordCmd cmd, String password)
426426

427427
Network defaultNetwork = _networkDao.findById(defaultNic.getNetworkId());
428428
NicProfile defaultNicProfile = new NicProfile(defaultNic, defaultNetwork, null, null, null,
429-
_networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork), _networkMgr.getNetworkTag(template.getHypervisorType(), defaultNetwork));
429+
_networkMgr.isSecurityGroupSupportedInNetwork(defaultNetwork),
430+
_networkMgr.getNetworkTag(template.getHypervisorType(), defaultNetwork));
430431
VirtualMachineProfile<VMInstanceVO> vmProfile = new VirtualMachineProfileImpl<VMInstanceVO>(vmInstance);
431432
vmProfile.setParameter(VirtualMachineProfile.Param.VmPassword, password);
432433

‎server/src/com/cloud/vm/VirtualMachineManager.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.List;
1616
import java.util.Map;
1717

18+
import com.cloud.agent.api.to.NicTO;
1819
import com.cloud.agent.api.to.VirtualMachineTO;
1920
import com.cloud.deploy.DeployDestination;
2021
import com.cloud.deploy.DeploymentPlan;
@@ -154,4 +155,11 @@ NicProfile addVmToNetwork(VirtualMachine vm, Network network) throws ConcurrentO
154155
*/
155156
boolean removeVmFromNetwork(VirtualMachine vm, Network network) throws ConcurrentOperationException, ResourceUnavailableException;
156157

158+
/**
159+
* @param nic
160+
* @param hypervisorType
161+
* @return
162+
*/
163+
NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType);
164+
157165
}

‎server/src/com/cloud/vm/VirtualMachineManagerImpl.java‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,7 +2131,8 @@ private void ensureVmRunningContext(long hostId, VMInstanceVO vm, Event cause) t
21312131
List<NicVO> nics = _nicsDao.listByVmId(profile.getId());
21322132
for (NicVO nic : nics) {
21332133
Network network = _networkMgr.getNetwork(nic.getNetworkId());
2134-
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null, _networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(profile.getHypervisorType(), network));
2134+
NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), null,
2135+
_networkMgr.isSecurityGroupSupportedInNetwork(network), _networkMgr.getNetworkTag(profile.getHypervisorType(), network));
21352136
profile.addNic(nicProfile);
21362137
}
21372138

@@ -2469,7 +2470,7 @@ public NicProfile addVmToNetwork(VirtualMachine vm, Network network) throws Conc
24692470
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
24702471

24712472
//4) Convert nicProfile to NicTO
2472-
NicTO nicTO = hvGuru.toNicTO(nic);
2473+
NicTO nicTO = toNicTO(nic, vmProfile.getVirtualMachine().getHypervisorType());
24732474

24742475
//5) plug the nic to the vm
24752476
VirtualMachineGuru<VMInstanceVO> vmGuru = getVmGuru(vmVO);
@@ -2483,6 +2484,14 @@ public NicProfile addVmToNetwork(VirtualMachine vm, Network network) throws Conc
24832484
}
24842485

24852486
}
2487+
2488+
@Override
2489+
public NicTO toNicTO(NicProfile nic, HypervisorType hypervisorType) {
2490+
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(hypervisorType);
2491+
2492+
NicTO nicTO = hvGuru.toNicTO(nic);
2493+
return nicTO;
2494+
}
24862495

24872496
@Override
24882497
public boolean removeVmFromNetwork(VirtualMachine vm, Network network) throws ConcurrentOperationException, ResourceUnavailableException {
@@ -2506,8 +2515,7 @@ public boolean removeVmFromNetwork(VirtualMachine vm, Network network) throws Co
25062515
HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vmProfile.getVirtualMachine().getHypervisorType());
25072516
VirtualMachineTO vmTO = hvGuru.implement(vmProfile);
25082517

2509-
//3) Convert nicProfile to NicTO
2510-
NicTO nicTO = hvGuru.toNicTO(nic);
2518+
NicTO nicTO = toNicTO(nic, vmProfile.getVirtualMachine().getHypervisorType());
25112519

25122520
boolean result = vmGuru.unplugNic(network, nicTO, vmTO, context, dest);
25132521
//4) Unplug the nic

‎wscript‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# the following two variables are used by the target "waf dist"
55
# 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
66

7-
VERSION = '3.0.3.2012-06-05T22:35:08Z'
7+
VERSION = '3.0.3.2012-06-05T23:07:27Z'
88
APPNAME = 'cloud'
99

1010
import shutil,os

0 commit comments

Comments
 (0)