Search in sources :

Example 21 with VmNetworkInterface

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

the class VmSnapshotInfoPanel method initNicsTable.

private void initNicsTable() {
    nicsTable = new EntityModelCellTable<>(false, true);
    nicsTable.enableColumnResizing();
    AbstractTextColumn<VmNetworkInterface> nameColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getName();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(nameColumn, constants.nameInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> networkNameColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getNetworkName();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(networkNameColumn, constants.networkNameInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> profileNameColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getVnicProfileName();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(profileNameColumn, constants.profileNameInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> typeColumn = new AbstractEnumColumn<VmNetworkInterface, VmInterfaceType>() {

        @Override
        protected VmInterfaceType getRawValue(VmNetworkInterface object) {
            return VmInterfaceType.forValue(object.getType());
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(typeColumn, constants.typeInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> macColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            return object.getMacAddress();
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(macColumn, constants.macInterface(), "80px");
    AbstractTextColumn<VmNetworkInterface> speedColumn = new AbstractTextColumn<VmNetworkInterface>() {

        @Override
        public String getValue(VmNetworkInterface object) {
            if (object.getSpeed() != null) {
                return object.getSpeed().toString();
            } else {
                return null;
            }
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(speedColumn, templates.sub(constants.speedInterface(), constants.mbps()), "80px");
    AbstractTextColumn<VmNetworkInterface> rxColumn = new AbstractRxTxRateColumn<VmNetworkInterface>() {

        @Override
        protected Double getRate(VmNetworkInterface object) {
            return object.getStatistics().getReceiveRate();
        }

        @Override
        protected Double getSpeed(VmNetworkInterface object) {
            if (object.getSpeed() != null) {
                return object.getSpeed().doubleValue();
            } else {
                return null;
            }
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(rxColumn, templates.sub(constants.rxRate(), constants.mbps()), "80px");
    AbstractTextColumn<VmNetworkInterface> txColumn = new AbstractRxTxRateColumn<VmNetworkInterface>() {

        @Override
        protected Double getRate(VmNetworkInterface object) {
            return object.getStatistics().getTransmitRate();
        }

        @Override
        protected Double getSpeed(VmNetworkInterface object) {
            if (object.getSpeed() != null) {
                return object.getSpeed().doubleValue();
            } else {
                return null;
            }
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(txColumn, templates.sub(constants.txRate(), constants.mbps()), "80px");
    AbstractTextColumn<VmNetworkInterface> dropsColumn = new AbstractSumUpColumn<VmNetworkInterface>() {

        @Override
        protected Double[] getRawValue(VmNetworkInterface object) {
            Double receiveDropRate = object != null ? object.getStatistics().getReceiveDropRate() : null;
            Double transmitDropRate = object != null ? object.getStatistics().getTransmitDropRate() : null;
            return new Double[] { receiveDropRate, transmitDropRate };
        }
    };
    // $NON-NLS-1$
    nicsTable.addColumn(dropsColumn, templates.sub(constants.dropsInterface(), constants.pkts()), "80px");
    nicsTable.setRowData(new ArrayList<EntityModel>());
    // $NON-NLS-1$
    nicsTable.setWidth("100%");
    nicsTable.setSelectionModel(new NoSelectionModel());
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) NoSelectionModel(com.google.gwt.view.client.NoSelectionModel) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) AbstractSumUpColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSumUpColumn) AbstractRxTxRateColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractRxTxRateColumn)

Example 22 with VmNetworkInterface

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

the class VmSnapshotListViewItem method createNicsItemContainerPanel.

private Container createNicsItemContainerPanel(List<VmNetworkInterface> nics) {
    RxTxRateRenderer rateRenderer = new RxTxRateRenderer();
    Row content = new Row();
    Container container = createItemContainerPanel(content);
    int i = 0;
    for (VmNetworkInterface nic : nics) {
        if (i % 4 == 0 && i > 0) {
            content = new Row();
            container.add(content);
        }
        Column column = new Column(calculateColSize(i));
        content.add(column);
        DListElement dl = Document.get().createDLElement();
        dl.addClassName(DL_HORIZONTAL);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.nameInterface()), SafeHtmlUtils.fromString(nic.getName()), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.networkNameInterface()), SafeHtmlUtils.fromString(nic.getNetworkName()), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.profileNameInterface()), SafeHtmlUtils.fromString(nic.getVnicProfileName()), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.typeInterface()), SafeHtmlUtils.fromString(VmInterfaceType.forValue(nic.getType()).getDescription()), dl);
        addDetailItem(SafeHtmlUtils.fromSafeConstant(constants.macInterface()), SafeHtmlUtils.fromString(nic.getMacAddress()), dl);
        addDetailItem(templates.sub(constants.rxRate(), constants.mbps()), SafeHtmlUtils.fromString(rateRenderer.render(new Double[] { nic.getStatistics().getReceiveRate(), nic.hasSpeed() ? nic.getSpeed().doubleValue() : 0 })), dl);
        addDetailItem(templates.sub(constants.txRate(), constants.mbps()), SafeHtmlUtils.fromString(rateRenderer.render(new Double[] { nic.getStatistics().getTransmitRate(), nic.hasSpeed() ? nic.getSpeed().doubleValue() : 0 })), dl);
        addDetailItem(templates.sub(constants.dropsInterface(), constants.pkts()), SafeHtmlUtils.fromString(String.valueOf(nic.getStatistics().getReceiveDropRate() != null ? nic.getStatistics().getReceiveDropRate() : "" + nic.getStatistics().getTransmitDropRate())), dl);
        column.getElement().appendChild(dl);
        i++;
    }
    if (nics.isEmpty()) {
        Column column = new Column(ColumnSize.MD_12);
        content.add(column);
        column.getElement().setInnerHTML(constants.noItemsToDisplay());
    }
    return container;
}
Also used : Container(org.gwtbootstrap3.client.ui.Container) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Column(org.gwtbootstrap3.client.ui.Column) RxTxRateRenderer(org.ovirt.engine.ui.common.widget.renderer.RxTxRateRenderer) Row(org.gwtbootstrap3.client.ui.Row) DListElement(com.google.gwt.dom.client.DListElement)

Example 23 with VmNetworkInterface

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

the class ImportVmFromExternalProviderModel method updateNetworkInterfacesForVm.

protected void updateNetworkInterfacesForVm(VM vm) {
    for (VmNetworkInterface iface : vm.getInterfaces()) {
        ImportNetworkData importNetworkData = getNetworkImportData(iface);
        VnicProfileView profile = importNetworkData.getSelectedNetworkProfile();
        if (profile != null) {
            iface.setNetworkName(profile.getNetworkName());
            iface.setVnicProfileName(profile.getName());
        }
    }
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView)

Example 24 with VmNetworkInterface

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

the class ImportVmFromExternalProviderPopupView method addNetworkColumn.

private void addNetworkColumn() {
    customSelectionCellNetwork = new CustomSelectionCell(new ArrayList<String>());
    customSelectionCellNetwork.setStyle(style.cellSelectBox());
    Column<VmNetworkInterface, String> networkColumn = new Column<VmNetworkInterface, String>(customSelectionCellNetwork) {

        @Override
        public String getValue(VmNetworkInterface iface) {
            ImportNetworkData importNetworkData = importModel.getNetworkImportData(iface);
            List<String> networkNames = importNetworkData.getNetworkNames();
            ((CustomSelectionCell) getCell()).setOptions(networkNames);
            if (networkNames.isEmpty()) {
                // $NON-NLS-1$
                return "";
            }
            String selectedNetworkName = importNetworkData.getSelectedNetworkName();
            return selectedNetworkName != null ? selectedNetworkName : networkNames.get(0);
        }
    };
    networkColumn.setFieldUpdater((index, iface, value) -> {
        importModel.getNetworkImportData(iface).setSelectedNetworkName(value);
        nicTable.asEditor().edit(importModel.getImportNetworkInterfaceListModel());
    });
    // $NON-NLS-1$
    nicTable.addColumn(networkColumn, constants.networkNameInterface(), "150px");
}
Also used : ImportNetworkData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList)

Example 25 with VmNetworkInterface

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

the class ImportVmFromExternalProviderPopupView method addNetworkProfileColumn.

private void addNetworkProfileColumn() {
    customSelectionCellNetwork = new CustomSelectionCell(new ArrayList<String>());
    customSelectionCellNetwork.setStyle(style.cellSelectBox());
    Column<VmNetworkInterface, String> profileColumn = new Column<VmNetworkInterface, String>(customSelectionCellNetwork) {

        @Override
        public String getValue(VmNetworkInterface iface) {
            ImportNetworkData importNetworkData = importModel.getNetworkImportData(iface);
            List<String> networkProfileNames = new ArrayList<>();
            for (VnicProfileView networkProfile : importNetworkData.getFilteredNetworkProfiles()) {
                networkProfileNames.add(networkProfile.getName());
            }
            ((CustomSelectionCell) getCell()).setOptions(networkProfileNames);
            if (networkProfileNames.isEmpty()) {
                // $NON-NLS-1$
                return "";
            }
            VnicProfileView selectedNetworkProfile = importModel.getNetworkImportData(iface).getSelectedNetworkProfile();
            return selectedNetworkProfile != null ? selectedNetworkProfile.getName() : networkProfileNames.get(0);
        }
    };
    profileColumn.setFieldUpdater((index, iface, value) -> importModel.getNetworkImportData(iface).setSelectedNetworkProfile(value));
    // $NON-NLS-1$
    nicTable.addColumn(profileColumn, constants.profileNameInterface(), "150px");
}
Also used : ImportNetworkData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportNetworkData) CustomSelectionCell(org.ovirt.engine.ui.webadmin.widget.table.cell.CustomSelectionCell) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) AbstractSafeHtmlColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractSafeHtmlColumn) VmTypeColumn(org.ovirt.engine.ui.webadmin.widget.table.column.VmTypeColumn) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractDiskSizeColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractDiskSizeColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) AbstractImageResourceColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractImageResourceColumn) Column(com.google.gwt.user.cellview.client.Column) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ArrayList(java.util.ArrayList) VnicProfileView(org.ovirt.engine.core.common.businessentities.network.VnicProfileView)

Aggregations

VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)115 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)25 Guid (org.ovirt.engine.core.compat.Guid)19 VM (org.ovirt.engine.core.common.businessentities.VM)16 HashMap (java.util.HashMap)11 List (java.util.List)9 Map (java.util.Map)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)6 MapVnicsContext (org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext)5 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)5 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)5 VmNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)5 Nic (org.ovirt.engine.api.model.Nic)4 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Collection (java.util.Collection)3