ey_stonith 0.1.5.pre2 → 0.1.5.pre3

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,13 +46,13 @@ module EY
46
46
  end
47
47
 
48
48
  # ripped from restclient so we can use eventmachine
49
- def process_payload(p = nil, parent_key = nil)
50
- p.keys.map do |k|
49
+ def process_payload(payload = nil, parent_key = nil)
50
+ payload.keys.map do |k|
51
51
  key = parent_key ? "#{parent_key}[#{k}]" : k
52
- if p[k].is_a? Hash
53
- process_payload(p[k], key)
52
+ if payload[k].is_a? Hash
53
+ process_payload(payload[k], key)
54
54
  else
55
- value = URI.escape(p[k].to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
55
+ value = URI.escape(payload[k].to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
56
56
  "#{key}=#{value}"
57
57
  end
58
58
  end.join("&")
@@ -63,6 +63,14 @@ module EY
63
63
  end
64
64
  end
65
65
 
66
+ def script
67
+ @script ||= File.join(File.dirname($0), SCRIPT_NAME)
68
+ end
69
+
70
+ def execute(command, args = "")
71
+ exec "#{script}-#{command}#{command_options} #{args}"
72
+ end
73
+
66
74
  def parse!
67
75
  parser.parse!(@argv)
68
76
  end
@@ -45,7 +45,7 @@ module EY
45
45
 
46
46
  if check_recorder.limit_exceeded?
47
47
  Stonith.logger.info "Invoking takeover of instance #{instance_id}"
48
- exec "#{SCRIPT_NAME} takeover#{command_options} --instance #{instance_id}"
48
+ execute :takeover, "--instance #{instance_id}"
49
49
  end
50
50
  end
51
51
 
@@ -35,6 +35,7 @@ module EY
35
35
  return unless master_hostname
36
36
 
37
37
  if config.meta_data_hostname == master_hostname
38
+ history << :claim
38
39
  abort "Already claimed, not claiming."
39
40
  else
40
41
  claim_path.delete
@@ -85,6 +86,7 @@ Failed attempts: #{attempts}
85
86
 
86
87
  if config.meta_data_hostname == master_hostname
87
88
  claim_path.open('w') {}
89
+ history << :claim
88
90
  abort "Already claimed, not claiming. Touching claim file."
89
91
  else
90
92
  abort "#{master_hostname} is master, not claiming."
@@ -11,6 +11,7 @@ module EY
11
11
  end
12
12
 
13
13
  def invoke
14
+ Stonith.logger.info "Stonith started"
14
15
  heartbeat_loop do |beat|
15
16
  unless_stopped { run_commands if beat.zero? }
16
17
  sleep 1
@@ -31,7 +32,7 @@ module EY
31
32
 
32
33
  def run_commands
33
34
  %w[claim notify check].each do |cmd|
34
- system("stonith #{cmd}#{command_options}")
35
+ system("#{script} #{cmd}#{command_options}")
35
36
  end
36
37
  end
37
38
  end
@@ -11,6 +11,7 @@ module EY
11
11
  end
12
12
 
13
13
  def invoke
14
+ Stonith.logger.info "Stonith resumed"
14
15
  config.stop_path.delete if config.stop_path.exist?
15
16
  end
16
17
  end
@@ -13,6 +13,8 @@ module EY
13
13
  def invoke
14
14
  config.stop_path.open('w') {}
15
15
  sleep(0.5) until history.last == "stop"
16
+
17
+ Stonith.logger.info "Stonith stopped"
16
18
  puts "takeover" if history.include?(:takeover)
17
19
  end
18
20
  end
@@ -73,7 +73,8 @@ module EY
73
73
  data = Data.new(config.meta_data_hostname, config.meta_data_id, ip)
74
74
  database.set data
75
75
 
76
- exec "#{SCRIPT_NAME} notify --force#{command_options}"
76
+ takeover_path.delete
77
+ execute :notify, "--force"
77
78
  end
78
79
 
79
80
  def relent!
@@ -26,7 +26,7 @@ module EY
26
26
 
27
27
  def self.invoke(argv)
28
28
  if COMMANDS.keys.include?(argv.first)
29
- exec "stonith-#{argv.join(' ')}"
29
+ exec "#{File.dirname($0)}/stonith-#{argv.join(' ')}"
30
30
  else
31
31
  NotFound.new(argv).call
32
32
  end
metadata CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
6
6
  - 0
7
7
  - 1
8
8
  - 5
9
- - pre2
10
- version: 0.1.5.pre2
9
+ - pre3
10
+ version: 0.1.5.pre3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ezra Zygmuntowicz
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-04-14 00:00:00 -07:00
20
+ date: 2010-04-19 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency