Shahar Havivi has uploaded a new change for review.

Change subject: DB: Vm Init - new Feature
......................................................................

DB: Vm Init - new Feature

Summry:
This Feature will allow persistent of Windows Sysprep and Cloud-Init
data to the Database. By persisting the data Admin can create a template
with VM-Init data that which will enable initialize VMs with relevant
Data.

Feature page:
http://www.ovirt.org/Features/vm-init-persistent

Change-Id: If6230e0543712cc8a8efd48ba45406ea43d0f778
Signed-off-by: Shahar Havivi <[email protected]>
---
M packaging/dbscripts/create_dwh_views.sql
M packaging/dbscripts/create_views.sql
A packaging/dbscripts/upgrade/03_04_0250_add_vm_init_table.sql
M packaging/dbscripts/vms_sp.sql
4 files changed, 115 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/23022/1

diff --git a/packaging/dbscripts/create_dwh_views.sql 
b/packaging/dbscripts/create_dwh_views.sql
index af4fb8a..45c1d83 100644
--- a/packaging/dbscripts/create_dwh_views.sql
+++ b/packaging/dbscripts/create_dwh_views.sql
@@ -228,7 +228,6 @@
                        cast(a.num_of_sockets as smallint) AS number_of_sockets,
                        a.mem_size_mb AS memory_size_mb,
             cast(a.os as smallint) AS operating_system,
-                       a.domain AS ad_domain,
                        a.dedicated_vm_for_vds AS default_host,
                        a.auto_startup AS high_availability,
             a.is_initialized AS initialized,
diff --git a/packaging/dbscripts/create_views.sql 
b/packaging/dbscripts/create_views.sql
index ebcc883..099958f 100644
--- a/packaging/dbscripts/create_views.sql
+++ b/packaging/dbscripts/create_views.sql
@@ -364,7 +364,6 @@
        vm_templates.description as description,
        vm_templates.free_text_comment as free_text_comment,
        vm_templates.vds_group_id as vds_group_id,
-       vm_templates.domain as domain,
        vm_templates.num_of_monitors as num_of_monitors,
        vm_templates.single_qxl_pci as single_qxl_pci,
        vm_templates.allow_console_reconnect as allow_console_reconnect,
@@ -429,7 +428,7 @@
                       vm_templates.os, vm_templates.creation_date,
                       vm_templates.child_count, vm_templates.num_of_sockets, 
vm_templates.cpu_per_socket,
                          
vm_templates.num_of_sockets*vm_templates.cpu_per_socket AS num_of_cpus, 
vm_templates.description, vm_templates.free_text_comment,
-                         vm_templates.vds_group_id, vm_templates.domain, 
vm_templates.num_of_monitors, vm_templates.single_qxl_pci, 
vm_templates.allow_console_reconnect, vm_templates.template_status AS status,
+                         vm_templates.vds_group_id, 
vm_templates.num_of_monitors, vm_templates.single_qxl_pci, 
vm_templates.allow_console_reconnect, vm_templates.template_status AS status,
                          vm_templates.usb_policy, vm_templates.time_zone, 
vm_templates.fail_back,
                          vds_groups.name AS vds_group_name, 
vm_templates.vm_type, vm_templates.nice_level, vm_templates.cpu_shares, 
storage_pool.id AS storage_pool_id, storage_pool.name
                       AS storage_pool_name,
@@ -450,7 +449,7 @@
 SELECT                vm_templates_1.vm_guid AS vmt_guid, 
vm_templates_1.vm_name AS name, vm_templates_1.mem_size_mb, vm_templates_1.os, 
vm_templates_1.creation_date,
                       vm_templates_1.child_count, 
vm_templates_1.num_of_sockets, vm_templates_1.cpu_per_socket,
                       
vm_templates_1.num_of_sockets*vm_templates_1.cpu_per_socket AS num_of_cpus, 
vm_templates_1.description, vm_templates_1.free_text_comment, 
vm_templates_1.vds_group_id,
-                      vm_templates_1.domain, vm_templates_1.num_of_monitors, 
vm_templates_1.single_qxl_pci, vm_templates_1.allow_console_reconnect, 
vm_templates_1.template_status AS status, vm_templates_1.usb_policy, 
vm_templates_1.time_zone,
+                      vm_templates_1.num_of_monitors, 
vm_templates_1.single_qxl_pci, vm_templates_1.allow_console_reconnect, 
vm_templates_1.template_status AS status, vm_templates_1.usb_policy, 
vm_templates_1.time_zone,
                       vm_templates_1.fail_back, vds_groups_1.name AS 
vds_group_name, vm_templates_1.vm_type,
                       vm_templates_1.nice_level, vm_templates_1.cpu_shares, 
storage_pool_1.id AS storage_pool_id,
                       storage_pool_1.name AS storage_pool_name, 
vm_templates_1.default_boot_sequence, vm_templates_1.default_display_type,
@@ -571,7 +570,7 @@
 AS
 SELECT     vm_static.vm_name as vm_name, vm_static.mem_size_mb as 
vm_mem_size_mb, vm_static.nice_level as nice_level, vm_static.cpu_shares as 
cpu_shares,
                       vm_static.vmt_guid as vmt_guid, vm_static.os as vm_os, 
vm_static.description as vm_description, vm_static.free_text_comment as 
vm_comment, vm_static.vds_group_id as vds_group_id,
-                      vm_static.domain as vm_domain, vm_static.creation_date 
as vm_creation_date, vm_static.auto_startup as auto_startup, 
vm_static.is_stateless as is_stateless,
+                      vm_static.creation_date as vm_creation_date, 
vm_static.auto_startup as auto_startup, vm_static.is_stateless as is_stateless,
                       vm_static.is_smartcard_enabled as is_smartcard_enabled, 
vm_static.is_delete_protected as is_delete_protected, vm_static.sso_method as 
sso_method, vm_static.dedicated_vm_for_vds as dedicated_vm_for_vds,
                       vm_static.fail_back as fail_back, 
vm_static.default_boot_sequence as default_boot_sequence, vm_static.vm_type as 
vm_type,
                       vds_groups.name as vds_group_name, 
vds_groups.transparent_hugepages as transparent_hugepages, 
vds_groups.trusted_service as trusted_service,
@@ -616,7 +615,7 @@
 CREATE OR REPLACE VIEW vms_with_tags
 AS
 SELECT      vms.vm_name, vms.vm_mem_size_mb, vms.nice_level, vms.cpu_shares, 
vms.vmt_guid, vms.vm_os, vms.vm_description, vms.vm_comment,
-            vms.vds_group_id, vms.vm_domain, vms.vm_creation_date, 
vms.auto_startup, vms.is_stateless, vms.is_smartcard_enabled, 
vms.is_delete_protected,
+            vms.vds_group_id, vms.vm_creation_date, vms.auto_startup, 
vms.is_stateless, vms.is_smartcard_enabled, vms.is_delete_protected,
             vms.sso_method, vms.dedicated_vm_for_vds, vms.fail_back, 
vms.default_boot_sequence, vms.vm_type,
             vms.vds_group_name, vms.storage_pool_id, vms.storage_pool_name,
             vms.vds_group_description, vms.vmt_name, vms.vmt_mem_size_mb, 
vms.vmt_os, vms.vmt_creation_date,
diff --git a/packaging/dbscripts/upgrade/03_04_0250_add_vm_init_table.sql 
b/packaging/dbscripts/upgrade/03_04_0250_add_vm_init_table.sql
new file mode 100644
index 0000000..7c6f2c7
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_04_0250_add_vm_init_table.sql
@@ -0,0 +1,32 @@
+-- ----------------------------------------------------------------------
+-- Add table "vm_init"
+-- ----------------------------------------------------------------------
+CREATE TABLE vm_init
+(
+    vm_id UUID NOT NULL,
+    host_name TEXT DEFAULT NULL,
+    domain TEXT DEFAULT NULL,
+    authorized_keys TEXT DEFAULT NULL,
+    regenerate_keys BOOLEAN DEFAULT FALSE,
+    time_zone VARCHAR(40) DEFAULT NULL,
+    dns_servers TEXT DEFAULT NULL,
+    dns_search_domains TEXT DEFAULT NULL,
+    networks TEXT DEFAULT NULL,
+    password TEXT DEFAULT NULL,
+    winkey VARCHAR(30) DEFAULT NULL,
+    custom_script TEXT DEFAULT NULL
+) WITH OIDS;
+
+
+-- ----------------------------------------------------------------------
+-- copy the domain and time_zone to the new vm_init table
+-- ----------------------------------------------------------------------
+insert into vm_init (vm_id, domain, time_zone) select
+vm_guid, domain, time_zone from vm_static
+where  entity_type='VM';
+
+
+-- ----------------------------------------------------------------------
+-- drop the domain from vm_static
+-- ----------------------------------------------------------------------
+ALTER TABLE vm_static DROP COLUMN domain CASCADE;
diff --git a/packaging/dbscripts/vms_sp.sql b/packaging/dbscripts/vms_sp.sql
index 741ab41..a5f9015 100644
--- a/packaging/dbscripts/vms_sp.sql
+++ b/packaging/dbscripts/vms_sp.sql
@@ -406,7 +406,6 @@
  v_vm_guid UUID,
  v_vm_name VARCHAR(255),
  v_vmt_guid UUID,
- v_domain  VARCHAR(40),
  v_creation_date TIMESTAMP WITH TIME ZONE,
  v_num_of_monitors INTEGER,
  v_single_qxl_pci BOOLEAN,
@@ -450,8 +449,8 @@
 RETURNS VOID
    AS $procedure$
 BEGIN
-INSERT INTO vm_static(description, free_text_comment, mem_size_mb, os, 
vds_group_id, vm_guid, VM_NAME, vmt_guid,domain,creation_date,num_of_monitors, 
single_qxl_pci, 
allow_console_reconnect,is_initialized,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, cpu_shares, 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, 
sso_method, host_cpu_flags, tunnel_migration, vnc_keyboard_layout, 
is_run_and_pause, created_by_user_id, instance_type_id, image_type_id)
-       VALUES(v_description, v_free_text_comment, 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_single_qxl_pci, v_allow_console_reconnect, 
v_is_initialized, 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_cpu_shares, 
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_sso_method, v_host_cpu_flags, v_tunnel_migration, v_vnc_keyboard_layout, 
v_is_run_and_pause, v_created_by_user_id, v_instance_type_id, v_image_type_id);
+INSERT INTO vm_static(description, free_text_comment, mem_size_mb, os, 
vds_group_id, vm_guid, VM_NAME, vmt_guid,creation_date,num_of_monitors, 
single_qxl_pci, 
allow_console_reconnect,is_initialized,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, cpu_shares, 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, 
sso_method, host_cpu_flags, tunnel_migration, vnc_keyboard_layout, 
is_run_and_pause, created_by_user_id, instance_type_id, image_type_id)
+       VALUES(v_description, v_free_text_comment, v_mem_size_mb, v_os, 
v_vds_group_id, v_vm_guid, v_vm_name, v_vmt_guid, v_creation_date, 
v_num_of_monitors,v_single_qxl_pci, v_allow_console_reconnect, 
v_is_initialized, 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_cpu_shares, 
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_sso_method, v_host_cpu_flags, v_tunnel_migration, v_vnc_keyboard_layout, 
v_is_run_and_pause, v_created_by_user_id, v_instance_type_id, v_image_type_id);
 -- 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));
@@ -528,7 +527,6 @@
  v_vm_guid UUID,
  v_vm_name VARCHAR(255),
  v_vmt_guid UUID,
- v_domain  VARCHAR(40),
  v_creation_date TIMESTAMP WITH TIME ZONE,
  v_num_of_monitors INTEGER,
  v_single_qxl_pci BOOLEAN,
@@ -577,7 +575,7 @@
       UPDATE vm_static
       SET description = v_description, free_text_comment = v_free_text_comment 
,mem_size_mb = v_mem_size_mb,os = v_os,vds_group_id = v_vds_group_id,
       VM_NAME = v_vm_name,vmt_guid = v_vmt_guid,
-      domain = v_domain,creation_date = v_creation_date,num_of_monitors = 
v_num_of_monitors,single_qxl_pci = v_single_qxl_pci,
+      creation_date = v_creation_date,num_of_monitors = 
v_num_of_monitors,single_qxl_pci = v_single_qxl_pci,
       allow_console_reconnect = v_allow_console_reconnect,
       is_initialized = v_is_initialized,
       num_of_sockets = v_num_of_sockets,cpu_per_socket = v_cpu_per_socket,
@@ -1100,3 +1098,79 @@
 END; $procedure$
 LANGUAGE plpgsql;
 
+
+---------------------
+-- vm_init functions
+---------------------
+
+Create or replace FUNCTION GetVmInitByVmId(v_vm_id UUID) RETURNS SETOF vm_init 
STABLE
+   AS $procedure$
+BEGIN
+RETURN QUERY SELECT vm_init.*
+   FROM vm_init
+   WHERE vm_id = v_vm_id;
+
+END; $procedure$
+LANGUAGE plpgsql;
+
+
+Create or replace FUNCTION UpdateVmInit(
+    v_vm_id UUID,
+    v_host_name TEXT DEFAULT NULL,
+    v_domain TEXT DEFAULT NULL,
+    v_authorized_keys TEXT DEFAULT NULL,
+    v_regenerate_keys BOOLEAN DEFAULT FALSE,
+    v_time_zone VARCHAR(40) DEFAULT FALSE,
+    v_dns_servers TEXT DEFAULT NULL,
+    v_dns_search_domains TEXT DEFAULT NULL,
+    v_networks TEXT DEFAULT NULL,
+    v_password TEXT DEFAULT NULL,
+    v_winkey VARCHAR(30) DEFAULT NULL,
+    v_custom_script TEXT DEFAULT NULL)
+RETURNS VOID
+
+   AS $procedure$
+BEGIN
+      UPDATE vm_init
+      SET host_name=v_host_name, domain=v_domain, 
authorized_keys=v_authorized_keys, regenerate_keys=v_regenerate_keys,
+          time_zone=v_time_zone, dns_servers=v_dns_servers, 
dns_search_domains=v_dns_search_domains,
+          networks=v_networks, password=v_password, winkey=v_winkey, 
custom_script=v_custom_script
+      WHERE vm_id = v_vm_id;
+END; $procedure$
+LANGUAGE plpgsql;
+
+
+Create or replace FUNCTION DeleteVmInit(v_vm_id UUID)
+RETURNS VOID
+   AS $procedure$
+BEGIN
+      DELETE FROM vm_init
+      WHERE vm_id = v_vm_id;
+
+END; $procedure$
+LANGUAGE plpgsql;
+
+
+Create or replace FUNCTION InsertVmInit(
+    v_vm_id UUID,
+    v_host_name TEXT DEFAULT NULL,
+    v_domain TEXT DEFAULT NULL,
+    v_authorized_keys TEXT DEFAULT NULL,
+    v_regenerate_keys BOOLEAN DEFAULT FALSE,
+    v_time_zone VARCHAR(40) DEFAULT NULL,
+    v_dns_servers TEXT DEFAULT NULL,
+    v_dns_search_domains TEXT DEFAULT NULL,
+    v_networks TEXT DEFAULT NULL,
+    v_password TEXT DEFAULT NULL,
+    v_winkey VARCHAR(30) DEFAULT NULL,
+    v_custom_script TEXT DEFAULT NULL)
+RETURNS VOID
+   AS $procedure$
+BEGIN
+INSERT INTO vm_init(vm_id, host_name, domain, authorized_keys, 
regenerate_keys, time_zone, dns_servers, dns_search_domains,
+                    networks, password, winkey, custom_script)
+       VALUES(v_vm_id, v_host_name, v_domain, v_authorized_keys, 
v_regenerate_keys, v_time_zone, v_dns_servers, v_dns_search_domains,
+                    v_networks, v_password, v_winkey, v_custom_script);
+END; $procedure$
+LANGUAGE plpgsql;
+


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

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

Reply via email to