staypuft 0.3.9 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -41,6 +41,11 @@ module Staypuft
41
41
  end
42
42
  end
43
43
  end
44
+ unless record.private_fixed_range.empty?
45
+ if record.network_size < 4
46
+ record.errors[:private_fixed_range] << "Fixed range is too small. Specify CIDR for network size #{record.min_fixed_range_cidr} or larger"
47
+ end
48
+ end
44
49
  end
45
50
  end
46
51
 
@@ -119,6 +124,37 @@ module Staypuft
119
124
  end
120
125
  end
121
126
 
127
+ def fixed_range_size
128
+ fixed_range_str = private_fixed_range
129
+ if fixed_range_str.empty?
130
+ 0
131
+ else
132
+ fixed_range = IPAddr.new(fixed_range_str).to_range
133
+ fixed_range.last.to_i - fixed_range.first.to_i + 1
134
+ end
135
+ end
136
+
137
+ # network size is equal to the number of IP addresses in
138
+ # the fixed range, divided by the number of networks,
139
+ # rounded *down* to the next power of two (or zero if <1)
140
+ def network_size
141
+ unrounded_size = fixed_range_size / num_networks
142
+ if unrounded_size < 1
143
+ 0
144
+ else
145
+ 2**Math.log(unrounded_size,2).floor
146
+ end
147
+ end
148
+
149
+ # for the current num_networks value (1 for non-vlan;
150
+ # based on the vlan range for VLAN, this calculates
151
+ # the smallest fixed range network cidr assuming the
152
+ # smallest useful network size of 4 (2 hosts+network
153
+ # address+broadcast address)
154
+ def min_fixed_range_cidr
155
+ "/#{32 - Math.log(4*num_networks,2).ceil}"
156
+ end
157
+
122
158
  def param_hash
123
159
  { 'network_manager' => network_manager,
124
160
  'vlan_range' => vlan_range,
@@ -128,7 +164,7 @@ module Staypuft
128
164
 
129
165
  class Jail < Safemode::Jail
130
166
  allow :network_manager, :network_overrides, :private_fixed_range, :public_floating_range,
131
- :num_networks
167
+ :num_networks, :network_size
132
168
  end
133
169
 
134
170
  end
@@ -7,7 +7,7 @@ end
7
7
 
8
8
  Deface::Override.new(:virtual_path => "hosts/_form",
9
9
  :name => "include_custom_js_for_hosts_edit",
10
- :insert_after => "erb[loud]:contains('form_for')",
10
+ :insert_after => "li > a[href='#network']",
11
11
  :text => "<%= javascript 'staypuft/host_edit'%>"
12
12
  )
13
13
 
@@ -11,43 +11,7 @@
11
11
  <%= submit_tag _("Unassign Hosts"), :class => "btn btn-primary btn-sm", :disabled => true, :id => "unassign_hosts_button" %>
12
12
  </div>
13
13
  </div>
14
- <table class="table table-bordered table-striped table-condensed">
15
- <thead>
16
- <tr>
17
- <th class="ca">
18
- <%= tag :input, type: 'checkbox', class: 'check_all' %>
19
- </th>
20
- <th><%= sort :name, :as => _('Name') %></th>
21
- <th><%= _("Deployment Role") %></th>
22
- <th><%= _("CPUs") %><br/><span class="text-muted small"><%= _("(cores)") %></span></th>
23
- <th><%= _("Memory") %><br/><span class="text-muted small"><%= _("(GB)") %></span></th>
24
- <th><%= _("NICs") %></th>
25
- <th class="hidden-s hidden-xs"><%= sort :ip, :as => _('IP Address') %></th>
26
- </tr>
27
- </thead>
28
- <tbody class="searchable">
29
- <% hosts.each do |host| %>
30
- <tr class="checkbox_highlight">
31
- <td class="ca">
32
- <%= check_box_tag 'host_ids[]',
33
- host.id,
34
- false,
35
- id: "host_ids_#{host.id}" %>
36
- </td>
37
- <td class="ellipsis">
38
- <%= host_label(host) %>
39
- </td>
40
- <td class="ellipsis">
41
- <%= link_to(host.hostgroup.role, hosts_path(:search => "os_description = #{host.hostgroup.role}")) if host.hostgroup %>
42
- </td>
43
- <td><%= host.cpus %></td>
44
- <td><%= host.mem %></td>
45
- <td><%= host_nics(host) %></td>
46
- <td class="hidden-s hidden-xs"><%= host.ip %></td>
47
- </tr>
48
- <% end %>
49
- </tbody>
50
- </table>
14
+ <%= render partial: "hosts_table", locals: { hosts: hosts, deployment_role_col: true } %>
51
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) %>">
52
16
  <div class="modal-dialog modal-lg">
53
17
  <div class="modal-content">
@@ -63,7 +27,7 @@
63
27
  </div>
64
28
  <div class="modal-footer">
65
29
  <button type="button" class="btn btn-default" data-dismiss="modal"><%= _("Cancel") %></button>
66
- <button type="button" class="btn btn-primarym" data-dismiss="modal"><%= _("Done") %></button>
30
+ <button type="button" class="btn btn-primary done" data-dismiss="modal"><%= _("Done") %></button>
67
31
  </div>
68
32
  </div>
69
33
  </div>
@@ -11,43 +11,7 @@
11
11
  data-target = "#role_modal" disabled="true"><%= _("Assign Hosts") %></button>
12
12
  </div>
13
13
  </div>
14
- <table class="table table-bordered table-striped table-condensed">
15
- <thead>
16
- <tr>
17
- <th class="ca">
18
- <%= tag :input, type: 'checkbox', class: 'check_all' %>
19
- </th>
20
- <th><%= sort :name, :as => _('Name') %></th>
21
- <th><%= _("Operating System") %></th>
22
- <th><%= _("CPUs") %><br/><span class="text-muted small"><%= _("(cores)") %></span></th>
23
- <th><%= _("Memory") %><br/><span class="text-muted small"><%= _("(GB)") %></span></th>
24
- <th><%= _("NICs") %></th>
25
- <th class="hidden-s hidden-xs"><%= sort :ip, :as => _('IP Address') %></th>
26
- </tr>
27
- </thead>
28
- <tbody class="searchable">
29
- <% hosts.each do |host| %>
30
- <tr class="checkbox_highlight">
31
- <td class="ca">
32
- <%= check_box_tag 'host_ids[]',
33
- host.id,
34
- false,
35
- id: "host_ids_#{host.id}" %>
36
- </td>
37
- <td class="ellipsis">
38
- <%= host_label(host) %>
39
- </td>
40
- <td class="ellipsis">
41
- <%= link_to(host.os.to_label, hosts_path(:search => "os_description = #{host.os.description}")) if host.respond_to?(:os) && host.os %>
42
- </td>
43
- <td><%= host.cpus if host.respond_to?(:cpu) %></td>
44
- <td><%= host.mem if host.respond_to?(:mem) %></td>
45
- <td><%= host_nics(host) %></td>
46
- <td class="hidden-s hidden-xs"><%= host.ip %></td>
47
- </tr>
48
- <% end %>
49
- </tbody>
50
- </table>
14
+ <%= render partial: "hosts_table", locals: { hosts: hosts, operating_system_col: true } %>
51
15
  <div class="modal fade" id="role_modal" tabindex="-1" role="dialog" aria-labelledby="Deployment Roles" aria-hidden="true">
52
16
  <div class="modal-dialog">
53
17
  <div class="modal-content">
@@ -4,6 +4,7 @@
4
4
  </th>
5
5
  <th><%= sort :name, :as => _('Name') %></th>
6
6
  <th><%= _('NICs') %></th>
7
+ <th><%= _('Storage') %></th>
7
8
  <% if local_assigns[:deploying_col] %>
8
9
  <th class="hidden-s hidden-xs"><%= _('Deploying?') %></th>
9
10
  <% end %>
@@ -16,6 +16,10 @@
16
16
  <%= host_nics(host) %>
17
17
  </td>
18
18
 
19
+ <td>
20
+ <%= host_disks(host) %>
21
+ </td>
22
+
19
23
  <% unless local_assigns[:disabled].nil? %>
20
24
  <td class="hidden-s hidden-xs">
21
25
  <% if disabled %>
@@ -0,0 +1,51 @@
1
+ <table class="table table-bordered table-striped table-condensed">
2
+ <thead>
3
+ <tr>
4
+ <th class="ca">
5
+ <%= tag :input, type: 'checkbox', class: 'check_all' %>
6
+ </th>
7
+ <th><%= sort :name, :as => _('Name') %></th>
8
+ <% if local_assigns[:deployment_role_col] %>
9
+ <th><%= _("Deployment Role") %></th>
10
+ <% end %>
11
+ <% if local_assigns[:operating_system_col] %>
12
+ <th><%= _("Operating System") %></th>
13
+ <% end %>
14
+ <th><%= _("CPUs") %><br/><span class="text-muted small"><%= _("(cores)") %></span></th>
15
+ <th><%= _("Memory") %><br/><span class="text-muted small"><%= _("(GB)") %></span></th>
16
+ <th><%= _("Storage") %></th>
17
+ <th><%= _("NICs") %></th>
18
+ <th class="hidden-s hidden-xs"><%= sort :ip, :as => _('IP Address') %></th>
19
+ </tr>
20
+ </thead>
21
+ <tbody class="searchable">
22
+ <% hosts.each do |host| %>
23
+ <tr class="checkbox_highlight">
24
+ <td class="ca">
25
+ <%= check_box_tag 'host_ids[]',
26
+ host.id,
27
+ false,
28
+ id: "host_ids_#{host.id}" %>
29
+ </td>
30
+ <td class="ellipsis">
31
+ <%= host_label(host) %>
32
+ </td>
33
+ <% if local_assigns[:deployment_role_col] %>
34
+ <td class="ellipsis">
35
+ <%= link_to(host.hostgroup.role, hosts_path(:search => "os_description = #{host.hostgroup.role}")) if host.hostgroup %>
36
+ </td>
37
+ <% end %>
38
+ <% if local_assigns[:operating_system_col] %>
39
+ <td class="ellipsis">
40
+ <%= link_to(host.os.to_label, hosts_path(:search => "os_description = #{host.os.description}")) if host.respond_to?(:os) && host.os %>
41
+ </td>
42
+ <% end %>
43
+ <td><%= host.cpus if host.respond_to?(:cpus) %></td>
44
+ <td><%= host.mem if host.respond_to?(:mem) %></td>
45
+ <td><%= host_disks(host) %></td>
46
+ <td><%= host_nics(host) %></td>
47
+ <td class="hidden-s hidden-xs"><%= host.ip %></td>
48
+ </tr>
49
+ <% end %>
50
+ </tbody>
51
+ </table>
@@ -2,6 +2,46 @@
2
2
 
3
3
  <% title _("Configure Interfaces (%s hosts)") % @hosts.size %>
4
4
 
5
+ <div class="row">
6
+ <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| %>
20
+ <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>
37
+ <% end %>
38
+ </tr>
39
+ <% end %>
40
+ </tbody>
41
+ </table>
42
+ </div>
43
+ </div>
44
+
5
45
  <div class="row">
6
46
  <div class="col-md-12">
7
47
  <h3><%= _("Configured Networks") %></h3>
@@ -1,4 +1,6 @@
1
1
  <%= f.fields_for :neutron, @deployment.neutron do |p| %>
2
+ <%= base_errors_for @deployment.neutron %>
3
+ <div class="form-group <%= @deployment.neutron.errors.empty? ? "" : 'has-error' %> hide"></div>
2
4
  <%= change_label_width(4, field(p, :network_segmentation, :label => _(Staypuft::Deployment::NeutronService::NetworkSegmentation::HUMAN)) do
3
5
  Staypuft::Deployment::NeutronService::NetworkSegmentation::LABELS.map do |value, label|
4
6
  radio_button_f_non_inline(p, :network_segmentation,
@@ -14,4 +16,41 @@
14
16
  help_inline: _(Staypuft::Deployment::NeutronService::TenantVlanRanges::HUMAN_AFTER)) %>
15
17
  </div>
16
18
 
19
+ <div class="form-group">
20
+ <label class="col-md-4 control-label"><%= _(Staypuft::Deployment::NeutronService::Ml2Mechanisms::HUMAN) %></label>
21
+ <div class="col-md-4">
22
+ <%= check_box_f_non_inline(p, :ml2_openvswitch,
23
+ :checked_value => 'true',
24
+ :unchecked_value => 'false',
25
+ :checked => @deployment.neutron.openvswitch_mechanism?,
26
+ :text => _(Staypuft::Deployment::NeutronService::Ml2Mechanisms::LABELS['openvswitch']))
27
+ %>
28
+ <%= check_box_f_non_inline(p, :ml2_l2population,
29
+ :checked_value => 'true',
30
+ :unchecked_value => 'false',
31
+ :checked => @deployment.neutron.l2population_mechanism?,
32
+ :text => _(Staypuft::Deployment::NeutronService::Ml2Mechanisms::LABELS['l2population']))
33
+ %>
34
+ <%= check_box_f_non_inline(p, :ml2_cisco_nexus,
35
+ :checked_value => 'true',
36
+ :unchecked_value => 'false',
37
+ :checked => @deployment.neutron.cisco_nexus_mechanism?,
38
+ :text => _(Staypuft::Deployment::NeutronService::Ml2Mechanisms::LABELS['cisco_nexus']))
39
+ %>
40
+ </div>
41
+ </div>
42
+ <div class="neutron_cisco_nexus col-md-offset-1 hide">
43
+ <div id="nexuses" class="neutron_nexus_picker">
44
+ <% @deployment.neutron.nexuses.each_with_index do |nexus, index| %>
45
+ <%= p.fields_for "nexuses[]", nexus, index: index do |e| %>
46
+ <% render partial: 'neutron_cisco_nexus_form', locals: {e: e} %>
47
+ <% end %>
48
+ <% end %>
49
+ </div>
50
+ <script type='html/template' id='nexus_form_template'>
51
+ <%= p.fields_for 'nexuses[]', Staypuft::Deployment::NeutronService::Cisconexus.new, index: 'NEW_RECORD' do |e| render(partial: 'neutron_cisco_nexus_form', locals: {e: e}); end %>
52
+ </script>
53
+ <button type="button" class= "btn btn-primary btn-sm add_another_switch"><%= _("Add Another Switch") %></button>
54
+ </div>
55
+
17
56
  <% end %>
@@ -0,0 +1,17 @@
1
+ <div class="nexus well">
2
+ <h5 class="muted"><a href="#" class="remove"><i class="glyphicon glyphicon-remove-sign ">&nbsp;</i></a>&nbsp;Switch #<span class="switch_number">1</span></h5>
3
+ <%= text_f e, :hostname, class: "neutron_cisco_nexus",
4
+ label: _(Staypuft::Deployment::NeutronService::Cisconexus::Hostname::HUMAN) %>
5
+ <%= text_f e, :ip, class: "neutron_cisco_nexus",
6
+ label: _(Staypuft::Deployment::NeutronService::Cisconexus::Ip::HUMAN) %>
7
+ <%= text_f e, :login, class: "neutron_cisco_nexus",
8
+ label: _(Staypuft::Deployment::NeutronService::Cisconexus::Login::HUMAN) %>
9
+ <%= text_f e, :password, class: "neutron_cisco_nexus",
10
+ label: _(Staypuft::Deployment::NeutronService::Cisconexus::Password::HUMAN) %>
11
+ <%= text_f e, :ssh_port, class: "neutron_cisco_nexus",
12
+ label: _(Staypuft::Deployment::NeutronService::Cisconexus::SshPort::HUMAN) %>
13
+ <%= textarea_f e, :port_map, class: "neutron_cisco_nexus",
14
+ label: _(Staypuft::Deployment::NeutronService::Cisconexus::PortMap::HUMAN),
15
+ rows: 5,
16
+ help_inline: _(Staypuft::Deployment::NeutronService::Cisconexus::PortMap::HELP_INLINE) %>
17
+ </div>
@@ -33,6 +33,7 @@ module Staypuft
33
33
  ::Host::Managed.send :include, Staypuft::Concerns::HostOpenStackAffiliation
34
34
  ::Host::Managed.send :include, Staypuft::Concerns::HostDetailsHelper
35
35
  ::Host::Discovered.send :include, Staypuft::Concerns::HostOpenStackAffiliation
36
+ ::Host::Discovered.send :include, Staypuft::Concerns::HostDetailsHelper
36
37
  ::Puppetclass.send :include, Staypuft::Concerns::PuppetclassExtensions
37
38
  ::Nic::Base.send :include, Staypuft::Concerns::SubnetIpManagement
38
39
  ::Nic::Base.send :include, Staypuft::Concerns::VipNicScopes
@@ -1,3 +1,3 @@
1
1
  module Staypuft
2
- VERSION = '0.3.9'
2
+ VERSION = '0.4.0'
3
3
  end