Search in sources :

Example 1 with ConfigDriveNetworkElement

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");
                    }
                }
            }
        }
    }
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) NetworkElement(com.cloud.network.element.NetworkElement) ConfigDriveNetworkElement(com.cloud.network.element.ConfigDriveNetworkElement) VirtualRouterElement(com.cloud.network.element.VirtualRouterElement) ConfigDriveNetworkElement(com.cloud.network.element.ConfigDriveNetworkElement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NicProfile(com.cloud.vm.NicProfile) NicVO(com.cloud.vm.NicVO) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider)

Aggregations

NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)1 ConfigDriveNetworkElement (com.cloud.network.element.ConfigDriveNetworkElement)1 NetworkElement (com.cloud.network.element.NetworkElement)1 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)1 VirtualRouterElement (com.cloud.network.element.VirtualRouterElement)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 NicProfile (com.cloud.vm.NicProfile)1 NicVO (com.cloud.vm.NicVO)1