right_chimp 1.0.7 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,6 +1,6 @@
1
1
  Chimp: a command-line tool for remote command execution using the RightScale platform
2
2
 
3
- The goal of the Chimp is to provide a simple command line utility for
3
+ The goal of the Chimp is to provide a simple command line utility for
4
4
  performing bulk operations on servers managed on the RightScale platform.
5
5
 
6
6
  EXAMPLE USAGE
@@ -18,7 +18,7 @@ Run a shell command on servers with a specific tag:
18
18
 
19
19
  chimp --tag="service:myservice=true" --ssh="uptime"
20
20
 
21
- Run a report:
21
+ Run a report:
22
22
 
23
23
  bin/chimp --tag="service:myservice=true" --report="nickname,ip-address,tag=myservice:version"
24
24
 
@@ -39,13 +39,13 @@ Would include both the server nickname and ip address to the report:
39
39
  server1-4.rightscale.com,192.168.0.4
40
40
 
41
41
  Any field present on a rest_connection Server object can be queried. This
42
- includes:
42
+ includes:
43
43
 
44
44
  Field Example
45
45
  ----------------------------------- ----------------------------
46
46
  aws-id i-12345
47
47
  aws-platform Linux/Unix
48
- cloud_id
48
+ cloud_id
49
49
  created_at
50
50
  current_instance_href
51
51
  deployment_href
@@ -77,4 +77,4 @@ Additionally you can report on instance tags:
77
77
 
78
78
  OBLIGATORY MAINTENANCE STRING
79
79
  -----------------------------
80
- maintained by Red_Team
80
+ Maintained by the RightScale Red_Team
@@ -434,35 +434,51 @@ module Chimp
434
434
  #
435
435
  class DisplayServlet < GenericServlet
436
436
  def do_GET(req, resp)
437
- job_filter = self.get_verb(req) || "running"
437
+ #
438
+ # First determine the path to the files to serve
439
+ #
440
+ if ENV['CHIMP_TEST'] != 'TRUE'
441
+ template_path = File.join(Gem.dir, 'gems', 'right_chimp-' + VERSION, 'lib/right_chimp/templates')
442
+ else
443
+ template_path = 'lib/right_chimp/templates'
444
+ end
438
445
 
439
- if not @template
440
- if ENV['CHIMP_TEST'] != 'TRUE'
441
- template_file_name = File.join(Gem.dir, 'gems', 'right_chimp-' + VERSION, 'lib/right_chimp/templates/all_jobs.erb')
442
- else
443
- template_file_name = 'lib/right_chimp/templates/all_jobs.erb'
444
- end
446
+ #
447
+ # Check for static CSS files and serve them
448
+ #
449
+ if req.request_uri.path =~ /\.(css|js)$/
450
+ filename = req.request_uri.path.split('/').last
451
+ resp.body = File.read(File.join(template_path, filename))
452
+ raise WEBrick::HTTPStatus::OK
453
+ else
445
454
 
446
- @template = ERB.new(File.read(template_file_name), nil, ">")
447
- end
455
+ #
456
+ # Otherwise process ERB template
457
+ #
458
+ job_filter = self.get_verb(req) || "running"
459
+
460
+ if not @template
461
+ @template = ERB.new(File.read(File.join(template_path, "all_jobs.erb")), nil, ">")
462
+ end
448
463
 
449
- queue = ChimpQueue.instance
450
- jobs = queue.get_jobs
451
- group_name = nil
464
+ queue = ChimpQueue.instance
465
+ jobs = queue.get_jobs
466
+ group_name = nil
452
467
 
453
- if job_filter == "group"
454
- group_name = req.request_uri.path.split('/')[-1]
455
- g = ChimpQueue[group_name.to_sym]
456
- jobs = g.get_jobs if g
457
- end
468
+ if job_filter == "group"
469
+ group_name = req.request_uri.path.split('/')[-1]
470
+ g = ChimpQueue[group_name.to_sym]
471
+ jobs = g.get_jobs if g
472
+ end
458
473
 
459
- count_jobs_running = queue.get_jobs_by_status(:running).size
460
- count_jobs_queued = queue.get_jobs_by_status(:none).size
461
- count_jobs_failed = queue.get_jobs_by_status(:error).size
462
- count_jobs_done = queue.get_jobs_by_status(:done).size
474
+ count_jobs_running = queue.get_jobs_by_status(:running).size
475
+ count_jobs_queued = queue.get_jobs_by_status(:none).size
476
+ count_jobs_failed = queue.get_jobs_by_status(:error).size
477
+ count_jobs_done = queue.get_jobs_by_status(:done).size
463
478
 
464
- resp.body = @template.result(binding)
465
- raise WEBrick::HTTPStatus::OK
479
+ resp.body = @template.result(binding)
480
+ raise WEBrick::HTTPStatus::OK
481
+ end
466
482
  end
467
483
  end # DisplayServlet
468
484
  end # ChimpDaemon
@@ -5,13 +5,13 @@
5
5
  module Chimp
6
6
  class QueueWorker
7
7
  attr_accessor :delay, :retry_count, :never_exit
8
-
8
+
9
9
  def initialize
10
10
  @delay = 0
11
11
  @retry_count = 0
12
12
  @never_exit = true
13
13
  end
14
-
14
+
15
15
  #
16
16
  # Grab work items from the ChimpQueue and process them
17
17
  # Only stop is @ever_exit is false
@@ -29,14 +29,21 @@ module Chimp
29
29
  else
30
30
  sleep 1
31
31
  end
32
-
33
- rescue StandardError => ex
34
- $stderr.puts "Exception in QueueWorker.run: #{ex}"
35
- puts ex.inspect
36
- puts ex.backtrace
32
+
33
+ #
34
+ # the rest_connection gem raises RuntimeErrors so we need to
35
+ # rescue Exception here
36
+ #
37
+ rescue Exception => ex
38
+ Log.error "Exception in QueueWorker.run: #{ex}"
39
+ Log.debug ex.inspect
40
+ Log.debug ex.backtrace
41
+
42
+ work_item.status = Executor::STATUS_ERROR
43
+ work_item.error = ex
37
44
  end
38
45
  end
39
46
  end
40
-
47
+
41
48
  end
42
49
  end
@@ -1,83 +1,22 @@
1
1
  <html><head>
2
2
  <title>chimpd</title>
3
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
3
4
  <meta http-equiv="refresh" content="5">
4
- <style type="text/css">
5
- body {
6
- color: #088A29;
7
- background-color: black;
8
- font-family: monospace;
9
- font-size: 10px;
10
- margin: 0;
5
+ <link rel="stylesheet" href="default.css" title="default" />
6
+ <link rel="alternate stylesheet" href="greenscreen.css" title="greenscreen" />
7
+ <link rel="alternate stylesheet" href="hotdogstand.css" title="hotdogstand" />
8
+ <script src="styleswitcher.js"></script>
9
+
10
+ <script type="text/javascript">
11
+
12
+ function chimpd_job_control(obj, url) {
13
+ obj.style.color = "red";
14
+ xmlhttp = new XMLHttpRequest();
15
+ xmlhttp.open("GET", url, true);
16
+ xmlhttp.send();
11
17
  }
12
-
13
- h3 {
14
- font-weight: bold;
15
- border-bottom: 2px solid #088A29;
16
- }
17
-
18
- ol, ul {
19
- list-style-type: none;
20
- }
21
-
22
- ol {
23
- padding-left: 10px;
24
- }
25
-
26
- ul {
27
- padding-bottom: 5px;
28
- border-bottom: solid #088A29 2px;
29
- }
30
-
31
- div#stats {
32
- background-color: black; /* #002A5C */
33
- color: #088A29;
34
- float: left;
35
- border-right: solid 2px #088A29;
36
- position: fixed;
37
- height: 100%;
38
- padding: 5px;
39
- padding-right: 15px;
40
- }
41
-
42
- div#jobs {
43
- position: absolute;
44
- left: 375px;
45
- top: 10px;
46
- width: 500px;
47
- padding-left: 20px;
48
- color: #088A29;
49
- }
50
-
51
- div#groups {
52
- color: #088A29;
53
- background-color: black;
54
- }
55
-
56
- div#groups a {
57
- color: #088A29;
58
- background-color: black;
59
- }
60
-
61
- .highlight {
62
- background-color: #088A29;
63
- color: black;
64
- }
65
-
66
- td {
67
- padding-right: 10px;
68
- }
69
-
70
- a {
71
- text-decoration: underline;
72
- color: #088A29;
73
- font-weight: bold;
74
- }
75
-
76
- a:hover, ol a:hover {
77
- text-decoration: underline;
78
- }
79
-
80
- </style>
18
+
19
+ </script>
81
20
 
82
21
  </head><body>
83
22
 
@@ -106,12 +45,12 @@ SINCE 2012</p>
106
45
  </table>
107
46
 
108
47
  <h3>Job Groups</h3>
109
- <div id="groups" width="90%" style="border: solid 1px #088A29; overflow-y: auto; height: 150px; background: black; color: #088A29;">
48
+ <div id="groups" width="90%" >
110
49
  <ol style="margin: 0; padding: 3px;">
111
50
  <% queue.group.values.each do |g| %>
112
51
  <li>
113
52
  [<%= sprintf( "%03d", g.get_jobs_by_status(:running).size) %>/<%= sprintf( "%03d", g.get_job_ids.size) %> <%= g.short_name %>] <% if group_name == g.group_id %><span class="highlight"><%=g.group_id%></span><% else %><a href="/display/group/<%=g.group_id%>"><%= g.group_id %></a><% end %>
114
-
53
+
115
54
  </li>
116
55
  <% end %>
117
56
  </ol>
@@ -120,19 +59,26 @@ SINCE 2012</p>
120
59
 
121
60
  <h3>Filter Results</h3>
122
61
 
123
- <p>[
124
- <% if job_filter == 'running' or job_filter == nil %>running jobs <% else %><a href="/display/running">running jobs</a><% end %> |
62
+ <p>[
63
+ <% if job_filter == 'running' or job_filter == nil %>running jobs <% else %><a href="/display/running">running jobs</a><% end %> |
125
64
  <% if job_filter == 'all' %>all jobs <% else %><a href="/display/all">all jobs</a> <% end %> |
126
- <% if job_filter == 'done' %>complete jobs <% else %><a href="/display/done">complete jobs</a><% end %> |
65
+ <% if job_filter == 'done' %>complete jobs <% else %><a href="/display/done">complete jobs</a><% end %> |
127
66
  <% if job_filter == 'error' %>failed jobs <% else %><a href="/display/error">failed jobs</a><% end %>
128
67
  ]
129
68
  </p>
130
69
 
131
70
  <h3>Commands</h3>
132
71
  <ol>
133
- <li><a href="/job/running/cancel">cancel running jobs</a></li>
134
- <li><a href="/job/error/retry">retry failed jobs </a></li>
135
- <li><a href="/job/all/report">download execution report</a></li>
72
+ <li><a href="#" onclick="chimpd_job_control(this, '/job/running/cancel')">cancel running jobs</a></li>
73
+ <li><a href="#" onclick="chimpd_job_control(this, '/job/error/retry')">retry failed jobs </a></li>
74
+ <li><a href="#" onclick="chimpd_job_control(this, '/job/all/report')">download execution report</a></li>
75
+ </ol>
76
+
77
+ <h3>Theme</h3>
78
+ <ol>
79
+ <li> <a href="#" onclick="setActiveStyleSheet('default')">default</a></li>
80
+ <li> <a href="#" onclick="setActiveStyleSheet('greenscreen')">green screen</a></li>
81
+ <li> <a href="#" onclick="setActiveStyleSheet('hotdogstand')">hot dog stand</a></li>
136
82
  </ol>
137
83
 
138
84
  </div>
@@ -144,7 +90,7 @@ SINCE 2012</p>
144
90
  <h1>Job Group: <%=CGI::escapeHTML(group_name)%></h1>
145
91
  <% end %>
146
92
 
147
- <%
93
+ <%
148
94
  #
149
95
  # Print out all the jobs
150
96
  #
@@ -154,12 +100,12 @@ end
154
100
 
155
101
  jobs.each do |j|
156
102
  next unless j
157
-
103
+
158
104
  status = j.status
159
105
  id = j.job_id
160
106
 
161
107
  server_name = CGI::escapeHTML(j.server['nickname']) if j.server
162
-
108
+
163
109
  if j.exec
164
110
  action = j.exec.to_s
165
111
  action = j.exec['right_script']['name'] if j.exec['right_script']
@@ -170,8 +116,8 @@ jobs.each do |j|
170
116
  if job_filter and not (job_filter == 'all' or job_filter == 'group' )
171
117
  next unless status == job_filter.to_sym
172
118
  end
173
-
174
- execution_time_seconds = j.get_total_exec_time
119
+
120
+ execution_time_seconds = j.get_total_exec_time
175
121
  h = (execution_time_seconds/3600).to_i
176
122
  m = (execution_time_seconds/60 - h*60).to_i
177
123
  s = (execution_time_seconds - (m*60 + h*3600))
@@ -179,9 +125,9 @@ jobs.each do |j|
179
125
 
180
126
  %>
181
127
 
182
- <h2 style="float: left; color: #088A29">#<%= id %></h2>
128
+ <h2>#<%= id %></h2>
183
129
  <%
184
- color = "#088A29"
130
+ color = "#088A29"
185
131
  color = "brightgreen" if status == Executor::STATUS_RUNNING
186
132
  color = "orange" if status == Executor::STATUS_RETRYING
187
133
  color = "red" if status == Executor::STATUS_ERROR
@@ -195,15 +141,15 @@ jobs.each do |j|
195
141
  <% if status != Executor::STATUS_RUNNING %>
196
142
  <li>Results: <span style="color:#777"><%= j.results %></span></li>
197
143
  <% end %>
198
-
144
+
199
145
  <li> <span class="action">
200
146
  <% if status == Executor::STATUS_ERROR %>
201
- <a href="/job/<%=id%>/ack">ack</a> |
202
- <a href="/job/<%=id%>/retry">retry</a>
147
+ <a href="#" onclick="chimpd_job_control(this, '/job/<%=id%>/ack')">ack</a> |
148
+ <a href="#" onclick="chimpd_job_control(this, '/job/<%=id%>/retry')">retry</a>
203
149
  <% elsif status == Executor::STATUS_RUNNING %>
204
- <a href="/job/<%=id%>/cancel">cancel</a>
150
+ <a href="#" onclick="chimpd_job_control(this, '/job/<%=id%>/cancel')">cancel</a>
205
151
  <% else %>
206
- <a href="/job/<%=id%>/retry">requeue</a>
152
+ <a href="#" onclick="chimpd_job_control(this, '/job/<%=id%>/retry')">requeue</a>
207
153
  <% end %>
208
154
  </li>
209
155
  </ul>
@@ -0,0 +1,81 @@
1
+ body {
2
+ color: black;
3
+ background-color: white;
4
+ font-family: monospace;
5
+ font-size: 10px;
6
+ margin: 0;
7
+ }
8
+
9
+ h3 {
10
+ font-weight: bold;
11
+ border-bottom: 2px solid black;
12
+ }
13
+
14
+ h2 {
15
+ float: left;
16
+ }
17
+
18
+ ol, ul {
19
+ list-style-type: none;
20
+ }
21
+
22
+ ol {
23
+ padding-left: 10px;
24
+ }
25
+
26
+ ul {
27
+ padding-bottom: 5px;
28
+ border-bottom: solid black 2px;
29
+ }
30
+
31
+ div#stats {
32
+ background-color: white; /* #002A5C */
33
+ color: black;
34
+ float: left;
35
+ border-right: solid 2px black;
36
+ position: fixed;
37
+ height: 100%;
38
+ padding: 5px;
39
+ padding-right: 15px;
40
+ }
41
+
42
+ div#jobs {
43
+ position: absolute;
44
+ left: 375px;
45
+ top: 10px;
46
+ width: 500px;
47
+ padding-left: 20px;
48
+ color: black;
49
+ }
50
+
51
+ div#groups {
52
+ color: black;
53
+ background-color: white;
54
+ border: solid 1px;
55
+ overflow-y: auto;
56
+ height: 150px;
57
+ }
58
+
59
+ div#groups a {
60
+ color: black;
61
+ background-color: white;
62
+ }
63
+
64
+ .highlight {
65
+ background-color: black;
66
+ color: white;
67
+ }
68
+
69
+ td {
70
+ padding-right: 10px;
71
+ }
72
+
73
+ a {
74
+ text-decoration: underline;
75
+ color: black;
76
+ font-weight: bold;
77
+ }
78
+
79
+ a:hover, ol a:hover {
80
+ text-decoration: underline;
81
+ }
@@ -0,0 +1,82 @@
1
+ body {
2
+ color: #088A29;
3
+ background-color: black;
4
+ font-family: monospace;
5
+ font-size: 10px;
6
+ margin: 0;
7
+ }
8
+
9
+ h3 {
10
+ font-weight: bold;
11
+ border-bottom: 2px solid #088A29;
12
+ }
13
+
14
+ h2 {
15
+ float: left;
16
+ color: #088A29;
17
+ }
18
+
19
+ ol, ul {
20
+ list-style-type: none;
21
+ }
22
+
23
+ ol {
24
+ padding-left: 10px;
25
+ }
26
+
27
+ ul {
28
+ padding-bottom: 5px;
29
+ border-bottom: solid #088A29 2px;
30
+ }
31
+
32
+ div#stats {
33
+ background-color: black; /* #002A5C */
34
+ color: #088A29;
35
+ float: left;
36
+ border-right: solid 2px #088A29;
37
+ position: fixed;
38
+ height: 100%;
39
+ padding: 5px;
40
+ padding-right: 15px;
41
+ }
42
+
43
+ div#jobs {
44
+ position: absolute;
45
+ left: 375px;
46
+ top: 10px;
47
+ width: 500px;
48
+ padding-left: 20px;
49
+ color: #088A29;
50
+ }
51
+
52
+ div#groups {
53
+ color: #088A29;
54
+ background-color: black;
55
+ border: solid 1px #088A29;
56
+ overflow-y: auto;
57
+ height: 150px;
58
+ }
59
+
60
+ div#groups a {
61
+ color: #088A29;
62
+ background-color: black;
63
+ }
64
+
65
+ .highlight {
66
+ background-color: #088A29;
67
+ color: black;
68
+ }
69
+
70
+ td {
71
+ padding-right: 10px;
72
+ }
73
+
74
+ a {
75
+ text-decoration: underline;
76
+ color: #088A29;
77
+ font-weight: bold;
78
+ }
79
+
80
+ a:hover, ol a:hover {
81
+ text-decoration: underline;
82
+ }
@@ -0,0 +1,82 @@
1
+ body {
2
+ color: yellow;
3
+ background-color: red;
4
+ font-family: monospace;
5
+ font-size: 10px;
6
+ margin: 0;
7
+ }
8
+
9
+ h3 {
10
+ font-weight: bold;
11
+ border-bottom: 2px solid yellow;
12
+ }
13
+
14
+ h2 {
15
+ float: left;
16
+ color: yellow;
17
+ }
18
+
19
+ ol, ul {
20
+ list-style-type: none;
21
+ }
22
+
23
+ ol {
24
+ padding-left: 10px;
25
+ }
26
+
27
+ ul {
28
+ padding-bottom: 5px;
29
+ border-bottom: solid yellow 2px;
30
+ }
31
+
32
+ div#stats {
33
+ background-color: red; /* #002A5C */
34
+ color: yellow;
35
+ float: left;
36
+ border-right: solid 2px yellow;
37
+ position: fixed;
38
+ height: 100%;
39
+ padding: 5px;
40
+ padding-right: 15px;
41
+ }
42
+
43
+ div#jobs {
44
+ position: absolute;
45
+ left: 375px;
46
+ top: 10px;
47
+ width: 500px;
48
+ padding-left: 20px;
49
+ color: yellow;
50
+ }
51
+
52
+ div#groups {
53
+ color: yellow;
54
+ background-color: red;
55
+ border: solid 1px yellow;
56
+ overflow-y: auto;
57
+ height: 150px;
58
+ }
59
+
60
+ div#groups a {
61
+ color: yellow;
62
+ background-color: red;
63
+ }
64
+
65
+ .highlight {
66
+ background-color: yellow;
67
+ color: red;
68
+ }
69
+
70
+ td {
71
+ padding-right: 10px;
72
+ }
73
+
74
+ a {
75
+ text-decoration: underline;
76
+ color: yellow;
77
+ font-weight: bold;
78
+ }
79
+
80
+ a:hover, ol a:hover {
81
+ text-decoration: underline;
82
+ }
@@ -0,0 +1 @@
1
+ function setActiveStyleSheet(title) {
2
  var i, a, main;
1
3
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
2
4
  if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
3
5
  a.disabled = true;
4
6
  if(a.getAttribute("title") == title) a.disabled = false;
5
7
  }
6
8
  }
7
9
  var i, a;
8
10
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
9
11
  if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
10
12
  }
11
13
  return null;
12
14
  var i, a;
13
15
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
14
16
  if(a.getAttribute("rel").indexOf("style") != -1
15
17
  && a.getAttribute("rel").indexOf("alt") == -1
16
18
  && a.getAttribute("title")
17
19
  ) return a.getAttribute("title");
18
20
  }
19
21
  return null;
20
22
  if (days) {
21
23
  var date = new Date();
22
24
  date.setTime(date.getTime()+(days*24*60*60*1000));
23
25
  var expires = "; expires="+date.toGMTString();
24
26
  }
25
27
  else expires = "";
26
28
  document.cookie = name+"="+value+expires+"; path=/";
27
29
  var nameEQ = name + "=";
28
30
  var ca = document.cookie.split(';');
29
31
  for(var i=0;i < ca.length;i++) {
30
32
  var c = ca[i];
31
33
  while (c.charAt(0)==' ') c = c.substring(1,c.length);
32
34
  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
33
35
  }
34
36
  return null;
35
37
  var cookie = readCookie("style");
36
38
  var title = cookie ? cookie : getPreferredStyleSheet();
37
39
  setActiveStyleSheet(title);
38
40
  var title = getActiveStyleSheet();
39
41
  createCookie("style", title, 365);
@@ -1,3 +1,3 @@
1
1
  module Chimp
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_chimp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-24 00:00:00.000000000 Z
12
+ date: 2013-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest_connection
@@ -143,6 +143,10 @@ files:
143
143
  - lib/right_chimp/queue/ExecutionGroup.rb
144
144
  - lib/right_chimp/queue/QueueWorker.rb
145
145
  - lib/right_chimp/templates/all_jobs.erb
146
+ - lib/right_chimp/templates/default.css
147
+ - lib/right_chimp/templates/greenscreen.css
148
+ - lib/right_chimp/templates/hotdogstand.css
149
+ - lib/right_chimp/templates/styleswitcher.js
146
150
  - lib/right_chimp/version.rb
147
151
  - spec/spec_chimp.rb
148
152
  - spec/spec_chimp_commandline.rb