cpee-model-management 1.0.17 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/tools/cpee-moma CHANGED
@@ -8,6 +8,7 @@ require 'zip'
8
8
  require 'typhoeus'
9
9
  require 'json'
10
10
  require 'securerandom'
11
+ require 'redis'
11
12
 
12
13
  def wrap(s, width=78, indent=18)
13
14
  lines = []
@@ -62,10 +63,12 @@ ARGV.options { |opt|
62
63
  opt.on(wrap("[cpui DIR] scaffolds a sample html client. New versions might require manual merging if you changed something."))
63
64
  opt.on("")
64
65
  opt.on(wrap("[convert] converts all testsets in the current directory to design terminology."))
66
+ opt.on("")
67
+ opt.on(wrap("[consistent] makes the instances db consistent. can only be run in server dir."))
65
68
  opt.parse!
66
69
  }
67
70
  if (ARGV.length == 0) ||
68
- (ARGV.length == 1 && !(%w(convert).include?(ARGV[0]))) ||
71
+ (ARGV.length == 1 && !(%w(convert consistent).include?(ARGV[0]))) ||
69
72
  (ARGV.length == 2 && !(%w(cpui new).include?(ARGV[0]))) ||
70
73
  (ARGV.length > 2)
71
74
  puts ARGV.options
@@ -182,6 +185,62 @@ elsif command == 'convert'
182
185
  File.unlink(f + '.creator') rescue nil
183
186
  File.unlink(f + '.author') rescue nil
184
187
  end
188
+ elsif command == 'consistent'
189
+ redis = Redis.new(path: 'redis.sock', db: 0)
190
+ redis.keys('*/instances').each do |instances|
191
+ engine = File.dirname(instances)
192
+ s_ready = s_running = s_stopped = 0
193
+ redis.lrange(instances,0,-1).each do |i|
194
+ prefix = File.join(engine,i.to_s)
195
+ url = redis.get(File.join(prefix,'instance-url'))
196
+ res = Typhoeus.get(url, :followlocation => true)
197
+ if res.success?
198
+ oldstate = redis.get(File.join(prefix,'state'))
199
+ case oldstate
200
+ when 'ready'
201
+ s_ready += 1
202
+ when 'running'
203
+ s_running += 1
204
+ when 'stopped'
205
+ s_stopped += 1
206
+ end
207
+ else
208
+ parent = redis.get(File.join(prefix,'parent'))
209
+ oldstate = redis.get(File.join(prefix,'state'))
210
+ children = redis.lrange(File.join(prefix,'children'),0,-1)
211
+ redis.multi do |multi|
212
+ multi.decr(File.join(engine,oldstate)) rescue nil
213
+ multi.incr(File.join(engine,'total_abandoned'))
214
+ multi.lrem(File.join(engine,'instances'),0,i.to_s)
215
+ multi.del(File.join(prefix,'instance-url'))
216
+ multi.del(File.join(prefix,'author'))
217
+ multi.del(File.join(prefix,'path'))
218
+ multi.del(File.join(prefix,'name'))
219
+ multi.del(File.join(prefix,'state'))
220
+ multi.del(File.join(prefix,'cpu'))
221
+ multi.del(File.join(prefix,'mem'))
222
+ multi.del(File.join(prefix,'time'))
223
+ children.each do |child|
224
+ if parent
225
+ multi.set(File.join(engine,child,'parent'),parent)
226
+ else
227
+ multi.del(File.join(engine,child,'parent'))
228
+ end
229
+ end
230
+ multi.del(File.join(prefix,'children'))
231
+ multi.del(File.join(prefix,'parent'))
232
+ if parent
233
+ multi.lrem(File.join(engine,parent,'children'),0,i.to_s)
234
+ end
235
+ end
236
+ end
237
+ end
238
+ redis.multi do |multi|
239
+ multi.set(File.join(engine,'ready'),s_ready.to_i)
240
+ multi.set(File.join(engine,'running'),s_running.to_i)
241
+ multi.set(File.join(engine,'stopped'),s_stopped.to_i)
242
+ end
243
+ end
185
244
  elsif command == 'new'
186
245
  if !File.exists?(p1)
187
246
  FileUtils.mkdir(File.join(p1)) rescue nil
data/ui/css/design.css CHANGED
@@ -26,6 +26,11 @@ ui-behind {
26
26
  color: #d0d0d0;
27
27
  }
28
28
 
29
+ ui-area > *:first-child {
30
+ padding-top: 0;
31
+ margin-top: 0;
32
+ }
33
+
29
34
  ui-behind span {
30
35
  cursor: pointer;
31
36
  }
data/ui/css/stats.css ADDED
@@ -0,0 +1,55 @@
1
+ #resources h1 {
2
+ font-size: 1.2em;
3
+ border-bottom: 0.1em solid var(--x-ui-border-color);
4
+ }
5
+
6
+ #resources table {
7
+ margin-left: 1.3em;
8
+ }
9
+
10
+ #instances h1 {
11
+ font-size: 1.2em;
12
+ border-bottom: 0.1em solid var(--x-ui-border-color);
13
+ }
14
+
15
+ .instances .text {
16
+ white-space: nowrap;
17
+ }
18
+ .instances .text > td {
19
+ display: inline-block;
20
+ white-space: nowrap;
21
+ overflow: hidden;
22
+ text-overflow: ellipsis;
23
+ padding-right: 0.5em;
24
+ padding-left: 0.5em;
25
+ }
26
+
27
+ .instances .name {
28
+ width: 12em;
29
+ }
30
+ .instances .state {
31
+ width: 7em
32
+ }
33
+ .instances .state:not([data-state=ready]):not([data-state=stopped]) > span.abandon {
34
+ display: none;
35
+ }
36
+ .instances .author {
37
+ width: 12em
38
+ }
39
+
40
+ .instances tr.sub, .instances tr.sub > td {
41
+ margin:0;
42
+ padding:0;
43
+ }
44
+
45
+ .instances .sub table {
46
+ margin-left: 0.8em;
47
+ }
48
+ .instances .sub table > tr.text > td:first-child::before {
49
+ content: '⤷';
50
+ margin-right: 0.5em;
51
+ }
52
+
53
+ .instances tr.text.even td {
54
+ background-color: var(--x-ui-content-light-background);
55
+ }
@@ -0,0 +1,7 @@
1
+ [is="x-ui-"] {
2
+ padding: 1em;
3
+ }
4
+ [is="x-ui-"] *:first-child {
5
+ padding-top: 0;
6
+ margin-top: 0;
7
+ }
data/ui/index.html CHANGED
@@ -35,6 +35,7 @@
35
35
  <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
36
  <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
37
  <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
+ <script type="text/javascript" src="/js_libs/plotly.min.js"></script>
38
39
 
39
40
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
40
41
 
@@ -52,20 +53,22 @@
52
53
 
53
54
  <!-- custom stuff, play arround -->
54
55
  <link rel="stylesheet" href="css/design.css" type="text/css"/>
56
+ <link rel="stylesheet" href="css/stats.css" type="text/css"/>
55
57
  <script type="text/javascript" src="js/design.js"></script>
58
+ <script type="text/javascript" src="js/stats.js"></script>
56
59
  </head>
57
60
  <body is="x-ui-">
58
61
  <ui-rest id="main">
59
62
  <ui-tabbar>
60
- <ui-before ></ui-before>
61
- <ui-tab class="" data-tab="models" >Models</ui-tab>
62
- <ui-tab class="inactive" data-tab="newmodel">New Model</ui-tab>
63
- <ui-tab class="inactive" data-tab="newdir" >New Dir</ui-tab>
64
- <ui-space ></ui-space>
65
- <ui-tab class="inactive" data-tab="running" >Running</ui-tab>
66
- <ui-tab class="inactive" data-tab="stopped" >Stopped</ui-tab>
67
- <ui-behind ><span></span></ui-behind>
68
- <ui-last ><a class="logo" href=".."></a></ui-last>
63
+ <ui-before ></ui-before>
64
+ <ui-tab class="" data-tab="models" >Models</ui-tab>
65
+ <ui-tab class="inactive" data-tab="newmodel" >New Model</ui-tab>
66
+ <ui-tab class="inactive" data-tab="newdir" >New Dir</ui-tab>
67
+ <ui-space ></ui-space>
68
+ <ui-tab class="inactive" data-tab="instances">Instances</ui-tab>
69
+ <ui-tab class="inactive" data-tab="resources">Resources</ui-tab>
70
+ <ui-behind ><span></span></ui-behind>
71
+ <ui-last ><a class="logo" href=".."></a></ui-last>
69
72
  </ui-tabbar>
70
73
  <ui-content class="noselect">
71
74
  <ui-area data-belongs-to-tab="models">
@@ -160,7 +163,62 @@
160
163
  <p>
161
164
  <button>New Directory</button>
162
165
  </p>
163
- </id>
166
+ </form>
167
+ </ui-area>
168
+ <ui-area data-belongs-to-tab="instances" class="inactive">
169
+ <p>
170
+ Show ready, running and stopped instances.
171
+ </p>
172
+ <template id="stats_instances">
173
+ <h1 class="stats_title">Engine: </h1>
174
+ <table class='instances'></table>
175
+ </template>
176
+ <template id="stats_instance">
177
+ <tr class="text">
178
+ <td class="name"><a href='' target='_blank'><em>no name</em></a></td>
179
+ <td class="num">(<span></span>)</td>
180
+ <td class="state"><span class='value'></span> <span class='abandon'>[<a href='#' title='abandon'>a</a>]</span></td>
181
+ <td class="author"><em>unknown</em></td>
182
+ <td class="mem"></em></td>
183
+ <td class="active"></em></td>
184
+ </tr>
185
+ <tr class="sub">
186
+ <td colspan="6"><table></table></td>
187
+ </tr>
188
+ </template>
189
+ <div id='instances'></div>
190
+ </ui-area>
191
+ <ui-area data-belongs-to-tab="resources" class="inactive">
192
+ <p>
193
+ Show statistics about instances per server, and metrics about the health of the environment.
194
+ </p>
195
+ <template id="stats_engine">
196
+ <h1 class="stats_title">Engine: </h1>
197
+ <div class="stats_plot"></div>
198
+ <div class="stats_text">
199
+ <table>
200
+ <tbody>
201
+ <tr>
202
+ <td>Total Instances <strong>Created</strong> / <strong>Finished</strong> / <strong>Abandoned</strong>:</td>
203
+ <td class='total_created'></td>
204
+ <td>/</td>
205
+ <td class='total_finished'></td>
206
+ <td>/</td>
207
+ <td class='total_abandoned'></td>
208
+ </tr>
209
+ <tr>
210
+ <td>Instances Currently <strong>Ready</strong> / <strong>Running</strong> / <strong>Stopped</strong>:</td>
211
+ <td class='current_ready'></td>
212
+ <td>/</td>
213
+ <td class='current_running'></td>
214
+ <td>/</td>
215
+ <td class='current_stopped'></td>
216
+ </tr>
217
+ </tbody>
218
+ </table>
219
+ </div>
220
+ </template>
221
+ <div id='resources'></div>
164
222
  </ui-area>
165
223
  </ui-content>
166
224
  </ui-rest>
data/ui/instances.html ADDED
@@ -0,0 +1,89 @@
1
+ <!--
2
+ This file is part of CPEE-MODEL-MANAGEMENT.
3
+
4
+ CPEE-MODEL-MANAGEMENT is free software: you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or (at your
7
+ option) any later version.
8
+
9
+ CPEE-MODEL-MANAGEMENT is distributed in the hope that it will be useful, but
10
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
+ more details.
13
+
14
+ You should have received a copy of the GNU General Public License along with
15
+ CPEE-MODEL-MANAGEMENT (file LICENSE in the main directory). If not, see
16
+ <http://www.gnu.org/licenses/>.
17
+ -->
18
+
19
+ <!DOCTYPE html>
20
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
21
+ <head>
22
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
23
+ <title>Instances</title>
24
+
25
+ <!-- libs, do not modify. When local than load local libs. -->
26
+ <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
27
+ <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
28
+ <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
29
+ <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
30
+ <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
31
+ <script type="text/javascript" src="/js_libs/util.js"></script>
32
+ <script type="text/javascript" src="/js_libs/printf.js"></script>
33
+ <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
34
+ <script type="text/javascript" src="/js_libs/parsequery.js"></script>
35
+ <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
+ <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
+ <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
+ <script type="text/javascript" src="/js_libs/plotly.min.js"></script>
39
+
40
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
41
+
42
+ <script type="text/javascript" src="/js_libs/relaxngui.js"></script>
43
+
44
+ <script type="text/javascript" src="/js_libs/uidash.js"></script>
45
+ <script type="text/javascript" src="/js_libs/custommenu.js"></script>
46
+
47
+ <link rel="stylesheet" href="/js_libs/custommenu.css" type="text/css"/>
48
+ <link rel="stylesheet" href="/js_libs/uidash.css" type="text/css"/>
49
+
50
+ <link rel="stylesheet" href="/global_ui/ui.css" type="text/css"/>
51
+
52
+ <link rel="stylesheet" href="/js_libs/relaxngui.css" type="text/css"/>
53
+
54
+ <!-- custom stuff, play arround -->
55
+ <link rel="stylesheet" href="css/design.css" type="text/css"/>
56
+ <link rel="stylesheet" href="css/stats.css" type="text/css"/>
57
+ <link rel="stylesheet" href="css/stats_standalone.css" type="text/css"/>
58
+ <script type="text/javascript" src="js/stats.js"></script>
59
+ <style>
60
+ [is="x-ui-"] {
61
+ overflow: scroll;
62
+ }
63
+ </style>
64
+ </head>
65
+ <body is="x-ui-">
66
+ <p>
67
+ Show ready, running and stopped instances.
68
+ </p>
69
+ <template id="stats_instances">
70
+ <h1 class="stats_title">Engine: </h1>
71
+ <table class='instances'></table>
72
+ </template>
73
+ <template id="stats_instance">
74
+ <tr class="text">
75
+ <td class="name"><a href='' target='_blank'><em>no name</em></a></td>
76
+ <td class="num">(<span></span>)</td>
77
+ <td class="state"><span class='value'></span> <span class='abandon'>[<a href='#' title='abandon'>a</a>]</span></td>
78
+ <td class="author"><em>unknown</em></td>
79
+ <td class="cpu"></td>
80
+ <td>/</td>
81
+ <td class="mem"></em></td>
82
+ </tr>
83
+ <tr class="sub">
84
+ <td colspan="6"><table></table></td>
85
+ </tr>
86
+ </template>
87
+ <div id='instances'></div>
88
+ </body>
89
+ </html>
@@ -0,0 +1,89 @@
1
+ <!--
2
+ This file is part of CPEE-MODEL-MANAGEMENT.
3
+
4
+ CPEE-MODEL-MANAGEMENT is free software: you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or (at your
7
+ option) any later version.
8
+
9
+ CPEE-MODEL-MANAGEMENT is distributed in the hope that it will be useful, but
10
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
+ more details.
13
+
14
+ You should have received a copy of the GNU General Public License along with
15
+ CPEE-MODEL-MANAGEMENT (file LICENSE in the main directory). If not, see
16
+ <http://www.gnu.org/licenses/>.
17
+ -->
18
+
19
+ <!DOCTYPE html>
20
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
21
+ <head>
22
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
23
+ <title>Instances</title>
24
+
25
+ <!-- libs, do not modify. When local than load local libs. -->
26
+ <script type="text/javascript" src="/js_libs/jquery.min.js"></script>
27
+ <script type="text/javascript" src="/js_libs/jquery.browser.js"></script>
28
+ <script type="text/javascript" src="/js_libs/jquery.svg.min.js"></script>
29
+ <script type="text/javascript" src="/js_libs/jquery.svgdom.min.js"></script>
30
+ <script type="text/javascript" src="/js_libs/vkbeautify.js"></script>
31
+ <script type="text/javascript" src="/js_libs/util.js"></script>
32
+ <script type="text/javascript" src="/js_libs/printf.js"></script>
33
+ <script type="text/javascript" src="/js_libs/strftime.min.js"></script>
34
+ <script type="text/javascript" src="/js_libs/parsequery.js"></script>
35
+ <script type="text/javascript" src="/js_libs/underscore.min.js"></script>
36
+ <script type="text/javascript" src="/js_libs/jquery.caret.min.js"></script>
37
+ <script type="text/javascript" src="/js_libs/jquery.cookie.js"></script>
38
+ <script type="text/javascript" src="/js_libs/plotly.min.js"></script>
39
+
40
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
41
+
42
+ <script type="text/javascript" src="/js_libs/relaxngui.js"></script>
43
+
44
+ <script type="text/javascript" src="/js_libs/uidash.js"></script>
45
+ <script type="text/javascript" src="/js_libs/custommenu.js"></script>
46
+
47
+ <link rel="stylesheet" href="/js_libs/custommenu.css" type="text/css"/>
48
+ <link rel="stylesheet" href="/js_libs/uidash.css" type="text/css"/>
49
+
50
+ <link rel="stylesheet" href="/global_ui/ui.css" type="text/css"/>
51
+
52
+ <link rel="stylesheet" href="/js_libs/relaxngui.css" type="text/css"/>
53
+
54
+ <!-- custom stuff, play arround -->
55
+ <link rel="stylesheet" href="css/design.css" type="text/css"/>
56
+ <link rel="stylesheet" href="css/stats.css" type="text/css"/>
57
+ <link rel="stylesheet" href="css/stats_standalone.css" type="text/css"/>
58
+ <script type="text/javascript" src="js/stats.js"></script>
59
+ <style>
60
+ [is="x-ui-"] {
61
+ overflow: scroll;
62
+ }
63
+ </style>
64
+ </head>
65
+ <body is="x-ui-">
66
+ <p>
67
+ Show ready, running and stopped instances.
68
+ </p>
69
+ <template id="stats_instances">
70
+ <h1 class="stats_title">Engine: </h1>
71
+ <table class='instances'></table>
72
+ </template>
73
+ <template id="stats_instance">
74
+ <tr class="text">
75
+ <td class="name"><a href='' target='_blank'><em>no name</em></a></td>
76
+ <td class="num">(<span></span>)</td>
77
+ <td class="state"><span class='value'></span></td>
78
+ <td class="author"><em>unknown</em></td>
79
+ <td class="cpu"></td>
80
+ <td>/</td>
81
+ <td class="mem"></em></td>
82
+ </tr>
83
+ <tr class="sub">
84
+ <td colspan="6"><table></table></td>
85
+ </tr>
86
+ </template>
87
+ <div id='instances'></div>
88
+ </body>
89
+ </html>
data/ui/js/design.js CHANGED
@@ -44,17 +44,17 @@ function delete_it(name) {
44
44
  }
45
45
  }
46
46
 
47
- function es_init(gdir,gstage) {
47
+ function design_init(gdir,gstage) {
48
48
  var es = new EventSource('server/');
49
49
  es.onopen = function() {
50
- console.log('es open');
50
+ console.log('design open');
51
51
  };
52
52
  es.onmessage = function(e) {
53
53
  paint(gdir,gstage);
54
54
  };
55
55
  es.onerror = function() {
56
- console.log('es error');
57
- // es_init();
56
+ console.log('design error');
57
+ // design_init();
58
58
  };
59
59
  }
60
60
 
@@ -114,7 +114,7 @@ $(document).ready(function() {
114
114
  gstage = urlParams.get('stage') || 'draft';
115
115
  gdir = urlParams.get('dir') ? (urlParams.get('dir') + '/').replace(/\/+/,'/') : '';
116
116
 
117
- es_init(gdir,gstage);
117
+ design_init(gdir,gstage);
118
118
 
119
119
  var shifts = []
120
120
  $.ajax({