Skip to content

Commit

Permalink
add LUKS and bcache devices to hasUserRole UI helper rockstor#550
Browse files Browse the repository at this point in the history
Extend the "hasUserRole" handlebars helper to identify future
user configurable disk roles of full disk LUKS container and
full disk backing and caching bcache devices which we already
label internally via the recent roles system.
  • Loading branch information
phillxnet committed Mar 20, 2017
1 parent c3240fb commit 3d0fe9c
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/rockstor/storageadmin/static/storageadmin/js/views/disks.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,14 +375,28 @@ DisksView = RockstorLayoutView.extend({
// Identify User assigned role disks by return of true / false.
// Works by examining the Disk.role field. Based on sister handlebars
// helper 'isBcache'
// Initially only the redirect role is a User assigned role.
// Initially only the redirect role was considered a User assigned
// role but this was expanded to include LUKS container and bcache
// backing and caching devices.
Handlebars.registerHelper('hasUserRole', function (role) {
var roleAsJson = asJSON(role);
if (roleAsJson == false) return false;
// We have a json string ie non legacy role info so we can examine:
// Test for each type of User role, essential a user requested
// purpose, ie use this partition, or make this a LUKS container.
// If found we can tag via this helper to avoid it's accidental
// re-use / deletion.
// Test for redirection (partition selection) role:
if (roleAsJson.hasOwnProperty('redirect')) {
// We have a User assigned role which we tag to avoid
// it's accidental re-use / delete.
return true;
}
// Test for LUKS container role:
if (roleAsJson.hasOwnProperty('LUKS')) {
return true;
}
// Test for bcache backing or caching roles:
if (roleAsJson.hasOwnProperty('bcache') ||
roleAsJson.hasOwnProperty('bcachecdev')) {
return true;
}
// In all other cases return false.
Expand Down

0 comments on commit 3d0fe9c

Please sign in to comment.