staypuft 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +5 -13
  2. data/app/assets/javascripts/staypuft/nics_assignment.js +35 -0
  3. data/app/assets/javascripts/staypuft/staypuft.js +4 -0
  4. data/app/assets/javascripts/staypuft/subnets_assignment.js +33 -3
  5. data/app/assets/stylesheets/staypuft/staypuft.css.scss +31 -0
  6. data/app/controllers/staypuft/bonds_controller.rb +131 -0
  7. data/app/controllers/staypuft/interface_assignments_controller.rb +7 -2
  8. data/app/controllers/staypuft/steps_controller.rb +1 -1
  9. data/app/controllers/staypuft/subnet_typings_controller.rb +45 -3
  10. data/app/lib/staypuft/seeder.rb +57 -27
  11. data/app/models/staypuft/deployment/glance_service.rb +1 -1
  12. data/app/models/staypuft/deployment/neutron_service.rb +1 -1
  13. data/app/models/staypuft/deployment.rb +4 -0
  14. data/app/models/staypuft/interface_assigner.rb +42 -22
  15. data/app/models/staypuft/subnet_type.rb +1 -0
  16. data/app/views/staypuft/bonds/add_slave.js.erb +10 -0
  17. data/app/views/staypuft/bonds/create.js.erb +10 -0
  18. data/app/views/staypuft/bonds/destroy.js.erb +10 -0
  19. data/app/views/staypuft/deployments/_assigned_hosts.html.erb +17 -17
  20. data/app/views/staypuft/interface_assignments/_interfaces.html.erb +31 -0
  21. data/app/views/staypuft/interface_assignments/_nics_assignment.html.erb +29 -0
  22. data/app/views/staypuft/interface_assignments/index.html.erb +42 -69
  23. data/app/views/staypuft/interfaces/_drop_zone.html.erb +72 -3
  24. data/app/views/staypuft/steps/_glance.html.erb +3 -3
  25. data/app/views/staypuft/steps/_neutron.html.erb +1 -1
  26. data/app/views/staypuft/steps/deployment_settings.html.erb +2 -2
  27. data/app/views/staypuft/steps/services_configuration.html.erb +1 -1
  28. data/app/views/staypuft/subnet_typings/create.js.erb +3 -0
  29. data/app/views/staypuft/subnet_typings/destroy.js.erb +3 -0
  30. data/app/views/staypuft/subnet_typings/update.js.erb +3 -0
  31. data/config/routes.rb +8 -0
  32. data/db/migrate/20141003223000_add_validation_to_subnet_types.rb +7 -0
  33. data/lib/staypuft/version.rb +1 -1
  34. metadata +143 -136
@@ -0,0 +1,10 @@
1
+ <% if @result %>
2
+ $("#nics_assignment").html(
3
+ '<%=j render :partial => 'staypuft/interface_assignments/nics_assignment',
4
+ :locals => { :host => @host,
5
+ :hosts => @hosts,
6
+ :deployment => @deployment,
7
+ :subnets => @subnets,
8
+ :interfaces => @interfaces } %>');
9
+ nics_assignment();
10
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% if @result %>
2
+ $("#nics_assignment").html(
3
+ '<%=j render :partial => 'staypuft/interface_assignments/nics_assignment',
4
+ :locals => { :host => @host,
5
+ :hosts => @hosts,
6
+ :deployment => @deployment,
7
+ :subnets => @subnets,
8
+ :interfaces => @interfaces } %>');
9
+ nics_assignment();
10
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <% if @result %>
2
+ $("#nics_assignment").html(
3
+ '<%=j render :partial => 'staypuft/interface_assignments/nics_assignment',
4
+ :locals => { :host => @host,
5
+ :hosts => @hosts,
6
+ :deployment => @deployment,
7
+ :subnets => @subnets,
8
+ :interfaces => @interfaces } %>');
9
+ nics_assignment();
10
+ <% end %>
@@ -13,25 +13,25 @@
13
13
  </div>
14
14
  <%= render partial: "hosts_table", locals: { hosts: hosts, deployment_role_col: true } %>
15
15
  <div class="modal fade" id="configure_networks_modal" tabindex="-1" role="dialog" aria-labelledby="<%= _("Configure Networks") %>" aria-hidden="true" data-path="<%= deployment_interface_assignments_path(@deployment.id) %>">
16
- <div class="modal-dialog modal-lg">
17
- <div class="modal-content">
18
- <div class="modal-header">
19
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
20
- <h2 class="modal-title" id="configure_networks_modal_label">
21
- <span class="glyphicon glyphicon-link">
22
- </span> <%= _("Configure Networks") %>
23
- </h2>
24
- </div>
25
- <div class="modal-body">
26
- <div id="interfaces"><%= image_tag '/assets/spinner.gif', style: "display: block; margin-left: auto; margin-right: auto" %></div>
27
- </div>
28
- <div class="modal-footer">
29
- <button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
30
- <button type="button" class="btn btn-primary done" data-dismiss="modal"><%= _("Done") %></button>
31
- </div>
32
- </div>
16
+ <div class="modal-dialog modal-lg">
17
+ <div class="modal-content">
18
+ <div class="modal-header">
19
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
20
+ <h2 class="modal-title" id="configure_networks_modal_label">
21
+ <span class="glyphicon glyphicon-link">
22
+ </span> <%= _("Configure Networks") %>
23
+ </h2>
24
+ </div>
25
+ <div class="modal-body">
26
+ <div id="interfaces"><%= image_tag '/assets/spinner.gif', style: "display: block; margin-left: auto; margin-right: auto" %></div>
27
+ </div>
28
+ <div class="modal-footer">
29
+ <button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
30
+ <button type="button" class="btn btn-primary done" data-dismiss="modal"><%= _("Done") %></button>
33
31
  </div>
34
32
  </div>
33
+ </div>
34
+ </div>
35
35
  <% end %>
36
36
  </div>
37
37
  <% else %>
@@ -0,0 +1,31 @@
1
+ <h3><%= _("Network Interfaces") %></h3>
2
+
3
+ <% interface_ids = interfaces.where(:type => 'Nic::Managed').map(&:identifier) %>
4
+ <% interface_ids.append(host.primary_interface) %>
5
+ <% interfaces_used_in_bonds = host.interfaces.where(:type => Nic::Bond).map(&:attached_devices).map{ |devices| devices.split(',') }.flatten.uniq %>
6
+
7
+ <% if (subnet = host.subnet) && !interfaces_used_in_bonds.include?(host.primary_interface) %>
8
+ <%= render 'staypuft/interfaces/drop_zone',
9
+ :identifier => host.primary_interface,
10
+ :attached_devices => [],
11
+ :bond_mode => nil,
12
+ :subnet => subnet,
13
+ :deployment => deployment,
14
+ :host => host,
15
+ :hosts => hosts,
16
+ :interface_ids => (interface_ids - interfaces_used_in_bonds - [host.primary_interface]) %>
17
+ <% end %>
18
+
19
+ <% @interfaces.each do |interface| %>
20
+ <% unless interfaces_used_in_bonds.include?(interface.identifier) %>
21
+ <%= render 'staypuft/interfaces/drop_zone',
22
+ :identifier => interface.identifier,
23
+ :attached_devices => interface.is_a?(Nic::Bond) ? interface.attached_devices.split(',') : [],
24
+ :bond_mode => interface.is_a?(Nic::Bond) ? interface.mode : nil,
25
+ :subnet => interface.subnet,
26
+ :deployment => deployment,
27
+ :host => host,
28
+ :hosts => hosts,
29
+ :interface_ids => (interface_ids - interfaces_used_in_bonds - [interface.identifier]) %>
30
+ <% end %>
31
+ <% end %>
@@ -0,0 +1,29 @@
1
+ <div class="row">
2
+ <div class="col-md-12">
3
+ <h3><%= _("Configured Networks") %></h3>
4
+ <div id="subnets" class="panel panel-default">
5
+ <div class="panel-body">
6
+ <% @subnets.each do |subnet| %>
7
+ <% next if is_pxe?(@deployment, subnet) # we skip PXE network which is always on primary interface %>
8
+ <% next if @host.interfaces.vip.where(:subnet_id => subnet.id).present? # we skip assigned subnets %>
9
+ <%= render 'staypuft/subnets/subnet_pull',
10
+ :subnet => subnet,
11
+ :deployment => @deployment,
12
+ :active => true,
13
+ :existing => false %>
14
+ <% end %>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ </div>
19
+
20
+ <div class="row" id='network-interfaces'>
21
+ <div class="col-md-12">
22
+ <%= render 'staypuft/interface_assignments/interfaces',
23
+ :host => @host,
24
+ :hosts => @hosts,
25
+ :deployment => @deployment,
26
+ :interface => @interface,
27
+ :interfaces => @interfaces %>
28
+ </div>
29
+ </div>
@@ -1,83 +1,56 @@
1
1
  <%= javascript 'staypuft/nics_assignment' %>
2
2
 
3
+ <script>
4
+ </script>
5
+
3
6
  <% title _("Configure Interfaces (%s hosts)") % @hosts.size %>
4
7
 
5
8
  <div class="row">
6
9
  <div class="col-md-12">
7
- <h3><%= @hosts.count %> <%= "#{n_('Host', 'Hosts', @hosts.count)} #{_('to be configured')}" %></h3>
8
- <table class="table table-striped table-condensed">
9
- <thead>
10
- <tr>
11
- <th><%= sort :name, :as => _('Host Name') %></th>
12
- <th><%= @host.primary_interface %></th>
13
- <% @interfaces.each do |interface| %>
14
- <th><%= interface.identifier %></th>
15
- <% end %>
16
- </tr>
17
- </thead>
18
- <tbody>
19
- <% @hosts.each do |host| %>
10
+ <h3 data-toggle="collapse" data-target="#hosts_to_configure"><%= @hosts.count %> <%= "#{n_('Host', 'Hosts', @hosts.count)} #{_('to be configured')}" %> <span class="small glyphicon glyphicon-chevron-down"></span></h3>
11
+ <div id="hosts_to_configure" class="collapse">
12
+ <table class="table table-striped table-condensed">
13
+ <thead>
20
14
  <tr>
21
- <td class="ellipsis">
22
- <%= host_label(host) %>
23
- </td>
24
- <td>
25
- <span class="glyphicon glyphicon-ok"></span> <%= _("ready") %> <br/>
26
- <%= host.mac %><br/>
27
- <%= host.ip %>
28
- </td>
29
- <% if host.interfaces.present? %>
30
- <td>
31
- <% host.interfaces.each do |interface| %>
32
- <span class="glyphicon glyphicon-ok"></span> <%= _("ready") %> <br/>
33
- <%= interface.mac %><br/>
34
- <%= interface.ip %>
35
- <% end %>
36
- </td>
15
+ <th><%= sort :name, :as => _('Host Name') %></th>
16
+ <th><%= @host.primary_interface %></th>
17
+ <% @interfaces.each do |interface| %>
18
+ <th><%= interface.identifier %></th>
37
19
  <% end %>
38
20
  </tr>
39
- <% end %>
40
- </tbody>
41
- </table>
42
- </div>
43
- </div>
44
-
45
- <div class="row">
46
- <div class="col-md-12">
47
- <h3><%= _("Configured Networks") %></h3>
48
- <div id="subnets" class="panel panel-default">
49
- <div class="panel-body">
50
- <% @subnets.each do |subnet| %>
51
- <% next if is_pxe?(@deployment, subnet) # we skip PXE network which is always on primary interface %>
52
- <% next if @host.interfaces.vip.where(:subnet_id => subnet.id).present? # we skip assigned subnets %>
53
- <%= render 'staypuft/subnets/subnet_pull',
54
- :subnet => subnet,
55
- :deployment => @deployment,
56
- :active => true,
57
- :existing => false %>
58
- <% end %>
59
- </div>
21
+ </thead>
22
+ <tbody>
23
+ <% @hosts.each do |host| %>
24
+ <tr>
25
+ <td class="ellipsis">
26
+ <%= host_label(host) %>
27
+ </td>
28
+ <td>
29
+ <%= host.mac %><br/>
30
+ <%= host.ip %>
31
+ </td>
32
+ <% if host.interfaces.present? %>
33
+ <td>
34
+ <% host.interfaces.each do |interface| %>
35
+ <%= interface.mac %><br/>
36
+ <%= interface.ip %>
37
+ <% end %>
38
+ </td>
39
+ <% end %>
40
+ </tr>
41
+ <% end %>
42
+ </tbody>
43
+ </table>
60
44
  </div>
61
45
  </div>
62
46
  </div>
63
47
 
64
- <div class="row">
65
- <div class="col-md-12">
66
- <h3><%= _("Network Interfaces") %></h3>
67
- <% if (subnet = @host.subnet) %>
68
- <%= render 'staypuft/interfaces/drop_zone',
69
- :identifier => @host.primary_interface,
70
- :subnet => subnet,
71
- :deployment => @deployment,
72
- :host => @host %>
73
- <% end %>
74
-
75
- <% @interfaces.each do |interface| %>
76
- <%= render 'staypuft/interfaces/drop_zone',
77
- :identifier => interface.identifier,
78
- :subnet => interface.subnet,
79
- :deployment => @deployment,
80
- :host => @host %>
81
- <% end %>
82
- </div>
48
+ <div id="nics_assignment">
49
+ <%= render 'staypuft/interface_assignments/nics_assignment',
50
+ :host => @host,
51
+ :hosts => @hosts,
52
+ :deployment => @deployment,
53
+ :subnets => @subnets,
54
+ :interface => @interface,
55
+ :interfaces => @interfaces %>
83
56
  </div>
@@ -1,7 +1,30 @@
1
1
  <div class="panel panel-default interface" id="<%= identifier %>-interface" data-interface="<%= identifier %>">
2
- <div class="panel-heading">
3
- <h3 class="panel-title"><%= identifier %></h3>
2
+ <div class="panel-heading clearfix">
3
+ <% if bond_mode %>
4
+ <div id="bonding_mode" class="dropdown pull-right" data-path="<%= change_mode_deployment_bond_path(:id => identifier) %>">
5
+ <%= _('Bonding Mode:') %>
6
+ <button class="btn btn-default btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
7
+ <%= bond_mode %>
8
+ <span class="caret"></span>
9
+ </button>
10
+ <ul class="dropdown-menu">
11
+ <% Nic::Bond::MODES.each do |mode| %>
12
+ <li class="<%= 'selected' if mode == bond_mode %>"><a href="#"><%= mode %></a></li>
13
+ <% end %>
14
+ </ul>
15
+ </div>
16
+ <% end %>
17
+
18
+ <h3 class="panel-title">
19
+ <%= identifier %>
20
+ <em>
21
+ <% unless attached_devices.empty? %>
22
+ (<%= attached_devices.join(', ') %>)
23
+ <% end %>
24
+ </em>
25
+ </h3>
4
26
  </div>
27
+
5
28
  <div class="panel-body">
6
29
  <!-- physical interface assignment (can be only one at most) -->
7
30
  <span id="<%= identifier %>-physicals">
@@ -14,7 +37,7 @@
14
37
 
15
38
  <!-- all virtual devices attached to this physical interface assignments -->
16
39
  <span id="<%= identifier %>-virtuals">
17
- <% host.interfaces.where(:physical_device => identifier).where("subnet_id IS NOT NULL").each do |virtual| %>
40
+ <% host.interfaces.where(:attached_to => identifier).where("subnet_id IS NOT NULL").each do |virtual| %>
18
41
  <%= render 'staypuft/subnets/subnet_pull',
19
42
  :subnet => virtual.subnet,
20
43
  :deployment => deployment,
@@ -23,6 +46,52 @@
23
46
  <% end %>
24
47
  </span>
25
48
 
49
+ <span class="top_actions pull-right">
50
+ <div class="btn-group">
51
+ <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
52
+ <span class="glyphicon glyphicon-link" /><span class="caret"/>
53
+ </button>
54
+ <ul class="dropdown-menu pull-right" role="menu">
55
+ <lh><%= _("Bond Interface With:") %></lh>
56
+ <% if interface_ids.length > 0 %>
57
+ <% interface_ids.each do |interface_id| %>
58
+ <li>
59
+ <% if attached_devices.empty? %>
60
+ <%= link_to deployment_bonds_path(:host_ids => hosts.map(&:id), :interfaces => [identifier, interface_id]), :remote => true, :method => :post do %>
61
+ <span class="glyphicon glyphicon-plus-sign">
62
+ <%= interface_id %>
63
+ </span>
64
+ <% end %>
65
+ <% else %>
66
+ <%= link_to add_slave_deployment_bond_path(:host_ids => hosts.map(&:id), :id => identifier, :interface => interface_id), :remote => true, :method => :put do %>
67
+ <span class="glyphicon glyphicon-plus-sign">
68
+ <%= interface_id %>
69
+ </span>
70
+ <% end %>
71
+ <% end %>
72
+ </li>
73
+ <% end %>
74
+ <% else %>
75
+ <li>
76
+ <span class="glyphicon glyphicon-info-sign" style="padding: 3px 20px;">
77
+ <%= _("No interface available") %>
78
+ </span>
79
+ </li>
80
+ <% end %>
81
+ <% unless attached_devices.empty? %>
82
+ <li role="presentation" class="divider"></li>
83
+ <li>
84
+ <%= link_to deployment_bond_path(:id => identifier, :host_ids => hosts.map(&:id)), :remote => true, :method => :delete do %>
85
+ <span class="glyphicon glyphicon-remove-sign">
86
+ <%= _("Release Bond") %>
87
+ </span>
88
+ <% end %>
89
+ </li>
90
+ <% end %>
91
+ </ul>
92
+ </div>
93
+ </span>
94
+
26
95
  <div class="empty-zone">
27
96
  &nbsp;
28
97
  </div>
@@ -8,9 +8,9 @@
8
8
  end.join
9
9
  end %>
10
10
 
11
- <div class="glance_nfs_network_path col-md-offset-0 hide">
12
- <%= text_f p, :nfs_network_path, class: "glance_nfs_network_path",
11
+ <div class="glance_nfs_network_path inset_form hide">
12
+ <%= change_label_width 4, text_f(p, :nfs_network_path, class: "glance_nfs_network_path",
13
13
  label: _(Staypuft::Deployment::GlanceService::NfsNetworkPath::HUMAN),
14
- help_inline: _(Staypuft::Deployment::GlanceService::NfsNetworkPath::HUMAN_AFTER) %>
14
+ help_inline: _(Staypuft::Deployment::GlanceService::NfsNetworkPath::HUMAN_AFTER)) %>
15
15
  </div>
16
16
  <% end %>
@@ -10,7 +10,7 @@
10
10
  end.join
11
11
  end) %>
12
12
 
13
- <div class="neutron_tenant_vlan_ranges col-md-offset-0 hide">
13
+ <div class="neutron_tenant_vlan_ranges inset_form hide">
14
14
  <%= change_label_width 4, text_f(p, :tenant_vlan_ranges, class: "neutron_tenant_vlan_ranges",
15
15
  label: _(Staypuft::Deployment::NeutronService::TenantVlanRanges::HUMAN),
16
16
  help_inline: _(Staypuft::Deployment::NeutronService::TenantVlanRanges::HUMAN_AFTER)) %>
@@ -38,7 +38,7 @@
38
38
  end.join
39
39
  end %>
40
40
 
41
- <div class="single_password col-md-offset-0 hide">
41
+ <div class="single_password inset_form hide">
42
42
  <%= password_f p, :single_password,
43
43
  :label => _("Password"),
44
44
  :class => "single_password",
@@ -49,7 +49,7 @@
49
49
  :class => "single_password",
50
50
  :placeholder => '' %>
51
51
  </div>
52
-
52
+
53
53
  <%= render :partial => "wizard_form_buttons",
54
54
  :locals => { :deployment => @deployment,
55
55
  :step => Staypuft::Deployment::STEP_SETTINGS } %>
@@ -43,7 +43,7 @@
43
43
  <%= link_to _("Cancel"), deployment_path(@deployment),
44
44
  :class => "btn btn-danger" %>
45
45
  <%= button_tag(:type => 'submit', :class => "btn btn-primary pull-right") do %>
46
- <%= _("Next") %>
46
+ <%= _("Submit") %>
47
47
  <% end %>
48
48
  </div>
49
49
  <% end %>
@@ -5,6 +5,9 @@
5
5
  :as => 'subnet_type',
6
6
  :locals => { :subnet_typing => @subnet_typing, :deployment => @deployment } %>');
7
7
  $("#<%= dom_id(@subnet_type) %>").draggable({revert: 'invalid'});
8
+ <% else %>
9
+ error = '<%=j @errors.map { |k, v| "#{h(k)}: #{v.join(', ')}" }.join('<br />').html_safe %>';
10
+ $.jnotify(error, { type: "error", sticky: true });
8
11
  <% end %>
9
12
 
10
13
  <% if @warn.present? %>
@@ -5,6 +5,9 @@
5
5
  :locals => { :deployment => @deployment },
6
6
  :as => 'subnet_type' %>');
7
7
  $("#<%= dom_id(@subnet_type) %>").draggable({revert: 'invalid'});
8
+ <% else %>
9
+ error = '<%=j @errors.map { |k, v| "#{h(k)}: #{v.join(', ')}" }.join('<br />').html_safe %>';
10
+ $.jnotify(error, { type: "error", sticky: true });
8
11
  <% end %>
9
12
 
10
13
  <% if @warn.present? %>
@@ -7,6 +7,9 @@
7
7
  $("#<%= dom_id(@subnet_type) %>").draggable({
8
8
  revert: 'invalid'
9
9
  });
10
+ <% else %>
11
+ error = '<%=j @errors.map { |k, v| "#{h(k)}: #{v.join(', ')}" }.join('<br />').html_safe %>';
12
+ $.jnotify(error, { type: "error", sticky: true });
10
13
  <% end %>
11
14
 
12
15
  <% if @warn.present? %>
data/config/routes.rb CHANGED
@@ -18,6 +18,14 @@ Rails.application.routes.draw do
18
18
  resources :steps
19
19
 
20
20
  resources :interface_assignments, :only => [:index, :create, :destroy]
21
+
22
+ resources :bonds, :only => [:create, :destroy] do
23
+ member do
24
+ put 'add_slave'
25
+ put 'remove_slave'
26
+ put 'change_mode'
27
+ end
28
+ end
21
29
  end
22
30
 
23
31
  resources :subnet_typings, :only => [:create, :destroy, :update]
@@ -0,0 +1,7 @@
1
+ class AddValidationToSubnetTypes < ActiveRecord::Migration
2
+ def change
3
+ add_column :staypuft_subnet_types, :foreman_managed_ips, :boolean, :default => true
4
+ add_column :staypuft_subnet_types, :default_to_provisioning, :boolean, :default => true
5
+ add_column :staypuft_subnet_types, :dedicated_subnet, :boolean, :default => false
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module Staypuft
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end