private static Guid getTargetVnicProfileId(VnicProfileMapping model) { return model.isSetTargetVnicProfile() ? Guid.createGuidFromString(model.getTargetVnicProfile().getId()) //this will set the target vnic profile to <empty> (no profile) : null; } }
@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()); } } } }
VnicProfileResource profileService = profilesService.getProfileResource(v4Profile.getId()); v4Profile = profileService.get();
/** * <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; }
@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())); } }
@Override protected void verify(Nic model, Nic transform) { assertNotNull(transform); assertEquals(model.getName(), transform.getName()); assertEquals(model.getId(), transform.getId()); assertNotNull(transform.getVm()); assertEquals(model.getVm().getId(), transform.getVm().getId()); assertNotNull(transform.getMac()); assertThat(model.getMac().getAddress(), IsEqualIgnoringCase.equalToIgnoringCase(transform.getMac().getAddress())); assertEquals(model.getInterface(), transform.getInterface()); assertEquals(model.isLinked(), transform.isLinked()); assertEquals(model.isPlugged(), transform.isPlugged()); assertNotNull(transform.getVnicProfile()); assertEquals(model.getVnicProfile().getId(), transform.getVnicProfile().getId()); } }
to.setId(from.getId());
entity.setVnicProfileId(GuidUtils.asGuid(model.getVnicProfile().getId())); } else { entity.setVnicProfileId(null);
template != null ? template : new org.ovirt.engine.core.common.businessentities.network.VnicProfile(); if (model.isSetId()) { entity.setId(GuidUtils.asGuid(model.getId()));