staypuft 0.4.15 → 0.5.0

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.
Files changed (37) hide show
  1. checksums.yaml +13 -5
  2. data/app/assets/javascripts/staypuft/staypuft.js +6 -0
  3. data/app/controllers/staypuft/bonds_controller.rb +18 -2
  4. data/app/controllers/staypuft/deployments_controller.rb +19 -36
  5. data/app/controllers/staypuft/interface_assignments_controller.rb +3 -3
  6. data/app/controllers/staypuft/steps_controller.rb +1 -0
  7. data/app/lib/actions/staypuft/deployment/deploy.rb +5 -2
  8. data/app/lib/actions/staypuft/deployment/populate.rb +1 -1
  9. data/app/lib/actions/staypuft/host/deploy.rb +6 -15
  10. data/app/lib/actions/staypuft/host/puppet_run.rb +5 -8
  11. data/app/lib/actions/staypuft/host/{wait_until_host_ready.rb → report_check.rb} +20 -11
  12. data/app/lib/actions/staypuft/host/{build.rb → trigger_provisioning.rb} +13 -9
  13. data/app/lib/actions/staypuft/host/update.rb +33 -0
  14. data/app/lib/actions/staypuft/host/{wait_until_installed.rb → wait_until_provisioned.rb} +7 -5
  15. data/app/lib/actions/staypuft/host/wait_until_ready.rb +56 -0
  16. data/app/lib/actions/staypuft/hostgroup/ordered_deploy.rb +98 -6
  17. data/app/lib/staypuft/network_query.rb +2 -10
  18. data/app/lib/staypuft/seeder.rb +1 -3
  19. data/app/models/staypuft/concerns/host_interface_management.rb +11 -29
  20. data/app/models/staypuft/deployment.rb +38 -2
  21. data/app/models/staypuft/deployment/cinder_service/equallogic.rb +1 -1
  22. data/app/models/staypuft/deployment/passwords.rb +1 -1
  23. data/app/models/staypuft/deployment_vip_nic.rb +13 -0
  24. data/app/models/staypuft/interface_assigner.rb +1 -1
  25. data/app/models/staypuft/vip_nic.rb +18 -0
  26. data/app/views/staypuft/deployments/_deployment_summary.html.erb +3 -0
  27. data/app/views/staypuft/deployments/_host_head_row.html.erb +1 -0
  28. data/app/views/staypuft/deployments/_host_row.html.erb +8 -0
  29. data/app/views/staypuft/interface_assignments/_nics_assignment.html.erb +1 -1
  30. data/app/views/staypuft/steps/network_configuration.html.erb +12 -1
  31. data/db/migrate/20141107144800_create_staypuft_deployment_vip_nics.rb +15 -0
  32. data/lib/staypuft/engine.rb +0 -2
  33. data/lib/staypuft/version.rb +1 -1
  34. metadata +22 -20
  35. data/app/lib/actions/staypuft/hostgroup/deploy.rb +0 -93
  36. data/app/models/staypuft/concerns/subnet_ip_management.rb +0 -17
  37. data/app/models/staypuft/concerns/vip_nic_scopes.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 321059b6c0b8215487c4923f3c767da8b0dc98d5
4
- data.tar.gz: abaa9a415228d9cc6859c95e3277fbfb41d2755e
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDYwM2Y4Nzc0YWE3Y2NjMGU2MzEwNDg3MTU0ZjY2Y2IzYjBhNzc3Ng==
5
+ data.tar.gz: !binary |-
6
+ NDcyMjFkN2Q5OWZhZDU0MzA0M2RmOWM2ZjkyMTFlZTAyNmFmZDhhMw==
5
7
  SHA512:
6
- metadata.gz: a99eae2273ce70538323bb33065d5b8b9ee45342975157b26b97702f7ae20cd25714add0c15fc58a72da05cf626cd0afdd12c3b501c44f50fa9e694ef55974c2
7
- data.tar.gz: 69436bf024671e0a8b273fb75ff6f00e7089463271eaf469e68c74595f4eff866863cb0b05b6bba7ac2ba277672b29f48ad1e121b94064a91bc55380877e21a8
8
+ metadata.gz: !binary |-
9
+ ZWRlZWU5YWMzMjMyODcyMGIxZjRhNzIxYzJiNTEwZDhhZDNiMzFiNzcxYzQ1
10
+ ZTEyNWYzNjY4YjI2NDMyM2I5MThjZGVmYWFhMWU0ZTI3ZTk3ZGUzMWQ4YWVh
11
+ YjI4ZTE5NDE4NGYzMmQ3OGUyYjI4YWZhOGZjMzQzNWZkZTc5M2M=
12
+ data.tar.gz: !binary |-
13
+ NGNmYzQwOWE5NDUxOTFjMTc5NzllNmI0NzAyNmYxZDA4ZGFmNjY4ZTY4ZDJj
14
+ NjQyZTdlYWI2ZWQ5MWE0OGM0MjFhMTA1OTFkN2UwYjEyMWZkZTc2ZGI2Mzc0
15
+ MGFlNDFmNjYyODdkNmUxOThlZjc1ZGVkNDA2MDliYmZlYTBiMTM=
@@ -299,6 +299,12 @@ $(function () {
299
299
  });
300
300
  });
301
301
 
302
+ $("#vip_modal_button").on('click', function(e) {
303
+ $("#vip_modal").modal('show');
304
+ });
305
+ $('#vip_modal').on('shown.bs.modal', function(){
306
+ $("#vip_modal_button").submit();
307
+ })
302
308
  var scrolled = false;
303
309
 
304
310
  $(window).scroll(function(){
@@ -28,6 +28,7 @@ module Staypuft
28
28
  results = @bonds.map(&:save)
29
29
  @result = results.all?
30
30
  clear_nic_assignments(params[:interfaces])
31
+ reassign_primary
31
32
  raise ActiveRecord::Rollback unless @result
32
33
  end
33
34
 
@@ -93,12 +94,12 @@ module Staypuft
93
94
  def find_hosts
94
95
  @hosts = Host::Managed.where(:id => params[:host_ids]).includes(:interfaces)
95
96
  @host = @hosts.first
96
- @interfaces = @host.interfaces.where("type <> 'Nic::BMC'").non_vip.order(:identifier).where(['(virtual = ? OR type = ?)', false, 'Nic::Bond'])
97
+ @interfaces = @host.interfaces.where("type <> 'Nic::BMC'").order(:identifier).where(['(virtual = ? OR type = ?)', false, 'Nic::Bond'])
97
98
  @deployment = Deployment.find(params[:deployment_id])
98
99
  end
99
100
 
100
101
  def find_unassigned_subnets
101
- assigned_subnet_ids = ([@host.subnet_id] + @host.interfaces.non_vip.map(&:subnet_id)).compact.uniq
102
+ assigned_subnet_ids = ([@host.subnet_id] + @host.interfaces.map(&:subnet_id)).compact.uniq
102
103
  @subnets = @deployment.subnets.where(["#{Subnet.table_name}.id NOT IN (?)", assigned_subnet_ids]).uniq
103
104
  end
104
105
 
@@ -127,5 +128,20 @@ module Staypuft
127
128
  end
128
129
  end
129
130
  end
131
+
132
+ def reassign_primary
133
+ @bonds.each do |bond|
134
+ if bond.attached_devices_identifiers.include? bond.host.primary_interface
135
+ subnet_typing = Staypuft::SubnetTyping.includes('subnet_type').where(:deployment_id => @deployment, :subnet_id => bond.host.subnet).first
136
+ if subnet_typing && subnet_typing.subnet_type.name == Staypuft::SubnetType::PXE
137
+ pxe_subnet = bond.host.subnet
138
+ assigner = InterfaceAssigner.new(@deployment, bond.host, bond.host.subnet)
139
+ assigner.unassign
140
+ pxe_assigner = InterfaceAssigner.new(@deployment, bond, pxe_subnet)
141
+ pxe_assigner.assign
142
+ end
143
+ end
144
+ end
145
+ end
130
146
  end
131
147
  end
@@ -115,26 +115,14 @@ module Staypuft
115
115
 
116
116
  hosts_to_unassign = ::Host::Base.find Array(params[:host_ids])
117
117
 
118
- removed_vips_hostgroup = nil
119
118
  hosts_to_unassign.each do |host|
120
119
  unless host.open_stack_deployed? && deployment_in_progress
121
- vip_interfaces = host.interfaces.vip
122
- removed_vips_hostgroup = host.hostgroup unless vip_interfaces.empty?
123
- vip_interfaces.each(&:destroy)
124
120
  host.open_stack_unassign
125
121
  host.environment = Environment.get_discovery
126
122
  host.save!
127
123
  host.setBuild
128
124
  end
129
125
  end
130
- if removed_vips_hostgroup
131
- removed_vips_hostgroup.reload
132
- newhost = removed_vips_hostgroup.hosts.first
133
- unless newhost.nil?
134
- build_vips_if_needed(newhost)
135
- newhost.save!
136
- end
137
- end
138
126
 
139
127
  redirect_to deployment_path(deployment)
140
128
  end
@@ -167,11 +155,11 @@ module Staypuft
167
155
 
168
156
  private
169
157
 
170
- def assign_host_to_hostgroup(discovered_host, hostgroup)
171
- converting_discovered = discovered_host.is_a? Host::Discovered
158
+ def assign_host_to_hostgroup(assignee_host, hostgroup)
159
+ converting_discovered = assignee_host.is_a? Host::Discovered
172
160
 
173
161
  if converting_discovered
174
- hosts_facts = FactValue.joins(:fact_name).where(host_id: discovered_host.id)
162
+ hosts_facts = FactValue.joins(:fact_name).where(host_id: assignee_host.id)
175
163
  discovery_bootif = hosts_facts.where(fact_names: { name: 'discovery_bootif' }).first or
176
164
  raise 'unknown discovery_bootif fact'
177
165
 
@@ -187,15 +175,21 @@ module Staypuft
187
175
  ip = hosts_facts.where(fact_names: { name: "ipaddress_#{interface}" }).first
188
176
  end
189
177
 
190
- original_type = discovered_host.type
191
- host = discovered_host.becomes(::Host::Managed)
192
- host.type = 'Host::Managed'
193
- host.managed = true
194
- host.build = true
195
- host.ip = ip.value if converting_discovered
196
- host.mac = discovery_bootif.value if converting_discovered
178
+ original_type = assignee_host.type
179
+ host = if converting_discovered
180
+ assignee_host.becomes(::Host::Managed).tap do |host|
181
+ host.type = 'Host::Managed'
182
+ host.managed = true
183
+ host.ip = ip.value
184
+ host.mac = discovery_bootif.value
185
+ end
186
+ else
187
+ assignee_host
188
+ end
197
189
 
198
190
  host.hostgroup = hostgroup
191
+ # set build to true so the PXE config-template takes effect under discovery environment
192
+ host.build = true if assignee_host.managed?
199
193
  # set discovery environment to keep booting discovery image
200
194
  host.environment = Environment.get_discovery
201
195
 
@@ -207,27 +201,16 @@ module Staypuft
207
201
  # by default foreman will try to manage all NICs unless user disables manually after assignment
208
202
  host.make_all_interfaces_managed
209
203
 
210
- # we create VIPs interfaces if this is the first host in Controller HA hostgroup
211
- build_vips_if_needed(host)
212
-
213
204
  # I do not why but the final save! adds following condytion to the update SQL command
214
205
  # "WHERE "hosts"."type" IN ('Host::Managed') AND "hosts"."id" = 283"
215
206
  # which will not find the record since it's still Host::Discovered.
216
207
  # Using #update_column to change it directly in DB
217
- # (discovered_host is used to avoid same WHERE condition problem here).
208
+ # (assignee_host is used to avoid same WHERE condition problem here).
218
209
  # FIXME this is definitely ugly, needs to be properly fixed
219
- discovered_host.update_column :type, 'Host::Managed'
210
+ assignee_host.update_column :type, 'Host::Managed'
220
211
 
221
212
  [host.save, host].tap do |saved, _|
222
- discovered_host.becomes(Host::Base).update_column(:type, original_type) unless saved
223
- end
224
- end
225
-
226
- def build_vips_if_needed(host)
227
- hostgroup = host.hostgroup
228
- hostgroup.reload if hostgroup
229
- if hostgroup && hostgroup.deployment.ha? && (hostgroup == hostgroup.deployment.controller_hostgroup) && hostgroup.hosts.all? { |h| h.interfaces.vip.empty? }
230
- host.build_vips(Staypuft::NetworkQuery::VIP_NAMES)
213
+ assignee_host.becomes(Host::Base).update_column(:type, original_type) unless saved
231
214
  end
232
215
  end
233
216
  end
@@ -7,10 +7,10 @@ module Staypuft
7
7
  host_ids = host_ids.split(',') unless host_ids.is_a? Array
8
8
  @hosts = Host::Managed.where(:id => host_ids).includes(:interfaces)
9
9
  @host = @hosts.first
10
- assigned_subnet_ids = ([@host.subnet_id] + @host.interfaces.non_vip.map(&:subnet_id)).compact.uniq
10
+ assigned_subnet_ids = ([@host.subnet_id] + @host.interfaces.map(&:subnet_id)).compact.uniq
11
11
  @subnets = @deployment.subnets.where(["#{Subnet.table_name}.id NOT IN (?)", assigned_subnet_ids]).uniq
12
12
  if @host
13
- @interfaces = @host.interfaces.where("type <> 'Nic::BMC'").non_vip.order(:identifier).where(['(virtual = ? OR type = ?)', false, 'Nic::Bond'])
13
+ @interfaces = @host.interfaces.where("type <> 'Nic::BMC'").order(:identifier).where(['(virtual = ? OR type = ?)', false, 'Nic::Bond'])
14
14
  else
15
15
  @interfaces = []
16
16
  end
@@ -82,7 +82,7 @@ module Staypuft
82
82
  end
83
83
 
84
84
  def get_interfaces_to_compare(host)
85
- host.interfaces.non_vip.where("type <> 'Nic::BMC'").order(:identifier)
85
+ host.interfaces.where("type <> 'Nic::BMC'").order(:identifier)
86
86
  end
87
87
  end
88
88
  end
@@ -55,6 +55,7 @@ module Staypuft
55
55
  when :network_configuration
56
56
  @deployment.form_step = Deployment::STEP_NETWORKING
57
57
  @subnets = Subnet.search_for(params[:search], :order => params[:order]).includes(:domains, :dhcp).paginate :page => params[:page]
58
+ @deployment.build_vips(NetworkQuery::VIP_NAMES) if @deployment.valid?
58
59
  else
59
60
  raise 'unknown step'
60
61
  end
@@ -18,11 +18,14 @@ module Actions
18
18
  include Actions::Helpers::Lock
19
19
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
20
20
 
21
- def plan(deployment)
21
+ def plan(deployment, hosts_to_deploy = nil, hosts_to_provision = nil)
22
22
  Type! deployment, ::Staypuft::Deployment
23
23
 
24
24
  input.update id: deployment.id, name: deployment.name
25
- plan_action Hostgroup::OrderedDeploy, deployment.child_hostgroups.deploy_order.to_a
25
+ plan_action Hostgroup::OrderedDeploy,
26
+ deployment.child_hostgroups.deploy_order.to_a,
27
+ hosts_to_deploy,
28
+ hosts_to_provision
26
29
  lock! deployment
27
30
  end
28
31
 
@@ -33,7 +33,7 @@ module Actions
33
33
  hostgroups = deployment.child_hostgroups
34
34
  hostgroups.each do |hostgroup|
35
35
  plan_action Actions::Staypuft::Host::Create,
36
- rand(1000).to_s,
36
+ "host-#{rand(1000).to_s}",
37
37
  hostgroup,
38
38
  compute_resource,
39
39
  start: false,
@@ -13,26 +13,22 @@
13
13
  module Actions
14
14
  module Staypuft
15
15
  module Host
16
- class Deploy < Actions::Base
16
+ class Deploy < Dynflow::Action
17
17
 
18
18
  def plan(host)
19
19
  Type! host, ::Host::Base
20
20
 
21
21
  input.update host: { id: host.id, name: host.name }
22
22
 
23
- unless host.open_stack_deployed?
24
- sequence do
25
- plan_action Host::Build, host.id
26
- plan_action Host::WaitUntilInstalled, host.id
27
- plan_action Host::WaitUntilHostReady, host.id
28
- end
29
- else
30
- # it is already deployed
23
+ sequence do
24
+ plan_action Actions::Staypuft::Host::Update, host, :environment => nil
25
+ puppet_run = plan_action Host::PuppetRun, host
26
+ plan_action Host::ReportCheck, host.id, puppet_run.output[:executed_at]
31
27
  end
32
28
  end
33
29
 
34
30
  def task_output
35
- steps = planned_actions.inject([]) { |s, a| s + a.steps[1..2] }.compact
31
+ steps = planned_actions(Host::ReportCheck).inject([]) { |s, a| s + a.steps[1..2] }.compact
36
32
  progress = if steps.empty?
37
33
  1
38
34
  else
@@ -44,11 +40,6 @@ module Actions
44
40
  input[:host].merge progress: progress
45
41
  end
46
42
 
47
- def humanized_output
48
- task_output = self.task_output
49
- format '%s %s%%', task_output[:name], (task_output[:progress]*100).to_i
50
- end
51
-
52
43
  end
53
44
  end
54
45
  end
@@ -13,21 +13,18 @@
13
13
  module Actions
14
14
  module Staypuft
15
15
  module Host
16
- class PuppetRun < Actions::Base
16
+ class PuppetRun < Dynflow::Action
17
17
 
18
18
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
19
19
 
20
20
  def plan(host)
21
- Type! host, ::Host
22
- plan_self id: host.id, name: host.name
21
+ Type! host, ::Host::Base
22
+ plan_self host_id: host.id, name: host.name
23
23
  end
24
24
 
25
25
  def run
26
- ::Host.find(id).puppetrun!
27
- end
28
-
29
- def humanized_input
30
- input[:name]
26
+ output[:executed_at] = DateTime.now.iso8601
27
+ ::Host.find(input.fetch(:host_id)).puppetrun!
31
28
  end
32
29
 
33
30
  end
@@ -14,13 +14,13 @@ module Actions
14
14
  module Staypuft
15
15
  module Host
16
16
 
17
- class WaitUntilHostReady < Actions::Base
17
+ class ReportCheck < Actions::Base
18
18
 
19
19
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
20
20
  include Dynflow::Action::Polling
21
21
 
22
- def plan(host_id)
23
- plan_self host_id: host_id
22
+ def plan(host_id, after)
23
+ plan_self host_id: host_id, after: after
24
24
  end
25
25
 
26
26
  def external_task
@@ -39,6 +39,15 @@ module Actions
39
39
  0.1
40
40
  end
41
41
 
42
+ def run(event = nil)
43
+ case event
44
+ when Dynflow::Action::Skip
45
+ output[:status] = true
46
+ else
47
+ super(event)
48
+ end
49
+ end
50
+
42
51
  private
43
52
 
44
53
  def invoke_external_task
@@ -50,20 +59,20 @@ module Actions
50
59
  end
51
60
 
52
61
  def poll_external_task
53
- host_ready?(input[:host_id])
62
+ host_ready?(input[:host_id], DateTime.parse(input[:after]).to_time)
54
63
  end
55
64
 
56
65
  def poll_interval
57
66
  5
58
67
  end
59
68
 
60
- def host_ready?(host_id)
61
- host = ::Host.find(host_id)
62
- # take reports oldest first ignoring always the first one (auto-sign)
63
- host.reports.order('reported_at DESC')[0..-2].any? do |report|
64
- check_for_failures(report, host.id)
65
- report_change?(report)
66
- end
69
+ def host_ready?(host_id, after)
70
+ host = ::Host.find(host_id)
71
+ report = host.reports.where('reported_at > ?', after).first
72
+ return false unless report
73
+
74
+ check_for_failures(report, host.id)
75
+ report_change?(report)
67
76
  end
68
77
 
69
78
  def report_change?(report)
@@ -13,23 +13,27 @@
13
13
  module Actions
14
14
  module Staypuft
15
15
  module Host
16
- class Build < Dynflow::Action
16
+ class TriggerProvisioning < Dynflow::Action
17
17
 
18
18
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
19
19
 
20
- def plan(host_id)
21
- plan_self host_id: host_id
20
+ def plan(host)
21
+ fail 'cannot provision unmanaged host' unless host.managed?
22
+
23
+ # return back to hostgroup's environment
24
+ sequence do
25
+ plan_action Actions::Staypuft::Host::Update, host, :environment => nil
26
+ plan_self host_id: host.id
27
+ end
22
28
  end
23
29
 
24
30
  def run
25
- host = ::Host.find(input[:host_id])
26
- # return back to hostgroup's environment
27
- host.environment = nil
31
+ host = ::Host.find(input[:host_id])
28
32
  host.expire_token
29
33
  host.set_token
30
34
  host.save!
31
35
  host.send :setTFTP
32
- restart(host)
36
+ restart host
33
37
  end
34
38
 
35
39
  private
@@ -48,7 +52,7 @@ module Actions
48
52
  def restart_with_power_management(power)
49
53
  check_expected_state(power.state)
50
54
  if %w(running on).include?(power.state)
51
- if !power.reset
55
+ unless power.reset
52
56
  fail(::Staypuft::Exception, 'Resetting Host Failed')
53
57
  end
54
58
  end
@@ -62,7 +66,7 @@ module Actions
62
66
  end
63
67
 
64
68
  def check_expected_state(state)
65
- if !%w(running on cycle shutoff off).include?(state.downcase)
69
+ unless %w(running on cycle shutoff off).include?(state.downcase)
66
70
  raise(::Staypuft::Exception, "Unexpected Host Power State: #{state}")
67
71
  end
68
72
  end
@@ -0,0 +1,33 @@
1
+ #
2
+ # Copyright 2014 Red Hat, Inc.
3
+ #
4
+ # This software is licensed to you under the GNU General Public
5
+ # License as published by the Free Software Foundation; either version
6
+ # 2 of the License (GPLv2) or (at your option) any later version.
7
+ # There is NO WARRANTY for this software, express or implied,
8
+ # including the implied warranties of MERCHANTABILITY,
9
+ # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
10
+ # have received a copy of GPLv2 along with this software; if not, see
11
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
12
+
13
+ module Actions
14
+ module Staypuft
15
+ module Host
16
+ class Update < Dynflow::Action
17
+
18
+ middleware.use Actions::Staypuft::Middleware::AsCurrentUser
19
+
20
+ def plan(host, updates)
21
+ plan_self host_id: host.id, updates: updates
22
+ end
23
+
24
+ def run
25
+ host = ::Host.find(input.fetch :host_id)
26
+ host.update_attributes input.fetch(:updates)
27
+ output.update changing: host.changes
28
+ host.save!
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end