mystro-common 0.1.11 → 0.2.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.
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +42 -4
- data/Gemfile +7 -1
- data/Rakefile +137 -1
- data/lib/{mystro/ext/fog → fog/ext}/balancer.rb +0 -0
- data/lib/fog/ext/dynect/dns.rb +140 -0
- data/lib/fog/ext/dynect/models/dns/record.rb +66 -0
- data/lib/fog/ext/dynect/models/dns/records.rb +87 -0
- data/lib/fog/ext/dynect/models/dns/zone.rb +60 -0
- data/lib/fog/ext/dynect/models/dns/zones.rb +29 -0
- data/lib/fog/ext/dynect/requests/dns/delete_record.rb +56 -0
- data/lib/fog/ext/dynect/requests/dns/delete_zone.rb +42 -0
- data/lib/fog/ext/dynect/requests/dns/get_all_records.rb +56 -0
- data/lib/fog/ext/dynect/requests/dns/get_node_list.rb +56 -0
- data/lib/fog/ext/dynect/requests/dns/get_record.rb +85 -0
- data/lib/fog/ext/dynect/requests/dns/get_zone.rb +58 -0
- data/lib/fog/ext/dynect/requests/dns/post_record.rb +72 -0
- data/lib/fog/ext/dynect/requests/dns/post_session.rb +44 -0
- data/lib/fog/ext/dynect/requests/dns/post_zone.rb +71 -0
- data/lib/fog/ext/dynect/requests/dns/put_zone.rb +76 -0
- data/lib/fog/ext/dynect.rb +26 -0
- data/lib/mystro/cloud/action.rb +22 -0
- data/lib/mystro/cloud/connect/aws/balancer.rb +55 -0
- data/lib/mystro/cloud/connect/aws/compute.rb +151 -0
- data/lib/mystro/cloud/connect/aws/listener.rb +36 -0
- data/lib/mystro/cloud/connect/aws/record.rb +58 -0
- data/lib/mystro/cloud/connect/aws/zone.rb +35 -0
- data/lib/mystro/cloud/connect/aws.rb +14 -0
- data/lib/mystro/cloud/connect/dynect/record.rb +72 -0
- data/lib/mystro/cloud/connect/dynect/zone.rb +35 -0
- data/lib/mystro/cloud/connect/dynect.rb +17 -0
- data/lib/mystro/cloud/connect/fog.rb +66 -0
- data/lib/mystro/cloud/connect.rb +64 -0
- data/lib/mystro/cloud/model/balancer.rb +15 -0
- data/lib/mystro/cloud/model/compute.rb +27 -0
- data/lib/mystro/cloud/model/listener.rb +30 -0
- data/lib/mystro/cloud/model/record.rb +20 -0
- data/lib/mystro/cloud/model/volume.rb +12 -0
- data/lib/mystro/cloud/model/zone.rb +9 -0
- data/lib/mystro/cloud/model.rb +183 -0
- data/lib/mystro/cloud.rb +32 -0
- data/lib/mystro/common/version.rb +4 -3
- data/lib/mystro/dsl/balancer.rb +18 -0
- data/lib/mystro/dsl/compute.rb +57 -0
- data/lib/mystro/dsl/health.rb +7 -0
- data/lib/mystro/dsl/listener.rb +5 -0
- data/lib/mystro/dsl/oldtemplate.rb +281 -0
- data/lib/mystro/dsl/template.rb +12 -278
- data/lib/mystro/dsl/template_file.rb +18 -0
- data/lib/mystro/dsl/volume.rb +8 -0
- data/lib/mystro/dsl.rb +40 -0
- data/lib/mystro/organization.rb +83 -0
- data/lib/mystro/plugin.rb +4 -3
- data/lib/mystro/provider.rb +40 -0
- data/lib/mystro/userdata.rb +1 -1
- data/lib/mystro-common.rb +32 -31
- data/mystro-common.gemspec +2 -1
- data/spec/cloud/aws/balancer_spec.rb +10 -0
- data/spec/cloud/aws/compute_spec.rb +10 -0
- data/spec/cloud/aws/record_spec.rb +10 -0
- data/spec/cloud/dynect/record_spec.rb +10 -0
- data/spec/model/compute_spec.rb +36 -0
- data/spec/model/model_spec.rb +89 -0
- data/spec/model/record_spec.rb +27 -0
- data/spec/spec_helper.rb +36 -0
- data/spec/support/balancer.rb +49 -0
- data/spec/support/compute.rb +65 -0
- data/spec/support/record.rb +45 -0
- data/test/config.yml +71 -0
- metadata +99 -14
- data/lib/mystro/account.rb +0 -105
- data/lib/mystro/connect/balancer.rb +0 -91
- data/lib/mystro/connect/compute.rb +0 -100
- data/lib/mystro/connect/dns.rb +0 -51
- data/lib/mystro/connect/environment.rb +0 -31
- data/lib/mystro/connect.rb +0 -124
- data/lib/mystro/job.rb +0 -0
- data/lib/mystro/model.rb +0 -71
data/lib/mystro/dsl/template.rb
CHANGED
@@ -1,281 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
elsif File.exists?("#{dir}/#{name_or_file}.rb")
|
13
|
-
template_name = name.to_sym
|
14
|
-
template_file = "#{dir}/#{name}.rb"
|
15
|
-
end
|
16
|
-
raise "could not load template #{template_name} (#{template_file})" unless template_file && File.file?(template_file)
|
17
|
-
#raise "template already loaded #{template_name}" if @templates[template_name]
|
18
|
-
@templates[template_name] ||= begin
|
19
|
-
t = Mystro::DSL::Template::DSL.new(template_name)
|
20
|
-
t.instance_eval(File.read(template_file), "Template(#{template_file})")
|
21
|
-
@templates[template_name] = t
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def load_yaml_file(path)
|
26
|
-
file = File.expand_path(path)
|
27
|
-
raise "Configuration not found: #{path} (#{file})" unless File.exists?(file)
|
28
|
-
yaml = YAML.load_file(file)
|
29
|
-
yaml = yaml[yaml.keys.first] if yaml.keys.count == 1
|
30
|
-
|
31
|
-
yaml
|
32
|
-
end
|
33
|
-
|
34
|
-
def list
|
35
|
-
Dir["#{dir}/*"].inject({}) do |h, e|
|
36
|
-
f = e.gsub("#{dir}/", "")
|
37
|
-
f = File.basename(f, ".yml")
|
38
|
-
h[f.to_sym] = e
|
39
|
-
h
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def dir
|
45
|
-
"#{Mystro.directory}/templates"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class DSL
|
50
|
-
attr_reader :balancers, :servers
|
51
|
-
|
52
|
-
def initialize(name)
|
53
|
-
@name = name.to_sym
|
54
|
-
@balancers = []
|
55
|
-
@servers = []
|
56
|
-
end
|
57
|
-
|
58
|
-
def template(&block)
|
59
|
-
instance_eval &block
|
60
|
-
end
|
61
|
-
|
62
|
-
def balancer(name, &block)
|
63
|
-
balancer = Balancer.new(name)
|
64
|
-
balancer.instance_eval &block
|
65
|
-
@balancers << balancer
|
66
|
-
end
|
67
|
-
|
68
|
-
def server(name, &block)
|
69
|
-
server = Server.new(name)
|
70
|
-
server.instance_eval &block
|
71
|
-
@servers << server
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
class Base
|
76
|
-
def attr(name, value=nil)
|
77
|
-
@attrs[name] = value unless value.nil?
|
78
|
-
@attrs[name]
|
79
|
-
end
|
80
|
-
|
81
|
-
def list_attr(name, value=nil)
|
82
|
-
@attrs[name] ||= []
|
83
|
-
unless value.nil?
|
84
|
-
if value.kind_of?(Array)
|
85
|
-
@attrs[name] += value
|
86
|
-
else
|
87
|
-
@attrs[name] << value
|
88
|
-
end
|
89
|
-
end
|
90
|
-
@attrs[name]
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
class Server < Base
|
95
|
-
def initialize(name)
|
96
|
-
@attrs = {
|
97
|
-
:name => name.to_sym,
|
98
|
-
:roles => [],
|
99
|
-
:groups => [],
|
100
|
-
:count => 1,
|
101
|
-
:image => nil,
|
102
|
-
:flavor => nil,
|
103
|
-
:keypair => nil,
|
104
|
-
:userdata => "default",
|
105
|
-
:dnsnames => [],
|
106
|
-
}
|
107
|
-
end
|
108
|
-
|
109
|
-
def name
|
110
|
-
@attrs[:name]
|
111
|
-
end
|
112
|
-
|
113
|
-
def roles
|
114
|
-
@attrs[:roles]
|
115
|
-
end
|
116
|
-
|
117
|
-
def groups
|
118
|
-
@attrs[:groups]
|
119
|
-
end
|
120
|
-
|
121
|
-
def dnsnames
|
122
|
-
@attrs[:dnsnames]
|
123
|
-
end
|
124
|
-
|
125
|
-
def role(r)
|
126
|
-
list_attr(:roles, r)
|
127
|
-
end
|
128
|
-
|
129
|
-
def count(c=nil)
|
130
|
-
attr(:count, c)
|
131
|
-
end
|
132
|
-
|
133
|
-
def image(i=nil)
|
134
|
-
attr(:image, i)
|
135
|
-
end
|
136
|
-
|
137
|
-
def flavor(f=nil)
|
138
|
-
attr(:flavor, f)
|
139
|
-
end
|
140
|
-
|
141
|
-
def group(g)
|
142
|
-
list_attr(:groups, g)
|
143
|
-
end
|
144
|
-
|
145
|
-
def keypair(k=nil)
|
146
|
-
attr(:keypair, k)
|
147
|
-
end
|
148
|
-
|
149
|
-
def userdata(u=nil)
|
150
|
-
attr(:userdata, u)
|
151
|
-
end
|
152
|
-
|
153
|
-
def balancer(b=nil, &block)
|
154
|
-
if block_given?
|
155
|
-
raise "balancer block must specify name" unless b
|
156
|
-
Mystro::DSL::Template::DSL.balancer(b, &block)
|
157
|
-
end
|
158
|
-
attr(:balancer, b)
|
159
|
-
end
|
160
|
-
|
161
|
-
def dns(name)
|
162
|
-
n = name.gsub(Mystro.get_config(:dns_zone), "")
|
163
|
-
list_attr(:dnsnames, n)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
class Balancer
|
168
|
-
attr_reader :name, :sticky, :primary, :sticky_type, :sticky_arg
|
169
|
-
|
170
|
-
def initialize(name)
|
171
|
-
@listeners = []
|
172
|
-
@name = name.to_sym
|
173
|
-
@primary = false
|
174
|
-
@sticky = false
|
175
|
-
end
|
176
|
-
|
177
|
-
def primary(enable = nil)
|
178
|
-
enable.nil? ? @primary : @primary = enable
|
179
|
-
end
|
180
|
-
|
181
|
-
def listener(&block)
|
182
|
-
listener = Listener.new
|
183
|
-
listener.instance_eval &block
|
184
|
-
@listeners << listener
|
185
|
-
end
|
186
|
-
|
187
|
-
def health(&block)
|
188
|
-
healthcheck = HealthCheck.new
|
189
|
-
healthcheck.instance_eval &block
|
190
|
-
@healthcheck = healthcheck
|
191
|
-
end
|
192
|
-
|
193
|
-
def listeners
|
194
|
-
@listeners.map { |e| e.spec }
|
195
|
-
end
|
196
|
-
|
197
|
-
def sticky(type=nil, expires_or_cookie=nil)
|
198
|
-
if type && expires_or_cookie
|
199
|
-
@sticky = true
|
200
|
-
@sticky_type = type
|
201
|
-
@sticky_arg = expires_or_cookie
|
202
|
-
end
|
203
|
-
@sticky
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
class Listener
|
208
|
-
def initialize
|
209
|
-
@from_proto = nil
|
210
|
-
@from_port = nil
|
211
|
-
@to_proto = nil
|
212
|
-
@to_port = nil
|
213
|
-
@cert = nil
|
214
|
-
end
|
215
|
-
|
216
|
-
def from(proto, port)
|
217
|
-
@from_proto = proto
|
218
|
-
@from_port = port
|
219
|
-
end
|
220
|
-
|
221
|
-
def to(proto, port)
|
222
|
-
@to_proto = proto
|
223
|
-
@to_port = port
|
224
|
-
end
|
225
|
-
|
226
|
-
def cert(cert)
|
227
|
-
@cert = cert
|
228
|
-
end
|
229
|
-
|
230
|
-
def spec
|
231
|
-
{
|
232
|
-
:from => "#@from_proto:#@from_port",
|
233
|
-
:to => "#@to_proto:#@to_port",
|
234
|
-
:cert => @cert,
|
235
|
-
}
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
class HealthCheck
|
240
|
-
def initialize
|
241
|
-
@healthy = 10
|
242
|
-
@unhealthy = 2
|
243
|
-
@interval = 30
|
244
|
-
@target = nil
|
245
|
-
@timeout = 5
|
246
|
-
end
|
247
|
-
|
248
|
-
def healthy(v)
|
249
|
-
@healthy = v
|
250
|
-
end
|
251
|
-
|
252
|
-
def unhealthy(v)
|
253
|
-
@unhealthy = v
|
254
|
-
end
|
255
|
-
|
256
|
-
def interval(v)
|
257
|
-
@interval = v
|
258
|
-
end
|
259
|
-
|
260
|
-
def target(v)
|
261
|
-
@target = v
|
262
|
-
end
|
263
|
-
|
264
|
-
def timeout(v)
|
265
|
-
@timeout = v
|
266
|
-
end
|
267
|
-
|
268
|
-
def spec
|
269
|
-
raise "target not specified for health check" unless @target
|
270
|
-
{
|
271
|
-
healthy: @healthy,
|
272
|
-
unhealthy: @unhealthy,
|
273
|
-
interval: @interval,
|
274
|
-
target: @target,
|
275
|
-
timeout: @timeout,
|
276
|
-
}
|
277
|
-
end
|
278
|
-
end
|
1
|
+
class Mystro::Dsl::Template < Mystro::Dsl::Base
|
2
|
+
has_many :computes, named: true
|
3
|
+
has_many :balancers, named: true
|
4
|
+
|
5
|
+
def actions
|
6
|
+
out = []
|
7
|
+
@data[:compute] && @data[:compute].each do |c|
|
8
|
+
out += c.actions
|
9
|
+
end
|
10
|
+
@data[:balancer] && @data[:balancer].each do |b|
|
11
|
+
out += b.actions
|
279
12
|
end
|
13
|
+
out
|
280
14
|
end
|
281
15
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Mystro::Dsl::TemplateFile < Mystro::Dsl::Base
|
2
|
+
has_one :template
|
3
|
+
def actions
|
4
|
+
@data[:template].actions
|
5
|
+
end
|
6
|
+
|
7
|
+
def compute(name)
|
8
|
+
n = name.to_sym
|
9
|
+
dsl = computes.detect {|e| e[:name] == n}
|
10
|
+
raise "no template entry for compute #{n}" unless dsl
|
11
|
+
act = dsl.actions.first
|
12
|
+
act.to_model
|
13
|
+
end
|
14
|
+
|
15
|
+
def computes
|
16
|
+
@data[:template] && @data[:template][:compute]
|
17
|
+
end
|
18
|
+
end
|
data/lib/mystro/dsl.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'damsel/data'
|
2
|
+
|
3
|
+
module Mystro
|
4
|
+
module Dsl
|
5
|
+
class Base < Damsel::Data
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def get(name)
|
11
|
+
n = name.to_sym
|
12
|
+
raise "no template named #{name}" unless @templates[n]
|
13
|
+
@templates[n]
|
14
|
+
end
|
15
|
+
|
16
|
+
def load(file)
|
17
|
+
@templates ||= {}
|
18
|
+
file = File.expand_path(file)
|
19
|
+
name = File.basename(file).gsub(/\.rb$/, "").to_sym
|
20
|
+
raise "file: '#{file}' does not exist" unless File.exist?(file)
|
21
|
+
@templates[name] ||= begin
|
22
|
+
t = Mystro::Dsl::TemplateFile.new(file)
|
23
|
+
t.instance_eval(File.read(file), "#{file}:[TemplateFile]")
|
24
|
+
t
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def actions(name)
|
29
|
+
tf = get(name)
|
30
|
+
t = tf[:template]
|
31
|
+
t.actions
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Dir["#{File.dirname(__FILE__)}/dsl/*rb"].each do |file|
|
38
|
+
#puts "dsl: #{file}"
|
39
|
+
require "#{file.gsub(/\.rb/, '')}"
|
40
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'mystro/cloud'
|
2
|
+
|
3
|
+
module Mystro
|
4
|
+
class Organization
|
5
|
+
class << self
|
6
|
+
attr_reader :selected
|
7
|
+
|
8
|
+
def [](name)
|
9
|
+
get(name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def get(name)
|
13
|
+
@list[name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def read
|
17
|
+
dir = Mystro.directory
|
18
|
+
@list = {}
|
19
|
+
|
20
|
+
Dir["#{dir}/organizations/*.y*ml"].each do |file|
|
21
|
+
name = file.gsub(/#{dir}\/organizations\//, "").gsub(/\.(\w+?)$/, "")
|
22
|
+
Mystro::Log.debug "loading organization '#{name}' '#{file}'"
|
23
|
+
@list[name] = self.new(name, file)
|
24
|
+
end
|
25
|
+
|
26
|
+
@selected = default
|
27
|
+
end
|
28
|
+
|
29
|
+
def default
|
30
|
+
return ENV['MYSTRO_ORGANIZATION'] if ENV['MYSTRO_ORGANIZATION']
|
31
|
+
return Mystro.config.default_organization if Mystro.config.default_organization?
|
32
|
+
return "default" if @list.keys.include?("default")
|
33
|
+
@list.keys.first
|
34
|
+
end
|
35
|
+
|
36
|
+
def select(name)
|
37
|
+
@selected = name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_reader :data
|
42
|
+
attr_reader :file
|
43
|
+
attr_reader :name
|
44
|
+
|
45
|
+
def initialize(name, file)
|
46
|
+
cfg = Mystro.config.to_hash
|
47
|
+
organization = File.exists?(file) ? YAML.load_file(file) : {}
|
48
|
+
@name = name
|
49
|
+
@file = file
|
50
|
+
@data = Hashie::Mash.new(cfg.deep_merge(organization))
|
51
|
+
@data.name = name
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_hash
|
55
|
+
@data.to_hash
|
56
|
+
end
|
57
|
+
|
58
|
+
def compute
|
59
|
+
@compute ||= connect(:compute)
|
60
|
+
end
|
61
|
+
|
62
|
+
def balancer
|
63
|
+
@balancer ||= connect(:balancer)
|
64
|
+
end
|
65
|
+
|
66
|
+
def record
|
67
|
+
@dns ||= connect(:record)
|
68
|
+
end
|
69
|
+
|
70
|
+
protected
|
71
|
+
|
72
|
+
def connect(type)
|
73
|
+
raise "#{type} not configured: see mystro/config.yml or mystro/organization/#{@name}.yml" unless @data[type]
|
74
|
+
raise "#{type} provider not configured: see mystro/config.yml or mystro/organization/#{@name}.yml" unless @data[type].provider!.name
|
75
|
+
return false if @data[type].disabled? && @data[type].disabled == true
|
76
|
+
options = @data[type].provider.to_hash.symbolize_keys
|
77
|
+
config = @data[type].config.to_hash.symbolize_keys if @data[type].config
|
78
|
+
pn = options.delete(:name)
|
79
|
+
raise "provider not set" unless pn
|
80
|
+
Mystro::Cloud.new(pn, type, {options: options, config: config})
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/mystro/plugin.rb
CHANGED
@@ -24,7 +24,8 @@ module Mystro
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def load(plugins={ })
|
27
|
-
plugins.
|
27
|
+
list = plugins.reject {|k, v| k == 'disabled'}
|
28
|
+
list.each do |plugin, data|
|
28
29
|
begin
|
29
30
|
f = "#{Mystro.directory}/plugins/#{plugin}"
|
30
31
|
Mystro::Log.debug "loading plugin: #{plugin} #{f}"
|
@@ -37,7 +38,7 @@ module Mystro
|
|
37
38
|
|
38
39
|
def disabled?(name)
|
39
40
|
Mystro::Log.debug "disabled? #{name}"
|
40
|
-
Mystro.config.disabled && Mystro.config.disabled[name]
|
41
|
+
Mystro.config.plugins && Mystro.config.plugins.disabled && Mystro.config.plugins.disabled[name]
|
41
42
|
end
|
42
43
|
|
43
44
|
def register(key, opts={})
|
@@ -95,7 +96,7 @@ module Mystro
|
|
95
96
|
|
96
97
|
def config_for(klass)
|
97
98
|
name = klass.name.split('::').last.downcase.to_sym
|
98
|
-
return Mystro.
|
99
|
+
return Mystro.organization.plugins[name] if Mystro.organization.plugins && Mystro.organization.plugins[name]
|
99
100
|
{ }
|
100
101
|
end
|
101
102
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Mystro
|
2
|
+
class Provider
|
3
|
+
class << self
|
4
|
+
def [](name)
|
5
|
+
get(name)
|
6
|
+
end
|
7
|
+
|
8
|
+
def get(name)
|
9
|
+
@list ||= {}
|
10
|
+
@list[name]
|
11
|
+
end
|
12
|
+
|
13
|
+
def read
|
14
|
+
dir = Mystro.directory
|
15
|
+
@list ||= { }
|
16
|
+
|
17
|
+
Dir["#{dir}/providers/*.y*ml"].each do |file|
|
18
|
+
name = file.gsub(/#{dir}\/providers\//, "").gsub(/\.(\w+?)$/, "")
|
19
|
+
Mystro::Log.debug "loading provider '#{name}' '#{file}'"
|
20
|
+
@list[name] = self.new(name, file)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :data
|
26
|
+
attr_reader :file
|
27
|
+
attr_reader :name
|
28
|
+
|
29
|
+
def initialize(name, file)
|
30
|
+
yaml = File.exists?(file) ? YAML.load_file(file) : { }
|
31
|
+
@name = name
|
32
|
+
@file = file
|
33
|
+
@data = Hashie::Mash.new(yaml)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_hash
|
37
|
+
@data.to_hash.symbolize_keys
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/mystro/userdata.rb
CHANGED
data/lib/mystro-common.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require "hashie/mash"
|
5
|
-
require "active_support/all"
|
1
|
+
require 'mystro/common/version'
|
2
|
+
require 'hashie/mash'
|
3
|
+
require 'active_support/all'
|
6
4
|
|
7
5
|
module Mystro
|
8
6
|
class << self
|
@@ -10,58 +8,61 @@ module Mystro
|
|
10
8
|
Mystro::Config.instance.data
|
11
9
|
end
|
12
10
|
|
13
|
-
def
|
14
|
-
raise "mystro
|
15
|
-
|
11
|
+
def organization
|
12
|
+
raise "mystro organization unset! default organization ('#{config.default_organization}') doesn't exist?" unless current_organization
|
13
|
+
current_organization.data
|
16
14
|
end
|
17
15
|
|
18
|
-
def
|
19
|
-
Mystro::
|
16
|
+
def current_organization
|
17
|
+
Mystro::Organization.get(selected)
|
20
18
|
end
|
21
19
|
|
22
20
|
def directory
|
23
21
|
@dir ||= begin
|
24
|
-
d =
|
25
|
-
if ENV[
|
26
|
-
d = ENV[
|
27
|
-
elsif File.exists?(
|
28
|
-
d =
|
29
|
-
elsif File.exists?(
|
30
|
-
d =
|
22
|
+
d = '~/.mystro'
|
23
|
+
if ENV['MYSTRO_CONFIG']
|
24
|
+
d = ENV['MYSTRO_CONFIG']
|
25
|
+
elsif File.exists?('./config/mystro')
|
26
|
+
d = './config/mystro'
|
27
|
+
elsif File.exists?('./.mystro')
|
28
|
+
d = './.mystro'
|
31
29
|
end
|
32
30
|
File.expand_path(d)
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
34
|
def selected
|
37
|
-
Mystro::
|
35
|
+
Mystro::Organization.selected
|
38
36
|
end
|
39
37
|
|
40
38
|
def compute
|
41
|
-
|
39
|
+
current_organization.compute
|
42
40
|
end
|
43
41
|
|
44
|
-
def
|
45
|
-
|
42
|
+
def record
|
43
|
+
current_organization.record
|
46
44
|
end
|
47
45
|
|
48
46
|
def balancer
|
49
|
-
|
47
|
+
current_organization.balancer
|
50
48
|
end
|
51
49
|
|
52
50
|
def environment
|
53
|
-
|
51
|
+
current_organization.environment
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
|
-
require
|
59
|
-
require
|
60
|
-
require
|
61
|
-
require
|
62
|
-
require
|
63
|
-
require
|
64
|
-
require
|
56
|
+
require 'mystro/config'
|
57
|
+
require 'mystro/log'
|
58
|
+
require 'mystro/cloud'
|
59
|
+
require 'mystro/provider'
|
60
|
+
require 'mystro/organization'
|
61
|
+
require 'mystro/dsl/oldtemplate'
|
62
|
+
require 'mystro/plugin'
|
63
|
+
require 'mystro/userdata'
|
64
|
+
require 'mystro/dsl'
|
65
65
|
|
66
66
|
Mystro::Config.instance
|
67
|
-
Mystro::
|
67
|
+
Mystro::Provider.read
|
68
|
+
Mystro::Organization.read
|
data/mystro-common.gemspec
CHANGED
@@ -17,10 +17,11 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency "fog", "~> 1.
|
20
|
+
gem.add_dependency "fog", "~> 1.15.0" # talk to cloud
|
21
21
|
gem.add_dependency "yell", "~> 1.2.0" # logging
|
22
22
|
gem.add_dependency "hashie" # better data objects
|
23
23
|
gem.add_dependency "activesupport", "3.2.14" # active support
|
24
24
|
gem.add_dependency "ipaddress" # ip address library
|
25
25
|
gem.add_dependency "erubis" # userdata templates
|
26
|
+
gem.add_dependency "damsel", "~> 0.1.0" # dsl
|
26
27
|
end
|