Search in sources :

Example 1 with VnicProfileModel

use of org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel in project ovirt-engine by oVirt.

the class NetworkModel method createDefaultProfile.

private VnicProfileModel createDefaultProfile() {
    final VnicProfileModel defaultProfile = new NewVnicProfileModel();
    // make sure default profile's name is in sync with network's name
    defaultProfile.getName().setEntity(getName().getEntity());
    final IEventListener<EventArgs> networkNameListener = (ev, sender, args) -> defaultProfile.getName().setEntity(getName().getEntity());
    getName().getEntityChangedEvent().addListener(networkNameListener);
    // if user overrides default name, stop tracking network's name
    defaultProfile.getName().getEntityChangedEvent().addListener(new IEventListener<EventArgs>() {

        @Override
        public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) {
            String defaultProfileName = defaultProfile.getName().getEntity();
            if ((defaultProfileName != null) && (!defaultProfileName.equals(getName().getEntity()))) {
                getName().getEntityChangedEvent().removeListener(networkNameListener);
                defaultProfile.getName().getEntityChangedEvent().removeListener(this);
            }
        }
    });
    return defaultProfile;
}
Also used : ExternalSubnetModel(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalSubnetModel) Arrays(java.util.Arrays) DnsResolverConfiguration(org.ovirt.engine.core.common.businessentities.network.DnsResolverConfiguration) RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) Provider(org.ovirt.engine.core.common.businessentities.Provider) Event(org.ovirt.engine.ui.uicompat.Event) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) SearchableListModel(org.ovirt.engine.ui.uicommonweb.models.SearchableListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ActionType(org.ovirt.engine.core.common.action.ActionType) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) AsyncDataProvider(org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation) QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DnsConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.dnsconfiguration.DnsConfigurationModel) NameServer(org.ovirt.engine.core.common.businessentities.network.NameServer) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) HasValidatedTabs(org.ovirt.engine.ui.uicommonweb.models.HasValidatedTabs) BusinessEntitiesDefinitions(org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions) StringHelper(org.ovirt.engine.core.compat.StringHelper) Collectors(java.util.stream.Collectors) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) List(java.util.List) ValidationCompleteEvent(org.ovirt.engine.ui.uicommonweb.models.ValidationCompleteEvent) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) QueryType(org.ovirt.engine.core.common.queries.QueryType) NewHostNetworkQosModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.qos.NewHostNetworkQosModel) Guid(org.ovirt.engine.core.compat.Guid) IFrontendActionAsyncCallback(org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase) IdQueryParameters(org.ovirt.engine.core.common.queries.IdQueryParameters) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) ArrayList(java.util.ArrayList) Frontend(org.ovirt.engine.ui.frontend.Frontend) NetworkProfilesModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NetworkProfilesModel) AddVnicProfileParameters(org.ovirt.engine.core.common.action.AddVnicProfileParameters) Network(org.ovirt.engine.core.common.businessentities.network.Network) LinkedList(java.util.LinkedList) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) Model(org.ovirt.engine.ui.uicommonweb.models.Model) Linq(org.ovirt.engine.ui.uicommonweb.Linq) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel) IValidation(org.ovirt.engine.ui.uicommonweb.validation.IValidation) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) ConfigValues(org.ovirt.engine.core.common.config.ConfigValues) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)

Example 2 with VnicProfileModel

use of org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel in project ovirt-engine by oVirt.

the class NetworkModel method validate.

private boolean validate() {
    LengthValidation tempVar = new LengthValidation();
    tempVar.setMaxLength(BusinessEntitiesDefinitions.NETWORK_NAME_SIZE);
    RegexValidation tempVar2 = new RegexValidation();
    tempVar2.setIsNegate(true);
    // $NON-NLS-1$
    tempVar2.setExpression("^(bond)");
    tempVar2.setMessage(ConstantsManager.getInstance().getConstants().networkNameStartMsg());
    getName().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar, tempVar2 });
    LengthValidation tempVar3 = new LengthValidation();
    tempVar3.setMaxLength(40);
    getDescription().validateEntity(new IValidation[] { tempVar3 });
    getComment().validateEntity(new IValidation[] { new SpecialAsciiI18NOrNoneValidation() });
    getVLanTag().setIsValid(true);
    if (getHasVLanTag().getEntity()) {
        IntegerValidation tempVar4 = new IntegerValidation();
        tempVar4.setMinimum(0);
        tempVar4.setMaximum(4094);
        getVLanTag().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar4 });
    }
    IntegerValidation tempVar5 = new IntegerValidation();
    tempVar5.setMinimum(68);
    getMtu().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar5 });
    getDnsConfigurationModel().validate();
    getExternalProviders().validateSelectedItem(new IValidation[] { new NotEmptyValidation() });
    boolean subnetValid = true;
    if (getExternal().getEntity() && getCreateSubnet().getEntity()) {
        subnetValid = getSubnetModel().validate();
    }
    boolean profilesValid = true;
    Iterable<VnicProfileModel> profiles = getProfiles().getItems();
    for (VnicProfileModel profileModel : profiles) {
        if (!profileModel.validate()) {
            profilesValid = false;
        }
    }
    getNetworkLabel().validateSelectedItem(new IValidation[] { new AsciiNameValidation() });
    setValidTab(TabName.GENERAL_TAB, isGeneralTabValid());
    setValidTab(TabName.SUBNET_TAB, subnetValid);
    setValidTab(TabName.PROFILES_TAB, profilesValid);
    ValidationCompleteEvent.fire(getEventBus(), this);
    return allTabsValid();
}
Also used : RegexValidation(org.ovirt.engine.ui.uicommonweb.validation.RegexValidation) NotEmptyValidation(org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation) SpecialAsciiI18NOrNoneValidation(org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel) AsciiNameValidation(org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation) LengthValidation(org.ovirt.engine.ui.uicommonweb.validation.LengthValidation) IntegerValidation(org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)

Example 3 with VnicProfileModel

use of org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel in project ovirt-engine by oVirt.

the class NetworkModel method flush.

public void flush() {
    network.setDataCenterId(getSelectedDc().getId());
    network.setName(getName().getEntity());
    network.setStp(getIsStpEnabled().getEntity());
    network.setDescription(getDescription().getEntity());
    network.setComment(getComment().getEntity());
    network.setVmNetwork(getIsVmNetwork().getEntity());
    String label = getNetworkLabel().getSelectedItem();
    if (getExternal().getEntity() && getConnectedToPhysicalNetwork().getEntity()) {
        label = !getUsePhysicalNetworkFromDatacenter().getEntity() ? getCustomPhysicalNetwork().getEntity() : null;
    }
    network.setLabel(StringHelper.isNotNullOrEmpty(label) ? label : null);
    network.setMtu(0);
    if (getMtu().getIsChangable()) {
        network.setMtu(Integer.parseInt(getMtu().getEntity().toString()));
    }
    network.setDnsResolverConfiguration(getDnsConfigurationModel().flush());
    network.setVlanId(null);
    if (getHasVLanTag().getEntity()) {
        network.setVlanId(Integer.parseInt(getVLanTag().getEntity().toString()));
    }
    for (VnicProfileModel profileModel : getProfiles().getItems()) {
        profileModel.flush();
    }
    if (getQos().getIsChangable()) {
        HostNetworkQos qos = getQos().getSelectedItem();
        network.setQosId(qos == EMPTY_HOST_NETWORK_QOS ? null : qos.getId());
    }
}
Also used : HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel)

Example 4 with VnicProfileModel

use of org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel in project ovirt-engine by oVirt.

the class NetworkModel method performProfilesActions.

private void performProfilesActions(Guid networkGuid) {
    List<VnicProfileModel> profileModels = (List<VnicProfileModel>) getProfiles().getItems();
    if (profileModels.isEmpty() || !getProfiles().getIsAvailable()) {
        return;
    }
    networkGuid = networkGuid == null ? getNetwork().getId() : networkGuid;
    ArrayList<ActionParametersBase> paramlist = new ArrayList<>();
    for (VnicProfileModel profileModel : profileModels) {
        if (!StringHelper.isNullOrEmpty(profileModel.getProfile().getName())) {
            VnicProfile vnicProfile = profileModel.getProfile();
            vnicProfile.setNetworkId(networkGuid);
            AddVnicProfileParameters parameters = new AddVnicProfileParameters(vnicProfile, true);
            parameters.setPublicUse(profileModel.getPublicUse().getEntity());
            paramlist.add(parameters);
        }
    }
    Frontend.getInstance().runMultipleActions(ActionType.AddVnicProfile, paramlist, // cast is required to avoid overload ambiguity
    (IFrontendActionAsyncCallback) null);
}
Also used : ArrayList(java.util.ArrayList) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) AddVnicProfileParameters(org.ovirt.engine.core.common.action.AddVnicProfileParameters) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel) ActionParametersBase(org.ovirt.engine.core.common.action.ActionParametersBase)

Example 5 with VnicProfileModel

use of org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel in project ovirt-engine by oVirt.

the class VnicProfilesEditor method createGhostValue.

@Override
protected VnicProfileModel createGhostValue() {
    VnicProfileModel profile = new NewVnicProfileModel();
    profile.initNetworkQoSList(dcId);
    return profile;
}
Also used : NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) NewVnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel) VnicProfileModel(org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel)

Aggregations

NewVnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel)5 VnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel)5 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 AddVnicProfileParameters (org.ovirt.engine.core.common.action.AddVnicProfileParameters)2 HostNetworkQos (org.ovirt.engine.core.common.businessentities.network.HostNetworkQos)2 VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)2 AsciiNameValidation (org.ovirt.engine.ui.uicommonweb.validation.AsciiNameValidation)2 IntegerValidation (org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation)2 LengthValidation (org.ovirt.engine.ui.uicommonweb.validation.LengthValidation)2 NotEmptyValidation (org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation)2 RegexValidation (org.ovirt.engine.ui.uicommonweb.validation.RegexValidation)2 SpecialAsciiI18NOrNoneValidation (org.ovirt.engine.ui.uicommonweb.validation.SpecialAsciiI18NOrNoneValidation)2 Arrays (java.util.Arrays)1 Collectors (java.util.stream.Collectors)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 BusinessEntitiesDefinitions (org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions)1 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)1