Search in sources :

Example 11 with NetworkCluster

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

the class NetworkPanel method getContents.

@Override
protected Widget getContents() {
    Image mgmtNetworkImage;
    Image defaultRouteImage;
    Image vmImage;
    Image monitorImage;
    Image migrationImage;
    Image notSyncImage;
    Image alertImage;
    Image glusterNwImage;
    if (!item.isManaged()) {
        monitorImage = null;
        mgmtNetworkImage = null;
        defaultRouteImage = null;
        vmImage = null;
        migrationImage = null;
        glusterNwImage = null;
        notSyncImage = null;
        alertImage = null;
    } else {
        NetworkCluster networkCluster = item.getNetwork().getCluster();
        monitorImage = networkCluster.isDisplay() ? new Image(resources.networkMonitor()) : null;
        mgmtNetworkImage = item.isManagement() ? new Image(resources.mgmtNetwork()) : null;
        defaultRouteImage = networkCluster.isDefaultRoute() ? new Image(resources.defaultRouteNetwork()) : null;
        vmImage = item.getNetwork().isVmNetwork() ? new Image(resources.networkVm()) : null;
        migrationImage = networkCluster.isMigration() ? new Image(resources.migrationNetwork()) : null;
        glusterNwImage = networkCluster.isGluster() ? new Image(resources.glusterNetwork()) : null;
        notSyncImage = !item.isInSync() ? new Image(resources.networkNotSyncImage()) : null;
        alertImage = item.getErrorMessage() != null ? new Image(resources.alertImage()) : null;
        if (item.isManagement()) {
            mgmtNetworkImage.setStylePrimaryName(style.networkImageBorder());
        }
        if (item.getNetwork().isVmNetwork()) {
            vmImage.setStylePrimaryName(style.networkImageBorder());
        }
        if (networkCluster.isDisplay()) {
            monitorImage.setStylePrimaryName(style.networkImageBorder());
        }
        if (networkCluster.isMigration()) {
            migrationImage.setStylePrimaryName(style.networkImageBorder());
        }
        if (networkCluster.isDefaultRoute()) {
            defaultRouteImage.setStylePrimaryName(style.networkImageBorder());
        }
        if (networkCluster.isGluster()) {
            glusterNwImage.setStylePrimaryName(style.networkImageBorder());
        }
        if (!item.isInSync()) {
            notSyncImage.setStylePrimaryName(style.syncImageBorder());
        }
    }
    actionButton.setVisible(item.getAttachedToNic() != null && (item.isManaged() || !item.isAttachedViaLabel()));
    Grid rowPanel = new Grid(item.hasVlan() ? 2 : 1, 10);
    rowPanel.setCellSpacing(0);
    // $NON-NLS-1$
    rowPanel.setWidth("100%");
    // $NON-NLS-1$
    rowPanel.setHeight("100%");
    ColumnFormatter columnFormatter = rowPanel.getColumnFormatter();
    // $NON-NLS-1$
    columnFormatter.setWidth(0, "5px");
    // $NON-NLS-1$
    columnFormatter.setWidth(1, "20px");
    // $NON-NLS-1$
    columnFormatter.setWidth(2, "100%");
    rowPanel.setWidget(0, 0, dragImage);
    Panel statusPanel = new HorizontalPanel();
    statusPanel.setStylePrimaryName(style.networkStatusPanel());
    rowPanel.setWidget(0, 1, statusPanel);
    if (alertImage != null) {
        statusPanel.add(alertImage);
    }
    ImageResource statusImage = getStatusImage();
    if (statusImage != null) {
        statusPanel.add(new Image(statusImage));
    }
    if (notSyncImage != null) {
        statusPanel.add(notSyncImage);
    }
    rowPanel.setWidget(0, 2, createTitlePanel());
    rowPanel.setWidget(0, 3, mgmtNetworkImage);
    rowPanel.setWidget(0, 4, monitorImage);
    rowPanel.setWidget(0, 5, vmImage);
    rowPanel.setWidget(0, 6, migrationImage);
    rowPanel.setWidget(0, 7, glusterNwImage);
    rowPanel.setWidget(0, 8, defaultRouteImage);
    rowPanel.setWidget(0, 9, actionButton);
    if (item.hasVlan()) {
        rowPanel.setWidget(1, 2, createVlanPanel());
        for (int i = 3; i < rowPanel.getColumnCount(); i++) {
            // we need to clear the unused widgets, otherwise there will be few pixels wide empty space
            rowPanel.setWidget(1, i, null);
        }
    }
    return rowPanel;
}
Also used : Panel(com.google.gwt.user.client.ui.Panel) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ImageResource(com.google.gwt.resources.client.ImageResource) Grid(com.google.gwt.user.client.ui.Grid) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Image(com.google.gwt.user.client.ui.Image) ColumnFormatter(com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter)

Example 12 with NetworkCluster

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

the class NewNetworkModel method createNetworkAttachments.

private List<NetworkCluster> createNetworkAttachments() {
    List<NetworkCluster> networkAttachments = new ArrayList<>();
    getClustersToAttach().forEach(networkClusterModel -> {
        NetworkCluster networkCluster = new NetworkCluster();
        // Network id is added in the backend
        networkCluster.setClusterId(networkClusterModel.getEntity().getId());
        networkCluster.setRequired(networkClusterModel.isRequired());
        networkAttachments.add(networkCluster);
    });
    return networkAttachments;
}
Also used : ArrayList(java.util.ArrayList) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster)

Example 13 with NetworkCluster

use of org.ovirt.engine.core.common.businessentities.network.NetworkCluster 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 14 with NetworkCluster

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

the class SubTabNetworkClusterView method initTable.

private void initTable() {
    getTable().enableColumnResizing();
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> nameColumn = new AbstractLinkColumn<PairQueryable<Cluster, NetworkCluster>>(new FieldUpdater<PairQueryable<Cluster, NetworkCluster>, String>() {

        @Override
        public void update(int index, PairQueryable<Cluster, NetworkCluster> cluster, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), cluster.getFirst().getName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameCluster(), "400px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> versionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getCompatibilityVersion().getValue();
        }
    };
    versionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersCluster(), "130px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> attachedColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getSecond() != null;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    attachedColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(attachedColumn, constants.attachedNetworkCluster(), "120px");
    NetworkClusterStatusColumn statusColumn = new NetworkClusterStatusColumn();
    statusColumn.makeSortable(new SimpleStatusColumnComparator<>(statusColumn));
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.networkStatus(), "120px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> netRequiredColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            if (object.getSecond() != null) {
                return object.getSecond().isRequired();
            }
            return false;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    netRequiredColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(netRequiredColumn, constants.requiredNetCluster(), "120px");
    AbstractSafeHtmlColumn<PairQueryable<Cluster, NetworkCluster>> netRoleColumn = createNetRoleColumn();
    netRoleColumn.makeSortable(new NetRoleColumnComparator());
    // $NON-NLS-1$
    getTable().addColumn(netRoleColumn, constants.roleNetCluster(), "120px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> descriptionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getDescription();
        }
    };
    descriptionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.descriptionCluster(), "400px");
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) NetworkClusterStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.NetworkClusterStatusColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 15 with NetworkCluster

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

the class UpdateClusterCommand method executeCommand.

@Override
protected void executeCommand() {
    Guid newMacPoolId = getNewMacPoolId();
    moveMacs.migrateMacsToAnotherMacPool(oldCluster, newMacPoolId, getContext());
    getCluster().setArchitecture(getArchitecture());
    setDefaultSwitchTypeIfNeeded();
    setDefaultFirewallTypeIfNeeded();
    // TODO: This code should be revisited and proper compensation logic should be introduced here
    checkMaxMemoryOverCommitValue();
    if (!Objects.equals(oldCluster.getCompatibilityVersion(), getParameters().getCluster().getCompatibilityVersion())) {
        String emulatedMachine = null;
        // pick an UP host randomly - all should have latest compat version already if we passed validate.
        for (VDS vds : allForCluster) {
            if (vds.getStatus() == VDSStatus.Up) {
                emulatedMachine = getEmulatedMachineOfHostInCluster(vds);
                break;
            }
        }
        if (emulatedMachine == null) {
            getParameters().getCluster().setDetectEmulatedMachine(true);
        } else {
            getParameters().getCluster().setEmulatedMachine(emulatedMachine);
        }
    } else if (oldCluster.getArchitecture() != getCluster().getArchitecture()) {
        // if architecture was changed, emulated machines must be updated when adding new host.
        // At this point the cluster is empty and have changed CPU name
        getParameters().getCluster().setDetectEmulatedMachine(true);
        getParameters().getCluster().setEmulatedMachine(null);
    }
    if (getParameters().isForceResetEmulatedMachine()) {
        getParameters().getCluster().setDetectEmulatedMachine(true);
    }
    boolean isKsmPolicyChanged = (getCluster().isKsmMergeAcrossNumaNodes() != getPrevCluster().isKsmMergeAcrossNumaNodes()) || (getCluster().isEnableKsm() != getPrevCluster().isEnableKsm());
    clusterDao.update(getParameters().getCluster());
    addOrUpdateAddtionalClusterFeatures();
    if (!oldCluster.supportsGlusterService() && getCluster().supportsGlusterService()) {
        // update gluster parameters on all hosts
        updateGlusterHosts();
    }
    if (isAddedToStoragePool) {
        for (VDS vds : allForCluster) {
            VdsActionParameters parameters = new VdsActionParameters();
            parameters.setVdsId(vds.getId());
            ActionReturnValue addVdsSpmIdReturn = runInternalAction(ActionType.AddVdsSpmId, parameters, cloneContextAndDetachFromParent());
            if (!addVdsSpmIdReturn.getSucceeded()) {
                setSucceeded(false);
                getReturnValue().setFault(addVdsSpmIdReturn.getFault());
                return;
            }
        }
        final NetworkCluster managementNetworkCluster = createManagementNetworkCluster();
        networkClusterDao.save(managementNetworkCluster);
    }
    alertIfFencingDisabled();
    if (isKsmPolicyChanged) {
        momPolicyUpdatedEvent.fire(getCluster());
    }
    updateDefaultNetworkProvider();
    // Call UpdateVmCommand on all VMs in the cluster to update defaults (i.e. DisplayType)
    updateVms();
    updateTemplates();
    if (getCluster().getFirewallType() != getPrevCluster().getFirewallType()) {
        markHostsForReinstall();
    }
    if (!failedUpgradeEntities.isEmpty()) {
        logFailedUpgrades();
        failValidation(Arrays.asList(EngineMessage.CLUSTER_CANNOT_UPDATE_CLUSTER_FAILED_TO_UPDATE_VMS), "$VmList " + StringUtils.join(failedUpgradeEntities.keySet(), ", "));
        getReturnValue().setValid(false);
        setSucceeded(false);
        return;
    }
    if (!Objects.equals(oldCluster.getCompatibilityVersion(), getCluster().getCompatibilityVersion())) {
        vmStaticDao.getAllByCluster(getCluster().getId()).forEach(this::updateClusterVersionInManager);
    }
    setSucceeded(true);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) VdsActionParameters(org.ovirt.engine.core.common.action.VdsActionParameters) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) Guid(org.ovirt.engine.core.compat.Guid)

Aggregations

NetworkCluster (org.ovirt.engine.core.common.businessentities.network.NetworkCluster)62 Test (org.junit.Test)19 Network (org.ovirt.engine.core.common.businessentities.network.Network)17 ArrayList (java.util.ArrayList)15 NetworkClusterId (org.ovirt.engine.core.common.businessentities.network.NetworkClusterId)7 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)6 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 ManageNetworkClustersParameters (org.ovirt.engine.core.common.action.ManageNetworkClustersParameters)5 List (java.util.List)4 Map (java.util.Map)4 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)4 Guid (org.ovirt.engine.core.compat.Guid)4 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)3 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)3 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 Collection (java.util.Collection)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2