Search in sources :

Example 41 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.

the class BaseImportNetworksModel method onProviderChosen.

private void onProviderChosen() {
    final Provider<?> provider = providers.getSelectedItem();
    if (provider == null) {
        return;
    }
    startProgress();
    AsyncQuery<List<StoragePool>> dataCenterQuery = new AsyncQuery<>(returnValue -> {
        final List<StoragePool> dataCenters = new LinkedList<>(returnValue);
        Collections.sort(dataCenters, new NameableComparator());
        AsyncQuery<QueryReturnValue> externalNetworksQuery = new AsyncQuery<>(queryReturnValue -> {
            if (queryReturnValue.getSucceeded()) {
                Map<Network, Set<Guid>> externalNetworkToDataCenters = queryReturnValue.getReturnValue();
                providerNetworks.setItems(getExternalNetworks(externalNetworkToDataCenters, dataCenters));
                importedNetworks.setItems(new LinkedList<ExternalNetwork>());
            } else {
                final ErrorPopupManager popupManager = (ErrorPopupManager) TypeResolver.getInstance().resolve(ErrorPopupManager.class);
                popupManager.show(ConstantsManager.getInstance().getMessages().failedToListExternalNetworks(queryReturnValue.getExceptionMessage()));
            }
            stopProgress();
        }, true);
        AsyncDataProvider.getInstance().getExternalNetworksByProviderId(externalNetworksQuery, provider.getId());
    });
    AsyncDataProvider.getInstance().getDataCenterList(dataCenterQuery);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) Set(java.util.Set) NameableComparator(org.ovirt.engine.core.common.businessentities.comparators.NameableComparator) LinkedList(java.util.LinkedList) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) Network(org.ovirt.engine.core.common.businessentities.network.Network) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) ErrorPopupManager(org.ovirt.engine.ui.uicommonweb.ErrorPopupManager) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork)

Example 42 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.

the class BaseImportNetworksModel method onImport.

public void onImport() {
    if (!validate()) {
        return;
    }
    List<ActionParametersBase> multipleActionParameters = new LinkedList<>();
    for (final ExternalNetwork externalNetwork : importedNetworks.getItems()) {
        final Network network = externalNetwork.getNetwork();
        final Guid dcId = externalNetwork.getDataCenters().getSelectedItem().getId();
        ImportExternalNetworkParameters params = new ImportExternalNetworkParameters(network.getProvidedBy().getProviderId(), network.getProvidedBy().getExternalId(), dcId, externalNetwork.isPublicUse(), true);
        multipleActionParameters.add(params);
    }
    Frontend.getInstance().runMultipleActions(ActionType.ImportExternalNetwork, multipleActionParameters, result -> sourceListModel.getSearchCommand().execute());
    cancel();
}
Also used : ImportExternalNetworkParameters(org.ovirt.engine.core.common.action.ImportExternalNetworkParameters) Network(org.ovirt.engine.core.common.businessentities.network.Network) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) Guid(org.ovirt.engine.core.compat.Guid) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) LinkedList(java.util.LinkedList) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork)

Example 43 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.

the class NetworkGeneralModel method updateProperties.

private void updateProperties() {
    Network extendedNetwork = getEntity();
    setName(extendedNetwork.getName());
    setId(extendedNetwork.getId());
    setDescription(extendedNetwork.getDescription());
    setVmNetwork(extendedNetwork.isVmNetwork());
    setVlan(extendedNetwork.getVlanId());
    setMtu(extendedNetwork.getMtu());
    if (extendedNetwork.isExternal()) {
        setExternalId(extendedNetwork.getProvidedBy().getExternalId());
    } else {
        setExternalId(null);
    }
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network)

Example 44 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.

the class VfsConfigModel method initNetworks.

private void initNetworks(List<Network> allClusterNetworks) {
    List<VfsConfigNetwork> vfsConfigNetworks = new ArrayList<>();
    Set<Guid> attachedNetworks = getEntity().getNetworks();
    for (Network network : allClusterNetworks) {
        boolean isAttached = attachedNetworks.contains(network.getId());
        VfsConfigNetwork vfsConfigNetwork = new VfsConfigNetwork(isAttached, labelsModel, network);
        vfsConfigNetworks.add(vfsConfigNetwork);
    }
    networks.setItems(vfsConfigNetworks);
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) ArrayList(java.util.ArrayList) Guid(org.ovirt.engine.core.compat.Guid)

Example 45 with Network

use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.

the class ItemInfoPopup method showNetwork.

private void showNetwork(LogicalNetworkModel networkModel) {
    boolean descriptionSectionHasValues = false;
    contents.removeAllRows();
    Network entity = networkModel.getNetwork();
    addRow(templates.titleSetupNetworkTooltip(networkModel.getName(), SafeStylesUtils.forTrustedBackgroundColor(BACKGROUND_COLOR)));
    // Not managed
    if (!networkModel.isManaged()) {
        addRow(templates.imageWithText(unknownImage, constants.unmanagedNetworkItemInfo()));
        addRow(SafeHtmlUtils.fromString(constants.unmanagedNetworkDescriptionItemInfo()));
        descriptionSectionHasValues = true;
    } else {
        if (networkModel.getErrorMessage() != null) {
            addRow(templates.imageTextSetupNetwork(alertImage, templates.maxWidthNteworkItemPopup(networkModel.getErrorMessage())));
            descriptionSectionHasValues = true;
        }
        // Description
        if (entity.getDescription() != null && !entity.getDescription().trim().equals("")) {
            // $NON-NLS-1$
            addRow(SafeHtmlUtils.fromString(entity.getDescription()));
            descriptionSectionHasValues = true;
        }
        // Not in sync
        if (!networkModel.isInSync()) {
            addSyncDiff(networkModel);
            descriptionSectionHasValues = true;
        }
    }
    if (descriptionSectionHasValues) {
        insertHorizontalLine();
    }
    boolean isDisplay = false;
    boolean isMigration = false;
    boolean isGluster = false;
    boolean isDefaultRoute = false;
    if (entity.getCluster() != null) {
        isDisplay = entity.getCluster().isDisplay();
        isMigration = entity.getCluster().isMigration();
        isGluster = entity.getCluster().isGluster();
        isDefaultRoute = entity.getCluster().isDefaultRoute();
    }
    // Usages
    if (networkModel.isManagement() || isDisplay || entity.isVmNetwork() || isMigration || isGluster || isDefaultRoute) {
        addRow(// $NON-NLS-1$
        templates.strongTextWithColor(// $NON-NLS-1$
        constants.usageItemInfo() + ":", SafeStylesUtils.forTrustedColor(WHITE_TEXT_COLOR)));
        if (networkModel.isManagement()) {
            addRow(templates.imageTextSetupNetworkUsage(mgmtNetworkImage, constants.managementItemInfo(), SafeStylesUtils.forTrustedColor(TEXT_COLOR)));
        }
        if (isDisplay) {
            addRow(templates.imageTextSetupNetworkUsage(monitorImage, constants.displayItemInfo(), SafeStylesUtils.forTrustedColor(TEXT_COLOR)));
        }
        if (entity.isVmNetwork()) {
            addRow(templates.imageTextSetupNetworkUsage(vmImage, constants.vmItemInfo(), SafeStylesUtils.forTrustedColor(TEXT_COLOR)));
        }
        if (isMigration) {
            addRow(templates.imageTextSetupNetworkUsage(migrationImage, constants.migrationItemInfo(), SafeStylesUtils.forTrustedColor(TEXT_COLOR)));
        }
        if (isGluster) {
            addRow(templates.imageTextSetupNetworkUsage(glusterNwImage, constants.glusterNwItemInfo(), SafeStylesUtils.forTrustedColor(TEXT_COLOR)));
        }
        if (isDefaultRoute) {
            addRow(templates.imageTextSetupNetworkUsage(defaultRouteImage, constants.defaultRouteItemInfo(), SafeStylesUtils.forTrustedColor(TEXT_COLOR)));
        }
        insertHorizontalLine();
    }
    // Mtu
    if (!entity.isExternal()) {
        addMtuInfo(entity.getMtu());
    }
    // Boot protocol and IP info
    if (networkModel.isAttached() && networkModel.isManaged()) {
        addBootProtoAndIpInfo(new InterfacePropertiesAccessor.FromNetworkAttachmentForModel(networkModel.getNetworkAttachment(), null, networkModel.getVlanDevice() != null ? networkModel.getVlanDevice() : networkModel.getAttachedToNic().getOriginalIface()));
    }
}
Also used : InterfacePropertiesAccessor(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor) Network(org.ovirt.engine.core.common.businessentities.network.Network)

Aggregations

Network (org.ovirt.engine.core.common.businessentities.network.Network)292 Test (org.junit.Test)105 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)63 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)47 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)46 ArrayList (java.util.ArrayList)44 Guid (org.ovirt.engine.core.compat.Guid)44 ProviderNetwork (org.ovirt.engine.core.common.businessentities.network.ProviderNetwork)39 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)23 List (java.util.List)21 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)21 HashMap (java.util.HashMap)19 NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)19 Map (java.util.Map)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)13 HashSet (java.util.HashSet)9 Set (java.util.Set)9 BusinessEntityMap (org.ovirt.engine.core.common.businessentities.BusinessEntityMap)9 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)9