orca 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orca (0.3.5)
4
+ orca (0.3.6)
5
5
  colored
6
6
  net-sftp
7
7
  net-ssh
data/README.md CHANGED
@@ -87,6 +87,7 @@ If you have a package with the same name as a group or node you can abreviate th
87
87
  You can also directly trigger actions from the CLI like so...
88
88
 
89
89
  orca trigger nginx:reload web-1
90
+ orca trigger firewall:add[allow,80] web-1
90
91
 
91
92
  Options, all commands support the following optional parameters...
92
93
 
@@ -22,7 +22,7 @@ module Orca
22
22
  end
23
23
  module_function :add_package
24
24
 
25
- def extension(name, &blk)
25
+ def extension(&blk)
26
26
  Orca::DSL.class_eval(&blk)
27
27
  end
28
28
  module_function :extension
@@ -1,4 +1,4 @@
1
- Orca.extension :apt do
1
+ Orca.extension do
2
2
 
3
3
  # supports three formats
4
4
  # apt_package 'git-core' - create a package 'git-core' that installs 'git-core'
@@ -1,4 +1,4 @@
1
- Orca.extension :file_sync do
1
+ Orca.extension do
2
2
  class Orca::Package
3
3
  def file(config, &blk)
4
4
  Orca::FileSync.new(self, config, &blk).configure
@@ -14,6 +14,10 @@ class Orca::Group
14
14
  return nil unless @groups
15
15
  @groups[name]
16
16
  end
17
+
18
+ def names
19
+ @groups.keys.sort
20
+ end
17
21
  end
18
22
 
19
23
  attr_reader :name, :nodes, :config
@@ -1,11 +1,11 @@
1
1
  class Orca::Logger
2
2
  def initialize(node, package)
3
3
  @node = node
4
- @package = package
4
+ set_package(package)
5
5
  end
6
6
 
7
7
  def set_package(package)
8
- @package = package
8
+ @package = package.to_s
9
9
  end
10
10
 
11
11
  def command(msg)
@@ -47,7 +47,7 @@ class Orca::Logger
47
47
  def say(msg, color=nil)
48
48
  msg.to_s.split("\n").each do |line|
49
49
  out = color ? line.send(color) : line
50
- Thread.exclusive { puts "#{@node.to_s} [#{@package.name.bold}] #{out}" }
50
+ Thread.exclusive { puts "#{@node.to_s} [#{@package.bold}] #{out}" }
51
51
  end
52
52
  end
53
53
  end
@@ -49,4 +49,8 @@ class Orca::Package
49
49
  def provides_command?(name)
50
50
  @commands.has_key?(name.to_sym)
51
51
  end
52
+
53
+ def to_s
54
+ self.name
55
+ end
52
56
  end
@@ -13,6 +13,7 @@ class Orca::Suite
13
13
 
14
14
  def run(group_name, pkg_name, command, sequential=false)
15
15
  group = Orca::Group.find(group_name)
16
+ raise Orca::MissingGroupError.new(group_name) if group.nil?
16
17
  runners = group.nodes.map do |node|
17
18
  @nodes << node
18
19
  if command == :trigger
@@ -43,4 +44,14 @@ class Orca::Suite
43
44
  runner.execute(command)
44
45
  end
45
46
  end
47
+ end
48
+
49
+ class Orca::MissingGroupError < StandardError
50
+ def initialize(group_name)
51
+ @group_name = group_name
52
+ end
53
+
54
+ def message
55
+ "No Group or Node exists with the name '#{@group_name}'. Try one of: #{Orca::Group.names.join(', ')}"
56
+ end
46
57
  end
@@ -1,14 +1,25 @@
1
1
  class Orca::TriggerRunner
2
- def initialize(node, action_ref)
2
+ def initialize(node, action_ref_with_args)
3
3
  @node = node
4
- @action_ref = action_ref
4
+ @action_ref, @args = *parse_action_ref(action_ref_with_args)
5
+ @log = Orca::Logger.new(@node, @action_ref)
5
6
  end
6
7
 
7
8
  def execute(_)
8
- Orca::ExecutionContext.new(@node).trigger(@action_ref)
9
+ Orca::ExecutionContext.new(@node, @log).trigger(@action_ref, *@args)
9
10
  end
10
11
 
11
12
  def demonstrate(_)
12
- Orca::MockExecutionContext.new(@node).trigger(@action_ref)
13
+ Orca::MockExecutionContext.new(@node, @log).trigger(@action_ref, *@args)
14
+ end
15
+
16
+ private
17
+
18
+ def parse_action_ref(action_ref_with_args)
19
+ matches = action_ref_with_args.match(/([\w\:]+?)(\[([\w\,]+?)\])/)
20
+ return [action_ref_with_args,[]] unless matches
21
+ action_ref = matches[1]
22
+ args = matches[3].split(',').map(&:strip)
23
+ [action_ref, args]
13
24
  end
14
25
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
11
11
  gem.name = "orca"
12
12
  gem.require_paths = ["lib"]
13
- gem.version = '0.3.5'
13
+ gem.version = '0.3.6'
14
14
  gem.add_dependency('colored')
15
15
  gem.add_dependency('net-ssh')
16
16
  gem.add_dependency('net-sftp')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
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: 2013-07-01 00:00:00.000000000 Z
12
+ date: 2013-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colored
@@ -133,7 +133,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  segments:
135
135
  - 0
136
- hash: -2049972371270429172
136
+ hash: -796320942601903817
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  segments:
144
144
  - 0
145
- hash: -2049972371270429172
145
+ hash: -796320942601903817
146
146
  requirements: []
147
147
  rubyforge_project:
148
148
  rubygems_version: 1.8.23