miasma 0.2.6 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/miasma/contrib/aws/compute.rb +15 -14
- data/lib/miasma/contrib/aws/orchestration.rb +14 -1
- data/lib/miasma/models/auto_scale/group.rb +1 -1
- data/lib/miasma/models/orchestration/stacks.rb +9 -11
- data/lib/miasma/types/api.rb +2 -2
- data/lib/miasma/types/collection.rb +1 -1
- data/lib/miasma/utils/smash.rb +18 -13
- data/lib/miasma/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a74043b0719d34f3ad9967c6345ad9f26175336
|
4
|
+
data.tar.gz: f58390eaca85d115434f260d6db8cf47869942f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25776c602dc8f1b1d2b8815fe8cb2b313ba1a7eada1f64918888a9668b309cc6853ea31de11932159f13ff9782b090c14558425d85bdd0e97a598198e69a3596
|
7
|
+
data.tar.gz: 3c9e161d83a4c092e9fc62bd401245509013bf1c29dd47ca8840f1fe947ec6c9995d3fc175e2182f748f8d1cfc463546b0ca7b71337d32d5322aa4197d94acf3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# v0.2.8
|
2
|
+
* Allow multiple expected response codes
|
3
|
+
* Fix API type provided when building server instance from ASG
|
4
|
+
* Remove automatic key sorting on Smash conversions
|
5
|
+
* Allow name based matching for data loading within AWS orchestration
|
6
|
+
|
1
7
|
# v0.2.6
|
2
8
|
* Add default filter implementation on collection
|
3
9
|
* Allow disable of automatic body extraction
|
@@ -89,20 +89,21 @@ module Miasma
|
|
89
89
|
request(:path => '/', :params => options.merge('Action' => 'DescribeInstances'))
|
90
90
|
end
|
91
91
|
results.map do |srv|
|
92
|
-
srv
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
92
|
+
[srv[:instancesSet][:item]].flatten.compact.map do |srv|
|
93
|
+
Server.new(
|
94
|
+
self,
|
95
|
+
:id => srv[:instanceId],
|
96
|
+
:name => srv.fetch(:tagSet, :item, []).map{|tag| tag[:value] if tag.is_a?(Hash) && tag[:key] == 'Name'}.compact.first,
|
97
|
+
:image_id => srv[:imageId],
|
98
|
+
:flavor_id => srv[:instanceType],
|
99
|
+
:state => SERVER_STATE_MAP.fetch(srv.get(:instanceState, :name), :pending),
|
100
|
+
:addresses_private => [Server::Address.new(:version => 4, :address => srv[:privateIpAddress])],
|
101
|
+
:addresses_public => [Server::Address.new(:version => 4, :address => srv[:ipAddress])],
|
102
|
+
:status => srv.get(:instanceState, :name),
|
103
|
+
:key_name => srv[:keyName]
|
104
|
+
).valid_state
|
105
|
+
end
|
106
|
+
end.flatten
|
106
107
|
end
|
107
108
|
|
108
109
|
end
|
@@ -67,7 +67,9 @@ module Miasma
|
|
67
67
|
d_stk['StackId'] == stk['StackId']
|
68
68
|
end || Smash.new
|
69
69
|
stk.merge!(desc)
|
70
|
-
|
70
|
+
if(stack)
|
71
|
+
next if stack.id != stk['StackId'] && stk['StackId'].split('/')[1] != stack.id
|
72
|
+
end
|
71
73
|
new_stack = stack || Stack.new(self)
|
72
74
|
new_stack.load_data(
|
73
75
|
:id => stk['StackId'],
|
@@ -228,6 +230,17 @@ module Miasma
|
|
228
230
|
end
|
229
231
|
end
|
230
232
|
|
233
|
+
# Return single stack
|
234
|
+
#
|
235
|
+
# @param ident [String] name or ID
|
236
|
+
# @return [Stack]
|
237
|
+
def stack_get(ident)
|
238
|
+
i = Stack.new(self)
|
239
|
+
i.id = ident
|
240
|
+
i.reload
|
241
|
+
i.name ? i : nil
|
242
|
+
end
|
243
|
+
|
231
244
|
# Return all stacks
|
232
245
|
#
|
233
246
|
# @param options [Hash] filter
|
@@ -37,7 +37,7 @@ module Miasma
|
|
37
37
|
attribute :desired_size, Integer, :coerce => lambda{|v| v.to_i}
|
38
38
|
attribute :current_size, Integer, :coerce => lambda{|v| v.to_i}
|
39
39
|
attribute :state, Symbol, :allowed_values => []
|
40
|
-
attribute :servers, Server, :multiple => true, :coerce => lambda{|v,obj| Server.new(obj.
|
40
|
+
attribute :servers, Server, :multiple => true, :coerce => lambda{|v,obj| Server.new(obj.api_for(:compute), v)}
|
41
41
|
|
42
42
|
on_missing :reload
|
43
43
|
|
@@ -7,17 +7,6 @@ module Miasma
|
|
7
7
|
# Abstract stack collection
|
8
8
|
class Stacks < Types::Collection
|
9
9
|
|
10
|
-
# Locate stack by name or ID
|
11
|
-
#
|
12
|
-
# @param ident [String, Numeric] name or ID
|
13
|
-
# @return [Stack]
|
14
|
-
def get(ident)
|
15
|
-
all.detect do |stack|
|
16
|
-
stack.id.to_s == ident.to_s ||
|
17
|
-
stack.name.to_s == ident.to_s
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
10
|
# Return stacks matching given filter
|
22
11
|
#
|
23
12
|
# @param options [Hash] filter options
|
@@ -39,6 +28,15 @@ module Miasma
|
|
39
28
|
api.stack_all
|
40
29
|
end
|
41
30
|
|
31
|
+
# @return [Stack]
|
32
|
+
def perform_get(ident)
|
33
|
+
if(api.respond_to?(:stack_get))
|
34
|
+
api.stack_get(ident)
|
35
|
+
else
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
42
40
|
end
|
43
41
|
|
44
42
|
end
|
data/lib/miasma/types/api.rb
CHANGED
@@ -65,7 +65,7 @@ module Miasma
|
|
65
65
|
# @param args [Hash] options
|
66
66
|
# @option args [String, Symbol] :method HTTP request method
|
67
67
|
# @option args [String] :path request path
|
68
|
-
# @option args [Integer] :expects expected response status code
|
68
|
+
# @option args [Integer, Array<Integer>] :expects expected response status code
|
69
69
|
# @option args [TrueClass, FalseClass] :disable_body_extraction do not auto-parse response body
|
70
70
|
# @return [Smash] {:result => HTTP::Response, :headers => Smash, :body => Object}
|
71
71
|
# @raises [Error::ApiError::RequestError]
|
@@ -94,7 +94,7 @@ module Miasma
|
|
94
94
|
_connection = connection
|
95
95
|
end
|
96
96
|
result = make_request(_connection, http_method, request_args)
|
97
|
-
unless(
|
97
|
+
unless([args.fetch(:expects, 200)].flatten.compact.map(&:to_i).include?(result.code))
|
98
98
|
raise Error::ApiError::RequestError.new(result.reason, :response => result)
|
99
99
|
end
|
100
100
|
format_response(result, !args[:disable_body_extraction])
|
data/lib/miasma/utils/smash.rb
CHANGED
@@ -80,15 +80,15 @@ module Miasma
|
|
80
80
|
# Convert to Hash
|
81
81
|
#
|
82
82
|
# @return [Hash]
|
83
|
-
def to_hash
|
84
|
-
self.to_type_converter(::Hash, :to_hash)
|
83
|
+
def to_hash(*args)
|
84
|
+
self.to_type_converter(::Hash, :to_hash, *args)
|
85
85
|
end
|
86
86
|
|
87
87
|
# Calculate checksum of hash (sha256)
|
88
88
|
#
|
89
89
|
# @return [String] checksum
|
90
90
|
def checksum
|
91
|
-
Digest::SHA256.hexdigest(self.to_smash.to_s)
|
91
|
+
Digest::SHA256.hexdigest(self.to_smash(:sorted).to_s)
|
92
92
|
end
|
93
93
|
|
94
94
|
end
|
@@ -102,8 +102,8 @@ class Hash
|
|
102
102
|
# Convert to Smash
|
103
103
|
#
|
104
104
|
# @return [Smash]
|
105
|
-
def to_smash
|
106
|
-
self.to_type_converter(::Smash, :to_smash)
|
105
|
+
def to_smash(*args)
|
106
|
+
self.to_type_converter(::Smash, :to_smash, *args)
|
107
107
|
end
|
108
108
|
alias_method :hulk_smash, :to_smash
|
109
109
|
|
@@ -114,12 +114,17 @@ class Hash
|
|
114
114
|
# @param type [Class] hash type
|
115
115
|
# @param convert_call [Symbol] builtin hash convert
|
116
116
|
# @return [Smash]
|
117
|
-
def to_type_converter(type, convert_call)
|
117
|
+
def to_type_converter(type, convert_call, *args)
|
118
118
|
type.new.tap do |smash|
|
119
|
-
|
120
|
-
entry
|
121
|
-
|
122
|
-
|
119
|
+
if(args.include?(:sorted))
|
120
|
+
process = self.sort_by do |entry|
|
121
|
+
entry.first.to_s
|
122
|
+
end
|
123
|
+
else
|
124
|
+
process = self
|
125
|
+
end
|
126
|
+
process.each do |k,v|
|
127
|
+
smash[k.is_a?(Symbol) ? k.to_s : k] = smash_conversion(v, convert_call, *args)
|
123
128
|
end
|
124
129
|
end
|
125
130
|
end
|
@@ -129,13 +134,13 @@ class Hash
|
|
129
134
|
# @param obj [Object]
|
130
135
|
# @param convert_call [Symbol] builtin hash convert
|
131
136
|
# @return [Smash, Object]
|
132
|
-
def smash_conversion(obj, convert_call)
|
137
|
+
def smash_conversion(obj, convert_call, *args)
|
133
138
|
case obj
|
134
139
|
when Hash
|
135
|
-
obj.send(convert_call)
|
140
|
+
obj.send(convert_call, *args)
|
136
141
|
when Array
|
137
142
|
obj.map do |i|
|
138
|
-
smash_conversion(i, convert_call)
|
143
|
+
smash_conversion(i, convert_call, *args)
|
139
144
|
end
|
140
145
|
else
|
141
146
|
obj
|
data/lib/miasma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miasma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|