opsicle 0.5.1 → 0.6.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.
- checksums.yaml +8 -8
- data/bin/opsicle +1 -0
- data/lib/opsicle.rb +1 -1
- data/lib/opsicle/commands/execute_recipes.rb +10 -2
- data/lib/opsicle/layer.rb +48 -0
- data/lib/opsicle/version.rb +1 -1
- data/spec/opsicle/commands/execute_recipes_spec.rb +19 -2
- data/spec/opsicle/layer_spec.rb +59 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGY1ZDM5ZDM1MDU0OTY0M2Y1NmZiODY1MTQzZmQ4MDBjODc0MTMxNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjhkZWQzNmRhY2I0ZDJjMWM0Y2RkYTYyN2MxY2Y4OTlmNzZmOTE0Nw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2JkYzEyN2I5MTUyMzc4MThiMmExYmJkODc0ZTljOWU5ZDQwMGQ4ZWYyYjA4
|
10
|
+
YzU3NjJmZGRhMTFlYWFmMmIwZjFmNzMyNmZmZDAxOGU1ZDViNzU1M2JhZWQ4
|
11
|
+
NmNmOWRmMjU0MTU4OTYyNDBkM2NlOTg0ZDdkNGIyMWIxMjljYmY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NWFkZmU4MDcyZTRkMzZlNTU3MWFhZTNhNmY1YTcyZWExYjlkNzQ0MTExYTVm
|
14
|
+
NzY3YWJmY2RlNTNmZjZjODFkNGJhYzhjNDk4ODRmYzg5ODVkZWY1YmI3OGYy
|
15
|
+
OWEzNGNjZjJiNWRiZDUyOWQxNGNkMzdjODJiZDhhMjllYzg4ZjA=
|
data/bin/opsicle
CHANGED
@@ -140,6 +140,7 @@ command 'execute-recipes' do |c|
|
|
140
140
|
c.switch [:m, :monitor], :desc => "Run the Stack Monitor on deploy", :default_value => true
|
141
141
|
c.flag [:r, :recipes], :desc => 'The recipes to execute', :type => Array, :required => true
|
142
142
|
c.flag [:i, :instance_ids], :desc => 'The specific instances to execute recipes on', :type => Array
|
143
|
+
c.flag [:l, :layers], :desc => 'The specific layers to execute recipes on', :type => Array
|
143
144
|
c.action do |global_options, options, args|
|
144
145
|
raise ArgumentError, "Environment is required" unless args.first
|
145
146
|
|
data/lib/opsicle.rb
CHANGED
@@ -17,12 +17,20 @@ module Opsicle
|
|
17
17
|
#http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/OpsWorks/Client.html#create_deployment-instance_method
|
18
18
|
command_args = {}
|
19
19
|
command_args["recipes"] = options[:recipes]
|
20
|
-
|
21
20
|
command_opts = {}
|
22
|
-
command_opts["instance_ids"] = options[:instance_ids]
|
21
|
+
command_opts["instance_ids"] = determine_instance_ids(options) if options[:instance_ids] || options[:layers]
|
23
22
|
|
24
23
|
response = client.run_command('execute_recipes', command_args, command_opts)
|
25
24
|
launch_stack_monitor(response, options)
|
26
25
|
end
|
26
|
+
|
27
|
+
def determine_instance_ids(options)
|
28
|
+
if options[:instance_ids]
|
29
|
+
options[:instance_ids]
|
30
|
+
elsif options[:layers]
|
31
|
+
Opsicle::Layer.instance_ids(client, options[:layers])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
27
35
|
end
|
28
36
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Opsicle
|
2
|
+
class Layer
|
3
|
+
|
4
|
+
attr_accessor :id, :name, :client
|
5
|
+
class <<self
|
6
|
+
attr_accessor :client
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(client, options = {})
|
10
|
+
@client = client
|
11
|
+
@id = options[:id]
|
12
|
+
@name = options[:name]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Public - Gets all the instance ids for a layer
|
16
|
+
#
|
17
|
+
# Return - An array of instance ids
|
18
|
+
def get_instance_ids
|
19
|
+
client.api_call('describe_instances', layer_id: id)[:instances].map{ |s| s[:instance_id] }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Private - Gets layer info from OpsWorks
|
23
|
+
#
|
24
|
+
# Return - An array of layer objects
|
25
|
+
def self.get_info
|
26
|
+
get_layers.map do |layer|
|
27
|
+
new(client, id: layer[:layer_id], name: layer[:shortname])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
private_class_method :get_info
|
31
|
+
|
32
|
+
def self.get_layers
|
33
|
+
client.api_call('describe_layers', stack_id: client.config.opsworks_config[:stack_id])[:layers]
|
34
|
+
end
|
35
|
+
# Public - gets all the layer ids for the given layers
|
36
|
+
#
|
37
|
+
# client - a new Client
|
38
|
+
# layers - an array of layer shortnames
|
39
|
+
#
|
40
|
+
# Return - An array of instance ids belonging to the input layers
|
41
|
+
def self.instance_ids(client, layers)
|
42
|
+
@client = client
|
43
|
+
get_info.map{ |layer| layer.get_instance_ids[0] if layers.include?(layer.name) }.uniq.compact
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
data/lib/opsicle/version.rb
CHANGED
@@ -5,10 +5,10 @@ module Opsicle
|
|
5
5
|
describe ExecuteRecipes do
|
6
6
|
subject { ExecuteRecipes.new('derp') }
|
7
7
|
let(:recipes) { ['herp'] }
|
8
|
+
let(:client) { double }
|
9
|
+
let(:monitor) { double(:start => nil) }
|
8
10
|
|
9
11
|
context "#execute" do
|
10
|
-
let(:client) { double }
|
11
|
-
let(:monitor) { double(:start => nil) }
|
12
12
|
before do
|
13
13
|
allow(Client).to receive(:new).with('derp').and_return(client)
|
14
14
|
allow(client).to receive(:run_command).with('execute_recipes', {"recipes" => ['herp']}, {}).and_return({deployment_id: 'derp'})
|
@@ -67,5 +67,22 @@ module Opsicle
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
context "#determine_instance_ids" do
|
71
|
+
before do
|
72
|
+
allow(Client).to receive(:new).with('derp').and_return(client)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns the instance_ids when passed in through options" do
|
76
|
+
options = {:instance_ids => ["abcdefg","1234567"]}
|
77
|
+
expect(subject.determine_instance_ids(options)).to eq(["abcdefg","1234567"])
|
78
|
+
end
|
79
|
+
|
80
|
+
it "returns the instance_ids when a layer is passed in" do
|
81
|
+
options = {:layers => ["main-util"]}
|
82
|
+
allow(Opsicle::Layer).to receive(:instance_ids).and_return(["a1b2c3"])
|
83
|
+
expect(subject.determine_instance_ids(options)).to eq(["a1b2c3"])
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
70
87
|
end
|
71
88
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "opsicle"
|
3
|
+
|
4
|
+
module Opsicle
|
5
|
+
describe Layer do
|
6
|
+
let(:client) { double }
|
7
|
+
let(:config) { double }
|
8
|
+
|
9
|
+
subject { Opsicle::Layer }
|
10
|
+
context "#get_info" do
|
11
|
+
let(:client) { double }
|
12
|
+
let(:layer1) { subject.new(client, :id => 1, :name => "layer1")}
|
13
|
+
let(:layer2) { subject.new(client, :id => 2, :name => "layer2")}
|
14
|
+
let(:layers) { [ { shortname: "layer1", layer_id: 1, name: "Layer 1" }, { shortname: "layer2", layer_id: 2, name: "Layer 2" }] }
|
15
|
+
|
16
|
+
before do
|
17
|
+
allow(subject).to receive(:get_layers).and_return(layers)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns an array of layer_ids from the input layer (singular)" do
|
21
|
+
expect(subject.send(:get_info)[0]).to be_an_instance_of Opsicle::Layer
|
22
|
+
expect(subject.send(:get_info)[1]).to be_an_instance_of Opsicle::Layer
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
context "#get_instance_ids" do
|
28
|
+
let(:response) {{ :instances => [{:stack_id => "aaa", :instance_id => "111"},{:stack_id => "bbb", :instance_id => "222"}]}}
|
29
|
+
before do
|
30
|
+
allow(client).to receive(:api_call).with('describe_instances',layer_id: "opsworkslayer").and_return(response)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "returns an array of instance_ids from the input layer_id" do
|
34
|
+
expect(subject.new(client, id: "opsworkslayer").get_instance_ids).to eq(["111","222"])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "#instance_ids" do
|
39
|
+
let(:layer1) { double }
|
40
|
+
let(:layer2) { double }
|
41
|
+
before do
|
42
|
+
allow(layer1).to receive(:name).and_return("aaa")
|
43
|
+
allow(layer2).to receive(:name).and_return("bbb")
|
44
|
+
allow(layer1).to receive(:get_instance_ids).and_return(["111","222"])
|
45
|
+
allow(layer2).to receive(:get_instance_ids).and_return(["333","444"])
|
46
|
+
allow(subject).to receive(:get_info).and_return([layer1,layer2])
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns the instance ids from layer_names" do
|
50
|
+
expect(subject.instance_ids(client, ["aaa","bbb"])).to eq(["111","333"])
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns the instance ids from layer_names, filters out doubles" do
|
54
|
+
allow(layer2).to receive(:get_instance_ids).and_return(["111","222"])
|
55
|
+
expect(subject.instance_ids(client, ["aaa","bbb"])).to eq(["111"])
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opsicle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Fleener
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/opsicle/deployment.rb
|
185
185
|
- lib/opsicle/deployments.rb
|
186
186
|
- lib/opsicle/instances.rb
|
187
|
+
- lib/opsicle/layer.rb
|
187
188
|
- lib/opsicle/monitor.rb
|
188
189
|
- lib/opsicle/monitor/app.rb
|
189
190
|
- lib/opsicle/monitor/panel.rb
|
@@ -211,6 +212,7 @@ files:
|
|
211
212
|
- spec/opsicle/commands/ssh_key_spec.rb
|
212
213
|
- spec/opsicle/commands/ssh_spec.rb
|
213
214
|
- spec/opsicle/config_spec.rb
|
215
|
+
- spec/opsicle/layer_spec.rb
|
214
216
|
- spec/opsicle/monitor/app_spec.rb
|
215
217
|
- spec/opsicle/monitor/panel_spec.rb
|
216
218
|
- spec/opsicle/monitor/screen_spec.rb
|
@@ -238,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
240
|
version: '0'
|
239
241
|
requirements: []
|
240
242
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.2.
|
243
|
+
rubygems_version: 2.2.2
|
242
244
|
signing_key:
|
243
245
|
specification_version: 4
|
244
246
|
summary: An opsworks specific abstraction on top of the aws sdk
|
@@ -252,6 +254,7 @@ test_files:
|
|
252
254
|
- spec/opsicle/commands/ssh_key_spec.rb
|
253
255
|
- spec/opsicle/commands/ssh_spec.rb
|
254
256
|
- spec/opsicle/config_spec.rb
|
257
|
+
- spec/opsicle/layer_spec.rb
|
255
258
|
- spec/opsicle/monitor/app_spec.rb
|
256
259
|
- spec/opsicle/monitor/panel_spec.rb
|
257
260
|
- spec/opsicle/monitor/screen_spec.rb
|