miasma 0.3.2 → 0.3.4
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 +5 -5
- data/CHANGELOG.md +4 -0
- data/LICENSE +1 -1
- data/README.md +5 -2
- data/lib/miasma.rb +14 -15
- data/lib/miasma/error.rb +17 -10
- data/lib/miasma/models.rb +9 -9
- data/lib/miasma/models/auto_scale.rb +5 -7
- data/lib/miasma/models/auto_scale/group.rb +8 -13
- data/lib/miasma/models/auto_scale/groups.rb +2 -4
- data/lib/miasma/models/block_storage.rb +1 -0
- data/lib/miasma/models/compute.rb +4 -6
- data/lib/miasma/models/compute/server.rb +5 -6
- data/lib/miasma/models/compute/servers.rb +2 -4
- data/lib/miasma/models/dns.rb +1 -0
- data/lib/miasma/models/load_balancer.rb +5 -7
- data/lib/miasma/models/load_balancer/balancer.rb +9 -11
- data/lib/miasma/models/load_balancer/balancers.rb +2 -4
- data/lib/miasma/models/monitoring.rb +1 -0
- data/lib/miasma/models/orchestration.rb +37 -7
- data/lib/miasma/models/orchestration/event.rb +2 -5
- data/lib/miasma/models/orchestration/events.rb +5 -7
- data/lib/miasma/models/orchestration/plan.rb +87 -0
- data/lib/miasma/models/orchestration/plans.rb +52 -0
- data/lib/miasma/models/orchestration/resource.rb +8 -10
- data/lib/miasma/models/orchestration/resources.rb +3 -5
- data/lib/miasma/models/orchestration/stack.rb +106 -20
- data/lib/miasma/models/orchestration/stacks.rb +3 -5
- data/lib/miasma/models/queues.rb +1 -0
- data/lib/miasma/models/queuing.rb +72 -0
- data/lib/miasma/models/queuing/queue.rb +77 -0
- data/lib/miasma/models/queuing/queues.rb +32 -0
- data/lib/miasma/models/storage.rb +8 -9
- data/lib/miasma/models/storage/bucket.rb +4 -7
- data/lib/miasma/models/storage/buckets.rb +2 -4
- data/lib/miasma/models/storage/file.rb +13 -16
- data/lib/miasma/models/storage/files.rb +3 -5
- data/lib/miasma/specs.rb +4 -4
- data/lib/miasma/specs/compute_abstract.rb +24 -33
- data/lib/miasma/specs/load_balancer_abstract.rb +17 -27
- data/lib/miasma/specs/orchestration_abstract.rb +26 -37
- data/lib/miasma/specs/storage_abstract.rb +21 -27
- data/lib/miasma/types.rb +6 -8
- data/lib/miasma/types/api.rb +28 -31
- data/lib/miasma/types/collection.rb +8 -10
- data/lib/miasma/types/data.rb +2 -5
- data/lib/miasma/types/model.rb +13 -16
- data/lib/miasma/types/thin_model.rb +7 -10
- data/lib/miasma/utils.rb +7 -7
- data/lib/miasma/utils/animal_strings.rb +1 -3
- data/lib/miasma/utils/api_methoding.rb +2 -5
- data/lib/miasma/utils/immutable.rb +2 -6
- data/lib/miasma/utils/lazy.rb +2 -2
- data/lib/miasma/utils/memoization.rb +1 -1
- data/lib/miasma/utils/smash.rb +1 -1
- data/lib/miasma/version.rb +1 -1
- data/miasma.gemspec +21 -19
- metadata +44 -12
@@ -1,14 +1,13 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Models
|
5
5
|
class Storage
|
6
6
|
# Abstract bucket
|
7
7
|
class Bucket < Types::Model
|
8
|
-
|
9
8
|
attribute :name, String, :required => true
|
10
|
-
attribute :created, Time, :coerce => lambda{|t| Time.parse(t.to_s)}
|
11
|
-
attribute :metadata, Smash, :coerce => lambda{|o| o.to_smash}
|
9
|
+
attribute :created, Time, :coerce => lambda { |t| Time.parse(t.to_s) }
|
10
|
+
attribute :metadata, Smash, :coerce => lambda { |o| o.to_smash }
|
12
11
|
|
13
12
|
# @return [Files]
|
14
13
|
def files
|
@@ -21,7 +20,7 @@ module Miasma
|
|
21
20
|
#
|
22
21
|
# @param filter [Hash]
|
23
22
|
# @return [Array<Bucket>]
|
24
|
-
def filter(filter={})
|
23
|
+
def filter(filter = {})
|
25
24
|
raise NotImplementedError
|
26
25
|
end
|
27
26
|
|
@@ -41,9 +40,7 @@ module Miasma
|
|
41
40
|
def perform_destroy
|
42
41
|
api.bucket_destroy(self)
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
46
|
-
|
47
44
|
end
|
48
45
|
end
|
49
46
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Models
|
@@ -9,7 +9,7 @@ module Miasma
|
|
9
9
|
class Buckets < Types::Collection
|
10
10
|
|
11
11
|
# @return [Bucket] new unsaved instance
|
12
|
-
def build(args={})
|
12
|
+
def build(args = {})
|
13
13
|
Bucket.new(api, args.to_smash)
|
14
14
|
end
|
15
15
|
|
@@ -24,9 +24,7 @@ module Miasma
|
|
24
24
|
def perform_population
|
25
25
|
api.bucket_all
|
26
26
|
end
|
27
|
-
|
28
27
|
end
|
29
|
-
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "miasma"
|
2
|
+
require "stringio"
|
3
3
|
|
4
4
|
module Miasma
|
5
5
|
module Models
|
@@ -15,15 +15,15 @@ module Miasma
|
|
15
15
|
attr_reader :io
|
16
16
|
|
17
17
|
def initialize(io_item)
|
18
|
-
unless
|
19
|
-
raise TypeError.new
|
18
|
+
unless io_item.respond_to?(:readpartial)
|
19
|
+
raise TypeError.new "Instance must respond to `#readpartial`"
|
20
20
|
end
|
21
21
|
@io = io_item
|
22
22
|
end
|
23
23
|
|
24
24
|
# Proxy missing methods to io
|
25
25
|
def method_missing(method_name, *args, &block)
|
26
|
-
if
|
26
|
+
if io.respond_to?(method_name)
|
27
27
|
io.send(method_name, *args, &block)
|
28
28
|
else
|
29
29
|
raise
|
@@ -34,14 +34,13 @@ module Miasma
|
|
34
34
|
#
|
35
35
|
# @param length [Integer] length to read
|
36
36
|
# @return [String]
|
37
|
-
def readpartial(length=nil)
|
37
|
+
def readpartial(length = nil)
|
38
38
|
begin
|
39
39
|
io.readpartial(length)
|
40
40
|
rescue EOFError
|
41
41
|
nil
|
42
42
|
end
|
43
43
|
end
|
44
|
-
|
45
44
|
end
|
46
45
|
|
47
46
|
attribute :name, String, :required => true
|
@@ -49,9 +48,9 @@ module Miasma
|
|
49
48
|
attribute :content_disposition, String
|
50
49
|
attribute :content_encoding, String
|
51
50
|
attribute :etag, String
|
52
|
-
attribute :updated, Time, :coerce => lambda{|t| Time.parse(t.to_s)}
|
51
|
+
attribute :updated, Time, :coerce => lambda { |t| Time.parse(t.to_s) }
|
53
52
|
attribute :size, Integer
|
54
|
-
attribute :metadata, Smash, :coerce => lambda{|o| o.to_smash}
|
53
|
+
attribute :metadata, Smash, :coerce => lambda { |o| o.to_smash }
|
55
54
|
|
56
55
|
on_missing :reload
|
57
56
|
|
@@ -63,7 +62,7 @@ module Miasma
|
|
63
62
|
# @param bucket [Bucket]
|
64
63
|
# @param args [Hash]
|
65
64
|
# @return [self]
|
66
|
-
def initialize(bucket, args={})
|
65
|
+
def initialize(bucket, args = {})
|
67
66
|
@bucket = bucket
|
68
67
|
super bucket.api, args
|
69
68
|
end
|
@@ -73,14 +72,14 @@ module Miasma
|
|
73
72
|
# @param options [Hash] filter options
|
74
73
|
# @return [Array<File>]
|
75
74
|
# @option options [String] :prefix key prefix
|
76
|
-
def filter(options={})
|
75
|
+
def filter(options = {})
|
77
76
|
raise NotImplementedError
|
78
77
|
end
|
79
78
|
|
80
79
|
# @return [IO-ish]
|
81
80
|
# @note object returned will provide #readpartial
|
82
81
|
def body
|
83
|
-
unless
|
82
|
+
unless attributes[:body]
|
84
83
|
data[:body] = api.file_body(self)
|
85
84
|
end
|
86
85
|
attributes[:body]
|
@@ -91,7 +90,7 @@ module Miasma
|
|
91
90
|
# @param io [IO, String]
|
92
91
|
# @return [IO]
|
93
92
|
def body=(io)
|
94
|
-
unless
|
93
|
+
unless io.respond_to?(:readpartial)
|
95
94
|
io = StringIO.new(io)
|
96
95
|
end
|
97
96
|
dirty[:body] = io
|
@@ -101,7 +100,7 @@ module Miasma
|
|
101
100
|
#
|
102
101
|
# @param timeout_in_seconds [Integer] optional if private (default: 60)
|
103
102
|
# @return [String] URL
|
104
|
-
def url(timeout_in_seconds=60)
|
103
|
+
def url(timeout_in_seconds = 60)
|
105
104
|
perform_file_url(timeout_in_seconds)
|
106
105
|
end
|
107
106
|
|
@@ -136,9 +135,7 @@ module Miasma
|
|
136
135
|
def perform_destroy
|
137
136
|
api.file_destroy(self)
|
138
137
|
end
|
139
|
-
|
140
138
|
end
|
141
|
-
|
142
139
|
end
|
143
140
|
end
|
144
141
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "miasma"
|
2
2
|
|
3
3
|
module Miasma
|
4
4
|
module Models
|
@@ -24,12 +24,12 @@ module Miasma
|
|
24
24
|
# @param options [Hash] filter options
|
25
25
|
# @return [Array<File>]
|
26
26
|
# @option options [String] :prefix key prefix
|
27
|
-
def filter(options={})
|
27
|
+
def filter(options = {})
|
28
28
|
super
|
29
29
|
end
|
30
30
|
|
31
31
|
# @return [File] new unsaved instance
|
32
|
-
def build(args={})
|
32
|
+
def build(args = {})
|
33
33
|
instance = self.model.new(bucket)
|
34
34
|
args.each do |m_name, m_value|
|
35
35
|
m_name = "#{m_name}="
|
@@ -54,9 +54,7 @@ module Miasma
|
|
54
54
|
def perform_filter(args)
|
55
55
|
api.file_filter(bucket, args)
|
56
56
|
end
|
57
|
-
|
58
57
|
end
|
59
|
-
|
60
58
|
end
|
61
59
|
end
|
62
60
|
end
|
data/lib/miasma/specs.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
Dir.glob(File.join(File.dirname(__FILE__),
|
2
|
-
s_file_name = File.basename(s_file).sub(
|
1
|
+
Dir.glob(File.join(File.dirname(__FILE__), "specs", "*.rb")).each do |s_file|
|
2
|
+
s_file_name = File.basename(s_file).sub(".rb", "")
|
3
3
|
require "miasma/specs/#{s_file_name}"
|
4
4
|
end
|
5
5
|
|
6
|
-
def miasma_spec_sleep(interval=20)
|
7
|
-
if
|
6
|
+
def miasma_spec_sleep(interval = 20)
|
7
|
+
if ENV["MIASMA_TEST_LIVE_REQUESTS"]
|
8
8
|
sleep(20)
|
9
9
|
else
|
10
10
|
sleep(0.1)
|
@@ -1,47 +1,43 @@
|
|
1
|
-
MIASMA_COMPUTE_ABSTRACT = ->{
|
1
|
+
MIASMA_COMPUTE_ABSTRACT = -> {
|
2
2
|
|
3
3
|
# Required `let`s:
|
4
4
|
# * compute: compute API
|
5
5
|
# * build_args: server build arguments [Smash]
|
6
6
|
|
7
7
|
describe Miasma::Models::Compute, :vcr do
|
8
|
-
|
9
|
-
it 'should provide #servers collection' do
|
8
|
+
it "should provide #servers collection" do
|
10
9
|
compute.servers.must_be_kind_of Miasma::Models::Compute::Servers
|
11
10
|
end
|
12
11
|
|
13
12
|
describe Miasma::Models::Compute::Servers do
|
14
|
-
|
15
|
-
it 'should provide instance class used within collection' do
|
13
|
+
it "should provide instance class used within collection" do
|
16
14
|
compute.servers.model.must_equal Miasma::Models::Compute::Server
|
17
15
|
end
|
18
16
|
|
19
|
-
it
|
20
|
-
instance = compute.servers.build(:name =>
|
17
|
+
it "should build new instance for collection" do
|
18
|
+
instance = compute.servers.build(:name => "test")
|
21
19
|
instance.must_be_kind_of Miasma::Models::Compute::Server
|
22
20
|
end
|
23
21
|
|
24
|
-
it
|
22
|
+
it "should provide #all servers" do
|
25
23
|
compute.servers.all.must_be_kind_of Array
|
26
24
|
end
|
27
|
-
|
28
25
|
end
|
29
26
|
|
30
27
|
describe Miasma::Models::Compute::Server do
|
31
|
-
|
32
28
|
before do
|
33
|
-
unless
|
34
|
-
VCR.use_cassette(
|
29
|
+
unless $miasma_instance
|
30
|
+
VCR.use_cassette("Miasma_Models_Compute_Global/GLOBAL_compute_instance_create") do
|
35
31
|
@instance = compute.servers.build(build_args)
|
36
32
|
@instance.save
|
37
|
-
until
|
33
|
+
until @instance.state == :running
|
38
34
|
miasma_spec_sleep
|
39
35
|
@instance.reload
|
40
36
|
end
|
41
37
|
$miasma_instance = @instance
|
42
38
|
end
|
43
39
|
Kernel.at_exit do
|
44
|
-
VCR.use_cassette(
|
40
|
+
VCR.use_cassette("Miasma_Models_Compute_Global/GLOBAL_compute_instance_destroy") do
|
45
41
|
$miasma_instance.destroy
|
46
42
|
end
|
47
43
|
end
|
@@ -51,68 +47,63 @@ MIASMA_COMPUTE_ABSTRACT = ->{
|
|
51
47
|
@instance.reload
|
52
48
|
end
|
53
49
|
|
54
|
-
let(:instance){ @instance }
|
55
|
-
|
56
|
-
describe 'instance methods' do
|
50
|
+
let(:instance) { @instance }
|
57
51
|
|
58
|
-
|
52
|
+
describe "instance methods" do
|
53
|
+
it "should have a name" do
|
59
54
|
instance.name.must_equal build_args[:name]
|
60
55
|
end
|
61
56
|
|
62
|
-
it
|
57
|
+
it "should have an image_id" do
|
63
58
|
instance.image_id.must_equal build_args[:image_id]
|
64
59
|
end
|
65
60
|
|
66
|
-
it
|
61
|
+
it "should have a flavor_id" do
|
67
62
|
instance.flavor_id.must_equal build_args[:flavor_id]
|
68
63
|
end
|
69
64
|
|
70
|
-
it
|
65
|
+
it "should have an address" do
|
71
66
|
instance.addresses.detect do |addr|
|
72
67
|
addr.version == 4
|
73
68
|
end.address.must_match /^(\d+)+\.(\d+)\.(\d+)\.(\d+)$/
|
74
69
|
end
|
75
70
|
|
76
|
-
it
|
71
|
+
it "should have a status" do
|
77
72
|
instance.status.wont_be_nil
|
78
73
|
end
|
79
74
|
|
80
|
-
it
|
75
|
+
it "should be in :running state" do
|
81
76
|
instance.state.must_equal :running
|
82
77
|
end
|
83
|
-
|
84
78
|
end
|
85
|
-
|
86
79
|
end
|
87
80
|
|
88
|
-
describe
|
89
|
-
it
|
81
|
+
describe "instance lifecycle" do
|
82
|
+
it "should create new server, reload details and destroy server" do
|
90
83
|
instance = compute.servers.build(build_args)
|
91
84
|
instance.save
|
92
85
|
instance.id.wont_be_nil
|
93
86
|
instance.state.must_equal :pending
|
94
87
|
compute.servers.reload.get(instance.id).wont_be_nil
|
95
|
-
until
|
88
|
+
until instance.state == :running
|
96
89
|
miasma_spec_sleep
|
97
90
|
instance.reload
|
98
91
|
end
|
99
92
|
instance.state.must_equal :running
|
100
93
|
instance.destroy
|
101
|
-
while
|
94
|
+
while instance.state == :running
|
102
95
|
miasma_spec_sleep
|
103
96
|
instance.reload
|
104
97
|
end
|
105
98
|
[:pending, :terminated].must_include instance.state
|
106
|
-
if
|
107
|
-
until
|
99
|
+
if instance.state == :pending
|
100
|
+
until instance.state == :terminated
|
108
101
|
miasma_spec_sleep
|
109
102
|
instance.reload
|
110
103
|
end
|
111
104
|
instance.state.must_equal :terminated
|
112
105
|
end
|
113
106
|
end
|
114
|
-
|
115
107
|
end
|
116
|
-
|
117
108
|
end
|
118
109
|
}
|
@@ -1,47 +1,43 @@
|
|
1
|
-
MIASMA_LOAD_BALANCER_ABSTRACT = ->{
|
1
|
+
MIASMA_LOAD_BALANCER_ABSTRACT = -> {
|
2
2
|
|
3
3
|
# Required `let`s:
|
4
4
|
# * load_balancer: load balancer API
|
5
5
|
# * build_args: load balancer build arguments [Smash]
|
6
6
|
|
7
7
|
describe Miasma::Models::LoadBalancer, :vcr do
|
8
|
-
|
9
|
-
it 'should provide #balancers collection' do
|
8
|
+
it "should provide #balancers collection" do
|
10
9
|
load_balancer.balancers.must_be_kind_of Miasma::Models::LoadBalancer::Balancers
|
11
10
|
end
|
12
11
|
|
13
12
|
describe Miasma::Models::LoadBalancer::Balancers do
|
14
|
-
|
15
|
-
it 'should provide instance class used within collection' do
|
13
|
+
it "should provide instance class used within collection" do
|
16
14
|
load_balancer.balancers.model.must_equal Miasma::Models::LoadBalancer::Balancer
|
17
15
|
end
|
18
16
|
|
19
|
-
it
|
17
|
+
it "should build new instance for collection" do
|
20
18
|
instance = load_balancer.balancers.build
|
21
19
|
instance.must_be_kind_of Miasma::Models::LoadBalancer::Balancer
|
22
20
|
end
|
23
21
|
|
24
|
-
it
|
22
|
+
it "should provide #all balancers" do
|
25
23
|
load_balancer.balancers.all.must_be_kind_of Array
|
26
24
|
end
|
27
|
-
|
28
25
|
end
|
29
26
|
|
30
27
|
describe Miasma::Models::LoadBalancer::Balancer do
|
31
|
-
|
32
28
|
before do
|
33
|
-
unless
|
34
|
-
VCR.use_cassette(
|
29
|
+
unless $miasma_balancer
|
30
|
+
VCR.use_cassette("Miasma_Models_LoadBalancer_Global/GLOBAL_load_balancer_create") do
|
35
31
|
@balancer = load_balancer.balancers.build(build_args)
|
36
32
|
@balancer.save
|
37
|
-
until
|
33
|
+
until @balancer.state == :active
|
38
34
|
miasma_spec_sleep
|
39
35
|
@balancer.reload
|
40
36
|
end
|
41
37
|
$miasma_balancer = @balancer
|
42
38
|
end
|
43
39
|
Kernel.at_exit do
|
44
|
-
VCR.use_cassette(
|
40
|
+
VCR.use_cassette("Miasma_Models_LoadBalancer_Global/GLOBAL_load_balancer_destroy") do
|
45
41
|
$miasma_balancer.destroy
|
46
42
|
end
|
47
43
|
end
|
@@ -51,38 +47,32 @@ MIASMA_LOAD_BALANCER_ABSTRACT = ->{
|
|
51
47
|
@balancer.reload
|
52
48
|
end
|
53
49
|
|
54
|
-
let(:balancer){ @balancer }
|
55
|
-
|
56
|
-
describe 'collection' do
|
50
|
+
let(:balancer) { @balancer }
|
57
51
|
|
58
|
-
|
52
|
+
describe "collection" do
|
53
|
+
it "should include balancer" do
|
59
54
|
load_balancer.balancers.reload.get(balancer.id).wont_be_nil
|
60
55
|
end
|
61
|
-
|
62
56
|
end
|
63
57
|
|
64
|
-
describe
|
65
|
-
|
66
|
-
it 'should have a name' do
|
58
|
+
describe "balancer methods" do
|
59
|
+
it "should have a name" do
|
67
60
|
balancer.name.must_equal build_args[:name]
|
68
61
|
end
|
69
62
|
|
70
|
-
it
|
63
|
+
it "should be in :active state" do
|
71
64
|
balancer.state.must_equal :active
|
72
65
|
end
|
73
66
|
|
74
|
-
it
|
67
|
+
it "should have a status" do
|
75
68
|
balancer.status.wont_be_nil
|
76
69
|
balancer.status.must_be_kind_of String
|
77
70
|
end
|
78
71
|
|
79
|
-
it
|
72
|
+
it "should have a public address" do
|
80
73
|
balancer.public_addresses.wont_be :empty?
|
81
74
|
end
|
82
|
-
|
83
75
|
end
|
84
|
-
|
85
76
|
end
|
86
|
-
|
87
77
|
end
|
88
78
|
}
|