You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/02/25 09:10:31 UTC

[GitHub] [cloudstack] weizhouapache commented on a change in pull request #4699: Add new registers in guest_os

weizhouapache commented on a change in pull request #4699:
URL: https://github.com/apache/cloudstack/pull/4699#discussion_r582661864



##########
File path: engine/schema/src/main/resources/META-INF/db/schema-41510to41600.sql
##########
@@ -301,3 +301,43 @@ from
         left join
     `cloud`.`resource_count` secondary_storage_count ON domain.id = secondary_storage_count.domain_id
         and secondary_storage_count.type = 'secondary_storage';
+
+-- PR#4699 Drop the procedure `ADD_GUEST_OS_AND_HYPERVISOR_MAPPING` if it already exist.
+DROP PROCEDURE IF EXISTS `cloud`.`ADD_GUEST_OS_AND_HYPERVISOR_MAPPING`;
+
+-- PR#4699 Create the procedure `ADD_GUEST_OS_AND_HYPERVISOR_MAPPING` to add guest_os and guest_os_hypervisor mapping.
+CREATE PROCEDURE `cloud`.`ADD_GUEST_OS_AND_HYPERVISOR_MAPPING` (
+    IN guest_os_category_id bigint(20) unsigned,
+    IN guest_os_display_name VARCHAR(255),
+    IN guest_os_hypervisor_hypervisor_type VARCHAR(32),
+    IN guest_os_hypervisor_hypervisor_version VARCHAR(32),
+    IN guest_os_hypervisor_guest_os_name VARCHAR(255)
+)
+BEGIN	
+	INSERT  INTO cloud.guest_os (uuid, category_id, display_name, created) 
+	SELECT 	UUID(), guest_os_category_id, guest_os_display_name, now()	
+	WHERE 	not exists( SELECT  1 
+	                    FROM    cloud.guest_os
+	                    WHERE   cloud.guest_os.category_id = guest_os_category_id
+	                    AND     cloud.guest_os.display_name = guest_os_display_name);	
+						
+	INSERT  INTO cloud.guest_os_hypervisor (uuid, hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created) 
+	SELECT 	UUID(), guest_os_hypervisor_hypervisor_type, guest_os_hypervisor_hypervisor_version, guest_os_hypervisor_guest_os_name, guest_os.id, now()
+	FROM 	cloud.guest_os
+	WHERE 	guest_os.category_id = guest_os_category_id
+	AND 	guest_os.display_name = guest_os_display_name
+	AND	NOT EXISTS (SELECT  1 
+	                    FROM    cloud.guest_os_hypervisor as hypervisor
+	                    WHERE   hypervisor_type = guest_os_hypervisor_hypervisor_type			
+	                    AND     hypervisor_version = guest_os_hypervisor_hypervisor_version
+	                    AND     hypervisor.guest_os_id = guest_os.id
+	                    AND     hypervisor.guest_os_name = guest_os_hypervisor_guest_os_name);    
+END;
+

Review comment:
       @GutoVeronezi 
   this procedure might work in mysql, but I think it will not in cloudstack upgrade.
   ";" should not be the last character of a line in a procedure in schema-XXX.sql.
   




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org