public BackendIscsiBondNetworksResource(String iscsiBondId) { super(QueryType.GetNetworksByIscsiBondId); this.iscsiBondId = Guid.createGuidFromString(iscsiBondId); }
public BackendIscsiBondStorageConnectionsResource(String iscsiBondId) { super(); this.iscsiBondId = Guid.createGuidFromString(iscsiBondId); }
private static LinkedList<Guid> convertToGuidList(String str, char delimiter) { LinkedList<Guid> results = new LinkedList<>(); if (str != null) { for (String id : str.split(String.format(" *%s *", delimiter))) { results.add(Guid.createGuidFromString(id)); } } return results; }
private static Guid getEntityId(String fileName) { return Guid.createGuidFromString(fileName.substring(0, fileName.length() - OVF_FILE_EXT.length())); }
private void readDedicatedHostsList(XmlNode content) { vmBase.setDedicatedVmForVdsList(new LinkedList<>()); // initialize to empty list for (XmlNode hostNode : selectNodes(content, DEDICATED_VM_FOR_VDS)) { if (hostNode != null && StringUtils.isNotEmpty(hostNode.innerText)) { vmBase.getDedicatedVmForVdsList().add(Guid.createGuidFromString(hostNode.innerText)); } } }
/** * Finds the provider that corresponds to the given identifier. * * @param resource the resource that will be used to perform the required queries * @param id the identifier of the provider * @return the reference to the provider or {@code null} if no such provider exists */ public static Provider getProvider(BackendResource resource, String id) { Guid guid = Guid.createGuidFromString(id); IdQueryParameters parameters = new IdQueryParameters(guid); return resource.getEntity(Provider.class, QueryType.GetProviderById, parameters, id, true); }
public static Guid fetchLeaseDomainId(String ovfData) { Guid leaseDomainId = null; try { XmlDocument xmlDocument = new XmlDocument(ovfData); XmlNode xmlNode = xmlDocument.selectSingleNode("//*/Content").selectSingleNode("LeaseDomainId"); if (xmlNode != null) { leaseDomainId = Guid.createGuidFromString(xmlNode.innerText); } } catch (Exception e) { log.debug("failed to parse a given ovf configuration: \n" + ovfData, e); } return leaseDomainId; }
public Set<Guid> fetchVmDisks(XmlDocument xmlDocument) { Set<Guid> disksIds = new HashSet<>(); XmlNode references = xmlDocument.selectSingleNode("//*/References"); // we assume that all files in OVFs that are generated by oVirt are disks for (XmlNode file : references.selectNodes("File")) { disksIds.add(Guid.createGuidFromString(file.attributes.get("ovf:href").getValue().substring(0, GUID_LENGTH))); } disksIds.addAll(fetchMemoryDisks(xmlDocument)); return disksIds; }
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; } }
private void setRngDevice(Template model) { List<VmRngDevice> rngDevices = getEntity(List.class, QueryType.GetRngDevice, new IdQueryParameters(Guid.createGuidFromString(model.getId())), "GetRngDevice", true); if (rngDevices != null && !rngDevices.isEmpty()) { model.setRngDevice(RngDeviceMapper.map(rngDevices.get(0), null)); } }
public static void setRngDevice(BackendResource resouce, Vm vm) { List<VmRngDevice> rngDevices = resouce.getEntity(List.class, QueryType.GetRngDevice, new IdQueryParameters(Guid.createGuidFromString(vm.getId())), "GetRngDevice", true); if (rngDevices != null && !rngDevices.isEmpty()) { vm.setRngDevice(RngDeviceMapper.map(rngDevices.get(0), null)); } } }
protected void setRngDevice(VmPool model) { List<VmRngDevice> rngDevices = getEntity(List.class, QueryType.GetRngDevice, new IdQueryParameters(Guid.createGuidFromString(model.getId())), "GetRngDevice", true); if (rngDevices != null && !rngDevices.isEmpty()) { model.setRngDevice(RngDeviceMapper.map(rngDevices.get(0), null)); } }
private void setRngDevice(InstanceType model) { List<VmRngDevice> rngDevices = getEntity(List.class, QueryType.GetRngDevice, new IdQueryParameters(Guid.createGuidFromString(model.getId())), "GetRngDevice", true); if (rngDevices != null && !rngDevices.isEmpty()) { model.setRngDevice(RngDeviceMapper.map(rngDevices.get(0), null)); } }
@Override public DiskAttachment get() { return performGet(QueryType.GetDiskVmElementById, new VmDeviceIdQueryParameters(new VmDeviceId(Guid.createGuidFromString(diskId), templateId)), Template.class); }
@Mapping(from = org.ovirt.engine.api.model.ClusterFeature.class, to = AdditionalFeature.class) public static AdditionalFeature map(org.ovirt.engine.api.model.ClusterFeature model, AdditionalFeature template) { AdditionalFeature entity = template != null ? template : new AdditionalFeature(); entity.setName(model.getName()); entity.setId(Guid.createGuidFromString(model.getId())); return entity; }
@Override public DiskAttachment get() { DiskAttachment diskAttachment = performGet(QueryType.GetDiskVmElementById, new VmDeviceIdQueryParameters(new VmDeviceId(Guid.createGuidFromString(diskId), vmId)), Vm.class); /* * Href of the diskattachment must be set manually due to a bug (https://bugzilla.redhat.com/1647018). * The bug is the result of an exceptional case where the same entity (disk-attachment) * has the same parent (vm) in 2 different locations in the API, causing ambiguity * in the link generation process. */ diskAttachment.setHref("/ovirt-engine/api/vms/" + vmId.toString() + "/diskattachments/" + diskAttachment.getId()); return diskAttachment; }
@Test public void testGetAllConnectionsOfNfsDomain() { List<StorageServerConnections> connections = dao.getAllForDomain(Guid.createGuidFromString("d9ede37f-e6c3-4bf9-a984-19174070aa31")); assertEquals(1, connections.size()); assertEquals("0cc146e8-e5ed-482c-8814-270bc48c2981", connections.get(0).getId()); }
private void flush() { LibvirtSecret secret = isNew() ? new LibvirtSecret() : getEntity(); secret.setUsageType(getUsageType().getSelectedItem()); secret.setDescription(getDescription().getEntity()); secret.setProviderId(Guid.createGuidFromString(getProviderId().getEntity())); secret.setId(Guid.createGuidFromString(uuid.getEntity())); if (StringHelper.isNotNullOrEmpty(getValue().getEntity())) { secret.setValue(getValue().getEntity()); } setEntity(secret); }
private Response performCreate(ImageTransfer imageTransfer, TransferDiskImageParameters params) { updateTransferType(imageTransfer, params); if (imageTransfer.isSetHost() && imageTransfer.getHost().isSetId()) { params.setVdsId(Guid.createGuidFromString(imageTransfer.getHost().getId())); } if (imageTransfer.isSetInactivityTimeout()) { params.setClientInactivityTimeout(imageTransfer.getInactivityTimeout()); } return performCreate(ActionType.TransferDiskImage, params, new QueryIdResolver<Guid>(QueryType.GetImageTransferById, IdQueryParameters.class)); }
@Test public void testUpdateHostPinningPolicy() { final VmStatic vmTemplate = new VmStatic(); vmTemplate.setDedicatedVmForVdsList(Guid.newGuid()); final Vm vm = new Vm(); vm.setPlacementPolicy(createPlacementPolicy(Guid.newGuid(), Guid.newGuid())); final VmStatic mappedVm = VmMapper.map(vm, vmTemplate); final List<Guid> hosts = new ArrayList<>(); for (Host host : vm.getPlacementPolicy().getHosts().getHosts()){ hosts.add(Guid.createGuidFromString(host.getId())); } assertEquals(new HashSet(hosts), new HashSet(mappedVm.getDedicatedVmForVdsList())); }