use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfVmReader method readSnapshotsSection.
@Override
protected void readSnapshotsSection(XmlNode section) {
XmlNodeList list = selectNodes(section, "Snapshot");
List<Snapshot> snapshots = new ArrayList<>();
_vm.setSnapshots(snapshots);
for (XmlNode node : list) {
XmlNode vmConfiguration = selectSingleNode(node, "VmConfiguration", _xmlNS);
Snapshot snapshot = new Snapshot(vmConfiguration != null);
snapshot.setId(new Guid(node.attributes.get("ovf:id").getValue()));
snapshot.setVmId(_vm.getId());
snapshot.setType(SnapshotType.valueOf(selectSingleNode(node, "Type", _xmlNS).innerText));
snapshot.setStatus(SnapshotStatus.OK);
snapshot.setDescription(selectSingleNode(node, "Description", _xmlNS).innerText);
XmlNode memory = selectSingleNode(node, "Memory", _xmlNS);
if (memory != null) {
List<Guid> guids = Guid.createGuidListFromString(memory.innerText);
snapshot.setMemoryDiskId(guids.get(2));
snapshot.setMetadataDiskId(guids.get(4));
}
final Date creationDate = OvfParser.utcDateStringToLocalDate(selectSingleNode(node, "CreationDate", _xmlNS).innerText);
if (creationDate != null) {
snapshot.setCreationDate(creationDate);
}
snapshot.setVmConfiguration(vmConfiguration == null ? null : new String(Base64.decodeBase64(vmConfiguration.innerText)));
XmlNode appList = selectSingleNode(node, "ApplicationList", _xmlNS);
if (appList != null) {
snapshot.setAppList(appList.innerText);
}
snapshots.add(snapshot);
}
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfUtils method fetchMemoryDisks.
public Set<Guid> fetchMemoryDisks(XmlDocument xmlDocument) {
Set<Guid> memoryDiskIds = new HashSet<>();
xmlDocument.selectNodes("ovf:SnapshotsSection_Type");
XmlNode content = xmlDocument.selectSingleNode("//*/Content");
XmlNodeList nodeList = content.selectNodes("Section");
if (nodeList != null) {
for (XmlNode section : nodeList) {
String value = section.attributes.get("xsi:type").getValue();
if (value.equals("ovf:SnapshotsSection_Type")) {
Iterator<XmlNode> snapshotIter = section.selectNodes("Snapshot").iterator();
while (snapshotIter.hasNext()) {
XmlNode memorySnapshot = snapshotIter.next().selectSingleNode("Memory");
if (memorySnapshot != null) {
List<Guid> guids = Guid.createGuidListFromString(memorySnapshot.innerText);
memoryDiskIds.add(guids.get(2));
memoryDiskIds.add(guids.get(4));
}
}
}
}
}
return memoryDiskIds;
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfUtils method getOsSection.
private ArchitectureType getOsSection(XmlDocument xmlDocument) {
ArchitectureType archType = null;
XmlNode content = xmlDocument.selectSingleNode("//*/Content");
XmlNodeList nodeList = content.selectNodes("Section");
XmlNode selectedSection = null;
if (nodeList != null) {
for (XmlNode section : nodeList) {
String value = section.attributes.get("xsi:type").getValue();
if (value.equals("ovf:OperatingSystemSection_Type")) {
selectedSection = section;
break;
}
}
if (selectedSection != null) {
int osId = osRepository.getOsIdByUniqueName(selectedSection.innerText);
archType = osRepository.getArchitectureFromOS(osId);
}
}
return archType;
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfOvaReader method buildDisk.
@Override
public void buildDisk() {
XmlNode diskSection = selectSingleNode(_document, "//*/DiskSection");
XmlNodeList list = diskSection.selectNodes("Disk");
for (XmlNode node : list) {
readDisk(node, null);
}
}
use of org.ovirt.engine.core.utils.ovf.xml.XmlNodeList in project ovirt-engine by oVirt.
the class OvfOvirtReader method readUserDomainsSection.
protected void readUserDomainsSection(@SuppressWarnings("unused") XmlNode section) {
XmlNodeList list = selectNodes(section, OvfProperties.USER);
Set<DbUser> dbUsers = new HashSet<>();
Map<String, Set<String>> userToRoles = new HashMap<>();
for (XmlNode node : list) {
String userDomain = selectSingleNode(node, OvfProperties.USER_DOMAIN, _xmlNS).innerText;
DbUser dbUser = new DbUser();
dbUser.setLoginName(userDomain.split("@")[0]);
dbUser.setDomain(userDomain.split("@")[1]);
dbUsers.add(dbUser);
XmlNode rolesElement = selectSingleNode(node, OvfProperties.USER_ROLES);
XmlNodeList roleNodes = selectNodes(rolesElement, OvfProperties.ROLE_NAME);
Set<String> roleNames = new HashSet<>();
for (XmlNode roleNode : roleNodes) {
String roleName = roleNode.innerText;
roleNames.add(roleName);
}
userToRoles.put(dbUser.getLoginName(), roleNames);
}
fullEntityOvfData.setDbUsers(dbUsers);
fullEntityOvfData.setUserToRoles(userToRoles);
}
Aggregations