staypuft 0.4.15 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/app/assets/javascripts/staypuft/staypuft.js +6 -0
- data/app/controllers/staypuft/bonds_controller.rb +18 -2
- data/app/controllers/staypuft/deployments_controller.rb +19 -36
- data/app/controllers/staypuft/interface_assignments_controller.rb +3 -3
- data/app/controllers/staypuft/steps_controller.rb +1 -0
- data/app/lib/actions/staypuft/deployment/deploy.rb +5 -2
- data/app/lib/actions/staypuft/deployment/populate.rb +1 -1
- data/app/lib/actions/staypuft/host/deploy.rb +6 -15
- data/app/lib/actions/staypuft/host/puppet_run.rb +5 -8
- data/app/lib/actions/staypuft/host/{wait_until_host_ready.rb → report_check.rb} +20 -11
- data/app/lib/actions/staypuft/host/{build.rb → trigger_provisioning.rb} +13 -9
- data/app/lib/actions/staypuft/host/update.rb +33 -0
- data/app/lib/actions/staypuft/host/{wait_until_installed.rb → wait_until_provisioned.rb} +7 -5
- data/app/lib/actions/staypuft/host/wait_until_ready.rb +56 -0
- data/app/lib/actions/staypuft/hostgroup/ordered_deploy.rb +98 -6
- data/app/lib/staypuft/network_query.rb +2 -10
- data/app/lib/staypuft/seeder.rb +1 -3
- data/app/models/staypuft/concerns/host_interface_management.rb +11 -29
- data/app/models/staypuft/deployment.rb +38 -2
- data/app/models/staypuft/deployment/cinder_service/equallogic.rb +1 -1
- data/app/models/staypuft/deployment/passwords.rb +1 -1
- data/app/models/staypuft/deployment_vip_nic.rb +13 -0
- data/app/models/staypuft/interface_assigner.rb +1 -1
- data/app/models/staypuft/vip_nic.rb +18 -0
- data/app/views/staypuft/deployments/_deployment_summary.html.erb +3 -0
- data/app/views/staypuft/deployments/_host_head_row.html.erb +1 -0
- data/app/views/staypuft/deployments/_host_row.html.erb +8 -0
- data/app/views/staypuft/interface_assignments/_nics_assignment.html.erb +1 -1
- data/app/views/staypuft/steps/network_configuration.html.erb +12 -1
- data/db/migrate/20141107144800_create_staypuft_deployment_vip_nics.rb +15 -0
- data/lib/staypuft/engine.rb +0 -2
- data/lib/staypuft/version.rb +1 -1
- metadata +22 -20
- data/app/lib/actions/staypuft/hostgroup/deploy.rb +0 -93
- data/app/models/staypuft/concerns/subnet_ip_management.rb +0 -17
- data/app/models/staypuft/concerns/vip_nic_scopes.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZDYwM2Y4Nzc0YWE3Y2NjMGU2MzEwNDg3MTU0ZjY2Y2IzYjBhNzc3Ng==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDcyMjFkN2Q5OWZhZDU0MzA0M2RmOWM2ZjkyMTFlZTAyNmFmZDhhMw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
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'").
|
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.
|
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(
|
171
|
-
converting_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:
|
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 =
|
191
|
-
host =
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|
-
# (
|
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
|
-
|
210
|
+
assignee_host.update_column :type, 'Host::Managed'
|
220
211
|
|
221
212
|
[host.save, host].tap do |saved, _|
|
222
|
-
|
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.
|
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'").
|
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.
|
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,
|
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
|
|
@@ -13,26 +13,22 @@
|
|
13
13
|
module Actions
|
14
14
|
module Staypuft
|
15
15
|
module Host
|
16
|
-
class Deploy <
|
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
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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 <
|
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
|
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
|
-
|
27
|
-
|
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
|
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
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
16
|
+
class TriggerProvisioning < Dynflow::Action
|
17
17
|
|
18
18
|
middleware.use Actions::Staypuft::Middleware::AsCurrentUser
|
19
19
|
|
20
|
-
def plan(
|
21
|
-
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|