@Override protected MapSqlParameterSource createFullParametersMapper(VnicProfile profile) { return createIdParameterMapper(profile.getId()) .addValue("name", profile.getName()) .addValue("network_id", profile.getNetworkId()) .addValue("network_qos_id", profile.getNetworkQosId()) .addValue("port_mirroring", profile.isPortMirroring()) .addValue("passthrough", profile.isPassthrough()) .addValue("migratable", profile.isMigratable()) .addValue("description", profile.getDescription()) .addValue("custom_properties", SerializationFactory.getSerializer().serialize(profile.getCustomProperties())) .addValue("network_filter_id", profile.getNetworkFilterId()); }
@Override protected VnicProfile generateNewEntity() { VnicProfile vnicProfile = new VnicProfile(); vnicProfile.setId(Guid.newGuid()); vnicProfile.setName("new_profile"); vnicProfile.setNetworkId(FixturesTool.NETWORK_ENGINE); vnicProfile.setNetworkQosId(FixturesTool.NETWORK_QOS); vnicProfile.setPortMirroring(false); vnicProfile.setPassthrough(false); vnicProfile.setNetworkFilterId(FixturesTool.VNIC_PROFILE_NETWORK_FILTER); vnicProfile.setMigratable(true); vnicProfile.setCustomProperties(Collections.emptyMap()); return vnicProfile; }
static org.ovirt.engine.core.common.businessentities.network.VnicProfile setUpEntityExpectations(org.ovirt.engine.core.common.businessentities.network.VnicProfile entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getDescription()).thenReturn(DESCRIPTIONS[index]); when(entity.getNetworkId()).thenReturn(GUIDS[index]); return entity; } }
public EditVnicProfileModel(SearchableListModel<?, ?> sourceModel, VnicProfile profile, Guid dcId, boolean customPropertiesVisible) { super(sourceModel, customPropertiesVisible, dcId, profile.getNetworkQosId()); setTitle(constants.vnicProfileTitle()); setHelpTag(HelpTag.edit_vnic_profile); setHashName("edit_vnic_profile"); //$NON-NLS-1$ setProfile(profile); getName().setEntity(profile.getName()); getDescription().setEntity(profile.getDescription()); getPassthrough().setEntity(getProfile().isPassthrough()); getMigratable().setEntity(!getProfile().isPassthrough() || getProfile().isMigratable()); getPortMirroring().setEntity(getProfile().isPortMirroring()); getPublicUse().setIsAvailable(false); updateChangabilityIfVmsUsingTheProfile(); }
/** * Ensures that the network interface profile is returned. */ @Test public void testGetWithPassthrough() { VnicProfile result = dao .get(FixturesTool.VM_NETWORK_INTERFACE_PASSTHROUGH_PROFILE); assertNotNull(result); assertEquals(FixturesTool.VM_NETWORK_INTERFACE_PASSTHROUGH_PROFILE, result.getId()); assertTrue(result.isPassthrough()); assertFalse(result.isMigratable()); }
/** * Ensures that the network interface profile is returned. */ @Test public void testGetWithPm() { VnicProfile result = dao.get(FixturesTool.VM_NETWORK_INTERFACE_PM_PROFILE); assertNotNull(result); assertEquals(FixturesTool.VM_NETWORK_INTERFACE_PM_PROFILE, result.getId()); assertTrue(result.isPortMirroring()); }
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, !getNetwork().isExternal()); parameters.setPublicUse(profileModel.getPublicUse().getEntity()); paramlist.add(parameters); } } Frontend.getInstance().runMultipleActions(ActionType.AddVnicProfile, paramlist, (IFrontendActionAsyncCallback) null); // cast is required to avoid overload ambiguity }
public void newProfile() { if (getWindow() != null) { return; } NewVnicProfileModel model = new NewVnicProfileModel(this, getEntity().getDataCenterId()); setWindow(model); VnicProfile profile = new VnicProfile(); profile.setNetworkId(getEntity().getId()); model.setProfile(profile); }
@Override public Object getQueryableId() { return getId(); }
protected void updateNetworks(Collection<Network> networks) { VnicProfile profile = getProfile(); if (profile != null && profile.getNetworkId() != null) { Network selected = networks.stream() .filter(net -> Objects.equals(profile.getNetworkId(), net.getId())) .findFirst().get(); getNetwork().setSelectedItem(selected); getNetwork().setIsChangeable(false); } }
@Override protected VnicProfile createVnicProfileEntity() { return new VnicProfile(); } }
protected VnicProfiles mapCollection(List<org.ovirt.engine.core.common.businessentities.network.VnicProfile> entities, Class<? extends BaseResource> suggestedParentType) { VnicProfiles collection = new VnicProfiles(); Map<Guid, Qos> qosMap = new HashMap<>(); for (org.ovirt.engine.core.common.businessentities.network.VnicProfile entity : entities) { VnicProfile profile = populate(map(entity), entity); collection.getVnicProfiles().add(profile); if (entity.getNetworkQosId() != null) { qosMap.put(entity.getNetworkQosId(), profile.getQos()); } } handleQosDataCenterLinks(qosMap); for (VnicProfile vnicProfile : collection.getVnicProfiles()) { addLinks(vnicProfile, suggestedParentType); } return collection; }
@Test public void testGetEntityNameByIdAndTypeForVNICProfile() { VnicProfile vnicProfile = vnicProfileDao.get(FixturesTool.VM_NETWORK_INTERFACE_PROFILE); assertNotNull(vnicProfile); String name = vnicProfile.getName(); assertEquals(name, dao.getEntityNameByIdAndType(FixturesTool.VM_NETWORK_INTERFACE_PROFILE, VdcObjectType.VnicProfile)); }
@Override protected void initCustomProperties() { getCustomPropertySheet().deserialize(KeyValueModel .convertProperties(getProfile().getCustomProperties())); }
static org.ovirt.engine.core.common.businessentities.network.VnicProfile setUpEntityExpectations(org.ovirt.engine.core.common.businessentities.network.VnicProfile entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getDescription()).thenReturn(DESCRIPTIONS[index]); when(entity.getNetworkId()).thenReturn(GUIDS[index]); return entity; } }
private void updateChangabilityIfVmsUsingTheProfile() { IdQueryParameters params = new IdQueryParameters(getProfile().getId()); startProgress(); Frontend.getInstance().runQuery(QueryType.GetVmsByVnicProfileId, params, new AsyncQuery<QueryReturnValue>(returnValue -> { Collection<VM> vms = returnValue.getReturnValue(); if (vms != null && !vms.isEmpty()) { getPortMirroring().setIsChangeable(false); getPortMirroring().setChangeProhibitionReason(constants.portMirroringNotChangedIfUsedByVms()); getPassthrough().setIsChangeable(false); getPassthrough().setChangeProhibitionReason(constants.passthroughNotChangedIfUsedByVms()); } stopProgress(); })); }
@Override public String toString() { return ToStringBuilder.forInstance(this) .append("id", getId()) .append("networkId", getNetworkId()) .append("networkQosId", getNetworkQosId()) .append("portMirroring", isPortMirroring()) .append("passthrough", isPassthrough()) .append("migratable", isMigratable()) .append("customProperties", getCustomProperties()) .append("description", getDescription()) .append("networkFilterId", getNetworkFilterId()) .build(); } }
public void flush() { if (vnicProfile == null) { vnicProfile = new VnicProfile(); } vnicProfile.setName(getName().getEntity()); Network network = getNetwork().getSelectedItem(); vnicProfile.setNetworkId(network != null ? network.getId() : null); NetworkQoS networkQoS = getNetworkQoS().getSelectedItem(); vnicProfile.setNetworkQosId(networkQoS != null && networkQoS.getId() != null && !networkQoS.getId().equals(Guid.Empty) ? networkQoS.getId() : null); NetworkFilter networkFilter = getNetworkFilter().getSelectedItem(); vnicProfile.setNetworkFilterId(networkFilter != null ? networkFilter.getId() : null); vnicProfile.setPortMirroring(getPortMirroring().getEntity()); vnicProfile.setPassthrough(getPassthrough().getEntity()); if (vnicProfile.isPassthrough()) { vnicProfile.setMigratable(getMigratable().getEntity()); } if (customPropertiesVisible) { vnicProfile.setCustomProperties(KeyValueModel.convertProperties(getCustomPropertySheet().serialize())); } else { vnicProfile.setCustomProperties(null); } vnicProfile.setDescription(getDescription().getEntity()); }
static org.ovirt.engine.core.common.businessentities.network.VnicProfile setUpEntityExpectations(org.ovirt.engine.core.common.businessentities.network.VnicProfile entity, int index) { when(entity.getId()).thenReturn(GUIDS[index]); when(entity.getName()).thenReturn(NAMES[index]); when(entity.getDescription()).thenReturn(DESCRIPTIONS[index]); when(entity.getNetworkId()).thenReturn(GUIDS[index]); return entity; } }
VnicProfile template) { VnicProfile model = template != null ? template : new VnicProfile(); if (entity.getId() != null) { model.setId(entity.getId().toString()); if (entity.getName() != null) { model.setName(entity.getName()); if (entity.getDescription() != null) { model.setDescription(entity.getDescription()); if (entity.getNetworkId() != null) { model.setNetwork(new Network()); model.getNetwork().setId(entity.getNetworkId().toString()); model.setPortMirroring(entity.isPortMirroring()); if (entity.getCustomProperties() != null && !entity.getCustomProperties().isEmpty()) { CustomProperties hooks = new CustomProperties(); hooks.getCustomProperties().addAll(CustomPropertiesParser.parse( DevicePropertiesUtils.getInstance().convertProperties(entity.getCustomProperties()), false)); model.setCustomProperties(hooks); if (entity.getNetworkQosId() != null) { model.setQos(new Qos()); model.getQos().setId(entity.getNetworkQosId().toString()); vnicPassThrough.setMode(map(entity.isPassthrough())); model.setPassThrough(vnicPassThrough); if (entity.getNetworkFilterId() != null){