Hello Shmuel Melamud,
I'd like you to do a code review. Please visit
https://gerrit.ovirt.org/40829
to review the following change.
Change subject: core: Save VM custom properties in OVF
......................................................................
core: Save VM custom properties in OVF
Added new tags and code to save/restore VM custom properties in OVF.
This makes possible editing VM custom properties when VM is running.
Change-Id: I985e2b5153f1531f98d167c97ff69c70cb9c4196
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1218973
Signed-off-by: Shmuel Melamud <[email protected]>
---
M
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfProperties.java
M
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
M
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
3 files changed, 28 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/40829/1
diff --git
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfProperties.java
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfProperties.java
index 24e2b87..5346ea3 100644
---
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfProperties.java
+++
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfProperties.java
@@ -76,4 +76,6 @@
final static String MIGRATION_SUPPORT = "MigrationSupport";
final static String DEDICATED_VM_FOR_VDS = "DedicatedVmForVds";
final static String USE_HOST_CPU = "UseHostCpu";
+ final static String PREDEFINED_PROPERTIES = "PredefinedProperties";
+ final static String USER_DEFINED_PROPERTIES = "UserDefinedProperties";
}
diff --git
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
index 790eb4d..48d1832 100644
---
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
+++
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfReader.java
@@ -37,6 +37,7 @@
import org.ovirt.engine.core.common.utils.SimpleDependecyInjector;
import org.ovirt.engine.core.common.utils.VmDeviceCommonUtils;
import org.ovirt.engine.core.common.utils.VmDeviceType;
+import org.ovirt.engine.core.common.utils.customprop.VmPropertiesUtils;
import org.ovirt.engine.core.compat.Guid;
import org.ovirt.engine.core.compat.Version;
import org.ovirt.engine.core.utils.VmInitUtils;
@@ -728,6 +729,23 @@
}
}
+ node = content.SelectSingleNode(OvfProperties.PREDEFINED_PROPERTIES);
+ if (node != null) {
+ if (StringUtils.isNotEmpty(node.innerText)) {
+ vmBase.setPredefinedProperties(node.innerText);
+ }
+ }
+
+ node = content.SelectSingleNode(OvfProperties.USER_DEFINED_PROPERTIES);
+ if (node != null) {
+ if (StringUtils.isNotEmpty(node.innerText)) {
+ vmBase.setUserDefinedProperties(node.innerText);
+ }
+ }
+
+
vmBase.setCustomProperties(VmPropertiesUtils.getInstance().customProperties(
+ vmBase.getPredefinedProperties(),
vmBase.getUserDefinedProperties()));
+
readGeneralData(content);
readVmInit(content);
diff --git
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
index 3760f8a..a24f87d 100644
---
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
+++
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/ovf/OvfWriter.java
@@ -408,6 +408,14 @@
_writer.WriteStartElement(OvfProperties.CUSTOM_CPU_NAME);
_writer.WriteRaw(vmBase.getCustomCpuName());
_writer.WriteEndElement();
+
+ _writer.WriteStartElement(OvfProperties.PREDEFINED_PROPERTIES);
+ _writer.WriteRaw(vmBase.getPredefinedProperties());
+ _writer.WriteEndElement();
+
+ _writer.WriteStartElement(OvfProperties.USER_DEFINED_PROPERTIES);
+ _writer.WriteRaw(vmBase.getUserDefinedProperties());
+ _writer.WriteEndElement();
}
protected abstract void writeAppList();
--
To view, visit https://gerrit.ovirt.org/40829
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I985e2b5153f1531f98d167c97ff69c70cb9c4196
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Shmuel Leib Melamud <[email protected]>
Gerrit-Reviewer: Shmuel Melamud <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches