Search in sources :

Example 1 with AnonymousHostNetworkQos

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

the class LogicalNetworkModelParametersHelper method applyOnAttachmentParamsFrom.

private void applyOnAttachmentParamsFrom(InterfacePropertiesAccessor interfacePropertiesAccessor, NetworkAttachment networkAttachment) {
    populateIpv4Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv4PrimaryAddress());
    populateIpv6Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv6PrimaryAddress());
    if (interfacePropertiesAccessor.isQosOverridden()) {
        AnonymousHostNetworkQos anonymousHostNetworkQos = AnonymousHostNetworkQos.fromHostNetworkQos(interfacePropertiesAccessor.getHostNetworkQos());
        networkAttachment.setHostNetworkQos(anonymousHostNetworkQos);
    }
    networkAttachment.setProperties(interfacePropertiesAccessor.getCustomProperties());
    networkAttachment.setDnsResolverConfiguration(interfacePropertiesAccessor.getDnsResolverConfiguration());
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)

Example 2 with AnonymousHostNetworkQos

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

the class HostSetupNetworksValidatorTest method createValidatorForTestingValidateQosOverridden.

private HostSetupNetworksValidator createValidatorForTestingValidateQosOverridden(Network network) {
    NetworkAttachment networkAttachment = new NetworkAttachment();
    networkAttachment.setNetworkId(network.getId());
    networkAttachment.setHostNetworkQos(new AnonymousHostNetworkQos());
    return new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(network).build();
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Example 3 with AnonymousHostNetworkQos

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

the class HostSetupNetworksModel method onEdit.

public void onEdit(NetworkItemModel<?> item) {
    Model editPopup = null;
    BaseCommandTarget okTarget = null;
    if (item instanceof BondNetworkInterfaceModel) {
        /**
         ***************
         * Bond Dialog
         ****************
         */
        boolean doesBondHaveVmNetworkAttached = doesBondHaveVmNetworkAttached((NetworkInterfaceModel) item);
        BondNetworkInterfaceModel bondModel = (BondNetworkInterfaceModel) item;
        final CreateOrUpdateBond createOrUpdateBondParameter = bondModel.getCreateOrUpdateBond();
        editPopup = new SetupNetworksEditBondModel(createOrUpdateBondParameter, doesBondHaveVmNetworkAttached);
        final SetupNetworksBondModel bondDialogModel = (SetupNetworksBondModel) editPopup;
        // OK Target
        okTarget = new BaseCommandTarget() {

            @Override
            public void executeCommand(UICommand command) {
                if (!bondDialogModel.validate()) {
                    return;
                }
                sourceListModel.setConfirmWindow(null);
                setBondOptions(createOrUpdateBondParameter, bondDialogModel);
                redraw();
            }
        };
    } else if (item instanceof NetworkInterfaceModel) {
        /**
         *****************
         * VFs Config Dialog
         ******************
         */
        final VdsNetworkInterface entity = ((NetworkInterfaceModel) item).getOriginalIface();
        final HostNicVfsConfig hostNicVfsConfig = nicToVfsConfig.get(entity.getId());
        if (hostNicVfsConfig != null) {
            final VfsConfigModel vfsConfigPopupModel = new VfsConfigModel(hostNicVfsConfig, allNetworks, dcLabels);
            vfsConfigPopupModel.setTitle(ConstantsManager.getInstance().getMessages().editHostNicVfsConfigTitle(entity.getName()));
            editPopup = vfsConfigPopupModel;
            // OK Target
            okTarget = new BaseCommandTarget() {

                @Override
                public void executeCommand(UICommand uiCommand) {
                    if (!vfsConfigPopupModel.validate()) {
                        return;
                    }
                    sourceListModel.setConfirmWindow(null);
                    commitVfsConfigChanges(hostNicVfsConfig, vfsConfigPopupModel);
                    redraw();
                }
            };
        }
    } else if (item instanceof LogicalNetworkModel) {
        /**
         ***************
         * Network Dialog
         ****************
         */
        final LogicalNetworkModel logicalNetworkModel = (LogicalNetworkModel) item;
        final VdsNetworkInterface nic;
        if (logicalNetworkModel.isInSync()) {
            nic = logicalNetworkModel.hasVlan() ? logicalNetworkModel.getVlanDevice() : logicalNetworkModel.getAttachedToNic().getOriginalIface();
        } else {
            nic = logicalNetworkModel.getVlanDevice() != null ? logicalNetworkModel.getVlanDevice() : logicalNetworkModel.getAttachedToNic().getOriginalIface();
        }
        final NetworkAttachmentModel networkAttachmentModel;
        String version = getEntity().getClusterCompatibilityVersion().getValue();
        final Network network = logicalNetworkModel.getNetwork();
        final String logicalNetworkModelName = network.getName();
        final NetworkAttachment networkAttachment = logicalNetworkModel.getNetworkAttachment();
        HostNetworkQos networkQos = qosById.get(network.getQosId());
        DnsResolverConfiguration reportedDnsResolverConfiguration = getEntity().getReportedDnsResolverConfiguration();
        if (logicalNetworkModel.isManagement()) {
            networkAttachmentModel = new ManagementNetworkAttachmentModel(network, nic, networkAttachment, networkQos, reportedDnsResolverConfiguration);
        } else {
            networkAttachmentModel = new NetworkAttachmentModel(network, nic, networkAttachment, networkQos, reportedDnsResolverConfiguration);
            networkAttachmentModel.getIpv4Gateway().setIsAvailable(true);
            networkAttachmentModel.getIpv6Gateway().setIsAvailable(false);
        }
        networkAttachmentModel.getQosOverridden().setIsAvailable(true);
        networkAttachmentModel.getQosModel().setIsAvailable(true);
        KeyValueModel customPropertiesModel = networkAttachmentModel.getCustomPropertiesModel();
        customPropertiesModel.setIsAvailable(true);
        Map<String, String> validProperties = KeyValueModel.convertProperties((String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.PreDefinedNetworkCustomProperties, version));
        // to backend and frontend (lvernia)
        if (!network.isVmNetwork()) {
            // $NON-NLS-1$
            validProperties.remove("bridge_opts");
        }
        validProperties.putAll(KeyValueModel.convertProperties((String) AsyncDataProvider.getInstance().getConfigValuePreConverted(ConfigValues.UserDefinedNetworkCustomProperties, version)));
        customPropertiesModel.setKeyValueMap(validProperties);
        customPropertiesModel.deserialize(KeyValueModel.convertProperties(networkAttachment.getProperties()));
        networkAttachmentModel.getIsToSync().setIsChangeable(!logicalNetworkModel.isInSync());
        networkAttachmentModel.getIsToSync().setEntity(shouldSyncNetwork(logicalNetworkModelName));
        networkAttachmentModel.getQosOverridden().setEntity(networkAttachment.isQosOverridden());
        editPopup = networkAttachmentModel;
        // OK Target
        okTarget = new BaseCommandTarget() {

            @Override
            public void executeCommand(UICommand command) {
                if (!networkAttachmentModel.validate()) {
                    return;
                }
                final FromNetworkAttachmentModel interfacePropertiesAccessor = new FromNetworkAttachmentModel(networkAttachmentModel);
                LogicalNetworkModelParametersHelper.populateIpv4Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv4PrimaryAddress());
                LogicalNetworkModelParametersHelper.populateIpv6Details(interfacePropertiesAccessor, networkAttachment.getIpConfiguration().getIpv6PrimaryAddress());
                if (networkAttachmentModel.getQosModel().getIsAvailable()) {
                    if (networkAttachmentModel.getQosOverridden().getEntity()) {
                        HostNetworkQos overriddenQos = new HostNetworkQos();
                        networkAttachmentModel.getQosModel().flush(overriddenQos);
                        AnonymousHostNetworkQos hostNetworkQos = fromHostNetworkQos(overriddenQos);
                        networkAttachment.setHostNetworkQos(hostNetworkQos);
                    } else {
                        networkAttachment.setHostNetworkQos(null);
                    }
                }
                if (networkAttachmentModel.getIsToSync().getEntity()) {
                    hostSetupNetworksParametersData.getNetworksToSync().add(logicalNetworkModelName);
                } else {
                    hostSetupNetworksParametersData.getNetworksToSync().remove(logicalNetworkModelName);
                }
                boolean customPropertiesAvailable = networkAttachmentModel.getCustomPropertiesModel().getIsAvailable();
                Map<String, String> customProperties = customPropertiesAvailable ? KeyValueModel.convertProperties(networkAttachmentModel.getCustomPropertiesModel().serialize()) : null;
                networkAttachment.setProperties(customProperties);
                networkAttachment.setDnsResolverConfiguration(networkAttachmentModel.getDnsConfigurationModel().flush());
                sourceListModel.setConfirmWindow(null);
                redraw();
            }
        };
    }
    // ok command
    // $NON-NLS-1$
    UICommand okCommand = UICommand.createDefaultOkUiCommand("OK", okTarget);
    // cancel command
    UICommand cancelCommand = new UICommand("Cancel", new // $NON-NLS-1$
    BaseCommandTarget() {

        @Override
        public void executeCommand(UICommand command) {
            sourceListModel.setConfirmWindow(null);
        }
    });
    cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel());
    cancelCommand.setIsCancel(true);
    if (editPopup != null) {
        editPopup.getCommands().add(okCommand);
        editPopup.getCommands().add(cancelCommand);
    }
    sourceListModel.setConfirmWindow(editPopup);
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) AnonymousHostNetworkQos.fromHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos.fromHostNetworkQos) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) BaseCommandTarget(org.ovirt.engine.ui.uicommonweb.BaseCommandTarget) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) CreateOrUpdateBond(org.ovirt.engine.core.common.action.CreateOrUpdateBond) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) DataFromHostSetupNetworksModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel) NetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkInterfaceModel) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) LogicalNetworkModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.LogicalNetworkModel) NewNetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel.NewNetworkLabelModel) FromNetworkAttachmentModel(org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) BondNetworkInterfaceModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel) NetworkItemModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkItemModel) NetworkLabelModel(org.ovirt.engine.ui.uicommonweb.models.hosts.network.NetworkLabelModel) KeyValueModel(org.ovirt.engine.ui.uicommonweb.models.vms.key_value.KeyValueModel) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with AnonymousHostNetworkQos

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

the class HostSetupNetworksValidatorTest method createHostNetworkQos.

private AnonymousHostNetworkQos createHostNetworkQos(int outAverageRealtime, int outAverageUpperlimit, int outAverageLinkshare) {
    AnonymousHostNetworkQos qos = new AnonymousHostNetworkQos();
    qos.setOutAverageRealtime(outAverageRealtime);
    qos.setOutAverageUpperlimit(outAverageUpperlimit);
    qos.setOutAverageLinkshare(outAverageLinkshare);
    return qos;
}
Also used : AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)

Example 5 with AnonymousHostNetworkQos

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

the class HostSetupNetworksValidatorTest method testValidateQosNotPartiallyConfigured.

private void testValidateQosNotPartiallyConfigured(boolean networkAttachment1HasQos, boolean networkAttachment2HasQos, Matcher<ValidationResult> matcher) {
    VdsNetworkInterface baseNic = createNic("baseNic");
    VdsNetworkInterface vlanNic1 = createVlanNic(baseNic, "vlanNic1", 10);
    VdsNetworkInterface vlanNic2 = createVlanNic(baseNic, "vlanNic2", 11);
    Network network1 = createNetworkWithName("network1");
    Network network2 = createNetworkWithName("network2");
    NetworkAttachment networkAttachment1 = createNetworkAttachment(network1, baseNic);
    NetworkAttachment networkAttachment2 = createNetworkAttachment(network2, baseNic);
    AnonymousHostNetworkQos qos = createHostNetworkQos(10, 10, 10);
    if (networkAttachment1HasQos) {
        networkAttachment1.setHostNetworkQos(qos);
    }
    if (networkAttachment2HasQos) {
        networkAttachment2.setHostNetworkQos(qos);
    }
    Collection<NetworkAttachment> networkAttachments = Arrays.asList(networkAttachment1, networkAttachment2);
    HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addNetworks(network1, network2).addExistingInterfaces(baseNic, vlanNic1, vlanNic2).build();
    assertThat(validator.validateQosNotPartiallyConfigured(networkAttachments), matcher);
}
Also used : FindActiveVmsUsingNetwork(org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork) Network(org.ovirt.engine.core.common.businessentities.network.Network) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) AnonymousHostNetworkQos(org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos) NetworkAttachment(org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)

Aggregations

AnonymousHostNetworkQos (org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos)5 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)3 Network (org.ovirt.engine.core.common.businessentities.network.Network)2 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)1 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)1 AnonymousHostNetworkQos.fromHostNetworkQos (org.ovirt.engine.core.common.businessentities.network.AnonymousHostNetworkQos.fromHostNetworkQos)1 DnsResolverConfiguration (org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration)1 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)1 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)1 BaseCommandTarget (org.ovirt.engine.ui.uicommonweb.BaseCommandTarget)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)1 Model (org.ovirt.engine.ui.uicommonweb.models.Model)1 SearchableListModel (org.ovirt.engine.ui.uicommonweb.models.SearchableListModel)1 FromNetworkAttachmentModel (org.ovirt.engine.ui.uicommonweb.models.hosts.InterfacePropertiesAccessor.FromNetworkAttachmentModel)1 BondNetworkInterfaceModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.BondNetworkInterfaceModel)1 DataFromHostSetupNetworksModel (org.ovirt.engine.ui.uicommonweb.models.hosts.network.DataFromHostSetupNetworksModel)1