Fix Bug CloudStack-9 can not change OS preference from OS to none
Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/dd07d159 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/dd07d159 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/dd07d159 Branch: refs/heads/javelin Commit: dd07d1598f4b0812385c0c2259f9fdf4ae70c9b5 Parents: 8a2259d Author: Mice Xia <[email protected]> Authored: Tue Sep 4 20:42:25 2012 +0800 Committer: Mice Xia <[email protected]> Committed: Tue Sep 4 20:51:03 2012 +0800 ---------------------------------------------------------------------- api/src/com/cloud/storage/GuestOsCategory.java | 2 ++ .../com/cloud/resource/ResourceManagerImpl.java | 2 +- setup/db/db/schema-302to40.sql | 2 ++ setup/db/templates.sql | 2 +- ui/scripts/system.js | 11 ++++++----- 5 files changed, 12 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dd07d159/api/src/com/cloud/storage/GuestOsCategory.java ---------------------------------------------------------------------- diff --git a/api/src/com/cloud/storage/GuestOsCategory.java b/api/src/com/cloud/storage/GuestOsCategory.java index 96123e4..42320d9 100644 --- a/api/src/com/cloud/storage/GuestOsCategory.java +++ b/api/src/com/cloud/storage/GuestOsCategory.java @@ -17,6 +17,8 @@ package com.cloud.storage; public interface GuestOsCategory { + // Used by OS preference, 'None' for no OS preference + public static final String CATEGORY_NONE ="None"; long getId(); String getName(); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dd07d159/server/src/com/cloud/resource/ResourceManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 7dbf63f..1414370 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -1211,7 +1211,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId); Map<String, String> hostDetails = _hostDetailsDao.findDetails(hostId); - if (guestOSCategory != null) { + if (guestOSCategory != null && !GuestOSCategoryVO.CATEGORY_NONE.equalsIgnoreCase(guestOSCategory.getName())) { // Save a new entry for guest.os.category.id hostDetails.put("guest.os.category.id", String.valueOf(guestOSCategory.getId())); } else { http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dd07d159/setup/db/db/schema-302to40.sql ---------------------------------------------------------------------- diff --git a/setup/db/db/schema-302to40.sql b/setup/db/db/schema-302to40.sql index aaf23e6..d1a5ea9 100644 --- a/setup/db/db/schema-302to40.sql +++ b/setup/db/db/schema-302to40.sql @@ -466,3 +466,5 @@ UPDATE `cloud`.`configuration` SET description='Comma separated list of cidrs in INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'site2site.vpn.vpngateway.connection.limit', '4', 'The maximum number of VPN connection per VPN gateway'); INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Network', 'DEFAULT', 'management-server', 'site2site.vpn.customergateway.subnets.limit', '10', 'The maximum number of subnets per customer gateway'); + +INSERT IGNORE INTO `cloud`.`guest_os_category` VALUES ('11','None',NULL); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dd07d159/setup/db/templates.sql ---------------------------------------------------------------------- diff --git a/setup/db/templates.sql b/setup/db/templates.sql index 3034c7f..0c85be4 100755 --- a/setup/db/templates.sql +++ b/setup/db/templates.sql @@ -48,7 +48,7 @@ INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (7, 'Other'); INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (8, 'Novel'); INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (9, 'Unix'); INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (10, 'Ubuntu'); - +INSERT INTO `cloud`.`guest_os_category` (id, name) VALUES (11, 'None'); INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (1, 1, 'CentOS 4.5 (32-bit)'); INSERT INTO `cloud`.`guest_os` (id, category_id, display_name) VALUES (2, 1, 'CentOS 4.6 (32-bit)'); http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/dd07d159/ui/scripts/system.js ---------------------------------------------------------------------- diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 2a4cf5f..3bf43d3 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -7635,7 +7635,7 @@ var array1 = []; array1.push("&hosttags=" + todb(args.data.hosttags)); - if (args.data.oscategoryid != null && args.data.oscategoryid != 'None') + if (args.data.oscategoryid != null) array1.push("&osCategoryId=" + args.data.oscategoryid); $.ajax({ @@ -7852,11 +7852,12 @@ async: true, success: function(json) { var oscategoryObjs = json.listoscategoriesresponse.oscategory; - var items = [ - { id: null, description: _l('label.none') } - ]; + var items = []; $(oscategoryObjs).each(function() { - items.push({id: this.id, description: this.name}); + if(this.name == 'None') + items.unshift({ id: this.id, description: _l('label.none') }); + else + items.push({id: this.id, description: this.name}); }); args.response.success({data: items}); }
