use of com.cloud.network.element.ConfigDriveNetworkElement in project cloudstack by apache.
the class NetworkOrchestrator method setHypervisorHostname.
@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");
}
}
}
}
}
}
Aggregations