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;
}
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();
}
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());
}
}
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);
}
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;
}
Aggregations