@Override public V3VnicProfile adapt(VnicProfile from) { V3VnicProfile to = new V3VnicProfile(); if (from.isSetLinks()) { to.getLinks().addAll(adaptOut(from.getLinks())); if (from.isSetActions()) { to.setActions(adaptOut(from.getActions())); if (from.isSetComment()) { to.setComment(from.getComment()); if (from.isSetCustomProperties()) { to.setCustomProperties(new V3CustomProperties()); to.getCustomProperties().getCustomProperty().addAll(adaptOut(from.getCustomProperties().getCustomProperties())); if (from.isSetDescription()) { to.setDescription(from.getDescription()); if (from.isSetId()) { to.setId(from.getId()); if (from.isSetHref()) { to.setHref(from.getHref()); if (from.isSetName()) { to.setName(from.getName()); if (from.isSetNetwork()) { to.setNetwork(adaptOut(from.getNetwork()));
static VnicProfile getModel(int index) { VnicProfile model = new VnicProfile(); model.setId(GUIDS[index].toString()); model.setName(NAMES[index]); model.setDescription(DESCRIPTIONS[index]); return model; }
@Override public Response add(VnicProfile vnicProfile) { if (!vnicProfile.isSetNetwork() || !vnicProfile.getNetwork().isSetId()) { vnicProfile.setNetwork(new Network()); vnicProfile.getNetwork().setId(networkId); } return super.add(vnicProfile); }
@Override public VnicProfile addParents(VnicProfile vnicProfile) { vnicProfile.setNetwork(new Network()); vnicProfile.getNetwork().setId(networkId); return vnicProfile; }
org.ovirt.engine.core.common.businessentities.network.VnicProfile entity = template != null ? template : new org.ovirt.engine.core.common.businessentities.network.VnicProfile(); if (model.isSetId()) { entity.setId(GuidUtils.asGuid(model.getId())); if (model.isSetName()) { entity.setName(model.getName()); if (model.isSetDescription()) { entity.setDescription(model.getDescription()); if (model.isSetNetwork() && model.getNetwork().isSetId()) { entity.setNetworkId(GuidUtils.asGuid(model.getNetwork().getId())); if (model.isSetPortMirroring()) { entity.setPortMirroring(model.isPortMirroring()); if (model.isSetCustomProperties()) { entity.setCustomProperties(DevicePropertiesUtils.getInstance() .convertProperties(CustomPropertiesParser.parse(model.getCustomProperties().getCustomProperties()))); if (model.isSetQos() && model.getQos().isSetId()) { entity.setNetworkQosId(GuidUtils.asGuid(model.getQos().getId())); if (model.isSetPassThrough() && model.getPassThrough().isSetMode()) { entity.setPassthrough(map(model.getPassThrough().getMode())); if (entity.isPassthrough() && model.isSetMigratable()) { entity.setMigratable(model.isMigratable());
@Mapping(from = org.ovirt.engine.core.common.businessentities.network.VnicProfile.class, to = VnicProfile.class) public static VnicProfile map(org.ovirt.engine.core.common.businessentities.network.VnicProfile entity, VnicProfile template) { VnicProfile model = template != null ? template : new VnicProfile(); if (entity.getId() != null) { model.setId(entity.getId().toString()); model.setName(entity.getName()); model.setDescription(entity.getDescription()); 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); model.setQos(new Qos()); model.getQos().setId(entity.getNetworkQosId().toString()); model.setPassThrough(vnicPassThrough); if (entity.getNetworkFilterId() != null){ model.setNetworkFilter(new NetworkFilter()); model.getNetworkFilter().setId(entity.getNetworkFilterId().toString()); model.setMigratable(entity.isMigratable());
@Override public VnicProfile adapt(V3VnicProfile from) { VnicProfile to = new VnicProfile(); if (from.isSetLinks()) { to.getLinks().addAll(adaptIn(from.getLinks())); to.setActions(adaptIn(from.getActions())); to.setComment(from.getComment()); to.setCustomProperties(new CustomProperties()); to.getCustomProperties().getCustomProperties().addAll(adaptIn(from.getCustomProperties().getCustomProperty())); to.setDescription(from.getDescription()); to.setId(from.getId()); to.setHref(from.getHref()); to.setName(from.getName()); to.setNetwork(adaptIn(from.getNetwork())); to.setPassThrough(adaptIn(from.getPassThrough())); to.setPortMirroring(from.isPortMirroring()); to.setQos(adaptIn(from.getQos()));
@Override protected void verify(VnicProfile model, VnicProfile transform) { assertNotNull(transform); assertEquals(model.getId(), transform.getId()); assertEquals(model.getName(), transform.getName()); assertEquals(model.getDescription(), transform.getDescription()); assertNotNull(transform.getNetwork()); assertEquals(model.getNetwork().getId(), transform.getNetwork().getId()); assertEquals(model.isPortMirroring(), transform.isPortMirroring()); assertNotNull(transform.getCustomProperties()); assertEquals(CustomPropertiesParser.parse(model.getCustomProperties().getCustomProperties()), CustomPropertiesParser.parse(transform.getCustomProperties().getCustomProperties())); } }
VnicProfileResource profileService = profilesService.getProfileResource(v4Profile.getId()); v4Profile = profileService.get(); Network v4Network = v4Profile.getNetwork(); V3Network v3Network = new V3Network(); v3Network.setId(v4Network.getId()); v4Network.setHref(v4Network.getHref()); v3Nic.setNetwork(v3Network); if (v4Profile.isSetPortMirroring() && v4Profile.isPortMirroring()) { V3PortMirroring v3PortMirroring = new V3PortMirroring(); V3Networks v3PortMirroringNetworks = new V3Networks();
/** * <pre> * - Best effort conversion of the input user mapping REST API object into an internal representation. * - If there is no target 'to' then it is considered as 'no mapping specified' for this 'from'. therefore the * user entry is ignored and the bll logic will try to use the sources on the ovf nic as the target. * </pre> * @param regMapping - user input for mapping * @return internal object representing the input user mapping */ private static ExternalVnicProfileMapping createExternalVnicProfileMapping(RegistrationVnicProfileMapping regMapping) { ExternalVnicProfileMapping m = new ExternalVnicProfileMapping( regMapping.getFrom().getNetwork().getName(), regMapping.getFrom().getName()); if(isSetToId(regMapping)) { try { Guid targetId = asGuid(regMapping.getTo().getId()); m.setTargetProfileId(targetId); } catch (Exception e){ //bad id - ignore } } if (isSetToName(regMapping)) { m.setTargetProfileName(regMapping.getTo().getName()); } if (isSetToNetworkName(regMapping)) { m.setTargetNetworkName(regMapping.getTo().getNetwork().getName()); } return m; }
.filter(profile -> validNetworkIds.contains(profile.getNetwork().getId())) .filter(profile -> isProfileCompatible(profile, v3Nic)) .sorted(comparing(VnicProfile::getName)) .findFirst() .ifPresent(id -> { VnicProfile v4Profile = new VnicProfile(); v4Profile.setId(id); v4Nic.setVnicProfile(v4Profile); });
public static void validateAdd(VnicProfile profile) { if (profile == null) { throw new ValidationException("Parameter 'profile' is mandatory but was not provided."); } if (profile.getName()==null) { throw new ValidationException("Parameter 'profile.name' is mandatory but was not provided."); } if (profile.getNetwork()==null || profile.getNetwork().getId()==null) { throw new ValidationException("Parameter 'profile.network.id' is mandatory but was not provided."); } }
private static boolean isSetFrom(RegistrationVnicProfileMapping regMapping) { return regMapping.isSetFrom() && regMapping.getFrom().isSetNetwork() && regMapping.getFrom().getNetwork().isSetName() && regMapping.getFrom().isSetName(); }
NetworkResource networkService = networksService.getNetworkResource(profile.getNetwork().getId()); Network profileNetwork = networkService.get(); if (!profile.isSetPortMirroring() || !profile.isPortMirroring()) { return false;
private static boolean isSetToNetworkName(RegistrationVnicProfileMapping regMapping) { return regMapping.isSetTo() && regMapping.getTo().isSetNetwork() && regMapping.getTo().getNetwork().isSetName(); }
@Mapping(from = VmNetworkInterface.class, to = Nic.class) public static Nic map(VmNetworkInterface entity, Nic template) { Nic model = template != null ? template : new Nic(); if (entity.getVmId() != null) { model.setVm(new Vm()); model.getVm().setId(entity.getVmId().toString()); } if (entity.getId() != null) { model.setId(entity.getId().toString()); } if (entity.getName() != null) { model.setName(entity.getName()); } if (entity.getMacAddress() != null) { model.setMac(new Mac()); model.getMac().setAddress(entity.getMacAddress()); } model.setLinked(entity.isLinked()); model.setInterface(map(entity.getType())); model.setPlugged(entity.isPlugged()); if (entity.getVnicProfileId() != null) { model.setVnicProfile(new VnicProfile()); model.getVnicProfile().setId(entity.getVnicProfileId().toString()); } return model; }
@Deprecated public static void validateVnicMappings(BackendResource br, Action action) { if (action.isSetVnicProfileMappings()) { br.validateParameters(action.getVnicProfileMappings(), "vnicProfileMappings"); for (VnicProfileMapping mapping: action.getVnicProfileMappings().getVnicProfileMappings()) { br.validateParameters(mapping, "sourceNetworkName"); br.validateParameters(mapping, "sourceNetworkProfileName"); // target is optional if (mapping.isSetTargetVnicProfile() && mapping.getTargetVnicProfile().isSetId()) { br.asGuid(mapping.getTargetVnicProfile().getId()); } } } }
@Override protected void validateParameters(VnicProfile vnicProfile) { validateParameters(vnicProfile, "name", "network.id"); String networkId = vnicProfile.getNetwork().getId(); // verify the network.id is well provided getEntity(Network.class, QueryType.GetNetworkById, new IdQueryParameters(asGuid(networkId)), "Network: id=" + networkId); }
/** * Create an instance of {@link VnicProfile } * */ public VnicProfile createVnicProfile() { return new VnicProfile(); }
public static void validateAdd(VnicProfile profile) { if (profile == null) { throw new ValidationException("Parameter 'profile' is mandatory but was not provided."); } if (profile.getName()==null) { throw new ValidationException("Parameter 'profile.name' is mandatory but was not provided."); } }