staypuft 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,7 +35,7 @@ module Actions
35
35
  def restart(host)
36
36
  power_management = begin
37
37
  host.power
38
- rescue Foreman::Exception => e
38
+ rescue ::Foreman::Exception => e
39
39
  if e.code == 'ERF42-9958' # Unknown power management support
40
40
  nil
41
41
  else
@@ -51,17 +51,19 @@ module Actions
51
51
  ::Host::Managed.new(
52
52
  name: input[:name],
53
53
  hostgroup_id: input[:hostgroup_id],
54
- build: false,
54
+ build: true,
55
55
  managed: true,
56
56
  enabled: true,
57
+ environment: Environment.get_discovery,
57
58
  mac: '0a:' + Array.new(5).map { format '%0.2X', rand(256) }.join(':'))
58
59
  else
59
60
  ::Host::Managed.new(
60
61
  name: input[:name],
61
62
  hostgroup_id: input[:hostgroup_id],
62
- build: false,
63
+ build: true,
63
64
  managed: true,
64
65
  enabled: true,
66
+ environment: Environment.get_discovery,
65
67
  compute_resource_id: input.fetch(:compute_resource_id),
66
68
  compute_attributes: input[:compute_attributes])
67
69
  end
@@ -49,15 +49,28 @@ module Actions
49
49
  5
50
50
  end
51
51
 
52
+ # TODO The puppet modules sometimes fail then become ready
53
+ # after subsequent hosts have started. For this reason
54
+ # we can not check to see if the host is ready using the
55
+ # stats on the host only. This needs fixing in the puppet
56
+ # modules then reflecting here.
52
57
  def host_ready?(host_id)
53
58
  host = ::Host.find(host_id)
54
- check_for_failures(host)
55
- host.skipped == 0 && host.pending == 0
59
+ host.reports.order('reported_at DESC').any? do |report|
60
+ #check_for_failures(report, host.id)
61
+ report_change?(report)
62
+ end
63
+ end
64
+
65
+ def report_change?(report)
66
+ report.status['applied'] > 0
56
67
  end
57
68
 
58
- def check_for_failures(host)
59
- if host.failed > 0
60
- fail(::Staypuft::Exception, "Latest Puppet Run Contains Failures for Host: #{host.id}")
69
+ # TODO To aid logging add the report ID to the exception or
70
+ # the output object.
71
+ def check_for_failures(report, id)
72
+ if report.status['failed'] > 0
73
+ fail(::Staypuft::Exception, "Latest Puppet Run Contains Failures for Host: #{id}")
61
74
  end
62
75
  end
63
76
  end
@@ -8,7 +8,7 @@ module Staypuft
8
8
  validates :layout, :presence => true
9
9
  validates :role, :presence => true
10
10
  validates :role_id, :uniqueness => {:scope => :layout_id}
11
- validates :deploy_order, :presence => true, :uniqueness => {:scope => :layout_id}
11
+ validates :deploy_order, :presence => true
12
12
 
13
13
  end
14
14
  end
data/db/seeds.rb CHANGED
@@ -158,7 +158,8 @@ services = {
158
158
  :qpid_ha => {:name => "qpid (HA)", :class => ["quickstack::pacemaker::qpid",
159
159
  "qpid::server"]},
160
160
  :glance_ha => {:name => "Glance (HA)", :class => ["quickstack::pacemaker::glance"]},
161
- :nova_ha => {:name => "Nova (HA)", :class => ["quickstack::pacemaker::nova"]}
161
+ :nova_ha => {:name => "Nova (HA)", :class => ["quickstack::pacemaker::nova"]},
162
+ :ha_db_temp => {:name => "Database (HA -- temp)", :class => ["quickstack::hamysql::singlenodetest"]}
162
163
  }
163
164
  services.each do |skey, svalue|
164
165
  service = Staypuft::Service.where(:name=>svalue[:name]).first_or_create!
@@ -194,7 +195,7 @@ end
194
195
  roles = [
195
196
  {:name=>"Controller (Nova)",
196
197
  :class=>"quickstack::nova_network::controller",
197
- :layouts=>[[:non_ha_nova, 1]],
198
+ :layouts=>[[:non_ha_nova, 2]],
198
199
  :services=>[:non_ha_qpid, :mysql, :non_ha_keystone, :nova_controller, :non_ha_glance, :cinder, :heat, :ceilometer]},
199
200
  {:name=>"Compute (Nova)",
200
201
  :class=>"quickstack::nova_network::compute",
@@ -202,7 +203,7 @@ roles = [
202
203
  :services=>[:nova_compute]},
203
204
  {:name=>"Controller (Neutron)",
204
205
  :class=>"quickstack::neutron::controller",
205
- :layouts=>[[:non_ha_neutron, 1]],
206
+ :layouts=>[[:non_ha_neutron, 2]],
206
207
  :services=>[:non_ha_qpid, :mysql, :non_ha_keystone, :neutron_controller, :non_ha_glance, :cinder, :heat, :ceilometer]},
207
208
  {:name=>"Compute (Neutron)",
208
209
  :class=>"quickstack::neutron::compute",
@@ -210,11 +211,11 @@ roles = [
210
211
  :services=>[:neutron_compute, :neutron_ovs_agent]},
211
212
  {:name=>"Neutron Networker",
212
213
  :class=>"quickstack::neutron::networker",
213
- :layouts=>[[:non_ha_neutron, 2]],
214
+ :layouts=>[[:non_ha_neutron, 3]],
214
215
  :services=>[:neutron_l3, :dhcp, :ovs]},
215
216
  {:name=>"LVM Block Storage",
216
217
  :class=>"quickstack::storage_backend::lvm_cinder",
217
- :layouts=>[[:ha_nova, 3], [:ha_neutron, 3], [:non_ha_nova, 3], [:non_ha_neutron, 3]],
218
+ :layouts=>[[:ha_nova, 1], [:ha_neutron, 1], [:non_ha_nova, 1], [:non_ha_neutron, 1]],
218
219
  :services=>[:cinder]},
219
220
  {:name=>"Swift Storage Node",
220
221
  :class=>"quickstack::swift::storage",
@@ -222,12 +223,17 @@ roles = [
222
223
  :services=>[:swift]},
223
224
  {:name=>"HA Controller (Nova)",
224
225
  :class=>[],
225
- :layouts=>[[:ha_nova, 1]],
226
+ :layouts=>[[:ha_nova, 3]],
226
227
  :services=>[:ha_controller, :keystone_ha, :load_balancer_ha, :memcached_ha, :qpid_ha, :glance_ha, :nova_ha]},
227
228
  {:name=>"HA Controller (Neutron)",
228
229
  :class=>[],
229
- :layouts=>[[:ha_neutron, 1]],
230
- :services=>[]}
230
+ :layouts=>[[:ha_neutron, 2]],
231
+ :services=>[]},
232
+ # this one is temporary -- goes away once db is added back to HA COntroller
233
+ {:name=>"HA Database (temporary)",
234
+ :class=>[],
235
+ :layouts=>[[:ha_nova, 2]],
236
+ :services=>[:ha_db_temp]}
231
237
  ]
232
238
 
233
239
  roles.each do |r|
@@ -1,3 +1,3 @@
1
1
  module Staypuft
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staypuft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-10 00:00:00.000000000 Z
12
+ date: 2014-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: foreman-tasks