From e901ccfe0732e204ce25e6f41165314f2b73aa04 Mon Sep 17 00:00:00 2001 From: nit Date: Fri, 11 Feb 2011 18:44:26 +0530 Subject: [PATCH] bug 8498: Make osTypeId optional. Introdue a new OS type None to be shown for non bootable ISOs. Add check that when the ISO is bootable a valid osTypeId gets passed --- api/src/com/cloud/api/commands/RegisterIsoCmd.java | 2 +- server/src/com/cloud/template/TemplateManagerImpl.java | 9 ++++++++- setup/db/templates.sql | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/src/com/cloud/api/commands/RegisterIsoCmd.java b/api/src/com/cloud/api/commands/RegisterIsoCmd.java index 6d1fdf30f60..ffe80c2b8ab 100755 --- a/api/src/com/cloud/api/commands/RegisterIsoCmd.java +++ b/api/src/com/cloud/api/commands/RegisterIsoCmd.java @@ -54,7 +54,7 @@ public class RegisterIsoCmd extends BaseCmd { @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the ISO") private String isoName; - @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.LONG, required=true, description="the ID of the OS Type that best represents the OS of this ISO") + @Parameter(name=ApiConstants.OS_TYPE_ID, type=CommandType.LONG, description="the ID of the OS Type that best represents the OS of this ISO") private Long osTypeId; @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=true, description="the URL to where the ISO is currently being hosted") diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java index 64edb7c4c0d..9097f3d8630 100755 --- a/server/src/com/cloud/template/TemplateManagerImpl.java +++ b/server/src/com/cloud/template/TemplateManagerImpl.java @@ -242,10 +242,17 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe if (userId == null) { userId = Long.valueOf(1); } - + if (bootable == null) { bootable = Boolean.TRUE; } + + if ((guestOSId == null || guestOSId == 138L) && bootable == true){ + throw new InvalidParameterValueException("Please pass a valid GuestOS Id"); + } + if (bootable == false){ + guestOSId = 138L; //Guest os id of None. + } //removing support for file:// type urls (bug: 4239) if(url.toLowerCase().contains("file://")){ diff --git a/setup/db/templates.sql b/setup/db/templates.sql index 9f4d5c0aefc..5e08ffb491f 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -163,6 +163,7 @@ INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (134, 3, ' INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (135, 3, 'Oracle Enterprise Linux 5.5 (64-bit)'); INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (136, 4, 'Red Hat Enterprise Linux 6.0 (32-bit)'); INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (137, 4, 'Red Hat Enterprise Linux 6.0 (64-bit)'); +INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (138, 7, 'None'); INSERT INTO `cloud`.`guest_os_hypervisor` (hypervisor_type, guest_os_name, guest_os_id) VALUES ("XenServer", 'CentOS 4.5 (32-bit)', 1);