Martin Betak has uploaded a new change for review.

Change subject: engine: Add created_by field to vm_static
......................................................................

engine: Add created_by field to vm_static

Added created_by field to vm_static
and createdByUserId property to VmBase representing UUID
of the user who created the VM/Template.

This field is set on AddVmCommand and AddVmTemplateCommand.

Change-Id: I465f9c49d05f49d42814cd970c3df1ed763a7fb5
Bug-Url: https://bugzilla.redhat.com/??????
Signed-off-by: Martin Betak <[email protected]>
---
M backend/manager/dbscripts/create_views.sql
A backend/manager/dbscripts/upgrade/03_03_0320_add_created_by_column.sql
M backend/manager/dbscripts/vm_templates_sp.sql
M backend/manager/dbscripts/vms_sp.sql
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
M backend/manager/modules/dal/src/test/resources/fixtures.xml
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
17 files changed, 93 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/35/16035/1

diff --git a/backend/manager/dbscripts/create_views.sql 
b/backend/manager/dbscripts/create_views.sql
index fc02d39..055db9f 100644
--- a/backend/manager/dbscripts/create_views.sql
+++ b/backend/manager/dbscripts/create_views.sql
@@ -379,7 +379,8 @@
        vm_templates.tunnel_migration,
        vm_templates.vnc_keyboard_layout as vnc_keyboard_layout,
        vm_templates.min_allocated_mem as min_allocated_mem,
-       vm_templates.is_run_and_pause as is_run_and_pause
+       vm_templates.is_run_and_pause as is_run_and_pause,
+       vm_templates.created_by as created_by
 FROM       vm_static AS vm_templates  INNER JOIN
 vds_groups ON vm_templates.vds_group_id = vds_groups.vds_group_id
 left outer JOIN
@@ -414,7 +415,7 @@
                          vm_templates.default_boot_sequence, 
vm_templates.default_display_type, vm_templates.priority, 
vm_templates.auto_startup,
                          vm_templates.is_stateless, vm_templates.iso_path, 
vm_templates.origin, vm_templates.initrd_url, vm_templates.kernel_url,
                          vm_templates.kernel_params, 
image_storage_domain_map.storage_domain_id AS storage_id,
-                          quota.quota_name as quota_name, 
vm_templates.is_disabled, vm_templates.min_allocated_mem, 
vm_templates.is_run_and_pause
+                          quota.quota_name as quota_name, 
vm_templates.is_disabled, vm_templates.min_allocated_mem, 
vm_templates.is_run_and_pause, vm_templates.created_by
 FROM                  vm_static AS vm_templates INNER JOIN
                          vds_groups ON vm_templates.vds_group_id = 
vds_groups.vds_group_id LEFT OUTER JOIN
                       storage_pool ON storage_pool.id = 
vds_groups.storage_pool_id INNER JOIN
@@ -434,7 +435,7 @@
                       vm_templates_1.priority, vm_templates_1.auto_startup, 
vm_templates_1.is_stateless, vm_templates_1.iso_path, vm_templates_1.origin,
                       vm_templates_1.initrd_url, vm_templates_1.kernel_url, 
vm_templates_1.kernel_params,
                       image_storage_domain_map.storage_domain_id AS storage_id,
-                      quota.quota_name as quota_name, 
vm_templates_1.is_disabled, vm_templates_1.min_allocated_mem, 
vm_templates_1.is_run_and_pause
+                      quota.quota_name as quota_name, 
vm_templates_1.is_disabled, vm_templates_1.min_allocated_mem, 
vm_templates_1.is_run_and_pause, vm_templates_1.created_by
 FROM                  vm_static AS vm_templates_1 INNER JOIN
                       vds_groups AS vds_groups_1 ON 
vm_templates_1.vds_group_id = vds_groups_1.vds_group_id LEFT OUTER JOIN
                       storage_pool AS storage_pool_1 ON storage_pool_1.id = 
vds_groups_1.storage_pool_id INNER JOIN
@@ -553,7 +554,7 @@
                       vm_statistics.usage_mem_percent as usage_mem_percent, 
vm_statistics.usage_cpu_percent as usage_cpu_percent, vds_static.vds_name as 
run_on_vds_name, vds_groups.cpu_name as vds_group_cpu_name,
                       vm_static.default_display_type as default_display_type, 
vm_static.priority as priority,vm_static.iso_path as iso_path, vm_static.origin 
as origin, vds_groups.compatibility_version as vds_group_compatibility_version,
                       vm_static.initrd_url as initrd_url, vm_static.kernel_url 
as kernel_url, vm_static.kernel_params as kernel_params, 
vm_dynamic.pause_status as pause_status, vm_dynamic.exit_message as 
exit_message, vm_dynamic.exit_status as exit_status,vm_static.migration_support 
as migration_support,vm_static.predefined_properties as 
predefined_properties,vm_static.userdefined_properties as 
userdefined_properties,vm_static.min_allocated_mem as min_allocated_mem,  
vm_dynamic.hash as hash, vm_static.cpu_pinning as cpu_pinning, 
vm_static.db_generation as db_generation, vm_static.host_cpu_flags as 
host_cpu_flags,
-                      vm_static.tunnel_migration as tunnel_migration, 
vm_static.vnc_keyboard_layout as vnc_keyboard_layout, 
vm_static.is_run_and_pause as is_run_and_pause,
+                      vm_static.tunnel_migration as tunnel_migration, 
vm_static.vnc_keyboard_layout as vnc_keyboard_layout, 
vm_static.is_run_and_pause as is_run_and_pause, vm_static.created_by as 
created_by,
                       vm_dynamic.last_watchdog_event as last_watchdog_event, 
vm_dynamic.last_watchdog_action as last_watchdog_action
 FROM         vm_static INNER JOIN
 vm_dynamic ON vm_static.vm_guid = vm_dynamic.vm_guid INNER JOIN
@@ -591,7 +592,7 @@
             vms.vds_group_compatibility_version, vms.initrd_url, 
vms.kernel_url, vms.kernel_params, vms.pause_status,
             vms.exit_status, vms.exit_message, vms.min_allocated_mem, 
storage_domain_static.id AS storage_id,
             vms.quota_id as quota_id, vms.quota_name as quota_name, 
vms.tunnel_migration as tunnel_migration,
-            vms.vnc_keyboard_layout as vnc_keyboard_layout, 
vms.is_run_and_pause as is_run_and_pause
+            vms.vnc_keyboard_layout as vnc_keyboard_layout, 
vms.is_run_and_pause as is_run_and_pause, vms.created_by as created_by
 FROM        vms LEFT OUTER JOIN
             tags_vm_map_view ON vms.vm_guid = tags_vm_map_view.vm_id LEFT 
OUTER JOIN
             vm_device ON vm_device.vm_id = vms.vm_guid LEFT OUTER JOIN
diff --git 
a/backend/manager/dbscripts/upgrade/03_03_0320_add_created_by_column.sql 
b/backend/manager/dbscripts/upgrade/03_03_0320_add_created_by_column.sql
new file mode 100644
index 0000000..fbbce9f
--- /dev/null
+++ b/backend/manager/dbscripts/upgrade/03_03_0320_add_created_by_column.sql
@@ -0,0 +1 @@
+select fn_db_add_column('vm_static', 'created_by', 'UUID default NULL');
diff --git a/backend/manager/dbscripts/vm_templates_sp.sql 
b/backend/manager/dbscripts/vm_templates_sp.sql
index af4a1c2..84b81ca 100644
--- a/backend/manager/dbscripts/vm_templates_sp.sql
+++ b/backend/manager/dbscripts/vm_templates_sp.sql
@@ -46,7 +46,8 @@
  v_tunnel_migration BOOLEAN,
  v_vnc_keyboard_layout VARCHAR(16),
  v_min_allocated_mem INTEGER,
- v_is_run_and_pause BOOLEAN)
+ v_is_run_and_pause BOOLEAN,
+ v_created_by UUID)
 
 RETURNS VOID
    AS $procedure$
@@ -94,7 +95,8 @@
     tunnel_migration,
     vnc_keyboard_layout,
     min_allocated_mem,
-    is_run_and_pause)
+    is_run_and_pause,
+    created_by)
 VALUES(
     -- This field is meaningless for templates for the time being, however we 
want to keep it not null for VMs.
     -- Thus, since templates are top level elements they "point" to the 
'Blank' template.
@@ -139,7 +141,8 @@
     v_tunnel_migration,
     v_vnc_keyboard_layout,
     v_min_allocated_mem,
-    v_is_run_and_pause);
+    v_is_run_and_pause,
+    v_created_by);
 -- perform deletion from vm_ovf_generations to ensure that no record exists 
when performing insert to avoid PK violation.
 DELETE FROM vm_ovf_generations gen WHERE gen.vm_guid = v_vmt_guid;
 INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id)
@@ -192,7 +195,8 @@
  v_tunnel_migration BOOLEAN,
  v_vnc_keyboard_layout VARCHAR(16),
  v_min_allocated_mem INTEGER,
- v_is_run_and_pause BOOLEAN)
+ v_is_run_and_pause BOOLEAN,
+ v_created_by UUID)
 RETURNS VOID
 
        --The [vm_templates] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -214,7 +218,7 @@
       kernel_url = v_kernel_url,kernel_params = v_kernel_params, _update_date 
= CURRENT_TIMESTAMP, quota_id = v_quota_id,
       migration_support = v_migration_support, dedicated_vm_for_vds = 
v_dedicated_vm_for_vds, is_smartcard_enabled = v_is_smartcard_enabled,
       is_delete_protected = v_is_delete_protected, is_disabled = 
v_is_disabled, tunnel_migration = v_tunnel_migration,
-      vnc_keyboard_layout = v_vnc_keyboard_layout, min_allocated_mem = 
v_min_allocated_mem, is_run_and_pause = v_is_run_and_pause
+      vnc_keyboard_layout = v_vnc_keyboard_layout, min_allocated_mem = 
v_min_allocated_mem, is_run_and_pause = v_is_run_and_pause, created_by = 
v_created_by
       WHERE vm_guid = v_vmt_guid
       AND   entity_type = 'TEMPLATE';
 END; $procedure$
diff --git a/backend/manager/dbscripts/vms_sp.sql 
b/backend/manager/dbscripts/vms_sp.sql
index 73a70c7..3842d6c 100644
--- a/backend/manager/dbscripts/vms_sp.sql
+++ b/backend/manager/dbscripts/vms_sp.sql
@@ -436,12 +436,13 @@
     v_host_cpu_flags BOOLEAN,
     v_tunnel_migration BOOLEAN,
     v_vnc_keyboard_layout VARCHAR(16),
-    v_is_run_and_pause BOOLEAN)
+    v_is_run_and_pause BOOLEAN,
+    v_created_by UUID)
 RETURNS VOID
    AS $procedure$
 BEGIN
-INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, 
VM_NAME, 
vmt_guid,domain,creation_date,num_of_monitors,allow_console_reconnect,is_initialized,is_auto_suspend,num_of_sockets,cpu_per_socket,usb_policy,
 time_zone,auto_startup,is_stateless,dedicated_vm_for_vds, fail_back, 
default_boot_sequence, vm_type, nice_level, default_display_type, 
priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,
 entity_type, quota_id, cpu_pinning, 
is_smartcard_enabled,is_delete_protected,host_cpu_flags, tunnel_migration, 
vnc_keyboard_layout, is_run_and_pause)
-       VALUES(v_description,  v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, 
v_vm_name, v_vmt_guid, v_domain, v_creation_date, v_num_of_monitors, 
v_allow_console_reconnect, v_is_initialized, v_is_auto_suspend, 
v_num_of_sockets, v_cpu_per_socket, v_usb_policy, v_time_zone, 
v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back, 
v_default_boot_sequence, v_vm_type, v_nice_level, v_default_display_type, 
v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,
 'VM', v_quota_id, v_cpu_pinning, 
v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags, 
v_tunnel_migration, v_vnc_keyboard_layout, v_is_run_and_pause);
+INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, 
VM_NAME, 
vmt_guid,domain,creation_date,num_of_monitors,allow_console_reconnect,is_initialized,is_auto_suspend,num_of_sockets,cpu_per_socket,usb_policy,
 time_zone,auto_startup,is_stateless,dedicated_vm_for_vds, fail_back, 
default_boot_sequence, vm_type, nice_level, default_display_type, 
priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,
 entity_type, quota_id, cpu_pinning, 
is_smartcard_enabled,is_delete_protected,host_cpu_flags, tunnel_migration, 
vnc_keyboard_layout, is_run_and_pause, created_by)
+       VALUES(v_description,  v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, 
v_vm_name, v_vmt_guid, v_domain, v_creation_date, v_num_of_monitors, 
v_allow_console_reconnect, v_is_initialized, v_is_auto_suspend, 
v_num_of_sockets, v_cpu_per_socket, v_usb_policy, v_time_zone, 
v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back, 
v_default_boot_sequence, v_vm_type, v_nice_level, v_default_display_type, 
v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,
 'VM', v_quota_id, v_cpu_pinning, 
v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags, 
v_tunnel_migration, v_vnc_keyboard_layout, v_is_run_and_pause, v_created_by);
 -- perform deletion from vm_ovf_generations to ensure that no record exists 
when performing insert to avoid PK violation.
 DELETE FROM vm_ovf_generations gen WHERE gen.vm_guid = v_vm_guid;
 INSERT INTO vm_ovf_generations(vm_guid, storage_pool_id) VALUES (v_vm_guid, 
(SELECT storage_pool_id FROM vds_groups vg WHERE vg.vds_group_id = 
v_vds_group_id));
@@ -552,7 +553,8 @@
 v_host_cpu_flags BOOLEAN,
 v_tunnel_migration BOOLEAN,
 v_vnc_keyboard_layout  VARCHAR(16),
-v_is_run_and_pause BOOLEAN)
+v_is_run_and_pause BOOLEAN,
+v_created_by UUID)
 RETURNS VOID
 
        --The [vm_static] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -576,7 +578,7 @@
       predefined_properties = v_predefined_properties,userdefined_properties = 
v_userdefined_properties,
       min_allocated_mem = v_min_allocated_mem, quota_id = v_quota_id, 
cpu_pinning = v_cpu_pinning, is_smartcard_enabled = v_is_smartcard_enabled,
       is_delete_protected = v_is_delete_protected, host_cpu_flags = 
v_host_cpu_flags, tunnel_migration = v_tunnel_migration,
-      vnc_keyboard_layout = v_vnc_keyboard_layout, is_run_and_pause = 
v_is_run_and_pause
+      vnc_keyboard_layout = v_vnc_keyboard_layout, is_run_and_pause = 
v_is_run_and_pause, created_by = v_created_by
       WHERE vm_guid = v_vm_guid
       AND   entity_type = 'VM';
 END; $procedure$
@@ -924,12 +926,13 @@
     v_cpu_pinning varchar(4000),
     v_host_cpu_flags BOOLEAN,
     v_tunnel_migration BOOLEAN,
-    v_is_run_and_pause BOOLEAN)
+    v_is_run_and_pause BOOLEAN,
+    v_created_by UUID)
 RETURNS VOID
    AS $procedure$
 BEGIN
-INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, 
VM_NAME, vmt_guid, num_of_monitors, allow_console_reconnect, is_initialized, 
is_auto_suspend, num_of_sockets, cpu_per_socket, usb_policy, 
time_zone,auto_startup,is_stateless,dedicated_vm_for_vds,fail_back,vm_type,nice_level,default_boot_sequence,default_display_type,priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,cpu_pinning,is_smartcard_enabled,is_delete_protected,host_cpu_flags,
 tunnel_migration, is_run_and_pause)
-       VALUES(v_description, v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, 
v_vm_name, v_vmt_guid, v_num_of_monitors, v_num_of_monitors, v_is_initialized, 
v_is_auto_suspend, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, 
v_time_zone,v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back,v_vm_type,v_nice_level,v_default_boot_sequence,v_default_display_type,v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,v_cpu_pinning,v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags,
 v_tunnel_migration, v_is_run_and_pause);
+INSERT INTO vm_static(description, mem_size_mb, os, vds_group_id, vm_guid, 
VM_NAME, vmt_guid, num_of_monitors, allow_console_reconnect, is_initialized, 
is_auto_suspend, num_of_sockets, cpu_per_socket, usb_policy, 
time_zone,auto_startup,is_stateless,dedicated_vm_for_vds,fail_back,vm_type,nice_level,default_boot_sequence,default_display_type,priority,iso_path,origin,initrd_url,kernel_url,kernel_params,migration_support,predefined_properties,userdefined_properties,min_allocated_mem,cpu_pinning,is_smartcard_enabled,is_delete_protected,host_cpu_flags,
 tunnel_migration, is_run_and_pause, created_by)
+       VALUES(v_description, v_mem_size_mb, v_os, v_vds_group_id, v_vm_guid, 
v_vm_name, v_vmt_guid, v_num_of_monitors, v_num_of_monitors, v_is_initialized, 
v_is_auto_suspend, v_num_of_sockets, v_cpu_per_socket, v_usb_policy, 
v_time_zone,v_auto_startup,v_is_stateless,v_dedicated_vm_for_vds,v_fail_back,v_vm_type,v_nice_level,v_default_boot_sequence,v_default_display_type,v_priority,v_iso_path,v_origin,v_initrd_url,v_kernel_url,v_kernel_params,v_migration_support,v_predefined_properties,v_userdefined_properties,v_min_allocated_mem,v_cpu_pinning,v_is_smartcard_enabled,v_is_delete_protected,v_host_cpu_flags,
 v_tunnel_migration, v_is_run_and_pause, v_created_by);
 
       INSERT INTO vm_dynamic(vm_guid, status) VALUES(v_vm_guid, 0);
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
index 8eb5f66..62eecc6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
@@ -612,6 +612,7 @@
         vmStatic.setId(getVmId());
         vmStatic.setQuotaId(getQuotaId());
         vmStatic.setCreationDate(new Date());
+        vmStatic.setCreatedByUserId(getUserId().getValue());
         // Parses the custom properties field that was filled by frontend to
         // predefined and user defined fields
         if (vmStatic.getCustomProperties() != null) {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
index 9a20233..c7716a2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
@@ -359,7 +359,8 @@
                         getParameters().getMasterVm().getVncKeyboardLayout(),
                         getParameters().getMasterVm().getMinAllocatedMem(),
                         getParameters().getMasterVm().isStateless(),
-                        getParameters().getMasterVm().isRunAndPause()));
+                        getParameters().getMasterVm().isRunAndPause(),
+                        getUserId().getValue()));
         
getVmTemplate().setAutoStartup(getParameters().getMasterVm().isAutoStartup());
         
getVmTemplate().setPriority(getParameters().getMasterVm().getPriority());
         
getVmTemplate().setDefaultDisplayType(getParameters().getMasterVm().getDefaultDisplayType());
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
index af6e872..5a3da3d 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java
@@ -1134,6 +1134,14 @@
         vmStatic.setRunAndPause(value);
     }
 
+    public Guid getCreatedByUserId() {
+        return vmStatic.getCreatedByUserId();
+    }
+
+    public void setCreatedByUserId(Guid value) {
+        vmStatic.setCreatedByUserId(value);
+    }
+
     public boolean isWin2kHackEnable() {
         return getDynamicData().getWin2kHackEnable();
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
index ffe19a2..f93f5d3 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmBase.java
@@ -199,6 +199,8 @@
     @EditableField
     private boolean runAndPause = false;
 
+    private Guid createdByUserId;
+
     public VmBase(Guid id,
             Guid vdsGroupId,
             int osId,
@@ -230,7 +232,8 @@
             Boolean tunnelMigration,
             String vncKeyboardLayout,
             int minAllocatedMem,
-            boolean runAndPause) {
+            boolean runAndPause,
+            Guid createdByUserId) {
         super();
         this.id = id;
         this.vdsGroupId = vdsGroupId;
@@ -263,6 +266,7 @@
         this.vncKeyboardLayout = vncKeyboardLayout;
         this.minAllocatedMem = minAllocatedMem;
         this.runAndPause = runAndPause;
+        this.createdByUserId = createdByUserId;
         setQuotaId(quotaId);
     }
 
@@ -592,6 +596,7 @@
         result = prime * result + ((migrationSupport == null) ? 0 : 
migrationSupport.hashCode());
         result = prime * result + ((tunnelMigration == null) ? 0 : 
tunnelMigration.hashCode());
         result = prime * result + ((vncKeyboardLayout == null) ? 0 : 
vncKeyboardLayout.hashCode());
+        result = prime * result + ((createdByUserId == null) ? 0 : 
createdByUserId.hashCode());
         return result;
     }
 
@@ -639,7 +644,8 @@
                 && ObjectUtils.objectsEqual(dedicatedVmForVds, 
other.dedicatedVmForVds)
                 && migrationSupport == other.migrationSupport
                 && ObjectUtils.objectsEqual(tunnelMigration, 
other.tunnelMigration)
-                && ObjectUtils.objectsEqual(vncKeyboardLayout, 
other.vncKeyboardLayout));
+                && ObjectUtils.objectsEqual(vncKeyboardLayout, 
other.vncKeyboardLayout)
+                && ObjectUtils.objectsEqual(createdByUserId, 
other.createdByUserId));
     }
 
     public Guid getQuotaId() {
@@ -739,4 +745,11 @@
         this.runAndPause = runAndPause;
     }
 
+    public Guid getCreatedByUserId() {
+        return createdByUserId;
+    }
+
+    public void setCreatedByUserId(Guid createdByUserId) {
+        this.createdByUserId = createdByUserId;
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
index d6da18c..9effb1f 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmStatic.java
@@ -86,7 +86,8 @@
                 vmStatic.getTunnelMigration(),
                 vmStatic.getVncKeyboardLayout(),
                 vmStatic.getMinAllocatedMem(),
-                vmStatic.isRunAndPause());
+                vmStatic.isRunAndPause(),
+                vmStatic.getCreatedByUserId());
         setName(vmStatic.getName());
         vmtGuid = vmStatic.getVmtGuid();
         setCustomProperties(vmStatic.getCustomProperties());
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
index cc71d2f..4f65d63 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmTemplate.java
@@ -59,7 +59,7 @@
             int numOfMonitors, int status, int usbPolicy, String timeZone, 
boolean autoSuspend, int niceLevel,
             boolean failBack, BootSequence defaultBootSequence, VmType vmType,
             boolean smartcardEnabled, boolean deleteProtected, Boolean 
tunnelMigration, String vncKeyboardLayout,
-            int minAllocatedMem, boolean stateless, boolean runAndPause) {
+            int minAllocatedMem, boolean stateless, boolean runAndPause, Guid 
createdByUserId) {
         super(
                 vmtGuid,
                 vdsGroupId,
@@ -92,7 +92,8 @@
                 tunnelMigration,
                 vncKeyboardLayout,
                 minAllocatedMem,
-                runAndPause);
+                runAndPause,
+                createdByUserId);
 
         diskTemplateMap = new HashMap<Guid, DiskImage>();
 
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
index 83f0ebd..197b375 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/AbstractVmRowMapper.java
@@ -8,6 +8,7 @@
 import org.ovirt.engine.core.common.businessentities.UsbPolicy;
 import org.ovirt.engine.core.common.businessentities.VmBase;
 import org.ovirt.engine.core.common.businessentities.VmType;
+import org.ovirt.engine.core.compat.Guid;
 import org.springframework.jdbc.core.RowMapper;
 
 /**
@@ -43,6 +44,7 @@
         entity.setTunnelMigration((Boolean) rs.getObject("tunnel_migration"));
         entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout"));
         entity.setRunAndPause(rs.getBoolean("is_run_and_pause"));
+        
entity.setCreatedByUserId(Guid.createGuidFromString(rs.getString("created_by")));
     }
 
 }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
index 6488f17..5512e56 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDAODbFacadeImpl.java
@@ -239,7 +239,8 @@
                 .addValue("guest_agent_nics_hash", vm.getGuestAgentNicsHash())
                 .addValue("tunnel_migration", vm.getTunnelMigration())
                 .addValue("vnc_keyboard_layout", vm.getVncKeyboardLayout())
-                .addValue("is_run_and_pause", vm.isRunAndPause()));
+                .addValue("is_run_and_pause", vm.isRunAndPause())
+                .addValue("created_by", vm.getCreatedByUserId()));
     }
 
     @Override
@@ -404,6 +405,7 @@
             entity.setVncKeyboardLayout(rs.getString("vnc_keyboard_layout"));
             entity.setRunAndPause(rs.getBoolean("is_run_and_pause"));
             entity.setLastWatchdogEvent(getLong(rs, "last_watchdog_event"));
+            
entity.setCreatedByUserId(Guid.createGuidFromString(rs.getString("created_by")));
             return entity;
         }
     }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
index 36c942c..bcc5f90 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmStaticDAODbFacadeImpl.java
@@ -86,7 +86,8 @@
                 .addValue("host_cpu_flags", vm.isUseHostCpuFlags())
                 .addValue("tunnel_migration", vm.getTunnelMigration())
                 .addValue("vnc_keyboard_layout", vm.getVncKeyboardLayout())
-                .addValue("is_run_and_pause", vm.isRunAndPause());
+                .addValue("is_run_and_pause", vm.isRunAndPause())
+                .addValue("created_by", vm.getCreatedByUserId());
     }
 
     @Override
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
index e6c09bb..866e015 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmTemplateDAODbFacadeImpl.java
@@ -166,7 +166,8 @@
                 .addValue("tunnel_migration", template.getTunnelMigration())
                 .addValue("vnc_keyboard_layout", 
template.getVncKeyboardLayout())
                 .addValue("min_allocated_mem", template.getMinAllocatedMem())
-                .addValue("is_run_and_pause", template.isRunAndPause());
+                .addValue("is_run_and_pause", template.isRunAndPause())
+                .addValue("created_by", template.getCreatedByUserId());
     }
 
     @Override
diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml 
b/backend/manager/modules/dal/src/test/resources/fixtures.xml
index 6b51918..fd8177d 100644
--- a/backend/manager/modules/dal/src/test/resources/fixtures.xml
+++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml
@@ -1167,6 +1167,7 @@
                <column>tunnel_migration</column>
                <column>min_allocated_mem</column>
                <column>is_run_and_pause</column>
+        <column>created_by</column>
         <!-- Templates -->
         <row>
             <value>00000000-0000-0000-0000-000000000000</value>
@@ -1213,6 +1214,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b79</value>
@@ -1259,6 +1261,7 @@
             <value>false</value>
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b80</value>
@@ -1305,6 +1308,7 @@
             <value>true</value>
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b81</value>
@@ -1351,6 +1355,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
          <row>
             <value>1b85420c-b84c-4f29-997e-0eb674b40b82</value>
@@ -1397,6 +1402,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+             <null />
         </row>
 
         <!-- VMS -->
@@ -1445,6 +1451,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4355</value>
@@ -1491,6 +1498,7 @@
             <value>false</value>
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4356</value>
@@ -1537,6 +1545,7 @@
             <value>true</value>
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4357</value>
@@ -1583,6 +1592,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4359</value>
@@ -1629,6 +1639,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f4360</value>
@@ -1675,6 +1686,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
         <row>
             <value>77296e00-0cad-4e5a-9299-008a7b6f5001</value>
@@ -1721,6 +1733,7 @@
             <null />
             <value>256</value>
             <value>false</value>
+            <null />
         </row>
     </table>
 
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 d6c2225..2bd1d4e 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
@@ -464,6 +464,13 @@
             }
         }
 
+        node = content.SelectSingleNode("CreatedByUserId");
+        if (node != null) {
+            if (StringUtils.isNotEmpty(node.InnerText)) {
+                
vmBase.setCreatedByUserId(Guid.createGuidFromString(node.InnerText));
+            }
+        }
+
         readGeneralData(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 14a1b37..4f66f66 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
@@ -272,6 +272,12 @@
         _writer.WriteStartElement("IsRunAndPause");
         _writer.WriteRaw(String.valueOf(vmBase.isRunAndPause()));
         _writer.WriteEndElement();
+
+        if (vmBase.getCreatedByUserId() != null) {
+            _writer.WriteStartElement("CreatedByUserId");
+            _writer.WriteRaw(String.valueOf(vmBase.getCreatedByUserId()));
+            _writer.WriteEndElement();
+        }
     }
 
     protected abstract void WriteAppList();


-- 
To view, visit http://gerrit.ovirt.org/16035
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I465f9c49d05f49d42814cd970c3df1ed763a7fb5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Betak <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to