miasma 0.2.10 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,85 +0,0 @@
1
- require 'miasma'
2
-
3
- module Miasma
4
- module Models
5
- class AutoScale
6
- class Rackspace < AutoScale
7
-
8
- include Contrib::OpenStackApiCore::ApiCommon
9
- include Contrib::RackspaceApiCore::ApiCommon
10
-
11
- # Save auto scale group
12
- #
13
- # @param group [Models::AutoScale::Group]
14
- # @return [Models::AutoScale::Group]
15
- def group_save(group)
16
- raise NotImplementedError
17
- end
18
-
19
- # Reload the group data from the API
20
- #
21
- # @param group [Models::AutoScale::Group]
22
- # @return [Models::AutoScale::Group]
23
- def group_reload(group)
24
- if(group.persisted?)
25
- result = request(
26
- :method => :get,
27
- :path => "/groups/#{group.id}",
28
- :expects => 200
29
- )
30
- grp = result.get(:body, :group)
31
- group.load_data(
32
- :name => grp.get('groupConfiguration', :name),
33
- :minimum_size => grp.get('groupConfiguration', 'minEntities'),
34
- :maximum_size => grp.get('groupConfiguration', 'maxEntities'),
35
- :desired_size => grp.get(:state, 'desiredCapacity'),
36
- :current_size => grp.get(:state, 'activeCapacity'),
37
- :servers => grp.get(:state, :active).map{|s| AutoScale::Group::Server.new(self, :id => s[:id])}
38
- ).valid_state
39
- else
40
- group
41
- end
42
- end
43
-
44
- # Delete auto scale group
45
- #
46
- # @param group [Models::AutoScale::Group]
47
- # @return [TrueClass, FalseClass]
48
- def group_destroy(group)
49
- if(group.persisted?)
50
- request(
51
- :path => "/groups/#{group.id}",
52
- :method => :delete,
53
- :expects => 204
54
- )
55
- true
56
- else
57
- false
58
- end
59
- end
60
-
61
- # Return all auto scale groups
62
- #
63
- # @param options [Hash] filter
64
- # @return [Array<Models::AutoScale::Group>]
65
- def group_all(options={})
66
- result = request(
67
- :method => :get,
68
- :path => '/groups',
69
- :expects => 200
70
- )
71
- result.fetch(:body, 'groups', []).map do |lb|
72
- Group.new(
73
- self,
74
- :id => lb[:id],
75
- :name => lb.get(:state, :name),
76
- :current_size => lb.get(:state, 'activeCapacity'),
77
- :desired_size => lb.get(:state, 'desiredCapacity')
78
- ).valid_state
79
- end
80
- end
81
-
82
- end
83
- end
84
- end
85
- end
@@ -1,13 +0,0 @@
1
- require 'miasma'
2
-
3
- module Miasma
4
- module Models
5
- class Compute
6
- class Rackspace < OpenStack
7
-
8
- include Contrib::RackspaceApiCore::ApiCommon
9
-
10
- end
11
- end
12
- end
13
- end
@@ -1,118 +0,0 @@
1
- require 'miasma'
2
-
3
- module Miasma
4
- module Models
5
- class LoadBalancer
6
- class Rackspace < LoadBalancer
7
-
8
- include Contrib::OpenStackApiCore::ApiCommon
9
- include Contrib::RackspaceApiCore::ApiCommon
10
-
11
- # Save load balancer
12
- #
13
- # @param balancer [Models::LoadBalancer::Balancer]
14
- # @return [Models::LoadBalancer::Balancer]
15
- def balancer_save(balancer)
16
- raise NotImplementedError
17
- end
18
-
19
- # Reload the balancer data from the API
20
- #
21
- # @param balancer [Models::LoadBalancer::Balancer]
22
- # @return [Models::LoadBalancer::Balancer]
23
- def balancer_reload(balancer)
24
- if(balancer.persisted?)
25
- result = request(
26
- :path => "/loadbalancers/#{balancer.id}",
27
- :method => :get,
28
- :expects => 200
29
- )
30
- lb = result.get(:body, 'loadBalancer')
31
- balancer.load_data(
32
- :name => lb[:name],
33
- :name => lb[:name],
34
- :state => lb[:status] == 'ACTIVE' ? :active : :pending,
35
- :status => lb[:status],
36
- :created => lb.get(:created, :time),
37
- :updated => lb.get(:updated, :time),
38
- :public_addresses => lb['virtualIps'].map{|addr|
39
- if(addr[:type] == 'PUBLIC')
40
- Balancer::Address.new(
41
- :address => addr[:address],
42
- :version => addr['ipVersion'].sub('IPV', '').to_i
43
- )
44
- end
45
- }.compact,
46
- :private_addresses => lb['virtualIps'].map{|addr|
47
- if(addr[:type] != 'PUBLIC')
48
- Balancer::Address.new(
49
- :address => addr[:address],
50
- :version => addr['ipVersion'].sub('IPV', '').to_i
51
- )
52
- end
53
- }.compact,
54
- :servers => lb.fetch('nodes', []).map{|s|
55
- srv = self.api_for(:compute).servers.all.detect do |csrv|
56
- csrv.addresses.map(&:address).include?(s[:address])
57
- end
58
- if(srv)
59
- Balancer::Server.new(self.api_for(:compute), :id => srv.id)
60
- end
61
- }.compact
62
- ).valid_state
63
- else
64
- balancer
65
- end
66
- end
67
-
68
- # Delete load balancer
69
- #
70
- # @param balancer [Models::LoadBalancer::Balancer]
71
- # @return [TrueClass, FalseClass]
72
- def balancer_destroy(balancer)
73
- raise NotImplementedError
74
- end
75
-
76
- # Return all load balancers
77
- #
78
- # @param options [Hash] filter
79
- # @return [Array<Models::LoadBalancer::Balancer>]
80
- def balancer_all(options={})
81
- result = request(
82
- :path => '/loadbalancers',
83
- :method => :get,
84
- :expects => 200
85
- )
86
- result.fetch(:body, 'loadBalancers', []).map do |lb|
87
- Balancer.new(
88
- self,
89
- :id => lb[:id],
90
- :name => lb[:name],
91
- :state => lb[:status] == 'ACTIVE' ? :active : :pending,
92
- :status => lb[:status],
93
- :created => lb.get(:created, :time),
94
- :updated => lb.get(:updated, :time),
95
- :public_addresses => lb['virtualIps'].map{|addr|
96
- if(addr[:type] == 'PUBLIC')
97
- Balancer::Address.new(
98
- :address => addr[:address],
99
- :version => addr['ipVersion'].sub('IPV', '').to_i
100
- )
101
- end
102
- }.compact,
103
- :private_addresses => lb['virtualIps'].map{|addr|
104
- if(addr[:type] != 'PUBLIC')
105
- Balancer::Address.new(
106
- :address => addr[:address],
107
- :version => addr['ipVersion'].sub('IPV', '').to_i
108
- )
109
- end
110
- }.compact
111
- ).valid_state
112
- end
113
- end
114
-
115
- end
116
- end
117
- end
118
- end
@@ -1,25 +0,0 @@
1
- require 'miasma'
2
-
3
- module Miasma
4
- module Models
5
- class Orchestration
6
- class Rackspace < OpenStack
7
-
8
- include Contrib::RackspaceApiCore::ApiCommon
9
-
10
- # @return [Smash] external to internal resource mapping
11
- RESOURCE_MAPPING = Smash.new(
12
- 'Rackspace::Cloud::Server' => Smash.new(
13
- :api => :compute,
14
- :collection => :servers
15
- ),
16
- 'Rackspace::AutoScale::Group' => Smash.new(
17
- :api => :auto_scale,
18
- :collection => :groups
19
- )
20
- )
21
-
22
- end
23
- end
24
- end
25
- end