Search in sources :

Example 56 with Network

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

the class SubTabClusterNetworkView method initTable.

private void initTable() {
    getTable().enableColumnResizing();
    NetworkStatusColumn statusIconColumn = new NetworkStatusColumn();
    statusIconColumn.setContextMenuTitle(constants.statusIconNetwork());
    // $NON-NLS-1$ //$NON-NLS-2$
    getTable().addColumn(statusIconColumn, "", "20px");
    AbstractTextColumn<Network> nameColumn = new AbstractLinkColumn<Network>(new FieldUpdater<Network, String>() {

        @Override
        public void update(int index, Network network, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), network.getName());
            parameters.put(FragmentParams.DATACENTER.getName(), getModelProvider().getMainModel().getSelectedItem().getStoragePoolName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.networkGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(Network object) {
            return object.getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameNetwork(), "400px");
    AbstractTextColumn<Network> statusColumn = new AbstractEnumColumn<Network, NetworkStatus>() {

        @Override
        public NetworkStatus getRawValue(Network object) {
            return object.getCluster().getStatus();
        }
    };
    statusColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.statusNetwork(), "100px");
    // $NON-NLS-1$
    getTable().addColumn(createNetRoleColumn(), constants.roleNetwork(), "90px");
    AbstractTextColumn<Network> descColumn = new AbstractTextColumn<Network>() {

        @Override
        public String getValue(Network object) {
            return object.getDescription();
        }
    };
    descColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descColumn, constants.descriptionNetwork(), "400px");
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) NetworkStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.NetworkStatusColumn) Network(org.ovirt.engine.core.common.businessentities.network.Network) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 57 with Network

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

the class SubTabClusterNetworkView method createNetRoleColumn.

private AbstractSafeHtmlColumn<Network> createNetRoleColumn() {
    return new AbstractSafeHtmlColumn<Network>() {

        @Override
        public SafeHtml getValue(Network network) {
            List<SafeHtml> images = new LinkedList<>();
            final NetworkCluster networkCluster = network.getCluster();
            if (networkCluster != null) {
                images.add(thisOrEmptyImage(networkCluster.isManagement(), managementImage));
                images.add(thisOrEmptyImage(networkCluster.isDisplay(), displayImage));
                images.add(thisOrEmptyImage(networkCluster.isMigration(), migrationImage));
                images.add(thisOrEmptyImage(network.getCluster().isGluster(), glusterNwImage));
                images.add(thisOrEmptyImage(networkCluster.isDefaultRoute(), defaultRouteImage));
            }
            return MultiImageColumnHelper.getValue(images);
        }

        @Override
        public SafeHtml getTooltip(Network network) {
            Map<SafeHtml, String> imagesToText = new LinkedHashMap<>();
            final NetworkCluster networkCluster = network.getCluster();
            if (networkCluster != null) {
                if (networkCluster.isManagement()) {
                    imagesToText.put(managementImage, constants.managementItemInfo());
                }
                if (networkCluster.isDisplay()) {
                    imagesToText.put(displayImage, constants.displayItemInfo());
                }
                if (networkCluster.isMigration()) {
                    imagesToText.put(migrationImage, constants.migrationItemInfo());
                }
                if (network.getCluster().isGluster()) {
                    imagesToText.put(glusterNwImage, constants.glusterNwItemInfo());
                }
                if (networkCluster.isDefaultRoute()) {
                    imagesToText.put(defaultRouteImage, constants.defaultRouteItemInfo());
                }
            }
            return MultiImageColumnHelper.getTooltip(imagesToText);
        }
    };
}
Also used : AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap)

Example 58 with Network

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

the class ChangeVDSClusterCommand method isSameManagementNetwork.

private boolean isSameManagementNetwork() {
    final Network sourceManagementNetwork = networkDao.getManagementNetwork(getSourceCluster().getId());
    final Network targetManagementNetwork = networkDao.getManagementNetwork(getTargetCluster().getId());
    return targetManagementNetwork != null && sourceManagementNetwork.getName().equals(targetManagementNetwork.getName());
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network)

Example 59 with Network

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

the class RunVmCommandBase method initParametersForExternalNetworks.

protected void initParametersForExternalNetworks(VDS vds, boolean isMigration) {
    for (VmNetworkInterface iface : getVm().getInterfaces()) {
        VnicProfile vnicProfile = vnicProfileDao.get(iface.getVnicProfileId());
        Network network = networkHelper.getNetworkByVnicProfile(vnicProfile);
        if (network != null && network.isExternal() && iface.isPlugged()) {
            Provider<?> provider = providerDao.get(network.getProvidedBy().getProviderId());
            NetworkProviderProxy providerProxy = providerProxyFactory.create(provider);
            Map<String, String> deviceProperties = providerProxy.allocate(network, vnicProfile, iface, vds, isMigration);
            getVm().getRuntimeDeviceCustomProperties().put(new VmDeviceId(iface.getId(), getVmId()), deviceProperties);
        }
    }
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 60 with Network

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

the class UpdateVmCommand method updateVmNetworks.

private void updateVmNetworks() {
    // check if the cluster has changed
    if (!Objects.equals(getVm().getClusterId(), getParameters().getVmStaticData().getClusterId())) {
        List<Network> networks = networkDao.getAllForCluster(getParameters().getVmStaticData().getClusterId());
        List<VmNic> interfaces = vmNicDao.getAllForVm(getParameters().getVmStaticData().getId());
        for (final VmNic iface : interfaces) {
            final Network network = networkHelper.getNetworkByVnicProfileId(iface.getVnicProfileId());
            boolean networkFound = networks.stream().anyMatch(n -> Objects.equals(n.getId(), network.getId()));
            // if network not exists in cluster we remove the network from the interface
            if (!networkFound) {
                iface.setVnicProfileId(null);
                vmNicDao.update(iface);
            }
        }
    }
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VmNic(org.ovirt.engine.core.common.businessentities.network.VmNic)

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