Dima Kuznetsov has uploaded a new change for review.

Change subject: core: Introduce boot time field in VDS
......................................................................

core: Introduce boot time field in VDS

Added DateTime with timezone to VDS db record, VDS struct and REST API.

Change-Id: I0ec679a4ce5ddfbc1735db380feab69eb3798ae6
Bug-Url: https://bugzilla.redhat.com/1070348
Signed-off-by: Dima Kuznetsov <dkuzn...@redhat.com>
---
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
M 
backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
M packaging/dbscripts/create_views.sql
A packaging/dbscripts/upgrade/03_05_0080_add_uptime_to_vds_dynamic.sql
M 
packaging/dbscripts/upgrade/post_upgrade/0010_add_object_column_white_list_table.sql
M packaging/dbscripts/vds_sp.sql
12 files changed, 46 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/25880/1

diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
index 9a70c3b..8e7eeba 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VDS.java
@@ -137,6 +137,7 @@
         vds.setUsageCpuPercent(getUsageCpuPercent());
         vds.setUsageNetworkPercent(getUsageNetworkPercent());
         vds.setReservedMem(getReservedMem());
+        vds.setBootTime(getBootTime());
         vds.setGuestOverhead(getGuestOverhead());
         vds.setPreviousStatus(getPreviousStatus());
         vds.setMemAvailable(getMemAvailable());
@@ -656,11 +657,18 @@
     public Integer getReservedMem() {
         return this.mVdsDynamic.getreserved_mem();
     }
-
     public void setReservedMem(Integer value) {
         this.mVdsDynamic.setreserved_mem(value);
     }
 
+    public Date getBootTime() {
+        return this.mVdsDynamic.getboot_time();
+    }
+
+    public void setBootTime(Date value) {
+        this.mVdsDynamic.setboot_time(value);
+    }
+
     public VDSStatus getPreviousStatus() {
         return this.mVdsDynamic.getprevious_status();
     }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
index b3fcc25..4133d02 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VdsDynamic.java
@@ -46,6 +46,8 @@
 
     private Integer reserved_mem;
 
+    private Date boot_time;
+
     private Integer guest_overhead;
 
     private String softwareVersion;
@@ -313,6 +315,14 @@
         this.reserved_mem = value;
     }
 
+    public Date getboot_time() {
+        return this.boot_time;
+    }
+
+    public void setboot_time(Date value) {
+        this.boot_time = value;
+    }
+
     public Integer getguest_overhead() {
         return this.guest_overhead;
     }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
index f4c7f50..d3d1aed 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDAODbFacadeImpl.java
@@ -346,6 +346,7 @@
             
entity.setHighlyAvailableGlobalMaintenance(rs.getBoolean("ha_global_maintenance"));
             
entity.setHighlyAvailableLocalMaintenance(rs.getBoolean("ha_local_maintenance"));
             entity.calculateFreeVirtualMemory();
+            entity.setBootTime(rs.getTimestamp("boot_time"));
             return entity;
         }
     }
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
index 1d7f0b0..3bae639 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VdsDynamicDAODbFacadeImpl.java
@@ -2,8 +2,10 @@
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.Calendar;
 import java.util.HashMap;
 import java.util.List;
+import java.util.TimeZone;
 
 import org.apache.commons.lang.NotImplementedException;
 import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
@@ -97,6 +99,7 @@
             entity.setHardwareFamily(rs.getString("hw_family"));
             entity.setHBAs(new 
JsonObjectDeserializer().deserialize(rs.getString("hbas"), HashMap.class));
             
entity.setPowerManagementControlledByPolicy(rs.getBoolean("controlled_by_pm_policy"));
+            entity.setboot_time(rs.getTimestamp("boot_time", 
Calendar.getInstance(TimeZone.getTimeZone("UTC"))));
 
             return entity;
         }
@@ -252,7 +255,8 @@
                 .addValue("hw_uuid", vds.getHardwareUUID())
                 .addValue("hw_family", vds.getHardwareFamily())
                 .addValue("hbas", new 
JsonObjectSerializer().serialize(vds.getHBAs()))
-                .addValue("supported_emulated_machines", 
vds.getSupportedEmulatedMachines());
+                .addValue("supported_emulated_machines", 
vds.getSupportedEmulatedMachines())
+                .addValue("boot_time", vds.getboot_time());
 
         return parameterSource;
     }
diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
index e78efde..4e6e827 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
@@ -1515,6 +1515,7 @@
           <xs:element name="libvirt_version" type="Version" minOccurs="0" 
maxOccurs="1"/>
 <!--           Optionally  specify the display address of this host explicitly 
-->
           <xs:element ref="display" minOccurs="0"/>
+          <xs:element name="boot_time" type="xs:dateTime" minOccurs="0" 
maxOccurs="1" />
         </xs:sequence>
       </xs:extension>
     </xs:complexContent>
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
index e3be06e..ed11318 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
@@ -329,6 +329,9 @@
             model.setVersion(version);
         }
         model.setOs(getHostOs(entity.getHostOs()));
+        if (entity.getBootTime() != null) {
+            model.setBootTime(DateMapper.map(entity.getBootTime(), null));
+        }
         model.setKsm(new KSM());
         model.getKsm().setEnabled(Boolean.TRUE.equals(entity.getKsmState()));
         model.setTransparentHugepages(new TransparentHugePages());
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
index 7e11fad..56c797c 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsBrokerObjectsBuilder.java
@@ -406,6 +406,7 @@
             hbas.put(el.getKey(), devicesList);
         }
         vds.setHBAs(hbas);
+        vds.setBootTime(AssignDatetimeValue(xmlRpcStruct, 
VdsProperties.bootTime));
     }
 
     public static void checkTimeDrift(VDS vds, Map<String, Object> 
xmlRpcStruct) {
@@ -693,6 +694,8 @@
         vds.setHighlyAvailableGlobalMaintenance(haGlobalMaint != null ? 
haGlobalMaint : false);
         vds.setHighlyAvailableLocalMaintenance(haLocalMaint != null ? 
haLocalMaint : false);
 
+        vds.setBootTime(AssignDatetimeValue(xmlRpcStruct, 
VdsProperties.bootTime));
+
     }
 
     /**
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
index 72c62b9..26d8cf2 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
@@ -42,6 +42,7 @@
     public static final String Protocol = "protocol";
     public static final String vm_types = "vmTypes"; // Currently not in use
     public static final String reservedMem = "reservedMem";
+    public static final String bootTime = "bootTime";
     // vds runtime (i.e. VdsDynamic req getVdsStats)
     public static final String netConfigDirty = "netConfigDirty";
     public static final String status = "status"; // in vm also
diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index 0705653..64e4e2e 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -729,7 +729,7 @@
                       vds_dynamic.hw_serial_number as hw_serial_number, 
vds_dynamic.hw_uuid as hw_uuid, vds_dynamic.hw_family as hw_family, 
vds_static.console_address as console_address,
                       vds_dynamic.hbas as hbas, 
vds_dynamic.supported_emulated_machines as supported_emulated_machines, 
vds_static.ssh_port as ssh_port, vds_static.ssh_username as ssh_username, 
vds_statistics.ha_score as ha_score,
                       vds_statistics.ha_configured as ha_configured, 
vds_statistics.ha_active as ha_active, vds_statistics.ha_global_maintenance as 
ha_global_maintenance,
-                      vds_statistics.ha_local_maintenance as 
ha_local_maintenance, vds_static.disable_auto_pm as disable_auto_pm, 
vds_dynamic.controlled_by_pm_policy as controlled_by_pm_policy
+                      vds_statistics.ha_local_maintenance as 
ha_local_maintenance, vds_static.disable_auto_pm as disable_auto_pm, 
vds_dynamic.controlled_by_pm_policy as controlled_by_pm_policy, 
vds_dynamic.boot_time as boot_time
 FROM         vds_groups INNER JOIN
 vds_static ON vds_groups.vds_group_id = vds_static.vds_group_id INNER JOIN
 vds_dynamic ON vds_static.vds_id = vds_dynamic.vds_id INNER JOIN
@@ -772,7 +772,8 @@
                       vds_dynamic.transparent_hugepages_state, 
vds_statistics.anonymous_hugepages, vds_dynamic.non_operational_reason,
                       storage_pool_iso_map.storage_id, vds_static.ssh_port, 
vds_static.ssh_username, vds_statistics.ha_score,
                       vds_statistics.ha_configured, vds_statistics.ha_active, 
vds_statistics.ha_global_maintenance, vds_statistics.ha_local_maintenance,
-                      vds_static.disable_auto_pm as disable_auto_pm, 
vds_dynamic.controlled_by_pm_policy as controlled_by_pm_policy
+                      vds_static.disable_auto_pm as disable_auto_pm, 
vds_dynamic.controlled_by_pm_policy as controlled_by_pm_policy,
+                      vds_dynamic.boot_time
 FROM         vds_groups INNER JOIN
 vds_static ON vds_groups.vds_group_id = vds_static.vds_group_id INNER JOIN
 vds_dynamic ON vds_static.vds_id = vds_dynamic.vds_id INNER JOIN
diff --git 
a/packaging/dbscripts/upgrade/03_05_0080_add_uptime_to_vds_dynamic.sql 
b/packaging/dbscripts/upgrade/03_05_0080_add_uptime_to_vds_dynamic.sql
new file mode 100644
index 0000000..1ee999d
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_05_0080_add_uptime_to_vds_dynamic.sql
@@ -0,0 +1 @@
+select fn_db_add_column('vds_dynamic', 'boot_time', 'timestamp with time 
zone');
diff --git 
a/packaging/dbscripts/upgrade/post_upgrade/0010_add_object_column_white_list_table.sql
 
b/packaging/dbscripts/upgrade/post_upgrade/0010_add_object_column_white_list_table.sql
index cf169f7..9074e24 100644
--- 
a/packaging/dbscripts/upgrade/post_upgrade/0010_add_object_column_white_list_table.sql
+++ 
b/packaging/dbscripts/upgrade/post_upgrade/0010_add_object_column_white_list_table.sql
@@ -55,7 +55,7 @@
           'vds_group_compatibility_version', 'vds_group_virt_service', 
'vds_group_gluster_service', 'host_os', 'kvm_version', 'libvirt_version', 
'spice_version', 'kernel_version',
           'iscsi_initiator_name', 'transparent_hugepages_state', 
'anonymous_hugepages',
           'non_operational_reason', 'recoverable', 'sshkeyfingerprint', 
'count_threads_as_cores', 'cpu_threads',
-          'hw_manufacturer', 'hw_product_name', 'hw_version', 
'hw_serial_number', 'hw_uuid', 'hw_family', 'ssh_port', 'ssh_username'));
+          'hw_manufacturer', 'hw_product_name', 'hw_version', 
'hw_serial_number', 'hw_uuid', 'hw_family', 'ssh_port', 'ssh_username', 
'boot_time'));
 -- pm_options are missing
 END; $function$
 LANGUAGE plpgsql;
diff --git a/packaging/dbscripts/vds_sp.sql b/packaging/dbscripts/vds_sp.sql
index 1afb8d3..bdcaf04 100644
--- a/packaging/dbscripts/vds_sp.sql
+++ b/packaging/dbscripts/vds_sp.sql
@@ -198,14 +198,15 @@
  v_hw_family VARCHAR(255),
  v_hbas VARCHAR(255),
  v_supported_emulated_machines VARCHAR(255),
- v_controlled_by_pm_policy BOOLEAN)
+ v_controlled_by_pm_policy BOOLEAN,
+ v_boot_time TIMESTAMP WITH TIME ZONE)
 RETURNS VOID
    AS $procedure$
 BEGIN
 
    BEGIN
-INSERT INTO vds_dynamic(cpu_cores, cpu_threads, cpu_model, cpu_speed_mh, 
if_total_speed, kvm_enabled, mem_commited, physical_mem_mb,   status, vds_id, 
vm_active, vm_count, vm_migrating, reserved_mem, guest_overhead, rpm_version, 
software_version, version_name, build_name, previous_status, cpu_flags, 
cpu_over_commit_time_stamp, vms_cores_count, pending_vcpus_count, 
pending_vmem_size, cpu_sockets,net_config_dirty, supported_cluster_levels, 
supported_engines, host_os, kvm_version, libvirt_version, spice_version, 
gluster_version, kernel_version, iscsi_initiator_name, 
transparent_hugepages_state, hooks, hw_manufacturer, hw_product_name, 
hw_version, hw_serial_number, hw_uuid, hw_family, hbas, 
supported_emulated_machines, controlled_by_pm_policy)
-       VALUES(v_cpu_cores,     v_cpu_threads, v_cpu_model,     v_cpu_speed_mh, 
v_if_total_speed, v_kvm_enabled, v_mem_commited, v_physical_mem_mb,     
v_status, v_vds_id, v_vm_active, v_vm_count, v_vm_migrating,    v_reserved_mem, 
v_guest_overhead, v_rpm_version, v_software_version, v_version_name, 
v_build_name, v_previous_status, v_cpu_flags, v_cpu_over_commit_time_stamp, 
v_vms_cores_count,v_pending_vcpus_count, v_pending_vmem_size, v_cpu_sockets, 
v_net_config_dirty, v_supported_cluster_levels, v_supported_engines, v_host_os, 
v_kvm_version, v_libvirt_version, v_spice_version, v_gluster_version, 
v_kernel_version, v_iscsi_initiator_name, v_transparent_hugepages_state, 
v_hooks, v_hw_manufacturer, v_hw_product_name, v_hw_version, 
v_hw_serial_number, v_hw_uuid, v_hw_family, v_hbas, 
v_supported_emulated_machines, v_controlled_by_pm_policy);
+INSERT INTO vds_dynamic(cpu_cores, cpu_threads, cpu_model, cpu_speed_mh, 
if_total_speed, kvm_enabled, mem_commited, physical_mem_mb,   status, vds_id, 
vm_active, vm_count, vm_migrating, reserved_mem, guest_overhead, rpm_version, 
software_version, version_name, build_name, previous_status, cpu_flags, 
cpu_over_commit_time_stamp, vms_cores_count, pending_vcpus_count, 
pending_vmem_size, cpu_sockets,net_config_dirty, supported_cluster_levels, 
supported_engines, host_os, kvm_version, libvirt_version, spice_version, 
gluster_version, kernel_version, iscsi_initiator_name, 
transparent_hugepages_state, hooks, hw_manufacturer, hw_product_name, 
hw_version, hw_serial_number, hw_uuid, hw_family, hbas, 
supported_emulated_machines, controlled_by_pm_policy, boot_time)
+       VALUES(v_cpu_cores,     v_cpu_threads, v_cpu_model,     v_cpu_speed_mh, 
v_if_total_speed, v_kvm_enabled, v_mem_commited, v_physical_mem_mb,     
v_status, v_vds_id, v_vm_active, v_vm_count, v_vm_migrating,    v_reserved_mem, 
v_guest_overhead, v_rpm_version, v_software_version, v_version_name, 
v_build_name, v_previous_status, v_cpu_flags, v_cpu_over_commit_time_stamp, 
v_vms_cores_count,v_pending_vcpus_count, v_pending_vmem_size, v_cpu_sockets, 
v_net_config_dirty, v_supported_cluster_levels, v_supported_engines, v_host_os, 
v_kvm_version, v_libvirt_version, v_spice_version, v_gluster_version, 
v_kernel_version, v_iscsi_initiator_name, v_transparent_hugepages_state, 
v_hooks, v_hw_manufacturer, v_hw_product_name, v_hw_version, 
v_hw_serial_number, v_hw_uuid, v_hw_family, v_hbas, 
v_supported_emulated_machines, v_controlled_by_pm_policy, v_boot_time);
    END;
 
    RETURN;
@@ -274,7 +275,8 @@
  v_hw_uuid VARCHAR(255),
  v_hw_family VARCHAR(255),
  v_hbas VARCHAR(255),
- v_supported_emulated_machines VARCHAR(255))
+ v_supported_emulated_machines VARCHAR(255),
+ v_boot_time TIMESTAMP WITH TIME ZONE)
 RETURNS VOID
 
        --The [vds_dynamic] table doesn't have a timestamp column. Optimistic 
concurrency logic cannot be generated
@@ -305,7 +307,8 @@
       _update_date = LOCALTIMESTAMP,non_operational_reason = 
v_non_operational_reason,
       hw_manufacturer = v_hw_manufacturer, hw_product_name = v_hw_product_name,
       hw_version = v_hw_version, hw_serial_number = v_hw_serial_number,
-      hw_uuid = v_hw_uuid, hw_family = v_hw_family, hbas = v_hbas, 
supported_emulated_machines = v_supported_emulated_machines
+      hw_uuid = v_hw_uuid, hw_family = v_hw_family, hbas = v_hbas, 
supported_emulated_machines = v_supported_emulated_machines,
+      boot_time = v_boot_time
       WHERE vds_id = v_vds_id;
    END;
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ec679a4ce5ddfbc1735db380feab69eb3798ae6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Dima Kuznetsov <dkuzn...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to