| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | |
| 4 that can be found in the LICENSE file. | |
| 5 | |
| 6 This in an HTML Import-able file that contains the definition | |
| 7 of the following elements: | |
| 8 | |
| 9 <swarming-index> | |
| 10 | |
| 11 Swarming Index is the landing page for the Swarming UI. | |
| 12 It will have links to all other pages and a high-level overview of the fleet
. | |
| 13 | |
| 14 Usage: | |
| 15 | |
| 16 <swarming-index></swarming-index> | |
| 17 | |
| 18 This is a top-level element. | |
| 19 | |
| 20 Properties: | |
| 21 client_id: String, Oauth 2.0 client id. It will be set by server-side | |
| 22 template evaluation. | |
| 23 | |
| 24 Methods: | |
| 25 None. | |
| 26 | |
| 27 Events: | |
| 28 None. | |
| 29 --> | |
| 30 | |
| 31 <link rel="import" href="/res/imp/common/common-behavior.html"> | |
| 32 <link rel="import" href="/res/imp/common/swarming-app.html"> | |
| 33 | |
| 34 <dom-module id="swarming-index"> | |
| 35 <template> | |
| 36 <style include="swarming-app-style"> | |
| 37 .command { | |
| 38 font-family: monospace; | |
| 39 margin-bottom: 10px; | |
| 40 margin-top: 10px; | |
| 41 white-space: pre-wrap; | |
| 42 background-color: #f5f5f5; | |
| 43 border: 1px solid #ccc; | |
| 44 border-radius: 4px; | |
| 45 } | |
| 46 </style> | |
| 47 | |
| 48 <swarming-app | |
| 49 client_id="[[client_id]]" | |
| 50 auth_headers="{{_auth_headers}}" | |
| 51 permissions="{{_permissions}}" | |
| 52 server_details="{{_server_details}}" | |
| 53 name="Swarming Server" | |
| 54 busy="[[_or(_busy1,busy2)]]"> | |
| 55 | |
| 56 <h2>Service Status</h2> | |
| 57 <div>Server Version: [[_server_details.server_version]]</div> | |
| 58 <div>Bot Version: [[_server_details.bot_version]]</div> | |
| 59 <ul> | |
| 60 <li> | |
| 61 <!-- TODO(kjlubick) convert these linked pages to Polymer--> | |
| 62 <a href="/stats">Usage statistics</a> | |
| 63 </li> | |
| 64 <li> | |
| 65 <a href="/restricted/mapreduce/status">Map Reduce Jobs</a> | |
| 66 </li> | |
| 67 <li> | |
| 68 <a href$="[[_makeInstancesUrl(_server_details,_project_id)]]">View ver
sion's instances on Cloud Console</a> | |
| 69 </li> | |
| 70 <li> | |
| 71 <a><a href$="[[_makeErrorUrl(_project_id)]]">View server errors on Clo
ud Console</a></a> | |
| 72 </li> | |
| 73 <li> | |
| 74 <a><a href$="[[_makeLogUrl(_project_id)]]">View logs for HTTP 5xx on C
loud Console</a></a> | |
| 75 </li> | |
| 76 </ul> | |
| 77 | |
| 78 <h2>Configuration</h2> | |
| 79 <ul> | |
| 80 <!-- TODO(kjlubick) convert these linked pages to Polymer--> | |
| 81 <li> | |
| 82 <a href="/restricted/config">View server config</a> | |
| 83 </li> | |
| 84 <li> | |
| 85 <a href="/restricted/upload/bootstrap">View/upload bootstrap.py</a> | |
| 86 </li> | |
| 87 <li> | |
| 88 <a href="/restricted/upload/bot_config">View/upload bot_config.py</a> | |
| 89 </li> | |
| 90 <li> | |
| 91 <a href="/auth/groups">View/edit user groups</a> | |
| 92 </li> | |
| 93 </ul> | |
| 94 | |
| 95 <div hidden$="[[_cannotBootstrap(_permissions)]]"> | |
| 96 <h2>Bootstrapping a bot</h2> | |
| 97 To bootstrap a bot, run one of these (all links are valid for 1 hour): | |
| 98 <ol> | |
| 99 <li> | |
| 100 <strong> TL;DR; </strong> | |
| 101 <pre class="command">python -c "import urllib; exec urllib.urlopen('[[_host_ur
l]]/bootstrap?tok=[[_bootstrap_token]]').read()"</pre> | |
| 102 </li> | |
| 103 <li> | |
| 104 Escaped version to pass as a ssh argument: | |
| 105 <pre class="command">'python -c "import urllib; exec urllib.urlopen('"'[[_host
_url]]/bootstrap?tok=[[_bootstrap_token]]'"').read()"'</pre> | |
| 106 </li> | |
| 107 <li> | |
| 108 Manually: | |
| 109 <pre class="command" style="margin-bottom:0">mkdir bot; cd bot | |
| 110 rm -f swarming_bot.zip; curl -sSLOJ [[_host_url]]/bot_code?tok=[[_bootstrap_to
ken]] | |
| 111 python swarming_bot.zip</pre> | |
| 112 </li> | |
| 113 </ol> | |
| 114 </div> | |
| 115 | |
| 116 <!-- TODO(kjlubick): Enable this when the stats endpoint uses oauth | |
| 117 <h2>Stats</h2> | |
| 118 <div class="stats"> | |
| 119 <stats-overview | |
| 120 auth_headers=[[_auth_headers]] | |
| 121 busy="{{_busy2}}"> | |
| 122 </stats-overview> | |
| 123 </div> | |
| 124 --> | |
| 125 </swarming-app> | |
| 126 | |
| 127 </template> | |
| 128 <script> | |
| 129 Polymer({ | |
| 130 is: 'swarming-index', | |
| 131 | |
| 132 behaviors: [ | |
| 133 SwarmingBehaviors.CommonBehavior, | |
| 134 ], | |
| 135 | |
| 136 properties: { | |
| 137 client_id: { | |
| 138 type: String, | |
| 139 }, | |
| 140 | |
| 141 | |
| 142 _auth_headers: { | |
| 143 type: String, | |
| 144 }, | |
| 145 _bootstrap_token: { | |
| 146 type: String, | |
| 147 value: "...", | |
| 148 }, | |
| 149 _busy1: { | |
| 150 type: Boolean, | |
| 151 value: false, | |
| 152 }, | |
| 153 _busy2: { | |
| 154 type: Boolean, | |
| 155 value: false, | |
| 156 }, | |
| 157 _host_url: { | |
| 158 type: String, | |
| 159 value: function() { | |
| 160 return location.origin; | |
| 161 }, | |
| 162 }, | |
| 163 _permissions: { | |
| 164 type: Object, | |
| 165 }, | |
| 166 _project_id: { | |
| 167 type: String, | |
| 168 value: function() { | |
| 169 var idx = location.hostname.indexOf(".appspot.com"); | |
| 170 return location.hostname.substring(0, idx); | |
| 171 }, | |
| 172 }, | |
| 173 _server_details: { | |
| 174 type: Object, | |
| 175 }, | |
| 176 }, | |
| 177 | |
| 178 observers: ["_fetchBootstrap(_permissions,_auth_headers)"], | |
| 179 | |
| 180 | |
| 181 _cannotBootstrap: function(permissions) { | |
| 182 return !(permissions && permissions.get_bootstrap_token); | |
| 183 }, | |
| 184 | |
| 185 _fetchBootstrap: function(permissions, auth_headers) { | |
| 186 if (!auth_headers || !permissions || this._cannotBootstrap(permissions))
{ | |
| 187 return; | |
| 188 } | |
| 189 this.set("_busy1", true); | |
| 190 | |
| 191 sk.request("POST", "/_ah/api/swarming/v1/server/token", undefined, auth_
headers).then(JSON.parse).then(function(t) { | |
| 192 this.set("_bootstrap_token", t.bootstrap_token); | |
| 193 this.set("_busy1", false); | |
| 194 }.bind(this)).catch(function(reason) { | |
| 195 console.log("Could not get token", reason); | |
| 196 this.set("_busy1", false); | |
| 197 }.bind(this)); | |
| 198 }, | |
| 199 | |
| 200 _makeInstancesUrl: function(details, project_id) { | |
| 201 return "https://console.cloud.google.com/appengine/instances?project="+ | |
| 202 project_id+"&versionId="+details.server_version; | |
| 203 }, | |
| 204 | |
| 205 _makeErrorUrl: function(project_id) { | |
| 206 return "https://console.cloud.google.com/errors?project="+ | |
| 207 project_id; | |
| 208 }, | |
| 209 | |
| 210 _makeLogUrl: function(project_id) { | |
| 211 return "https://pantheon.corp.google.com/logs/viewer?filters=text:status
:500..599&project="+ | |
| 212 project_id; | |
| 213 }, | |
| 214 | |
| 215 }); | |
| 216 </script> | |
| 217 </dom-module> | |
| OLD | NEW |