Class: Staypuft::BondsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Staypuft::BondsController
- Defined in:
- app/controllers/staypuft/bonds_controller.rb
Instance Method Summary collapse
Instance Method Details
#add_slave ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/controllers/staypuft/bonds_controller.rb', line 48 def add_slave @bonds.each { |bond| bond.add_slave(params[:interface]) } ActiveRecord::Base.transaction do results = @bonds.map(&:save) @result = results.all? clear_nic_assignments([params[:interface]]) raise ActiveRecord::Rollback unless @result end find_unassigned_subnets end |
#change_mode ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/staypuft/bonds_controller.rb', line 61 def change_mode @bonds.each { |bond| bond.mode = params[:mode] } ActiveRecord::Base.transaction do results = @bonds.map(&:save) @result = results.all? raise ActiveRecord::Rollback unless @result end render :nothing => true end |
#create ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/staypuft/bonds_controller.rb', line 6 def create @bonds = [] @hosts.each do |host| existing = host.interfaces.select { |i| i.is_a?(Nic::Bond) }.map(&:identifier) i = 0 while existing.include?("bond#{i}") do i +=1 end bond = Nic::Bond.new bond.identifier = "bond#{i}" params[:interfaces].each do |interface| bond.add_slave(interface) end bond.mode = 'balance-tlb' bond. = 'miimon=100' bond.host = host @bonds.push bond end ActiveRecord::Base.transaction do results = @bonds.map(&:save) @result = results.all? clear_nic_assignments(params[:interfaces]) raise ActiveRecord::Rollback unless @result end find_unassigned_subnets end |
#destroy ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/staypuft/bonds_controller.rb', line 37 def destroy ActiveRecord::Base.transaction do clear_nic_assignments([params[:id]]) results = @bonds.map(&:destroy) @result = results.all? raise ActiveRecord::Rollback unless @result end find_unassigned_subnets end |
#remove_slave ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/staypuft/bonds_controller.rb', line 74 def remove_slave @bonds.each { |bond| bond.remove_slave(params[:interface]) } ActiveRecord::Base.transaction do results = @bonds.map(&:save) @result = results.all? clear_nic_assignments(params[:interfaces]) raise ActiveRecord::Rollback unless @result end end |