use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class MapVnicFlowTestUtils method profileOf.
static VnicProfile profileOf(String profileName, Guid networkId) {
VnicProfile vp = new VnicProfile();
vp.setName(profileName);
vp.setNetworkId(networkId);
return vp;
}
use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class MapVnicFlowTestUtils method profileOf.
static VnicProfile profileOf(Guid profileId, String profileName, Guid networkId) {
VnicProfile vp = profileOf(profileName, networkId);
vp.setId(profileId);
return vp;
}
use of org.ovirt.engine.core.common.businessentities.network.VnicProfile 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.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class BackwardCompatibilityVnicHelper method updateNicForBackwardCompatibility.
/**
* Since the network name and port mirroring attributed were replaced on the {@link VmNic} with the vnic profile id,
* a certain logic should be applied to translate a given usage of the former api to the expected one.
*
* @param nic
* the candidate nic to apply the logic for
* @param oldNic
* the existing nic
* @param networkName
* the network name to be configured for the nic
* @param portMirroring
* indicator if port mirroring should be configured for the network
* @param vm
* the vm which contains the nic
* @param user
* the user which execute the action
*/
public ValidationResult updateNicForBackwardCompatibility(VmNic nic, VmNic oldNic, String networkName, boolean portMirroring, VmBase vm, DbUser user) {
// if network wasn't provided, no need for backward compatibility logic
if (networkName == null) {
return ValidationResult.VALID;
}
// if the network was provided but unchanged, use the provided vnic profile id
if (oldNic != null && oldNic.getVnicProfileId() != null) {
VnicProfile oldProfile = vnicProfileDao.get(oldNic.getVnicProfileId());
Network oldNetwork = networkDao.get(oldProfile.getNetworkId());
if (StringUtils.equals(networkName, oldNetwork.getName())) {
return ValidationResult.VALID;
}
}
// empty network name is considered as an empty (unlinked) network
if ("".equals(networkName)) {
if (portMirroring) {
return new ValidationResult(EngineMessage.PORT_MIRRORING_REQUIRES_NETWORK);
} else {
nic.setVnicProfileId(null);
return ValidationResult.VALID;
}
}
if (vm.getClusterId() == null) {
return networkOfGivenNameNotExistsInCluster(networkName);
}
// if the network was provided with changed name, resolve a suitable profile for it
Network network = networkDao.getByNameAndCluster(networkName, vm.getClusterId());
if (network == null) {
return networkOfGivenNameNotExistsInCluster(networkName);
}
List<VnicProfile> vnicProfiles = vnicProfileDao.getAllForNetwork(network.getId());
for (VnicProfile profile : vnicProfiles) {
if (isVnicProfilePermitted(user, profile, portMirroring)) {
nic.setVnicProfileId(profile.getId());
return ValidationResult.VALID;
}
}
return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_CANNOT_FIND_VNIC_PROFILE_FOR_NETWORK);
}
use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class NetworkHelper method createVnicProfile.
public VnicProfile createVnicProfile(Network net) {
VnicProfile profile = new VnicProfile();
profile.setId(Guid.newGuid());
profile.setName(net.getName());
profile.setNetworkId(net.getId());
profile.setPortMirroring(false);
if (!net.isExternal()) {
NetworkFilter defaultNetworkFilter = resolveVnicProfileDefaultNetworkFilter();
profile.setNetworkFilterId(defaultNetworkFilter == null ? null : defaultNetworkFilter.getId());
}
return profile;
}
Aggregations