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



##########
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:
       @weizhouapache done.
   
   I misunderstood it at first, but now i see.
   
   I took a look into the file that reads and execute the SQL script and 
wondered why it was wrote that way.




----------------------------------------------------------------
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:
[email protected]


Reply via email to