miasma 0.3.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +4 -0
  3. data/LICENSE +1 -1
  4. data/README.md +5 -2
  5. data/lib/miasma.rb +14 -15
  6. data/lib/miasma/error.rb +17 -10
  7. data/lib/miasma/models.rb +9 -9
  8. data/lib/miasma/models/auto_scale.rb +5 -7
  9. data/lib/miasma/models/auto_scale/group.rb +8 -13
  10. data/lib/miasma/models/auto_scale/groups.rb +2 -4
  11. data/lib/miasma/models/block_storage.rb +1 -0
  12. data/lib/miasma/models/compute.rb +4 -6
  13. data/lib/miasma/models/compute/server.rb +5 -6
  14. data/lib/miasma/models/compute/servers.rb +2 -4
  15. data/lib/miasma/models/dns.rb +1 -0
  16. data/lib/miasma/models/load_balancer.rb +5 -7
  17. data/lib/miasma/models/load_balancer/balancer.rb +9 -11
  18. data/lib/miasma/models/load_balancer/balancers.rb +2 -4
  19. data/lib/miasma/models/monitoring.rb +1 -0
  20. data/lib/miasma/models/orchestration.rb +37 -7
  21. data/lib/miasma/models/orchestration/event.rb +2 -5
  22. data/lib/miasma/models/orchestration/events.rb +5 -7
  23. data/lib/miasma/models/orchestration/plan.rb +87 -0
  24. data/lib/miasma/models/orchestration/plans.rb +52 -0
  25. data/lib/miasma/models/orchestration/resource.rb +8 -10
  26. data/lib/miasma/models/orchestration/resources.rb +3 -5
  27. data/lib/miasma/models/orchestration/stack.rb +106 -20
  28. data/lib/miasma/models/orchestration/stacks.rb +3 -5
  29. data/lib/miasma/models/queues.rb +1 -0
  30. data/lib/miasma/models/queuing.rb +72 -0
  31. data/lib/miasma/models/queuing/queue.rb +77 -0
  32. data/lib/miasma/models/queuing/queues.rb +32 -0
  33. data/lib/miasma/models/storage.rb +8 -9
  34. data/lib/miasma/models/storage/bucket.rb +4 -7
  35. data/lib/miasma/models/storage/buckets.rb +2 -4
  36. data/lib/miasma/models/storage/file.rb +13 -16
  37. data/lib/miasma/models/storage/files.rb +3 -5
  38. data/lib/miasma/specs.rb +4 -4
  39. data/lib/miasma/specs/compute_abstract.rb +24 -33
  40. data/lib/miasma/specs/load_balancer_abstract.rb +17 -27
  41. data/lib/miasma/specs/orchestration_abstract.rb +26 -37
  42. data/lib/miasma/specs/storage_abstract.rb +21 -27
  43. data/lib/miasma/types.rb +6 -8
  44. data/lib/miasma/types/api.rb +28 -31
  45. data/lib/miasma/types/collection.rb +8 -10
  46. data/lib/miasma/types/data.rb +2 -5
  47. data/lib/miasma/types/model.rb +13 -16
  48. data/lib/miasma/types/thin_model.rb +7 -10
  49. data/lib/miasma/utils.rb +7 -7
  50. data/lib/miasma/utils/animal_strings.rb +1 -3
  51. data/lib/miasma/utils/api_methoding.rb +2 -5
  52. data/lib/miasma/utils/immutable.rb +2 -6
  53. data/lib/miasma/utils/lazy.rb +2 -2
  54. data/lib/miasma/utils/memoization.rb +1 -1
  55. data/lib/miasma/utils/smash.rb +1 -1
  56. data/lib/miasma/version.rb +1 -1
  57. data/miasma.gemspec +21 -19
  58. metadata +44 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2c65e39cdf1ae2259539eda0cdcfd900fed14529
4
- data.tar.gz: 3cc1b80e89671fdb47541c486bf74da96fc117e9
2
+ SHA256:
3
+ metadata.gz: b6ec4c699bde261e0e44469339a19cdcb55f58faad4c5ccbde0439321a22da83
4
+ data.tar.gz: d1d2c89ce389385c6e5a5a6462e201299e00b0f21da5d17ca9013e1149fe8df6
5
5
  SHA512:
6
- metadata.gz: 0c7972847006c49f64fb588fc998451d732183af250e70f639c7661b5049a36832f164d67a8555e66d17c9f7113d81fbb540c3c8bfaecccd54bbf6d5b24d4ccd
7
- data.tar.gz: 2d5378f22f14cfc6d80dc0f6d01f69b793d4b10d9c7d32e7dfe8fff09da22b139e0f8f7052f536b3cd82410127147e39c67af19c823c2c3e5eb5fcd6f3ad6727
6
+ metadata.gz: 564daaf08564aff07e67fdd1fe0b117ab86dad1fa3a9f17a34baf9774e456fb771ee3351de708e719446fd3a5c316a1b3c8cbcd686de98fa2f1c76dec9a8f8ad
7
+ data.tar.gz: 10832fe2f29d56c4096384e2486f2b6e71c9c0c7bd741f315cc6fc3b5a54766f24f45c3a378969df59cedc225381343e274f6b24c2a0b455acf09059c05279e1
@@ -1,3 +1,7 @@
1
+ # v0.3.4
2
+ * Add queue modeling abstracts
3
+ * Add orchestration stack plan abstracts
4
+
1
5
  # v0.3.2
2
6
  * Update events update! helper to properly fetch new items
3
7
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 Chris Roberts
1
+ Copyright 2018 Chris Roberts
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -148,9 +148,12 @@ should provide a simple feature matrix for a quick
148
148
  check on support availability:
149
149
 
150
150
  * [AWS](https://github.com/miasma-rb/miasma-aws)
151
- * [Rackspace](https://github.com/miasma-rb/miasma-rackspace)
152
- * [OpenStack](https://github.com/miasma-rb/miasma-open-stack)
151
+ * [Azure](https://github.com/miasma-rb/miasma-azure)
152
+ * [Google](https://github.com/miasma-rb/miasma-google)
153
153
  * [Local](https://github.com/miasma-rb/miasma-local)
154
+ * [OpenStack](https://github.com/miasma-rb/miasma-open-stack)
155
+ * [Rackspace](https://github.com/miasma-rb/miasma-rackspace)
156
+ * [Terraform](https://github.com/miasma-rb/miasma-terraform)
154
157
 
155
158
  ## Info
156
159
 
@@ -1,18 +1,18 @@
1
1
  # Load in dependencies
2
- require 'http'
3
- require 'bogo'
4
- require 'bogo/http_proxy'
5
- require 'multi_json'
6
- require 'multi_xml'
2
+ require "http"
3
+ require "bogo"
4
+ require "bogo/http_proxy"
5
+ require "multi_json"
6
+ require "multi_xml"
7
7
 
8
8
  # Make version available
9
- require 'miasma/version'
9
+ require "miasma/version"
10
10
 
11
11
  module Miasma
12
- autoload :Error, 'miasma/error'
13
- autoload :Models, 'miasma/models'
14
- autoload :Types, 'miasma/types'
15
- autoload :Utils, 'miasma/utils'
12
+ autoload :Error, "miasma/error"
13
+ autoload :Models, "miasma/models"
14
+ autoload :Types, "miasma/types"
15
+ autoload :Utils, "miasma/utils"
16
16
 
17
17
  # Generate and API connection
18
18
  #
@@ -20,10 +20,10 @@ module Miasma
20
20
  # @option args [String, Symbol] :type API type (:compute, :dns, etc)
21
21
  # @option args [String, Symbol] :provider Service provider
22
22
  # @option args [Hash] :credentials Service provider credentials
23
- def self.api(args={})
23
+ def self.api(args = {})
24
24
  args = Utils::Smash.new(args)
25
25
  [:type, :provider].each do |key|
26
- unless(args[key])
26
+ unless args[key]
27
27
  raise ArgumentError.new "Missing required api argument `#{key.inspect}`!"
28
28
  end
29
29
  end
@@ -37,9 +37,9 @@ module Miasma
37
37
  end
38
38
  begin
39
39
  base_klass = Models.const_get(args[:type])
40
- if(base_klass)
40
+ if base_klass
41
41
  api_klass = base_klass.const_get(args[:provider])
42
- if(api_klass)
42
+ if api_klass
43
43
  api_klass.new(args[:credentials].to_smash)
44
44
  else
45
45
  raise Error.new "Failed to locate #{args[:type]} API for #{args[:provider].inspect}"
@@ -51,5 +51,4 @@ module Miasma
51
51
  raise Error.new "Failed to load requested API type #{args[:type].inspect} (Reason: #{e.class} - #{e})"
52
52
  end
53
53
  end
54
-
55
54
  end
@@ -1,4 +1,4 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  # Generic Error class
@@ -9,7 +9,7 @@ module Miasma
9
9
  # @param msg [String] error message
10
10
  # @param args [Hash] optional arguments
11
11
  # @return [self]
12
- def initialize(msg, args={})
12
+ def initialize(msg, args = {})
13
13
  super msg
14
14
  end
15
15
 
@@ -26,7 +26,7 @@ module Miasma
26
26
  # @param msg [String] error message
27
27
  # @param args [Hash] optional arguments
28
28
  # @option args [HTTP::Response] :response response from request
29
- def initialize(msg, args={})
29
+ def initialize(msg, args = {})
30
30
  super
31
31
  @response = args.to_smash[:response]
32
32
  @message = msg
@@ -35,7 +35,7 @@ module Miasma
35
35
 
36
36
  # @return [String] provides response error suffix
37
37
  def message
38
- [@message, @response_error_msg].compact.join(' - ')
38
+ [@message, @response_error_msg].compact.join(" - ")
39
39
  end
40
40
 
41
41
  # Attempt to extract error message from response
@@ -47,16 +47,16 @@ module Miasma
47
47
  begin
48
48
  content = MultiJson.load(response.body.to_s).to_smash
49
49
  @response_error_msg = [[:error, :message]].map do |path|
50
- if(result = content.get(*path))
50
+ if result = content.get(*path)
51
51
  "#{content[:code]}: #{result}"
52
52
  end
53
53
  end.flatten.compact.first
54
54
  rescue MultiJson::ParseError
55
55
  begin
56
56
  content = MultiXml.parse(response.body.to_s).to_smash
57
- @response_error_msg = [['ErrorResponse', 'Error'], ['Error']].map do |path|
58
- if(result = content.get(*path))
59
- "#{result['Code']}: #{result['Message']}"
57
+ @response_error_msg = [["ErrorResponse", "Error"], ["Error"]].map do |path|
58
+ if result = content.get(*path)
59
+ "#{result["Code"]}: #{result["Message"]}"
60
60
  end
61
61
  end.compact.first
62
62
  rescue MultiXml::ParseError
@@ -74,13 +74,21 @@ module Miasma
74
74
 
75
75
  # Api authentication error
76
76
  class AuthenticationError < ApiError; end
77
-
78
77
  end
79
78
 
80
79
  # Orchestration error
81
80
  class OrchestrationError < Error
82
81
  # Template failed to validate
83
82
  class InvalidTemplate < OrchestrationError; end
83
+
84
+ # Stack is not in correct state for planning
85
+ class InvalidPlanState < OrchestrationError; end
86
+
87
+ # Plan is no longer valid for stack
88
+ class InvalidStackPlan < OrchestrationError; end
89
+
90
+ # Plan already exists
91
+ class StackPlanExists < OrchestrationError; end
84
92
  end
85
93
 
86
94
  # Invalid modification request
@@ -88,6 +96,5 @@ module Miasma
88
96
 
89
97
  # Model has not been persisted
90
98
  class ModelPersistError < Error; end
91
-
92
99
  end
93
100
  end
@@ -1,14 +1,14 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
5
- autoload :AutoScale, 'miasma/models/auto_scale'
6
- autoload :BlockStorage, 'miasma/models/block_storage'
7
- autoload :Compute, 'miasma/models/compute'
8
- autoload :Dns, 'miasma/models/dns'
9
- autoload :LoadBalancer, 'miasma/models/load_balancer'
10
- autoload :Orchestration, 'miasma/models/orchestration'
11
- autoload :Queues, 'miasma/models/queues'
12
- autoload :Storage, 'miasma/models/storage'
5
+ autoload :AutoScale, "miasma/models/auto_scale"
6
+ autoload :BlockStorage, "miasma/models/block_storage"
7
+ autoload :Compute, "miasma/models/compute"
8
+ autoload :Dns, "miasma/models/dns"
9
+ autoload :LoadBalancer, "miasma/models/load_balancer"
10
+ autoload :Orchestration, "miasma/models/orchestration"
11
+ autoload :Queues, "miasma/models/queues"
12
+ autoload :Storage, "miasma/models/storage"
13
13
  end
14
14
  end
@@ -1,18 +1,17 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
5
5
  # Abstract auto scale API
6
6
  class AutoScale < Types::Api
7
-
8
- autoload :Group, 'miasma/models/auto_scale/group'
9
- autoload :Groups, 'miasma/models/auto_scale/groups'
7
+ autoload :Group, "miasma/models/auto_scale/group"
8
+ autoload :Groups, "miasma/models/auto_scale/groups"
10
9
 
11
10
  # Auto scale groups
12
11
  #
13
12
  # @param filter [Hash] filtering options
14
13
  # @return [Types::Collection<Models::AutoScale::Groups>] auto scale groups
15
- def groups(filter={})
14
+ def groups(filter = {})
16
15
  memoize(:groups) do
17
16
  Groups.new(self)
18
17
  end
@@ -46,10 +45,9 @@ module Miasma
46
45
  #
47
46
  # @param options [Hash] filter
48
47
  # @return [Array<Models::AutoScale::Group>]
49
- def group_all(options={})
48
+ def group_all(options = {})
50
49
  raise NotImplementedError
51
50
  end
52
-
53
51
  end
54
52
  end
55
53
  end
@@ -1,13 +1,11 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
5
5
  class AutoScale
6
6
  # Abstract group
7
7
  class Group < Types::Model
8
-
9
8
  class Server < Types::ThinModel
10
-
11
9
  model Miasma::Models::Compute::Server
12
10
  attribute :name, String
13
11
 
@@ -18,7 +16,6 @@ module Miasma
18
16
  end
19
17
 
20
18
  class Balancer < Types::ThinModel
21
-
22
19
  model Miasma::Models::LoadBalancer::Balancer
23
20
  attribute :name, String
24
21
 
@@ -26,18 +23,17 @@ module Miasma
26
23
  def expand
27
24
  api.api_for(:load_balancer).balancers.get(self.id || self.name)
28
25
  end
29
-
30
26
  end
31
27
 
32
28
  attribute :name, String, :required => true
33
- attribute :created, Time, :coerce => lambda{|v| Time.parse(v.to_s)}
34
- attribute :load_balancers, Balancer, :multiple => true, :coerce => lambda{|v,obj| Balancer.new(obj.api, v)}
35
- attribute :minimum_size, Integer, :coerce => lambda{|v| v.to_i}
36
- attribute :maximum_size, Integer, :coerce => lambda{|v| v.to_i}
37
- attribute :desired_size, Integer, :coerce => lambda{|v| v.to_i}
38
- attribute :current_size, Integer, :coerce => lambda{|v| v.to_i}
29
+ attribute :created, Time, :coerce => lambda { |v| Time.parse(v.to_s) }
30
+ attribute :load_balancers, Balancer, :multiple => true, :coerce => lambda { |v, obj| Balancer.new(obj.api, v) }
31
+ attribute :minimum_size, Integer, :coerce => lambda { |v| v.to_i }
32
+ attribute :maximum_size, Integer, :coerce => lambda { |v| v.to_i }
33
+ attribute :desired_size, Integer, :coerce => lambda { |v| v.to_i }
34
+ attribute :current_size, Integer, :coerce => lambda { |v| v.to_i }
39
35
  attribute :state, Symbol, :allowed_values => []
40
- attribute :servers, Server, :multiple => true, :coerce => lambda{|v,obj| Server.new(obj.api_for(:compute), v)}
36
+ attribute :servers, Server, :multiple => true, :coerce => lambda { |v, obj| Server.new(obj.api_for(:compute), v) }
41
37
 
42
38
  on_missing :reload
43
39
 
@@ -57,7 +53,6 @@ module Miasma
57
53
  def perform_destroy
58
54
  api.group_destroy(self)
59
55
  end
60
-
61
56
  end
62
57
  end
63
58
  end
@@ -1,4 +1,4 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
@@ -11,7 +11,7 @@ module Miasma
11
11
  #
12
12
  # @param options [Hash] filter options
13
13
  # @return [Array<Group>]
14
- def filter(options={})
14
+ def filter(options = {})
15
15
  raise NotImplementedError
16
16
  end
17
17
 
@@ -26,9 +26,7 @@ module Miasma
26
26
  def perform_population
27
27
  api.group_all
28
28
  end
29
-
30
29
  end
31
-
32
30
  end
33
31
  end
34
32
  end
@@ -1,12 +1,11 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
5
5
  # Abstract compute API
6
6
  class Compute < Types::Api
7
-
8
- autoload :Server, 'miasma/models/compute/server'
9
- autoload :Servers, 'miasma/models/compute/servers'
7
+ autoload :Server, "miasma/models/compute/server"
8
+ autoload :Servers, "miasma/models/compute/servers"
10
9
 
11
10
  # All compute instances
12
11
  #
@@ -22,7 +21,7 @@ module Miasma
22
21
  # @param filter [Hash] search filter
23
22
  # @option filter [Symbol] :state state of server `Server::VALID_COMPUTE_STATES`
24
23
  # @return [Array<Server>]
25
- def server_filter(filter={})
24
+ def server_filter(filter = {})
26
25
  end
27
26
 
28
27
  # Create new server instance
@@ -64,7 +63,6 @@ module Miasma
64
63
  def server_change_state(server, action)
65
64
  raise NotImplementedError
66
65
  end
67
-
68
66
  end
69
67
  end
70
68
  end
@@ -1,4 +1,4 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
@@ -28,11 +28,11 @@ module Miasma
28
28
  attribute :flavor_id, [String, Numeric]
29
29
  attribute :state, Symbol, :allowed => VALID_COMPUTE_STATES
30
30
  attribute :status, String
31
- attribute :addresses_public, Address, :multiple => true, :coerce => lambda{|v| Address.new(v)}
32
- attribute :addresses_private, Address, :multiple => true, :coerce => lambda{|v| Address.new(v)}
33
- attribute :networks, Network, :multiple => true, :coerce => lambda{|v| Network.new(v)}
31
+ attribute :addresses_public, Address, :multiple => true, :coerce => lambda { |v| Address.new(v) }
32
+ attribute :addresses_private, Address, :multiple => true, :coerce => lambda { |v| Address.new(v) }
33
+ attribute :networks, Network, :multiple => true, :coerce => lambda { |v| Network.new(v) }
34
34
  attribute :personality, [Hash, String], :default => {}
35
- attribute :metadata, Hash, :coerce => lambda{|o| o.to_smash}
35
+ attribute :metadata, Hash, :coerce => lambda { |o| o.to_smash }
36
36
  attribute :key_name, String
37
37
 
38
38
  on_missing :reload
@@ -67,7 +67,6 @@ module Miasma
67
67
  api.server_destroy(self)
68
68
  end
69
69
  end
70
-
71
70
  end
72
71
  end
73
72
  end
@@ -1,4 +1,4 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
@@ -12,7 +12,7 @@ module Miasma
12
12
  # @param options [Hash] filter options
13
13
  # @option options [String] :state current instance state
14
14
  # @return [Array<Server>]
15
- def filter(options={})
15
+ def filter(options = {})
16
16
  raise NotImplementedError
17
17
  end
18
18
 
@@ -27,9 +27,7 @@ module Miasma
27
27
  def perform_population
28
28
  api.server_all
29
29
  end
30
-
31
30
  end
32
-
33
31
  end
34
32
  end
35
33
  end
@@ -0,0 +1 @@
1
+
@@ -1,18 +1,17 @@
1
- require 'miasma'
1
+ require "miasma"
2
2
 
3
3
  module Miasma
4
4
  module Models
5
5
  # Abstract load balancer API
6
6
  class LoadBalancer < Types::Api
7
-
8
- autoload :Balancer, 'miasma/models/load_balancer/balancer'
9
- autoload :Balancers, 'miasma/models/load_balancer/balancers'
7
+ autoload :Balancer, "miasma/models/load_balancer/balancer"
8
+ autoload :Balancers, "miasma/models/load_balancer/balancers"
10
9
 
11
10
  # Load balancers
12
11
  #
13
12
  # @param filter [Hash] filtering options
14
13
  # @return [Types::Collection<Models::LoadBalancer::Balancer>] auto scale groups
15
- def balancers(filter={})
14
+ def balancers(filter = {})
16
15
  memoize(:balancers) do
17
16
  Balancers.new(self)
18
17
  end
@@ -46,10 +45,9 @@ module Miasma
46
45
  #
47
46
  # @param options [Hash] filter
48
47
  # @return [Array<Models::LoadBalancer::Balancer>]
49
- def balancer_all(options={})
48
+ def balancer_all(options = {})
50
49
  raise NotImplementedError
51
50
  end
52
-
53
51
  end
54
52
  end
55
53
  end