DaanHoogland commented on code in PR #8371:
URL: https://github.com/apache/cloudstack/pull/8371#discussion_r1437549325
##########
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java:
##########
@@ -2798,28 +2766,38 @@ public void finalizeStop(final VirtualMachineProfile
profile, final Answer answe
final VirtualMachine vm = profile.getVirtualMachine();
final DomainRouterVO domR = _routerDao.findById(vm.getId());
processStopOrRebootAnswer(domR, answer);
- final List<? extends Nic> routerNics =
_nicDao.listByVmId(profile.getId());
- for (final Nic nic : routerNics) {
- final Network network =
_networkModel.getNetwork(nic.getNetworkId());
- final DataCenterVO dcVO =
_dcDao.findById(network.getDataCenterId());
-
- if (network.getTrafficType() == TrafficType.Guest &&
nic.getBroadcastUri() != null &&
nic.getBroadcastUri().getScheme().equals("pvlan")) {
- final NicProfile nicProfile = new NicProfile(nic, network,
nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic");
-
- final NetworkTopology networkTopology =
_networkTopologyContext.retrieveNetworkTopology(dcVO);
- try {
- networkTopology.setupDhcpForPvlan(false, domR,
domR.getHostId(), nicProfile);
- } catch (final ResourceUnavailableException e) {
- s_logger.debug("ERROR in finalizeStop: ", e);
- }
- }
+ if
(Boolean.TRUE.equals(RemoveControlIpOnStop.valueIn(profile.getVirtualMachine().getDataCenterId())))
{
+ removeNics(vm, domR);
}
-
}
}
@Override
public void finalizeExpunge(final VirtualMachine vm) {
+ final DomainRouterVO domR = _routerDao.findById(vm.getId());
+ // not sure if it would hurt to do it in any case, but
+ if
(Boolean.FALSE.equals(RemoveControlIpOnStop.valueIn(vm.getDataCenterId()))) {
+ removeNics(vm, domR);
+ }
+ }
+
+ private void removeNics(VirtualMachine vm, DomainRouterVO domR) {
+ final List<? extends Nic> routerNics = _nicDao.listByVmId(vm.getId());
+ for (final Nic nic : routerNics) {
+ final Network network =
_networkModel.getNetwork(nic.getNetworkId());
Review Comment:
Not sure if we can.
For DC we might. We'd have to assume that the network are all in the same
DC, which sounds like a safe assumption, but might not be. I think we better
trust the DAO caching in this case, can we?
For network, for sure we can't. networks on NICs of a VM might be on
different network types. For VRs they surely are on at least two types (and in
case of a VPN on a third type?).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]