shwstppr commented on code in PR #7360:
URL: https://github.com/apache/cloudstack/pull/7360#discussion_r1161501890
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java:
##########
@@ -1811,20 +1812,32 @@ public void finalizeUpdateInSequence(Network network,
boolean success) {
@Override
public void setHypervisorHostname(VirtualMachineProfile vm,
DeployDestination dest, boolean migrationSuccessful) throws
ResourceUnavailableException {
- final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
- for (final NicVO nic : nics) {
- final NetworkVO network =
_networksDao.findById(nic.getNetworkId());
- final Integer networkRate =
_networkModel.getNetworkRate(network.getId(), vm.getId());
- final NicProfile profile = new NicProfile(nic, network,
nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
_networkModel.isSecurityGroupSupportedInNetwork(network),
- _networkModel.getNetworkTag(vm.getHypervisorType(),
network));
- for (final NetworkElement element : networkElements) {
- if
(_networkModel.areServicesSupportedInNetwork(network.getId(), Service.UserData)
&& element instanceof UserDataServiceProvider) {
- if (element instanceof ConfigDriveNetworkElement &&
!migrationSuccessful || element instanceof VirtualRouterElement &&
migrationSuccessful) {
- final UserDataServiceProvider sp =
(UserDataServiceProvider) element;
- if (!sp.saveHypervisorHostname(profile, network, vm,
dest)) {
- throw new CloudRuntimeException("Failed to Add
hypervisor hostname");
- }
+ String hypervisorHostName =
VirtualMachineManager.getHypervisorHostname(dest.getHost().getName());
+ if (StringUtils.isNotEmpty(hypervisorHostName)) {
+ final List<NicVO> nics = _nicDao.listByVmId(vm.getId());
+ for (final NicVO nic : nics) {
+ final NetworkVO network =
_networksDao.findById(nic.getNetworkId());
+ final Integer networkRate =
_networkModel.getNetworkRate(network.getId(), vm.getId());
+ final NicProfile profile = new NicProfile(nic, network,
nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
_networkModel.isSecurityGroupSupportedInNetwork(network),
+ _networkModel.getNetworkTag(vm.getHypervisorType(),
network));
+ setHypervisorHostnameInNetwork(vm, dest, network, profile,
migrationSuccessful);
+ }
+ }
+ }
+
+ private void setHypervisorHostnameInNetwork(VirtualMachineProfile vm,
DeployDestination dest, Network network, NicProfile profile, boolean
migrationSuccessful) {
+ for (final NetworkElement element : networkElements) {
+ if (_networkModel.areServicesSupportedInNetwork(network.getId(),
Service.UserData) && element instanceof UserDataServiceProvider
Review Comment:
minor: @harikrishna-patnala do we really need to check for `element
instanceof UserDataServiceProvider` when we are checking for
ConfigDriveNetworkElement and VirtualRouterElement, both of which implement
UserDataServiceProvider?
--
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]