Skip to content

Commit a782d17

Browse files
CLOUDSTACK-3806: OS Preference can not be set.
1 parent 013f100 commit a782d17

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

server/src/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,23 +1274,29 @@ public Host updateHost(UpdateHostCmd cmd) throws NoTransitionException {
12741274

12751275
if (guestOSCategoryId != null) {
12761276
// Verify that the guest OS Category exists
1277-
if (guestOSCategoryId > 0) {
1278-
if (_guestOSCategoryDao.findById(guestOSCategoryId) == null) {
1279-
throw new InvalidParameterValueException("Please specify a valid guest OS category.");
1280-
}
1277+
if (!(guestOSCategoryId > 0) || _guestOSCategoryDao.findById(guestOSCategoryId) == null) {
1278+
throw new InvalidParameterValueException("Please specify a valid guest OS category.");
12811279
}
12821280

12831281
GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
1284-
Map<String, String> hostDetails = _hostDetailsDao.findDetails(hostId);
1282+
DetailVO guestOSDetail = _hostDetailsDao.findDetail(hostId, "guest.os.category.id");
12851283

1286-
if (guestOSCategory != null) {
1287-
// Save a new entry for guest.os.category.id
1288-
hostDetails.put("guest.os.category.id", String.valueOf(guestOSCategory.getId()));
1284+
if (guestOSCategory != null && !GuestOSCategoryVO.CATEGORY_NONE.equalsIgnoreCase(guestOSCategory.getName())) {
1285+
// Create/Update an entry for guest.os.category.id
1286+
if (guestOSDetail != null) {
1287+
guestOSDetail.setValue(String.valueOf(guestOSCategory.getId()));
1288+
_hostDetailsDao.update(guestOSDetail.getId(), guestOSDetail);
1289+
} else {
1290+
Map<String, String> detail = new HashMap<String, String>();
1291+
detail.put("guest.os.category.id", String.valueOf(guestOSCategory.getId()));
1292+
_hostDetailsDao.persist(hostId, detail);
1293+
}
12891294
} else {
12901295
// Delete any existing entry for guest.os.category.id
1291-
hostDetails.remove("guest.os.category.id");
1296+
if (guestOSDetail != null) {
1297+
_hostDetailsDao.remove(guestOSDetail.getId());
1298+
}
12921299
}
1293-
_hostDetailsDao.persist(hostId, hostDetails);
12941300
}
12951301

12961302
List<String> hostTags = cmd.getHostTags();

ui/scripts/system.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14252,7 +14252,7 @@
1425214252
var oscategoryObjs = json.listoscategoriesresponse.oscategory;
1425314253
var items = [{
1425414254
id: '',
14255-
description: _l('label.none')
14255+
description: _l('')
1425614256
}];
1425714257
$(oscategoryObjs).each(function() {
1425814258
items.push({

0 commit comments

Comments
 (0)