Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Unified Diff: appengine/swarming/elements/res/imp/botlist/bot-list-shared.html

Issue 2211163003: Update new botlist to use dimensions endpoint (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@limiting
Patch Set: Make devices column make more sense Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/elements/res/imp/botlist/bot-list-shared.html
diff --git a/appengine/swarming/elements/res/imp/botlist/bot-list-shared.html b/appengine/swarming/elements/res/imp/botlist/bot-list-shared.html
index ca8d6cf47aa088459da5dfa4fba9001618e2b609..83fa6df99ac7aba57ac8ef632d493f1963e71de2 100644
--- a/appengine/swarming/elements/res/imp/botlist/bot-list-shared.html
+++ b/appengine/swarming/elements/res/imp/botlist/bot-list-shared.html
@@ -17,6 +17,7 @@
var ANDROID_ALIASES = {
"bullhead": "Nexus 5X",
"flo": "Nexus 7",
+ "flounder": "Nexus 9",
"hammerhead": "Nexus 5",
"mako": "Nexus 4",
"shamu": "Nexus 6",
@@ -28,11 +29,13 @@
var UNAUTHENTICATED = "unauthenticated";
var AVAILABLE = "available";
+ var UNKNOWN = "unknown";
var GPU_ALIASES = {
"1002": "AMD",
"1002:6779": "AMD Radeon HD 6450/7450/8450",
"1002:6821": "AMD Radeon HD 8870M",
+ "1002:9830": "AMD Radeon HD 8400",
"102b": "Matrox",
"102b:0522": "Matrox MGA G200e",
"102b:0532": "Matrox MGA G200eW",
@@ -58,14 +61,34 @@
// This behavior wraps up all the shared bot-list functionality.
SwarmingBehaviors.BotListBehavior = {
- _androidAlias: function(device) {
- if (device.notReady) {
- return UNAUTHENTICATED.toUpperCase();
- }
- var t = this._deviceType(device);
- var a = ANDROID_ALIASES[t];
+ properties: {
+ // TODO(kjlubick): Add more of these things from state, as they
+ // needed/useful/requested.
+ DIMENSIONS: {
+ type: Array,
+ value: function(){
+ return ["android_devices", "cores", "cpu", "device_type",
+ "device_os", "gpu", "id", "os", "pool"];
+ },
+ },
+ DIMENSIONS_WITH_ALIASES: {
+ type: Array,
+ value: function(){
+ return ["device_type", "gpu"];
+ },
+ },
+ BOT_PROPERTIES: {
+ type: Array,
+ value: function() {
+ return ["disk_space", "task", "status"];
+ }
+ },
+ },
+
+ _androidAlias: function(dt) {
+ var a = ANDROID_ALIASES[dt];
jcgregorio 2016/08/08 16:14:42 return ANDROID_ALIASES[dt] || UNKNOWN;
kjlubick 2016/08/08 19:07:10 Done.
if (!a) {
- return "UNKNOWN";
+ return UNKNOWN;
}
return a;
},
@@ -75,15 +98,12 @@
return alias +" ("+orig+")";
},
- _cores: function(bot) {
- // For whatever reason, sometimes cores are in dimensions and sometimes
- // they are in state, but never both.
- var c = (bot && bot.state && bot.state.cores);
- if (c && c.length > 0) {
- return c;
- }
- c = this._dimension(bot, "cores") || ["Unknown"];
- return c;
+ // _attribute looks first in dimension and then in state for the
+ // specified attribute. This will always return an array. If there is
+ // no matching attribute, ["unknown"] will be returned.
+ _attribute: function(bot, attr, none) {
+ none = none || UNKNOWN;
+ return this._dimension(bot, attr) || this._state(bot, attr) || [none];
},
_devices: function(bot) {
@@ -102,15 +122,15 @@
// _deviceType returns the codename of a given Android device.
_deviceType: function(device) {
if (!device || !device.build) {
- return "unknown";
+ return UNKNOWN;
}
var t = device.build["build.product"] || device.build["product.board"] ||
- device.build["product.device"] || "unknown";
+ device.build["product.device"] || UNKNOWN;
return t.toLowerCase();
},
// _dimension returns the given dimension of a bot. If it is defined, it
- // is typically an array of strings.
+ // is an array of strings.
_dimension: function(bot, dim) {
if (!bot || !bot.dimensions || !dim) {
return undefined;
@@ -126,7 +146,7 @@
_gpuAlias: function(gpu) {
var a = GPU_ALIASES[gpu];
kjlubick 2016/08/08 19:07:10 Also fixed, like ANDROID_ALIASES
if (!a) {
- return "UNKNOWN";
+ return UNKNOWN;
}
return a;
},
@@ -144,6 +164,20 @@
return result;
},
+ // _state returns the requested attribute from a bot's state.
+ // For consistency with _dimension, if the attribute is not an array,
+ // it is put as theonly element in an array.
jcgregorio 2016/08/08 16:14:42 the only
kjlubick 2016/08/08 19:07:10 Done.
+ _state: function(bot, attr) {
+ if (!bot || !bot.state || !bot.state[attr]) {
+ return undefined
+ }
+ var state = bot.state[attr];
+ if (Array.isArray(state)) {
+ return state;
+ }
+ return [state];
+ },
+
_taskId: function(bot) {
if (bot && bot.task_id) {
return bot.task_id;

Powered by Google App Engine
This is Rietveld 408576698