naf 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +17 -0
- data/LICENSE +2 -0
- data/README.rdoc +22 -0
- data/RELEASE_NOTES.rdoc +18 -0
- data/Rakefile +43 -0
- data/app/assets/images/bg-grad.png +0 -0
- data/app/assets/images/clock.png +0 -0
- data/app/assets/images/control_play_blue.png +0 -0
- data/app/assets/images/down_arrow.gif +0 -0
- data/app/assets/images/papertrail_job.png +0 -0
- data/app/assets/images/papertrail_machine.png +0 -0
- data/app/assets/images/papertrail_machine_runner.png +0 -0
- data/app/assets/images/terminate.png +0 -0
- data/app/assets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/app/assets/images/ui-bg_flat_0_ffffff_40x100.png +0 -0
- data/app/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/app/assets/images/ui-bg_glass_0_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_65_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_75_f4f4f4_1x400.png +0 -0
- data/app/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/app/assets/images/ui-bg_highlight-soft_0_f4f4f4_1x100.png +0 -0
- data/app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/app/assets/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/app/assets/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/ui-icons_888888_256x240.png +0 -0
- data/app/assets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/app/assets/images/up_arrow.gif +0 -0
- data/app/assets/javascripts/dataTablesTemplates/applications.js +94 -0
- data/app/assets/javascripts/dataTablesTemplates/jobs.js +163 -0
- data/app/assets/javascripts/dataTablesTemplates/machine_runner_invocations.js +60 -0
- data/app/assets/javascripts/dataTablesTemplates/machine_runners.js +82 -0
- data/app/assets/javascripts/dataTablesTemplates/machines.js +93 -0
- data/app/assets/javascripts/date.js +104 -0
- data/app/assets/javascripts/iso8601.js +41 -0
- data/app/assets/javascripts/jquery.dataTables.custom.js +62 -0
- data/app/assets/javascripts/jquery.dataTables.js +6862 -0
- data/app/assets/javascripts/naf.js +30 -0
- data/app/assets/javascripts/underscore.js +713 -0
- data/app/assets/stylesheets/jquery_ui/jquery-ui-1.8.5.custom.css.erb +572 -0
- data/app/assets/stylesheets/min_naf.css +14 -0
- data/app/assets/stylesheets/min_naf/layout.css.scss +355 -0
- data/app/assets/stylesheets/naf.css +14 -0
- data/app/assets/stylesheets/naf/layout.css.scss +497 -0
- data/app/controllers/naf/affinities_controller.rb +61 -0
- data/app/controllers/naf/application_controller.rb +43 -0
- data/app/controllers/naf/application_schedule_affinity_tabs_controller.rb +75 -0
- data/app/controllers/naf/applications_controller.rb +153 -0
- data/app/controllers/naf/historical_job_affinity_tabs_controller.rb +65 -0
- data/app/controllers/naf/historical_jobs_controller.rb +159 -0
- data/app/controllers/naf/janitorial_assignments_controller.rb +77 -0
- data/app/controllers/naf/logger_names_controller.rb +58 -0
- data/app/controllers/naf/logger_styles_controller.rb +59 -0
- data/app/controllers/naf/machine_affinity_slots_controller.rb +69 -0
- data/app/controllers/naf/machine_runner_invocations_controller.rb +59 -0
- data/app/controllers/naf/machine_runners_controller.rb +26 -0
- data/app/controllers/naf/machines_controller.rb +95 -0
- data/app/helpers/naf/application_helper.rb +275 -0
- data/app/models/log4r/papertrail_outputter.rb +19 -0
- data/app/models/logical/naf/application.rb +183 -0
- data/app/models/logical/naf/construction_zone/ad_hoc_work_order.rb +22 -0
- data/app/models/logical/naf/construction_zone/application_schedule_work_order.rb +15 -0
- data/app/models/logical/naf/construction_zone/application_work_order.rb +25 -0
- data/app/models/logical/naf/construction_zone/boss.rb +123 -0
- data/app/models/logical/naf/construction_zone/foreman.rb +53 -0
- data/app/models/logical/naf/construction_zone/proletariat.rb +40 -0
- data/app/models/logical/naf/construction_zone/work_order.rb +100 -0
- data/app/models/logical/naf/create_infrastructure.rb +48 -0
- data/app/models/logical/naf/job.rb +357 -0
- data/app/models/logical/naf/job_creator.rb +155 -0
- data/app/models/logical/naf/job_fetcher.rb +167 -0
- data/app/models/logical/naf/job_statuses/errored.rb +27 -0
- data/app/models/logical/naf/job_statuses/finished.rb +26 -0
- data/app/models/logical/naf/job_statuses/finished_less_minute.rb +25 -0
- data/app/models/logical/naf/job_statuses/queued.rb +32 -0
- data/app/models/logical/naf/job_statuses/running.rb +34 -0
- data/app/models/logical/naf/job_statuses/terminated.rb +25 -0
- data/app/models/logical/naf/job_statuses/waiting.rb +43 -0
- data/app/models/logical/naf/machine.rb +85 -0
- data/app/models/logical/naf/machine_runner.rb +46 -0
- data/app/models/logical/naf/machine_runner_invocation.rb +50 -0
- data/app/models/logical/naf/pickler.rb +74 -0
- data/app/models/logical/naf/unpickler.rb +98 -0
- data/app/models/naf/affinity.rb +145 -0
- data/app/models/naf/affinity_classification.rb +44 -0
- data/app/models/naf/application.rb +100 -0
- data/app/models/naf/application_run_group_restriction.rb +39 -0
- data/app/models/naf/application_schedule.rb +181 -0
- data/app/models/naf/application_schedule_affinity_tab.rb +86 -0
- data/app/models/naf/application_schedule_prerequisite.rb +50 -0
- data/app/models/naf/application_type.rb +72 -0
- data/app/models/naf/by_historical_job_id.rb +86 -0
- data/app/models/naf/historical_job.rb +334 -0
- data/app/models/naf/historical_job_affinity_tab.rb +61 -0
- data/app/models/naf/historical_job_prerequisite.rb +19 -0
- data/app/models/naf/janitorial_archive_assignment.rb +36 -0
- data/app/models/naf/janitorial_assignment.rb +37 -0
- data/app/models/naf/janitorial_create_assignment.rb +36 -0
- data/app/models/naf/janitorial_drop_assignment.rb +36 -0
- data/app/models/naf/logger_level.rb +21 -0
- data/app/models/naf/logger_name.rb +23 -0
- data/app/models/naf/logger_style.rb +58 -0
- data/app/models/naf/logger_style_name.rb +28 -0
- data/app/models/naf/machine.rb +257 -0
- data/app/models/naf/machine_affinity_slot.rb +78 -0
- data/app/models/naf/machine_runner.rb +51 -0
- data/app/models/naf/machine_runner_invocation.rb +71 -0
- data/app/models/naf/naf_base.rb +9 -0
- data/app/models/naf/queued_job.rb +164 -0
- data/app/models/naf/running_job.rb +80 -0
- data/app/models/process/naf/application.rb +164 -0
- data/app/models/process/naf/janitor.rb +117 -0
- data/app/models/process/naf/machine_manager.rb +150 -0
- data/app/models/process/naf/machine_upgrader.rb +112 -0
- data/app/models/process/naf/runner.rb +539 -0
- data/app/views/naf/affinities/_form.html.erb +50 -0
- data/app/views/naf/affinities/edit.html.erb +11 -0
- data/app/views/naf/affinities/index.html.erb +57 -0
- data/app/views/naf/affinities/new.html.erb +15 -0
- data/app/views/naf/affinities/show.html.erb +48 -0
- data/app/views/naf/application_schedule_affinity_tabs/_form.html.erb +31 -0
- data/app/views/naf/application_schedule_affinity_tabs/edit.html.erb +12 -0
- data/app/views/naf/application_schedule_affinity_tabs/new.html.erb +11 -0
- data/app/views/naf/applications/_application_schedule.html.erb +80 -0
- data/app/views/naf/applications/_application_schedule_prerequisites.html.erb +14 -0
- data/app/views/naf/applications/_form.html.erb +109 -0
- data/app/views/naf/applications/_search_container.html.erb +94 -0
- data/app/views/naf/applications/_show.html.erb +34 -0
- data/app/views/naf/applications/edit.html.erb +11 -0
- data/app/views/naf/applications/index.html.erb +51 -0
- data/app/views/naf/applications/index.json.erb +11 -0
- data/app/views/naf/applications/new.html.erb +11 -0
- data/app/views/naf/applications/show.html.erb +203 -0
- data/app/views/naf/datatable.html.erb +49 -0
- data/app/views/naf/historical_job_affinity_tabs/_form.html.erb +36 -0
- data/app/views/naf/historical_job_affinity_tabs/edit.html.erb +11 -0
- data/app/views/naf/historical_job_affinity_tabs/new.html.erb +11 -0
- data/app/views/naf/historical_jobs/_form.html.erb +94 -0
- data/app/views/naf/historical_jobs/_runners.html.erb +22 -0
- data/app/views/naf/historical_jobs/_search_container.html.erb +140 -0
- data/app/views/naf/historical_jobs/edit.html.erb +11 -0
- data/app/views/naf/historical_jobs/index.html.erb +48 -0
- data/app/views/naf/historical_jobs/index.json.erb +26 -0
- data/app/views/naf/historical_jobs/new.html.erb +61 -0
- data/app/views/naf/historical_jobs/show.html.erb +201 -0
- data/app/views/naf/janitorial_assignments/_form.html.erb +38 -0
- data/app/views/naf/janitorial_assignments/_rows.html.erb +17 -0
- data/app/views/naf/janitorial_assignments/edit.html.erb +11 -0
- data/app/views/naf/janitorial_assignments/index.html.erb +56 -0
- data/app/views/naf/janitorial_assignments/index.js.erb +1 -0
- data/app/views/naf/janitorial_assignments/new.html.erb +11 -0
- data/app/views/naf/layouts/jquery_datatables.json.erb +6 -0
- data/app/views/naf/logger_names/_form.html.erb +18 -0
- data/app/views/naf/logger_names/edit.html.erb +11 -0
- data/app/views/naf/logger_names/new.html.erb +11 -0
- data/app/views/naf/logger_names/show.html.erb +44 -0
- data/app/views/naf/logger_styles/_form.html.erb +30 -0
- data/app/views/naf/logger_styles/_logger_style_names.html.erb +19 -0
- data/app/views/naf/logger_styles/edit.html.erb +11 -0
- data/app/views/naf/logger_styles/new.html.erb +11 -0
- data/app/views/naf/logger_styles/show.html.erb +48 -0
- data/app/views/naf/machine_affinity_slots/_form.html.erb +36 -0
- data/app/views/naf/machine_affinity_slots/edit.html.erb +11 -0
- data/app/views/naf/machine_affinity_slots/new.html.erb +11 -0
- data/app/views/naf/machine_runner_invocations/_filter.html.erb +21 -0
- data/app/views/naf/machine_runner_invocations/index.html.erb +36 -0
- data/app/views/naf/machine_runner_invocations/index.json.erb +16 -0
- data/app/views/naf/machine_runner_invocations/show.html.erb +91 -0
- data/app/views/naf/machine_runners/index.html.erb +82 -0
- data/app/views/naf/machine_runners/index.json.erb +16 -0
- data/app/views/naf/machine_runners/show.html.erb +113 -0
- data/app/views/naf/machines/_filter.html.erb +26 -0
- data/app/views/naf/machines/_form.html.erb +62 -0
- data/app/views/naf/machines/_show.html.erb +169 -0
- data/app/views/naf/machines/edit.html.erb +11 -0
- data/app/views/naf/machines/index.html.erb +51 -0
- data/app/views/naf/machines/index.json.erb +23 -0
- data/app/views/naf/machines/new.html.erb +11 -0
- data/app/views/naf/machines/show.html.erb +92 -0
- data/app/views/naf/record.html.erb +46 -0
- data/app/views/naf/shared/_application.html.erb +50 -0
- data/app/views/naf/shared/_information_container.html.erb +19 -0
- data/app/views/naf/shared/_select_per_page.html.erb +72 -0
- data/ci/test-build.sh +17 -0
- data/ci/travis.sh +26 -0
- data/config/initializers/naf.rb +3 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20120820023848_naf_schema.rb +413 -0
- data/doc/README_FOR_APP +2 -0
- data/lib/generators/naf_generator.rb +45 -0
- data/lib/generators/templates/config/logging/af.yml +26 -0
- data/lib/generators/templates/config/logging/naf.yml +22 -0
- data/lib/generators/templates/config/logging/nafjob.yml +16 -0
- data/lib/generators/templates/config/logging/nafrunner.yml +17 -0
- data/lib/generators/templates/naf.rb +11 -0
- data/lib/generators/templates/naf_layout.html.erb +15 -0
- data/lib/naf.rb +48 -0
- data/lib/naf/configuration.rb +23 -0
- data/lib/naf/engine.rb +18 -0
- data/lib/naf/version.rb +3 -0
- data/lib/tasks/naf_tasks.rake +370 -0
- data/naf.gemspec +30 -0
- data/script/rails +10 -0
- data/spec/controllers/naf/affinities_controller_spec.rb +79 -0
- data/spec/controllers/naf/application_controller_spec.rb +10 -0
- data/spec/controllers/naf/application_schedule_affinity_tabs_controller_spec.rb +106 -0
- data/spec/controllers/naf/applications_controller_spec.rb +109 -0
- data/spec/controllers/naf/historical_job_affinity_tabs_controller_spec.rb +96 -0
- data/spec/controllers/naf/historical_jobs_controller_spec.rb +19 -0
- data/spec/controllers/naf/machine_affinity_slots_controller_spec.rb +109 -0
- data/spec/controllers/naf/machines_controller_spec.rb +74 -0
- data/spec/dummy/.gitignore +12 -0
- data/spec/dummy/README +19 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css +14 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/my_script.rb +8 -0
- data/spec/dummy/app/models/other/base.rb.sample +10 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/naf_layout.html.erb +15 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database-non_primary.yml +20 -0
- data/spec/dummy/config/database-primary.yml +16 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/naf.rb.non_primary +4 -0
- data/spec/dummy/config/initializers/naf.rb.primary +3 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/logging/af.yml +26 -0
- data/spec/dummy/config/logging/naf.yml +22 -0
- data/spec/dummy/config/logging/nafjob.yml +16 -0
- data/spec/dummy/config/logging/nafrunner.yml +17 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/db/.gitignore +2 -0
- data/spec/dummy/lib/tasks/dummy.rake +60 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories/naf.rb +433 -0
- data/spec/helpers/naf/application_helper_spec.rb +0 -0
- data/spec/models/logical/naf/application_spec.rb +69 -0
- data/spec/models/logical/naf/job_creator_spec.rb +32 -0
- data/spec/models/logical/naf/job_fetcher_spec.rb +140 -0
- data/spec/models/logical/naf/job_spec.rb +282 -0
- data/spec/models/logical/naf/machine_spec.rb +61 -0
- data/spec/models/naf/affinity_classification_spec.rb +56 -0
- data/spec/models/naf/affinity_spec.rb +100 -0
- data/spec/models/naf/application_run_group_restriction_spec.rb +57 -0
- data/spec/models/naf/application_schedule_affinity_tab_spec.rb +85 -0
- data/spec/models/naf/application_schedule_prerequisite_spec.rb +35 -0
- data/spec/models/naf/application_schedule_spec.rb +166 -0
- data/spec/models/naf/application_spec.rb +128 -0
- data/spec/models/naf/application_type_spec.rb +104 -0
- data/spec/models/naf/historical_job_affinity_tab_spec.rb +59 -0
- data/spec/models/naf/historical_job_prerequisite_spec.rb +25 -0
- data/spec/models/naf/historical_job_spec.rb +334 -0
- data/spec/models/naf/logger_level_spec.rb +34 -0
- data/spec/models/naf/logger_name_spec.rb +35 -0
- data/spec/models/naf/logger_style_name_spec.rb +39 -0
- data/spec/models/naf/logger_style_spec.rb +89 -0
- data/spec/models/naf/machine_affinity_slot_spec.rb +77 -0
- data/spec/models/naf/machine_runner_invocation_spec.rb +38 -0
- data/spec/models/naf/machine_runner_spec.rb +37 -0
- data/spec/models/naf/machine_spec.rb +425 -0
- data/spec/models/naf/naf_base_spec.rb +14 -0
- data/spec/models/naf/queued_job_spec.rb +171 -0
- data/spec/models/naf/running_job_spec.rb +107 -0
- data/spec/models/process/naf/application_spec.rb +8 -0
- data/spec/models/process/naf/janitor_spec.rb +10 -0
- data/spec/models/process/naf/runner_spec.rb +10 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/engine_routing.rb +27 -0
- data/spec/support/script_spec_helper.rb +58 -0
- metadata +590 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
<% content_for :body do %>
|
2
|
+
<div id="record">
|
3
|
+
<%= render partial: 'naf/shared/information_container', locals: { record_name: naf_model_name } %>
|
4
|
+
|
5
|
+
<%= naf_generate_back_link %>
|
6
|
+
<% if !naf_generate_edit_link.blank? && !naf_generate_back_link.blank? %>
|
7
|
+
|
|
8
|
+
<% end %>
|
9
|
+
<%= naf_generate_edit_link %>
|
10
|
+
|
11
|
+
<div id="flash_message">
|
12
|
+
<% unless notice.blank? %>
|
13
|
+
<script type='text/javascript'>
|
14
|
+
jQuery("<p id='notice'><%= notice %></p>")
|
15
|
+
.appendTo('#flash_message')
|
16
|
+
.slideDown().delay(5000).slideUp();
|
17
|
+
</script>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<br/>
|
22
|
+
<table id="naf_table_show">
|
23
|
+
<tr>
|
24
|
+
<th>Attribute</th>
|
25
|
+
<th>Value</th>
|
26
|
+
</tr>
|
27
|
+
<tbody>
|
28
|
+
<% @attributes.each do |a| %>
|
29
|
+
<tr>
|
30
|
+
<td scope="row"><%= naf_make_header(a.to_s) %></td>
|
31
|
+
<td> <%= @record.send(a) %></td>
|
32
|
+
</tr>
|
33
|
+
<% end %>
|
34
|
+
</tbody>
|
35
|
+
</table>
|
36
|
+
<br/>
|
37
|
+
|
38
|
+
<%= naf_generate_child_resources_link %>
|
39
|
+
<% if !naf_generate_destroy_link.blank? && !naf_generate_child_resources_link.blank? %>
|
40
|
+
|
|
41
|
+
<% end %>
|
42
|
+
<%= naf_generate_destroy_link %>
|
43
|
+
</div>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
<%= render partial: 'naf/shared/application' %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<div id='naf'>
|
2
|
+
<div id="fluid">
|
3
|
+
<div id='hd'>
|
4
|
+
<div id="header">
|
5
|
+
<h3><%= link_to Naf.title.html_safe, naf.root_url %></h3>
|
6
|
+
</div>
|
7
|
+
</div>
|
8
|
+
<div id="navigation">
|
9
|
+
<ul id="tabs">
|
10
|
+
<% naf_tabs.each_key do |tab| %>
|
11
|
+
<% if naf_highlight_tab?(tab) %>
|
12
|
+
<li id="on">
|
13
|
+
<% else %>
|
14
|
+
<li>
|
15
|
+
<% end %>
|
16
|
+
<%= naf_generate_index_link(tab) %>
|
17
|
+
</li>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
20
|
+
<div class="clear"></div>
|
21
|
+
</div>
|
22
|
+
<div id='bd'>
|
23
|
+
<% naf_tabs.each do |tab, child_tabs| %>
|
24
|
+
<% if naf_highlight_tab?(tab) && !child_tabs.blank? %>
|
25
|
+
<div id="child_navigation">
|
26
|
+
<ul id="child_tabs">
|
27
|
+
<% child_tabs.each do |child_tab| %>
|
28
|
+
<% if naf_highlight_tab?(child_tab) %>
|
29
|
+
<li id="on">
|
30
|
+
<% else %>
|
31
|
+
<li>
|
32
|
+
<% end %>
|
33
|
+
<%= naf_generate_index_link(child_tab) %>
|
34
|
+
</li>
|
35
|
+
<% end %>
|
36
|
+
</ul>
|
37
|
+
<div class="clear"></div>
|
38
|
+
</div>
|
39
|
+
<div id='child_bd'>
|
40
|
+
<% @naf_render_body = true %>
|
41
|
+
<%= yield :body %>
|
42
|
+
</div>
|
43
|
+
<% end %>
|
44
|
+
<% end %>
|
45
|
+
<% unless @naf_render_body %>
|
46
|
+
<%= yield :body %>
|
47
|
+
<% end %>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<div id='page-label'>
|
2
|
+
<h3 id="record_name"><%= record_name %> </h3>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<% if current_page?(naf.root_url) or current_page?(action: 'index') %>
|
6
|
+
<% if flash[:error] -%>
|
7
|
+
<div class="error"><%= flash[:error] %></div></br>
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
<div id='create_links'>
|
11
|
+
<span id="create"> <%= naf_generate_create_link %> </span>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% if naf_nested_resource_index? %>
|
16
|
+
<div id='parent_links'>
|
17
|
+
<span id="parent"> <%= naf_parent_resource_link %> </span>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<% content_for :javascripts do %>
|
2
|
+
<script type='text/javascript'>
|
3
|
+
|
4
|
+
function initPageSelect() {
|
5
|
+
var pageSelect = jQuery('#page-select-container');
|
6
|
+
var refreshPage = jQuery('#refresh-page-container');
|
7
|
+
jQuery('#datatable_paginate').append(pageSelect).append(refreshPage);
|
8
|
+
pageSelect.show();
|
9
|
+
refreshPage.show();
|
10
|
+
}
|
11
|
+
|
12
|
+
function getDisplayLength() {
|
13
|
+
return parseInt(jQuery('#iDisplayLength').val());
|
14
|
+
}
|
15
|
+
|
16
|
+
// Global to store the current timeout id value.
|
17
|
+
var timeout_id = null;
|
18
|
+
|
19
|
+
// Redraw datatable.
|
20
|
+
var redrawDatatable = function() {
|
21
|
+
jQuery("#datatable").dataTable().fnDraw(false);
|
22
|
+
if ( jQuery('#auto_refresh').is(':checked') ) {
|
23
|
+
timeout_id = setTimeout(redrawDatatable, 10000);
|
24
|
+
}
|
25
|
+
};
|
26
|
+
|
27
|
+
jQuery(document).ready(function() {
|
28
|
+
jQuery('#page-select-container form select').change(function() {
|
29
|
+
var ddTable = jQuery('#datatable');
|
30
|
+
ddTable.dataTableSettings[0]._iDisplayStart = 0;
|
31
|
+
ddTable.dataTableSettings[0]._iDisplayLength = parseInt(this.value);
|
32
|
+
jQuery('#datatable').dataTable().fnDraw();
|
33
|
+
});
|
34
|
+
|
35
|
+
<% if controller_name == 'historical_jobs' %>
|
36
|
+
timeout_id = setTimeout(redrawDatatable, 10000);
|
37
|
+
jQuery('#auto_refresh').prop('checked', true);
|
38
|
+
<% end %>
|
39
|
+
|
40
|
+
jQuery('#refresh_datatable').click(function(){
|
41
|
+
jQuery('#datatable').dataTable().fnDraw();
|
42
|
+
});
|
43
|
+
|
44
|
+
// Set change event to enabled/disable auto-refresh
|
45
|
+
jQuery('#auto_refresh').change(function() {
|
46
|
+
if ( jQuery(this).is(':checked') ) {
|
47
|
+
timeout_id = setTimeout(redrawDatatable, 10000);
|
48
|
+
} else {
|
49
|
+
clearTimeout(timeout_id);
|
50
|
+
timeout_id = null;
|
51
|
+
}
|
52
|
+
});
|
53
|
+
});
|
54
|
+
|
55
|
+
</script>
|
56
|
+
<% end %>
|
57
|
+
|
58
|
+
<div id='refresh-page-container'>
|
59
|
+
<%= link_to "Refresh Table", "#", id: :refresh_datatable %>
|
60
|
+
|
61
|
+
<%= label_tag :auto_refresh, 'Auto Refresh:' %>
|
62
|
+
<%= check_box_tag :auto_refresh, 1, false, id: :auto_refresh %>
|
63
|
+
</div>
|
64
|
+
|
65
|
+
<div id="page-select-container" class="ui-state-default ui-corner-all">
|
66
|
+
<%= form_tag({ controller: params[:controller], action: params[:action], format: 'js' }, method: :get) do %>
|
67
|
+
<%= label_tag :iDisplayLength, "Rows Per Page:", class: "label" %>
|
68
|
+
<%= select_tag :iDisplayLength,
|
69
|
+
options_for_select(::Naf.configuration.default_page_options, @rows_per_page),
|
70
|
+
class: "page-select datatable_variable ui-state-default ui-corner-all" %>
|
71
|
+
<% end %>
|
72
|
+
</div>
|
data/ci/test-build.sh
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
echo 'Dropping your naf_development database if it exists'
|
4
|
+
|
5
|
+
psql -U postgres -c "drop database if exists naf_development"
|
6
|
+
psql -U postgres -c "drop database if exists primary_development"
|
7
|
+
|
8
|
+
echo 'Removing existing migration in dummy application'
|
9
|
+
|
10
|
+
rm -f spec/dummy/app/models/other/base.rb
|
11
|
+
|
12
|
+
rm -rf spec/dummy/db/naf
|
13
|
+
|
14
|
+
rm -f spec/dummy/db/migrate/*.rb
|
15
|
+
|
16
|
+
./ci/travis.sh
|
17
|
+
|
data/ci/travis.sh
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
rake="bundle exec rake"
|
4
|
+
|
5
|
+
cd spec/dummy
|
6
|
+
|
7
|
+
# Bring in the initializer
|
8
|
+
|
9
|
+
if [ $SPEC_GROUP == 'non_primary_database' ]
|
10
|
+
then
|
11
|
+
echo 'Testing non primary database install'
|
12
|
+
cp config/database-non_primary.yml config/database.yml
|
13
|
+
cp app/models/other/base.rb.sample app/models/other/base.rb
|
14
|
+
cp config/initializers/naf.rb.non_primary config/initializers/naf.rb
|
15
|
+
$rake naf:install:migrations naf:isolate:migrations db:create:all naf:db:migrate naf:janitor:infrastructure naf:db:test:clone_structure
|
16
|
+
else
|
17
|
+
echo 'Testing primary database install'
|
18
|
+
cp config/database-primary.yml config/database.yml
|
19
|
+
cp config/initializers/naf.rb.primary config/initializers/naf.rb
|
20
|
+
$rake naf:install:migrations db:create db:migrate naf:janitor:infrastructure db:test:clone_structure
|
21
|
+
fi
|
22
|
+
|
23
|
+
cd ../..
|
24
|
+
|
25
|
+
$rake spec
|
26
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
Naf::Engine.routes.draw do
|
2
|
+
resources :historical_jobs do
|
3
|
+
resources :historical_job_affinity_tabs, except: [:destroy]
|
4
|
+
end
|
5
|
+
|
6
|
+
resources :applications, except: [:destroy] do
|
7
|
+
resources :application_schedules, only: [] do
|
8
|
+
resources :application_schedule_affinity_tabs
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
resources :machines, except: [:destroy] do
|
13
|
+
resources :machine_affinity_slots
|
14
|
+
end
|
15
|
+
|
16
|
+
resources :machine_runners, only: [:index, :show]
|
17
|
+
resources :machine_runner_invocations, only: [:index, :show, :update] do
|
18
|
+
collection do
|
19
|
+
get :wind_down_all
|
20
|
+
end
|
21
|
+
end
|
22
|
+
resources :logger_styles
|
23
|
+
resources :logger_names
|
24
|
+
resources :affinities
|
25
|
+
|
26
|
+
resources :janitorial_archive_assignments, controller: "janitorial_assignments",
|
27
|
+
type: "Naf::JanitorialArchiveAssignment",
|
28
|
+
except: [:destroy]
|
29
|
+
resources :janitorial_create_assignments, controller: "janitorial_assignments",
|
30
|
+
type: "Naf::JanitorialCreateAssignment",
|
31
|
+
except: [:destroy]
|
32
|
+
resources :janitorial_drop_assignments, controller: "janitorial_assignments",
|
33
|
+
type: "Naf::JanitorialDropAssignment",
|
34
|
+
except: [:destroy]
|
35
|
+
|
36
|
+
match "jobs" => "historical_jobs#index"
|
37
|
+
root to: "historical_jobs#index"
|
38
|
+
end
|
@@ -0,0 +1,413 @@
|
|
1
|
+
class NafSchema < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def up
|
4
|
+
# Define a schema_name, the scheduling tables fall under:
|
5
|
+
schema_name = Naf.schema_name
|
6
|
+
|
7
|
+
# affinities
|
8
|
+
# names: normal, canary, perennial
|
9
|
+
# location: ip address
|
10
|
+
# application/release on machine: application-release-number
|
11
|
+
execute <<-SQL
|
12
|
+
|
13
|
+
do LANGUAGE plpgsql $$
|
14
|
+
begin
|
15
|
+
if (SELECT count(*) FROM pg_namespace WHERE nspname !~ '^pg_.*' AND nspname NOT IN ('information_schema') AND nspname = '#{schema_name}') > 0 THEN
|
16
|
+
raise notice 'Skipping creation of schema: #{schema_name}, already exists';
|
17
|
+
else
|
18
|
+
raise notice 'Creating new schema #{schema_name}';
|
19
|
+
create schema #{schema_name};
|
20
|
+
end if;
|
21
|
+
end;
|
22
|
+
$$;
|
23
|
+
|
24
|
+
create table #{schema_name}.affinity_classifications
|
25
|
+
(
|
26
|
+
id serial not null primary key,
|
27
|
+
created_at timestamp not null default now(),
|
28
|
+
updated_at timestamp,
|
29
|
+
affinity_classification_name text not null unique
|
30
|
+
);
|
31
|
+
insert into #{schema_name}.affinity_classifications (affinity_classification_name) values
|
32
|
+
('location'), ('purpose'), ('application'), ('weight'), ('machine');
|
33
|
+
create table #{schema_name}.affinities
|
34
|
+
(
|
35
|
+
id serial not null primary key,
|
36
|
+
created_at timestamp not null default now(),
|
37
|
+
updated_at timestamp,
|
38
|
+
selectable boolean not null default true,
|
39
|
+
affinity_classification_id integer not null references #{schema_name}.affinity_classifications,
|
40
|
+
affinity_name text not null,
|
41
|
+
affinity_short_name text unique check ( affinity_short_name ~ '^[a-zA-Z_][a-zA-Z0-9_]*$' ),
|
42
|
+
affinity_note text null,
|
43
|
+
unique (affinity_classification_id, affinity_name)
|
44
|
+
);
|
45
|
+
insert into #{schema_name}.affinities (affinity_classification_id, affinity_name, affinity_short_name) values
|
46
|
+
((select id from #{schema_name}.affinity_classifications where affinity_classification_name = 'purpose'), 'normal', 'normal'),
|
47
|
+
((select id from #{schema_name}.affinity_classifications where affinity_classification_name = 'purpose'), 'canary', 'canary'),
|
48
|
+
((select id from #{schema_name}.affinity_classifications where affinity_classification_name = 'purpose'), 'perennial', 'perennial'),
|
49
|
+
((select id from #{schema_name}.affinity_classifications where affinity_classification_name = 'weight'), 'memory', 'memory'),
|
50
|
+
((select id from #{schema_name}.affinity_classifications where affinity_classification_name = 'weight'), 'cpus', 'cpus');
|
51
|
+
create table #{schema_name}.machines
|
52
|
+
(
|
53
|
+
id serial not null primary key,
|
54
|
+
created_at timestamp not null default now(),
|
55
|
+
updated_at timestamp,
|
56
|
+
server_address inet not null unique,
|
57
|
+
server_name text,
|
58
|
+
short_name text unique check ( short_name ~ '^[a-zA-Z_][a-zA-Z0-9_]*$' ),
|
59
|
+
server_note text,
|
60
|
+
enabled boolean not null default true,
|
61
|
+
thread_pool_size integer not null default 5,
|
62
|
+
last_checked_schedules_at timestamp null,
|
63
|
+
last_seen_alive_at timestamp null,
|
64
|
+
marked_down boolean not null default false,
|
65
|
+
marked_down_by_machine_id integer null references #{schema_name}.machines,
|
66
|
+
marked_down_at timestamp null,
|
67
|
+
log_level text null,
|
68
|
+
deleted boolean not null default false check (deleted = false OR enabled = false)
|
69
|
+
);
|
70
|
+
create table #{schema_name}.machine_affinity_slots
|
71
|
+
(
|
72
|
+
id serial not null primary key,
|
73
|
+
created_at timestamp not null default now(),
|
74
|
+
machine_id integer not null references #{schema_name}.machines,
|
75
|
+
affinity_id integer not null references #{schema_name}.affinities,
|
76
|
+
affinity_parameter numeric null,
|
77
|
+
required boolean not null default false,
|
78
|
+
unique (machine_id, affinity_id)
|
79
|
+
);
|
80
|
+
create table #{schema_name}.machine_runners
|
81
|
+
(
|
82
|
+
id serial not null primary key,
|
83
|
+
created_at timestamp not null default now(),
|
84
|
+
machine_id integer not null references #{schema_name}.machines,
|
85
|
+
runner_cwd text not null,
|
86
|
+
unique (machine_id, runner_cwd)
|
87
|
+
);
|
88
|
+
create table #{schema_name}.machine_runner_invocations
|
89
|
+
(
|
90
|
+
id serial not null primary key,
|
91
|
+
created_at timestamp not null default now(),
|
92
|
+
updated_at timestamp,
|
93
|
+
machine_runner_id integer not null references #{schema_name}.machine_runners,
|
94
|
+
pid integer not null,
|
95
|
+
dead_at timestamp null,
|
96
|
+
wind_down_at timestamp null,
|
97
|
+
commit_information text null,
|
98
|
+
branch_name text null,
|
99
|
+
repository_name text null,
|
100
|
+
deployment_tag text null
|
101
|
+
);
|
102
|
+
create table #{schema_name}.application_types
|
103
|
+
(
|
104
|
+
id serial not null primary key,
|
105
|
+
created_at timestamp not null default now(),
|
106
|
+
updated_at timestamp,
|
107
|
+
enabled boolean not null default true,
|
108
|
+
script_type_name text unique not null,
|
109
|
+
description text,
|
110
|
+
invocation_method text not null
|
111
|
+
);
|
112
|
+
insert into #{schema_name}.application_types (script_type_name, description, invocation_method) values
|
113
|
+
('rails', 'ruby on rails NAF application', 'rails_invocator'),
|
114
|
+
('bash command', 'bash command', 'bash_command_invocator'),
|
115
|
+
('bash script', 'bash script', 'bash_script_invocator'),
|
116
|
+
('ruby', 'ruby script', 'ruby_script_invocator');
|
117
|
+
create table #{schema_name}.applications
|
118
|
+
(
|
119
|
+
id serial not null primary key,
|
120
|
+
created_at timestamp not null default now(),
|
121
|
+
updated_at timestamp,
|
122
|
+
deleted boolean not null default false,
|
123
|
+
application_type_id integer not null references #{schema_name}.application_types,
|
124
|
+
command text not null,
|
125
|
+
title text not null,
|
126
|
+
short_name text null unique check ( short_name ~ '^[a-zA-Z_][a-zA-Z0-9_]*$' ),
|
127
|
+
log_level text null
|
128
|
+
);
|
129
|
+
insert into #{schema_name}.applications (application_type_id, command, title) values
|
130
|
+
(
|
131
|
+
(select id from #{schema_name}.application_types where script_type_name = 'rails'),
|
132
|
+
'::Process::Naf::Janitor.run',
|
133
|
+
'Database Janitorial Work'
|
134
|
+
);
|
135
|
+
create table #{schema_name}.application_run_group_restrictions
|
136
|
+
(
|
137
|
+
id serial not null primary key,
|
138
|
+
created_at timestamp not null default now(),
|
139
|
+
application_run_group_restriction_name text unique not null
|
140
|
+
);
|
141
|
+
insert into #{schema_name}.application_run_group_restrictions (application_run_group_restriction_name) values
|
142
|
+
('no limit'), ('limited per machine'), ('limited per all machines');
|
143
|
+
create table #{schema_name}.application_schedules
|
144
|
+
(
|
145
|
+
id serial not null primary key,
|
146
|
+
created_at timestamp not null default now(),
|
147
|
+
updated_at timestamp,
|
148
|
+
enabled boolean not null default true,
|
149
|
+
visible boolean not null default true,
|
150
|
+
application_id integer unique not null references #{schema_name}.applications,
|
151
|
+
application_run_group_restriction_id integer not null references #{schema_name}.application_run_group_restrictions,
|
152
|
+
application_run_group_name text null,
|
153
|
+
application_run_group_limit integer null check (application_run_group_limit >= 1 or application_run_group_limit is null),
|
154
|
+
run_start_minute integer null check (run_start_minute >= 0 and run_start_minute < (24 * 60)),
|
155
|
+
run_interval integer null check (run_interval >= 0),
|
156
|
+
priority integer not null default 0,
|
157
|
+
enqueue_backlogs boolean not null default false,
|
158
|
+
check (visible = true OR enabled = false),
|
159
|
+
check (run_start_minute is null OR run_interval is null)
|
160
|
+
);
|
161
|
+
insert into #{schema_name}.application_schedules
|
162
|
+
(application_id, application_run_group_restriction_id, application_run_group_name, application_run_group_limit, run_start_minute, run_interval) values
|
163
|
+
(
|
164
|
+
(select id from #{schema_name}.applications where command = '::Process::Naf::Janitor.run'),
|
165
|
+
(select id from #{schema_name}.application_run_group_restrictions where application_run_group_restriction_name = 'limited per all machines'),
|
166
|
+
'::Process::Naf::Janitor.run',
|
167
|
+
1,
|
168
|
+
5,
|
169
|
+
null
|
170
|
+
);
|
171
|
+
create unique index applications_have_one_schedule_udx on #{schema_name}.application_schedules (application_id) where enabled = true;
|
172
|
+
create table #{schema_name}.application_schedule_affinity_tabs
|
173
|
+
(
|
174
|
+
id serial not null primary key,
|
175
|
+
created_at timestamp not null default now(),
|
176
|
+
application_schedule_id integer not null references #{schema_name}.application_schedules,
|
177
|
+
affinity_id integer not null references #{schema_name}.affinities,
|
178
|
+
affinity_parameter numeric null,
|
179
|
+
UNIQUE (application_schedule_id, affinity_id)
|
180
|
+
);
|
181
|
+
create table #{schema_name}.application_schedule_prerequisites
|
182
|
+
(
|
183
|
+
id serial not null primary key,
|
184
|
+
created_at timestamp not null default now(),
|
185
|
+
application_schedule_id integer not null references #{schema_name}.application_schedules,
|
186
|
+
prerequisite_application_schedule_id integer not null references #{schema_name}.application_schedules,
|
187
|
+
UNIQUE (application_schedule_id, prerequisite_application_schedule_id),
|
188
|
+
CHECK (application_schedule_id <> prerequisite_application_schedule_id)
|
189
|
+
);
|
190
|
+
create table #{schema_name}.historical_jobs
|
191
|
+
(
|
192
|
+
id bigserial not null primary key,
|
193
|
+
created_at timestamp not null default now(),
|
194
|
+
updated_at timestamp,
|
195
|
+
|
196
|
+
application_id integer null references #{schema_name}.applications,
|
197
|
+
application_type_id integer not null references #{schema_name}.application_types,
|
198
|
+
command text not null,
|
199
|
+
|
200
|
+
application_run_group_restriction_id integer not null references #{schema_name}.application_run_group_restrictions,
|
201
|
+
application_run_group_name text null,
|
202
|
+
application_run_group_limit integer null default 1,
|
203
|
+
|
204
|
+
priority integer not null default 0,
|
205
|
+
|
206
|
+
started_on_machine_id integer null references #{schema_name}.machines,
|
207
|
+
|
208
|
+
failed_to_start boolean null,
|
209
|
+
started_at timestamp null,
|
210
|
+
pid integer null,
|
211
|
+
finished_at timestamp null,
|
212
|
+
exit_status integer null,
|
213
|
+
termination_signal integer null,
|
214
|
+
|
215
|
+
state text null,
|
216
|
+
|
217
|
+
request_to_terminate boolean not null default false,
|
218
|
+
|
219
|
+
marked_dead_by_machine_id integer null references #{schema_name}.machines,
|
220
|
+
marked_dead_at timestamp null,
|
221
|
+
|
222
|
+
log_level text null,
|
223
|
+
tags text[],
|
224
|
+
machine_runner_invocation_id integer null references #{schema_name}.machine_runner_invocations
|
225
|
+
);
|
226
|
+
create table #{schema_name}.historical_job_prerequisites
|
227
|
+
(
|
228
|
+
id bigserial not null primary key,
|
229
|
+
created_at timestamp not null default now(),
|
230
|
+
historical_job_id bigint not null, -- references #{schema_name}.historical_jobs,
|
231
|
+
prerequisite_historical_job_id bigint not null, -- references #{schema_name}.historical_jobs,
|
232
|
+
UNIQUE (historical_job_id, prerequisite_historical_job_id),
|
233
|
+
CHECK (historical_job_id <> prerequisite_historical_job_id)
|
234
|
+
);
|
235
|
+
create table #{schema_name}.historical_job_affinity_tabs
|
236
|
+
(
|
237
|
+
id bigserial not null primary key,
|
238
|
+
created_at timestamp not null default now(),
|
239
|
+
historical_job_id bigint not null, -- references #{schema_name}.historical_jobs,
|
240
|
+
affinity_id bigint not null references #{schema_name}.affinities,
|
241
|
+
affinity_parameter numeric null,
|
242
|
+
UNIQUE (historical_job_id, affinity_id)
|
243
|
+
);
|
244
|
+
create table #{schema_name}.queued_jobs
|
245
|
+
(
|
246
|
+
id bigint not null primary key, -- references #{schema_name}.historical_jobs
|
247
|
+
created_at timestamp not null default now(),
|
248
|
+
updated_at timestamp,
|
249
|
+
|
250
|
+
application_id integer null references #{schema_name}.applications,
|
251
|
+
application_type_id integer not null references #{schema_name}.application_types,
|
252
|
+
command text not null,
|
253
|
+
|
254
|
+
application_run_group_restriction_id integer not null references #{schema_name}.application_run_group_restrictions,
|
255
|
+
application_run_group_name text null,
|
256
|
+
application_run_group_limit integer null default 1,
|
257
|
+
|
258
|
+
priority integer not null default 0
|
259
|
+
);
|
260
|
+
create table #{schema_name}.running_jobs
|
261
|
+
(
|
262
|
+
id bigint not null primary key, -- references #{schema_name}.historical_jobs
|
263
|
+
created_at timestamp not null default now(),
|
264
|
+
updated_at timestamp,
|
265
|
+
|
266
|
+
application_id integer null references #{schema_name}.applications,
|
267
|
+
application_type_id integer not null references #{schema_name}.application_types,
|
268
|
+
command text not null,
|
269
|
+
|
270
|
+
application_run_group_restriction_id integer not null references #{schema_name}.application_run_group_restrictions,
|
271
|
+
application_run_group_name text null,
|
272
|
+
application_run_group_limit integer null default 1,
|
273
|
+
|
274
|
+
started_on_machine_id integer not null references #{schema_name}.machines,
|
275
|
+
|
276
|
+
started_at timestamp null,
|
277
|
+
pid integer null,
|
278
|
+
|
279
|
+
request_to_terminate boolean not null default false,
|
280
|
+
|
281
|
+
marked_dead_by_machine_id integer null references #{schema_name}.machines,
|
282
|
+
marked_dead_at timestamp null,
|
283
|
+
|
284
|
+
log_level text null
|
285
|
+
);
|
286
|
+
create table #{schema_name}.janitorial_assignments
|
287
|
+
(
|
288
|
+
id serial not null primary key,
|
289
|
+
created_at timestamp not null default now(),
|
290
|
+
updated_at timestamp,
|
291
|
+
type text not null,
|
292
|
+
enabled boolean not null default true,
|
293
|
+
deleted boolean not null default false,
|
294
|
+
model_name text not null, -- ::Naf::HistoricalJob
|
295
|
+
assignment_order integer not null default 0,
|
296
|
+
check (deleted = false OR enabled = false)
|
297
|
+
);
|
298
|
+
create table #{schema_name}.logger_styles
|
299
|
+
(
|
300
|
+
id serial not null primary key,
|
301
|
+
created_at timestamp not null default now(),
|
302
|
+
updated_at timestamp,
|
303
|
+
name text not null unique,
|
304
|
+
note text null
|
305
|
+
);
|
306
|
+
create table #{schema_name}.logger_names
|
307
|
+
(
|
308
|
+
id serial not null primary key,
|
309
|
+
created_at timestamp not null default now(),
|
310
|
+
updated_at timestamp,
|
311
|
+
name text not null unique
|
312
|
+
);
|
313
|
+
create table #{schema_name}.logger_levels
|
314
|
+
(
|
315
|
+
id serial not null primary key,
|
316
|
+
created_at timestamp not null default now(),
|
317
|
+
updated_at timestamp,
|
318
|
+
level text not null unique
|
319
|
+
);
|
320
|
+
insert into #{schema_name}.logger_levels (level) values
|
321
|
+
('ALL'),
|
322
|
+
('DEBUG'),
|
323
|
+
('DEBUG_FINE'),
|
324
|
+
('DEBUG_MEDIUM'),
|
325
|
+
('DEBUG_GROSS'),
|
326
|
+
('DETAIL'),
|
327
|
+
('INFO'),
|
328
|
+
('WARN'),
|
329
|
+
('ALARM'),
|
330
|
+
('ERROR'),
|
331
|
+
('FATAL'),
|
332
|
+
('OFF');
|
333
|
+
create table #{schema_name}.logger_style_names
|
334
|
+
(
|
335
|
+
id serial not null primary key,
|
336
|
+
created_at timestamp not null default now(),
|
337
|
+
updated_at timestamp,
|
338
|
+
logger_style_id integer not null references #{schema_name}.logger_styles,
|
339
|
+
logger_name_id integer not null references #{schema_name}.logger_names,
|
340
|
+
logger_level_id integer not null references #{schema_name}.logger_levels,
|
341
|
+
UNIQUE(logger_style_id, logger_name_id)
|
342
|
+
);
|
343
|
+
insert into #{schema_name}.janitorial_assignments (type, assignment_order, model_name) values
|
344
|
+
('Naf::JanitorialCreateAssignment', 500, '::Naf::HistoricalJob'),
|
345
|
+
('Naf::JanitorialDropAssignment', 500, '::Naf::HistoricalJob'),
|
346
|
+
('Naf::JanitorialCreateAssignment', 125, '::Naf::HistoricalJobPrerequisite'),
|
347
|
+
('Naf::JanitorialDropAssignment', 125, '::Naf::HistoricalJobPrerequisite'),
|
348
|
+
('Naf::JanitorialCreateAssignment', 250, '::Naf::HistoricalJobAffinityTab'),
|
349
|
+
('Naf::JanitorialDropAssignment', 250, '::Naf::HistoricalJobAffinityTab');
|
350
|
+
|
351
|
+
set search_path = 'public';
|
352
|
+
|
353
|
+
SQL
|
354
|
+
end
|
355
|
+
|
356
|
+
def down
|
357
|
+
schema_name = Naf.schema_name
|
358
|
+
execute <<-SQL
|
359
|
+
drop table #{schema_name}.janitorial_assignments cascade;
|
360
|
+
drop table #{schema_name}.historical_job_affinity_tabs cascade;
|
361
|
+
drop table #{schema_name}.historical_job_prerequisites cascade;
|
362
|
+
drop table #{schema_name}.historical_jobs cascade;
|
363
|
+
drop table #{schema_name}.running_jobs cascade;
|
364
|
+
drop table #{schema_name}.queued_jobs cascade;
|
365
|
+
drop table #{schema_name}.affinities cascade;
|
366
|
+
drop table #{schema_name}.affinity_classifications cascade;
|
367
|
+
drop table #{schema_name}.machines cascade;
|
368
|
+
drop table #{schema_name}.machine_runner_invocations cascade;
|
369
|
+
drop table #{schema_name}.machine_runners cascade;
|
370
|
+
drop table #{schema_name}.machine_affinity_slots cascade;
|
371
|
+
drop table #{schema_name}.applications cascade;
|
372
|
+
drop table #{schema_name}.application_types cascade;
|
373
|
+
drop table #{schema_name}.application_run_group_restrictions cascade;
|
374
|
+
drop table #{schema_name}.application_schedule_prerequisites cascade;
|
375
|
+
drop table #{schema_name}.application_schedules cascade;
|
376
|
+
drop table #{schema_name}.application_schedule_affinity_tabs cascade;
|
377
|
+
drop table #{schema_name}.logger_levels cascade;
|
378
|
+
drop table #{schema_name}.logger_names cascade;
|
379
|
+
drop table #{schema_name}.logger_styles cascade;
|
380
|
+
drop table #{schema_name}.logger_style_names cascade;
|
381
|
+
SQL
|
382
|
+
|
383
|
+
if schema_name != "public"
|
384
|
+
execute <<-SQL
|
385
|
+
do LANGUAGE plpgsql $$
|
386
|
+
begin
|
387
|
+
if (SELECT COUNT(*) FROM pg_tables WHERE schemaname = '#{schema_name}') > 0 THEN
|
388
|
+
raise notice 'Skipping drop of schema:: #{schema_name}, there are still other tables under it!';
|
389
|
+
else
|
390
|
+
raise notice 'Dropping schema #{schema_name}';
|
391
|
+
drop schema #{schema_name} cascade;
|
392
|
+
end if;
|
393
|
+
end;
|
394
|
+
$$;
|
395
|
+
SQL
|
396
|
+
end
|
397
|
+
|
398
|
+
schemas = execute <<-SQL
|
399
|
+
SELECT 'drop schema ' || nspname ||' cascade;'
|
400
|
+
FROM pg_namespace
|
401
|
+
WHERE nspname = 'naf_historical_job_affinity_tabs_partitions' OR
|
402
|
+
nspname = 'naf_historical_job_prerequisites_partitions' OR
|
403
|
+
nspname = 'naf_historical_jobs_partitions';
|
404
|
+
SQL
|
405
|
+
|
406
|
+
schemas.values.each do |schema|
|
407
|
+
execute <<-SQL
|
408
|
+
#{schema.first}
|
409
|
+
SQL
|
410
|
+
end
|
411
|
+
|
412
|
+
end
|
413
|
+
end
|