coral_core 0.2.30 → 0.4.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.
- checksums.yaml +7 -0
- data/Gemfile +2 -8
- data/Gemfile.lock +15 -86
- data/Rakefile +1 -3
- data/VERSION +1 -1
- data/coral_core.gemspec +12 -102
- metadata +18 -239
- data/lib/coral/command/shell.rb +0 -140
- data/lib/coral/machine/fog.rb +0 -215
- data/lib/coral/network/default.rb +0 -26
- data/lib/coral/node/rackspace.rb +0 -23
- data/lib/coral_core/config/collection.rb +0 -57
- data/lib/coral_core/config/options.rb +0 -70
- data/lib/coral_core/config/project.rb +0 -225
- data/lib/coral_core/config.rb +0 -329
- data/lib/coral_core/core.rb +0 -58
- data/lib/coral_core/event/puppet_event.rb +0 -98
- data/lib/coral_core/event/regexp_event.rb +0 -55
- data/lib/coral_core/event.rb +0 -170
- data/lib/coral_core/mixin/config_collection.rb +0 -52
- data/lib/coral_core/mixin/config_ops.rb +0 -51
- data/lib/coral_core/mixin/config_options.rb +0 -38
- data/lib/coral_core/mixin/lookup.rb +0 -211
- data/lib/coral_core/mixin/macro/object_interface.rb +0 -292
- data/lib/coral_core/mixin/macro/plugin_interface.rb +0 -277
- data/lib/coral_core/mixin/settings.rb +0 -46
- data/lib/coral_core/mixin/sub_config.rb +0 -208
- data/lib/coral_core/mod/hash.rb +0 -29
- data/lib/coral_core/mod/hiera_backend.rb +0 -63
- data/lib/coral_core/plugin/command.rb +0 -95
- data/lib/coral_core/plugin/machine.rb +0 -152
- data/lib/coral_core/plugin/network.rb +0 -24
- data/lib/coral_core/plugin/node.rb +0 -184
- data/lib/coral_core/plugin.rb +0 -261
- data/lib/coral_core/plugin_base.rb +0 -147
- data/lib/coral_core/repository.rb +0 -553
- data/lib/coral_core/resource.rb +0 -243
- data/lib/coral_core/template/environment.rb +0 -72
- data/lib/coral_core/template/json.rb +0 -13
- data/lib/coral_core/template/wrapper.rb +0 -13
- data/lib/coral_core/template/yaml.rb +0 -13
- data/lib/coral_core/template.rb +0 -92
- data/lib/coral_core/util/cli.rb +0 -293
- data/lib/coral_core/util/data.rb +0 -389
- data/lib/coral_core/util/disk.rb +0 -105
- data/lib/coral_core/util/git.rb +0 -40
- data/lib/coral_core/util/interface.rb +0 -190
- data/lib/coral_core/util/process.rb +0 -43
- data/lib/coral_core/util/shell.rb +0 -183
- data/lib/coral_core.rb +0 -375
- data/locales/en.yml +0 -8
- data/spec/coral_core/interface_spec.rb +0 -489
- data/spec/coral_mock_input.rb +0 -29
- data/spec/coral_test_kernel.rb +0 -22
- data/spec/spec_helper.rb +0 -15
data/lib/coral/command/shell.rb
DELETED
@@ -1,140 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Command
|
4
|
-
class Shell < Plugin::Command
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Command operations
|
8
|
-
|
9
|
-
def normalize
|
10
|
-
super
|
11
|
-
set(:command, executable(self))
|
12
|
-
end
|
13
|
-
|
14
|
-
#---
|
15
|
-
|
16
|
-
def build(components = {}, overrides = nil, override_key = false)
|
17
|
-
|
18
|
-
command = string(components[:command])
|
19
|
-
flags = array( components.has_key?(:flags) ? components[:flags] : [] )
|
20
|
-
data = string_map(hash( components.has_key?(:data) ? components[:data] : {} ))
|
21
|
-
args = array( components.has_key?(:args) ? components[:args] : [] )
|
22
|
-
subcommand = hash( components.has_key?(:subcommand) ? components[:subcommand] : {} )
|
23
|
-
|
24
|
-
override_key = command unless override_key
|
25
|
-
override_key = override_key.to_sym
|
26
|
-
|
27
|
-
command_string = command.dup
|
28
|
-
subcommand_string = ''
|
29
|
-
|
30
|
-
escape_characters = /[\'\"]+/
|
31
|
-
escape_replacement = '\"'
|
32
|
-
|
33
|
-
dash_pattern = /^([\-]+)/
|
34
|
-
assignment_pattern = /\=$/
|
35
|
-
|
36
|
-
# Flags
|
37
|
-
if overrides && overrides.has_key?(:flags)
|
38
|
-
if overrides[:flags].is_a?(Hash)
|
39
|
-
if overrides[:flags].has_key?(override_key)
|
40
|
-
flags = array(overrides[:flags][override_key])
|
41
|
-
end
|
42
|
-
else
|
43
|
-
flags = array(overrides[:flags])
|
44
|
-
end
|
45
|
-
end
|
46
|
-
flags.each do |flag|
|
47
|
-
flag = string(flag)
|
48
|
-
if ! flag.empty?
|
49
|
-
if flag.match(dash_pattern)
|
50
|
-
dashes = $1
|
51
|
-
else
|
52
|
-
dashes = ( flag.size == 1 ? '-' : '--' )
|
53
|
-
end
|
54
|
-
command_string << " #{dashes}#{flag}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Data
|
59
|
-
if overrides && overrides.has_key?(:data)
|
60
|
-
if overrides[:data].has_key?(override_key)
|
61
|
-
data = hash(overrides[:data][override_key])
|
62
|
-
else
|
63
|
-
override = true
|
64
|
-
overrides[:data].each do |key, value|
|
65
|
-
if ! value.is_a?(String)
|
66
|
-
override = false
|
67
|
-
end
|
68
|
-
end
|
69
|
-
data = hash(overrides[:data]) if override
|
70
|
-
end
|
71
|
-
end
|
72
|
-
data.each do |key, value|
|
73
|
-
key = string(key)
|
74
|
-
value = string(value).strip.sub(escape_characters, escape_replacement)
|
75
|
-
|
76
|
-
if key.match(dash_pattern)
|
77
|
-
dashes = $1
|
78
|
-
else
|
79
|
-
dashes = ( key.size == 1 ? '-' : '--' )
|
80
|
-
end
|
81
|
-
space = ( key.match(assignment_pattern) ? '' : ' ' )
|
82
|
-
|
83
|
-
command_string << " #{dashes}#{key}#{space}'#{value}'"
|
84
|
-
end
|
85
|
-
|
86
|
-
# Arguments
|
87
|
-
if overrides && overrides.has_key?(:args)
|
88
|
-
if overrides[:args].is_a?(Hash)
|
89
|
-
if overrides[:args].has_key?(override_key)
|
90
|
-
args = array(overrides[:args][override_key])
|
91
|
-
end
|
92
|
-
else
|
93
|
-
args = array(overrides[:args])
|
94
|
-
end
|
95
|
-
end
|
96
|
-
args.each do |arg|
|
97
|
-
arg = string(arg).sub(escape_characters, escape_replacement)
|
98
|
-
command_string << " '#{arg}'"
|
99
|
-
end
|
100
|
-
|
101
|
-
# Subcommand
|
102
|
-
subcommand_overrides = ( overrides ? overrides[:subcommand] : nil )
|
103
|
-
if subcommand && subcommand.is_a?(Hash) && ! subcommand.empty?
|
104
|
-
subcommand_string = build(subcommand, subcommand_overrides)
|
105
|
-
end
|
106
|
-
|
107
|
-
return (command_string + ' ' + subcommand_string).strip
|
108
|
-
end
|
109
|
-
|
110
|
-
#-----------------------------------------------------------------------------
|
111
|
-
|
112
|
-
def exec!(options = {}, overrides = nil)
|
113
|
-
config = Config.ensure(options)
|
114
|
-
|
115
|
-
config[:ui] = @ui
|
116
|
-
success = Util::Shell.exec!(build(properties, overrides), config) do |line|
|
117
|
-
block_given? ? yield(line) : true
|
118
|
-
end
|
119
|
-
return success
|
120
|
-
end
|
121
|
-
|
122
|
-
#-----------------------------------------------------------------------------
|
123
|
-
# Utilities
|
124
|
-
|
125
|
-
def executable(options)
|
126
|
-
config = Config.ensure(options)
|
127
|
-
|
128
|
-
if config.get(:coral, false)
|
129
|
-
return 'vagrant coral ' + config[:coral]
|
130
|
-
|
131
|
-
elsif config.get(:vagrant, false)
|
132
|
-
return 'vagrant ' + config[:vagrant]
|
133
|
-
|
134
|
-
elsif config.get(:command, false)
|
135
|
-
return config[:command]
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
data/lib/coral/machine/fog.rb
DELETED
@@ -1,215 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Machine
|
4
|
-
class Fog < Plugin::Machine
|
5
|
-
|
6
|
-
include Mixin::SubConfig
|
7
|
-
|
8
|
-
#-----------------------------------------------------------------------------
|
9
|
-
# Machine plugin interface
|
10
|
-
|
11
|
-
def normalize
|
12
|
-
super
|
13
|
-
set_connection
|
14
|
-
end
|
15
|
-
|
16
|
-
#-----------------------------------------------------------------------------
|
17
|
-
# Checks
|
18
|
-
|
19
|
-
def created?
|
20
|
-
return server && ! server.state != 'DELETED'
|
21
|
-
end
|
22
|
-
|
23
|
-
#---
|
24
|
-
|
25
|
-
def running?
|
26
|
-
return created? && server.ready?
|
27
|
-
end
|
28
|
-
|
29
|
-
#-----------------------------------------------------------------------------
|
30
|
-
# Property accessors / modifiers
|
31
|
-
|
32
|
-
def set_connection
|
33
|
-
set(:compute, Fog::Compute.new(_export))
|
34
|
-
end
|
35
|
-
protected :set_connection
|
36
|
-
|
37
|
-
#---
|
38
|
-
|
39
|
-
def compute
|
40
|
-
return get(:compute)
|
41
|
-
end
|
42
|
-
|
43
|
-
#---
|
44
|
-
|
45
|
-
def server
|
46
|
-
return get(:server)
|
47
|
-
end
|
48
|
-
|
49
|
-
#---
|
50
|
-
|
51
|
-
def name
|
52
|
-
return ( server ? server.id : '' )
|
53
|
-
end
|
54
|
-
|
55
|
-
#---
|
56
|
-
|
57
|
-
def name=id
|
58
|
-
set(:server, compute.servers.get(id)) if id
|
59
|
-
end
|
60
|
-
|
61
|
-
#---
|
62
|
-
|
63
|
-
def hostname
|
64
|
-
return server.name if server
|
65
|
-
return ''
|
66
|
-
end
|
67
|
-
|
68
|
-
#---
|
69
|
-
|
70
|
-
def state
|
71
|
-
return server.state if server
|
72
|
-
return nil
|
73
|
-
end
|
74
|
-
|
75
|
-
#---
|
76
|
-
|
77
|
-
def public_ip
|
78
|
-
return server.public_ip_address if server
|
79
|
-
return nil
|
80
|
-
end
|
81
|
-
|
82
|
-
#---
|
83
|
-
|
84
|
-
def private_ip
|
85
|
-
return server.private_ip_address if server
|
86
|
-
return nil
|
87
|
-
end
|
88
|
-
|
89
|
-
#---
|
90
|
-
|
91
|
-
def flavors
|
92
|
-
return compute.flavors if compute
|
93
|
-
return nil
|
94
|
-
end
|
95
|
-
|
96
|
-
#---
|
97
|
-
|
98
|
-
def flavor
|
99
|
-
return server.flavor if server
|
100
|
-
return nil
|
101
|
-
end
|
102
|
-
|
103
|
-
#---
|
104
|
-
|
105
|
-
def images
|
106
|
-
return compute.images if compute
|
107
|
-
return nil
|
108
|
-
end
|
109
|
-
|
110
|
-
#---
|
111
|
-
|
112
|
-
def image
|
113
|
-
return server.image if server
|
114
|
-
return nil
|
115
|
-
end
|
116
|
-
|
117
|
-
#-----------------------------------------------------------------------------
|
118
|
-
# Management
|
119
|
-
|
120
|
-
def create(options = {})
|
121
|
-
success = super(options)
|
122
|
-
if success && ! created?
|
123
|
-
set(:server, compute.servers.bootstrap(options))
|
124
|
-
end
|
125
|
-
return success
|
126
|
-
end
|
127
|
-
|
128
|
-
#---
|
129
|
-
|
130
|
-
def start(options = {})
|
131
|
-
success = super(options)
|
132
|
-
if success
|
133
|
-
unless created?
|
134
|
-
return create(options)
|
135
|
-
end
|
136
|
-
unless running?
|
137
|
-
server_info = compute.servers.create(options)
|
138
|
-
|
139
|
-
Fog.wait_for do
|
140
|
-
compute.servers.get(server_info.id).ready? ? true : false
|
141
|
-
end
|
142
|
-
@server = compute.servers.get(server_info.id)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
return success
|
146
|
-
end
|
147
|
-
|
148
|
-
#---
|
149
|
-
|
150
|
-
def stop(options = {})
|
151
|
-
success = super(options)
|
152
|
-
if success && running?
|
153
|
-
if image_id = create_image(name)
|
154
|
-
|
155
|
-
Fog.wait_for do
|
156
|
-
compute.images.get(image_id).ready? ? true : false
|
157
|
-
end
|
158
|
-
|
159
|
-
server.destroy
|
160
|
-
return image_id
|
161
|
-
end
|
162
|
-
end
|
163
|
-
return success
|
164
|
-
end
|
165
|
-
|
166
|
-
#---
|
167
|
-
|
168
|
-
def reload(options = {})
|
169
|
-
success = super(options)
|
170
|
-
if success && created?
|
171
|
-
# Don't quite know what this should do yet??
|
172
|
-
return server.reboot(options)
|
173
|
-
end
|
174
|
-
return success
|
175
|
-
end
|
176
|
-
|
177
|
-
#---
|
178
|
-
|
179
|
-
def destroy(options = {})
|
180
|
-
success = super(options)
|
181
|
-
if success && created?
|
182
|
-
return server.destroy(options)
|
183
|
-
end
|
184
|
-
return success
|
185
|
-
end
|
186
|
-
|
187
|
-
#---
|
188
|
-
|
189
|
-
def exec(options = {})
|
190
|
-
success = super(options)
|
191
|
-
if success && running?
|
192
|
-
if commands = options.delete(:commands)
|
193
|
-
return server.ssh(commands, options)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
return success
|
197
|
-
end
|
198
|
-
|
199
|
-
#---
|
200
|
-
|
201
|
-
def create_image(name, options = {})
|
202
|
-
success = super(options)
|
203
|
-
if success && created?
|
204
|
-
image = server.create_image(name, options)
|
205
|
-
return ( image ? image.id : false )
|
206
|
-
end
|
207
|
-
return success
|
208
|
-
end
|
209
|
-
|
210
|
-
#-----------------------------------------------------------------------------
|
211
|
-
# Utilities
|
212
|
-
|
213
|
-
end
|
214
|
-
end
|
215
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Network
|
4
|
-
class Default < Plugin::Network
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Cloud plugin interface
|
8
|
-
|
9
|
-
def normalize
|
10
|
-
super
|
11
|
-
end
|
12
|
-
|
13
|
-
#-----------------------------------------------------------------------------
|
14
|
-
# Checks
|
15
|
-
|
16
|
-
|
17
|
-
#-----------------------------------------------------------------------------
|
18
|
-
# Property accessors / modifiers
|
19
|
-
|
20
|
-
|
21
|
-
#-----------------------------------------------------------------------------
|
22
|
-
# Coral cloud operations
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/coral/node/rackspace.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
module Node
|
4
|
-
class Rackspace < Plugin::Node
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Node plugin interface
|
8
|
-
|
9
|
-
def normalize
|
10
|
-
#super
|
11
|
-
dbg('hello from rackspace node')
|
12
|
-
end
|
13
|
-
|
14
|
-
#-----------------------------------------------------------------------------
|
15
|
-
# Checks
|
16
|
-
|
17
|
-
|
18
|
-
#-----------------------------------------------------------------------------
|
19
|
-
# Property accessors / modifiers
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
|
2
|
-
module Coral
|
3
|
-
class Config
|
4
|
-
class Collection
|
5
|
-
|
6
|
-
#-----------------------------------------------------------------------------
|
7
|
-
# Property accessor / modifiers
|
8
|
-
|
9
|
-
@@properties = {}
|
10
|
-
|
11
|
-
#---
|
12
|
-
|
13
|
-
def self.all
|
14
|
-
return @@properties
|
15
|
-
end
|
16
|
-
|
17
|
-
#---
|
18
|
-
|
19
|
-
def self.get(name)
|
20
|
-
return @@properties[name.to_sym]
|
21
|
-
end
|
22
|
-
|
23
|
-
#---
|
24
|
-
|
25
|
-
def self.set(name, value)
|
26
|
-
@@properties[name.to_sym] = value
|
27
|
-
end
|
28
|
-
|
29
|
-
#---
|
30
|
-
|
31
|
-
def self.delete(name)
|
32
|
-
@@properties.delete(name.to_sym)
|
33
|
-
end
|
34
|
-
|
35
|
-
#---
|
36
|
-
|
37
|
-
def self.clear
|
38
|
-
@@properties = {}
|
39
|
-
end
|
40
|
-
|
41
|
-
#---
|
42
|
-
|
43
|
-
def self.save
|
44
|
-
log_options = Options.get(:coral_log)
|
45
|
-
|
46
|
-
unless Util::Data.empty?(log_options[:config_log])
|
47
|
-
config_log = log_options[:config_log]
|
48
|
-
|
49
|
-
if log_options[:config_store]
|
50
|
-
Util::Disk.write(config_log, MultiJson.dump(@@properties, :pretty => true))
|
51
|
-
Util::Disk.close(config_log)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|