Search in sources :

Example 36 with NetworkElement

use of com.cloud.network.element.NetworkElement in project cloudstack by apache.

the class NetworkOrchestrator method commitNicForMigration.

@Override
public void commitNicForMigration(final VirtualMachineProfile src, final VirtualMachineProfile dst) {
    for (final NicProfile nicSrc : src.getNics()) {
        final NetworkVO network = _networksDao.findById(nicSrc.getNetworkId());
        final NetworkGuru guru = AdapterBase.getAdapterByName(networkGurus, network.getGuruName());
        final NicProfile nicDst = findNicProfileById(dst, nicSrc.getId());
        final ReservationContext src_context = new ReservationContextImpl(nicSrc.getReservationId(), null, null);
        final ReservationContext dst_context = new ReservationContextImpl(nicDst.getReservationId(), null, null);
        if (guru instanceof NetworkMigrationResponder) {
            ((NetworkMigrationResponder) guru).commitMigration(nicSrc, network, src, src_context, dst_context);
        }
        final List<Provider> providersToImplement = getNetworkProviders(network.getId());
        for (final NetworkElement element : networkElements) {
            if (providersToImplement.contains(element.getProvider())) {
                if (!_networkModel.isProviderEnabledInPhysicalNetwork(_networkModel.getPhysicalNetworkId(network), element.getProvider().getName())) {
                    throw new CloudRuntimeException("Service provider " + element.getProvider().getName() + " either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
                }
                if (element instanceof NetworkMigrationResponder) {
                    ((NetworkMigrationResponder) element).commitMigration(nicSrc, network, src, src_context, dst_context);
                }
            }
        }
        // update the reservation id
        final NicVO nicVo = _nicDao.findById(nicDst.getId());
        nicVo.setReservationId(nicDst.getReservationId());
        _nicDao.persist(nicVo);
    }
}
Also used : PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) NetworkMigrationResponder(com.cloud.network.NetworkMigrationResponder) NetworkElement(com.cloud.network.element.NetworkElement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) NetworkGuru(com.cloud.network.guru.NetworkGuru) NicProfile(com.cloud.vm.NicProfile) ReservationContextImpl(com.cloud.vm.ReservationContextImpl) NicVO(com.cloud.vm.NicVO) ReservationContext(com.cloud.vm.ReservationContext) DnsServiceProvider(com.cloud.network.element.DnsServiceProvider) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) DhcpServiceProvider(com.cloud.network.element.DhcpServiceProvider) LoadBalancingServiceProvider(com.cloud.network.element.LoadBalancingServiceProvider) StaticNatServiceProvider(com.cloud.network.element.StaticNatServiceProvider) Provider(com.cloud.network.Network.Provider)

Aggregations

NetworkElement (com.cloud.network.element.NetworkElement)36 Provider (com.cloud.network.Network.Provider)23 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)17 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)17 StaticNatServiceProvider (com.cloud.network.element.StaticNatServiceProvider)15 Service (com.cloud.network.Network.Service)14 DhcpServiceProvider (com.cloud.network.element.DhcpServiceProvider)13 LoadBalancingServiceProvider (com.cloud.network.element.LoadBalancingServiceProvider)13 DnsServiceProvider (com.cloud.network.element.DnsServiceProvider)12 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)11 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)11 HashMap (java.util.HashMap)10 Map (java.util.Map)10 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)9 Capability (com.cloud.network.Network.Capability)8 NetworkVO (com.cloud.network.dao.NetworkVO)8 NetworkGuru (com.cloud.network.guru.NetworkGuru)8 ArrayList (java.util.ArrayList)8 NicProfile (com.cloud.vm.NicProfile)7 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)6