corl 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/bootstrap/os/ubuntu/06_puppet.sh +1 -1
- data/corl.gemspec +171 -3
- data/lib/CORL/builder/identity.rb +6 -3
- data/lib/CORL/builder/package.rb +3 -3
- data/lib/CORL/configuration/file.rb +21 -7
- data/lib/CORL/machine/vagrant.rb +3 -3
- data/lib/CORL/node/vagrant.rb +2 -5
- data/lib/CORL/provisioner/puppetnode.rb +8 -8
- data/lib/core/facade.rb +7 -3
- data/lib/core/mixin/action/keypair.rb +3 -3
- data/lib/core/mixin/action/registration.rb +31 -0
- data/lib/core/mixin/lookup.rb +50 -6
- data/lib/core/mixin/machine/ssh.rb +4 -4
- data/lib/core/plugin/cloud_action.rb +8 -1
- data/lib/core/plugin/configuration.rb +6 -7
- data/lib/core/plugin/fog_node.rb +7 -0
- data/lib/core/plugin/network.rb +31 -0
- data/lib/core/plugin/node.rb +182 -117
- data/lib/core/vagrant/provisioner/provisioner.rb +1 -1
- data/lib/nucleon/action/cloud/config.rb +259 -0
- data/lib/nucleon/action/cloud/images.rb +1 -1
- data/lib/nucleon/action/cloud/inspect.rb +11 -2
- data/lib/nucleon/action/cloud/machines.rb +1 -1
- data/lib/nucleon/action/cloud/regions.rb +1 -1
- data/lib/nucleon/action/cloud/settings.rb +185 -0
- data/lib/nucleon/action/node/IP.rb +1 -1
- data/lib/nucleon/action/node/bootstrap.rb +1 -1
- data/lib/nucleon/action/node/cache.rb +133 -0
- data/lib/nucleon/action/node/fact.rb +119 -0
- data/lib/nucleon/action/node/facts.rb +16 -16
- data/lib/nucleon/action/node/group.rb +115 -0
- data/lib/nucleon/action/node/groups.rb +33 -0
- data/lib/nucleon/action/node/identity.rb +75 -0
- data/lib/nucleon/action/node/lookup.rb +20 -7
- data/lib/nucleon/action/node/seed.rb +6 -6
- data/lib/nucleon/action/node/status.rb +76 -0
- data/lib/nucleon/action/plugin/create.rb +169 -0
- data/lib/nucleon/action/plugin/list.rb +69 -0
- data/lib/nucleon/action/plugin/template/nucleon.action.erb +56 -0
- data/lib/nucleon/action/plugins.rb +14 -0
- data/locales/en.yml +3 -0
- data/rdoc/site/0.5.0/CORL/Build.html +757 -0
- data/rdoc/site/0.5.0/CORL/Builder/Identity.html +569 -0
- data/rdoc/site/0.5.0/CORL/Builder/Package.html +576 -0
- data/rdoc/site/0.5.0/CORL/Builder.html +360 -0
- data/rdoc/site/0.5.0/CORL/Configuration/File.html +1148 -0
- data/rdoc/site/0.5.0/CORL/Configuration.html +359 -0
- data/rdoc/site/0.5.0/CORL/Errors.html +359 -0
- data/rdoc/site/0.5.0/CORL/Facade.html +899 -0
- data/rdoc/site/0.5.0/CORL/Machine/AWS.html +753 -0
- data/rdoc/site/0.5.0/CORL/Machine/Fog.html +1289 -0
- data/rdoc/site/0.5.0/CORL/Machine/Physical.html +1059 -0
- data/rdoc/site/0.5.0/CORL/Machine/Rackspace.html +534 -0
- data/rdoc/site/0.5.0/CORL/Machine/Vagrant.html +1320 -0
- data/rdoc/site/0.5.0/CORL/Machine.html +363 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Action/Keypair.html +592 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Action.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Builder/Global.html +604 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Builder/Instance.html +696 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Builder.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Lookup.html +1139 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Machine/SSH.html +675 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Machine.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Macro/NetworkSettings.html +484 -0
- data/rdoc/site/0.5.0/CORL/Mixin/Macro.html +359 -0
- data/rdoc/site/0.5.0/CORL/Mixin.html +363 -0
- data/rdoc/site/0.5.0/CORL/Network/CORL.html +411 -0
- data/rdoc/site/0.5.0/CORL/Network.html +359 -0
- data/rdoc/site/0.5.0/CORL/Node/AWS.html +736 -0
- data/rdoc/site/0.5.0/CORL/Node/Fog.html +1212 -0
- data/rdoc/site/0.5.0/CORL/Node/Local.html +444 -0
- data/rdoc/site/0.5.0/CORL/Node/Rackspace.html +729 -0
- data/rdoc/site/0.5.0/CORL/Node/Vagrant.html +1476 -0
- data/rdoc/site/0.5.0/CORL/Node.html +363 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Builder.html +500 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Configuration.html +1271 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Machine.html +1299 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Network.html +1580 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Node.html +4041 -0
- data/rdoc/site/0.5.0/CORL/Plugin/Provisioner.html +1115 -0
- data/rdoc/site/0.5.0/CORL/Plugin.html +649 -0
- data/rdoc/site/0.5.0/CORL/Provisioner/Puppetnode.html +1177 -0
- data/rdoc/site/0.5.0/CORL/Provisioner.html +359 -0
- data/rdoc/site/0.5.0/CORL/Util/Puppet/Resource.html +1058 -0
- data/rdoc/site/0.5.0/CORL/Util/Puppet/ResourceGroup.html +940 -0
- data/rdoc/site/0.5.0/CORL/Util/Puppet.html +1107 -0
- data/rdoc/site/0.5.0/CORL/Util.html +361 -0
- data/rdoc/site/0.5.0/CORL/Vagrant/Config.html +943 -0
- data/rdoc/site/0.5.0/CORL/Vagrant.html +438 -0
- data/rdoc/site/0.5.0/CORL.html +471 -0
- data/rdoc/site/0.5.0/Fog/Compute/AWS/Server.html +443 -0
- data/rdoc/site/0.5.0/Fog/Compute/AWS.html +365 -0
- data/rdoc/site/0.5.0/Fog/Compute/RackspaceV2/Server.html +428 -0
- data/rdoc/site/0.5.0/Fog/Compute/RackspaceV2.html +365 -0
- data/rdoc/site/0.5.0/Fog/Compute.html +360 -0
- data/rdoc/site/0.5.0/Fog.html +360 -0
- data/rdoc/site/0.5.0/Hiera/Backend.html +442 -0
- data/rdoc/site/0.5.0/Hiera/Corl_logger.html +469 -0
- data/rdoc/site/0.5.0/Hiera.html +366 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Create.html +538 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Hiera.html +566 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Images.html +572 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Inspect.html +524 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Machines.html +567 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Regions.html +567 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud/Vagrantfile.html +515 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Cloud.html +365 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Authorize.html +543 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Bootstrap.html +604 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Build.html +526 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Destroy.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Exec.html +530 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Facts.html +456 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/IP.html +453 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Image.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Keypair.html +572 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Lookup.html +532 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Provision.html +553 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Reboot.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Revoke.html +541 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/SSH.html +583 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Seed.html +602 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Spawn.html +675 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Start.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node/Stop.html +573 -0
- data/rdoc/site/0.5.0/Nucleon/Action/Node.html +376 -0
- data/rdoc/site/0.5.0/Nucleon/Action.html +383 -0
- data/rdoc/site/0.5.0/Nucleon/Config.html +377 -0
- data/rdoc/site/0.5.0/Nucleon/Event/Puppet.html +693 -0
- data/rdoc/site/0.5.0/Nucleon/Event.html +359 -0
- data/rdoc/site/0.5.0/Nucleon/Plugin/Base.html +365 -0
- data/rdoc/site/0.5.0/Nucleon/Plugin/CloudAction.html +838 -0
- data/rdoc/site/0.5.0/Nucleon/Plugin.html +360 -0
- data/rdoc/site/0.5.0/Nucleon/Template/Environment.html +548 -0
- data/rdoc/site/0.5.0/Nucleon/Template.html +359 -0
- data/rdoc/site/0.5.0/Nucleon.html +387 -0
- data/rdoc/site/0.5.0/Object.html +378 -0
- data/rdoc/site/0.5.0/Puppet/DataBinding/Corl.html +365 -0
- data/rdoc/site/0.5.0/Puppet/DataBinding.html +358 -0
- data/rdoc/site/0.5.0/Puppet/Indirector/Corl.html +477 -0
- data/rdoc/site/0.5.0/Puppet/Indirector.html +358 -0
- data/rdoc/site/0.5.0/Puppet/Parser/Functions.html +500 -0
- data/rdoc/site/0.5.0/Puppet/Parser.html +358 -0
- data/rdoc/site/0.5.0/Puppet.html +358 -0
- data/rdoc/site/0.5.0/README_rdoc.html +360 -0
- data/rdoc/site/0.5.0/Vagrant/Config/Loader.html +419 -0
- data/rdoc/site/0.5.0/Vagrant/Config.html +359 -0
- data/rdoc/site/0.5.0/Vagrant/Vagrantfile.html +412 -0
- data/rdoc/site/0.5.0/Vagrant.html +366 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/DeleteCache.html +422 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/InitKeys.html +428 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action/LinkNetwork.html +426 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Action.html +361 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/BaseAction.html +511 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Command/Launcher.html +553 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Command.html +359 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Config/CORL.html +752 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Config.html +359 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Plugin.html +365 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Provisioner/CORL.html +556 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL/Provisioner.html +359 -0
- data/rdoc/site/0.5.0/VagrantPlugins/CORL.html +366 -0
- data/rdoc/site/0.5.0/VagrantPlugins.html +366 -0
- data/rdoc/site/0.5.0/created.rid +103 -0
- data/rdoc/site/0.5.0/images/add.png +0 -0
- data/rdoc/site/0.5.0/images/brick.png +0 -0
- data/rdoc/site/0.5.0/images/brick_link.png +0 -0
- data/rdoc/site/0.5.0/images/bug.png +0 -0
- data/rdoc/site/0.5.0/images/bullet_black.png +0 -0
- data/rdoc/site/0.5.0/images/bullet_toggle_minus.png +0 -0
- data/rdoc/site/0.5.0/images/bullet_toggle_plus.png +0 -0
- data/rdoc/site/0.5.0/images/date.png +0 -0
- data/rdoc/site/0.5.0/images/delete.png +0 -0
- data/rdoc/site/0.5.0/images/find.png +0 -0
- data/rdoc/site/0.5.0/images/loadingAnimation.gif +0 -0
- data/rdoc/site/0.5.0/images/macFFBgHack.png +0 -0
- data/rdoc/site/0.5.0/images/package.png +0 -0
- data/rdoc/site/0.5.0/images/page_green.png +0 -0
- data/rdoc/site/0.5.0/images/page_white_text.png +0 -0
- data/rdoc/site/0.5.0/images/page_white_width.png +0 -0
- data/rdoc/site/0.5.0/images/plugin.png +0 -0
- data/rdoc/site/0.5.0/images/ruby.png +0 -0
- data/rdoc/site/0.5.0/images/tag_blue.png +0 -0
- data/rdoc/site/0.5.0/images/tag_green.png +0 -0
- data/rdoc/site/0.5.0/images/transparent.png +0 -0
- data/rdoc/site/0.5.0/images/wrench.png +0 -0
- data/rdoc/site/0.5.0/images/wrench_orange.png +0 -0
- data/rdoc/site/0.5.0/images/zoom.png +0 -0
- data/rdoc/site/0.5.0/index.html +359 -0
- data/rdoc/site/0.5.0/js/darkfish.js +155 -0
- data/rdoc/site/0.5.0/js/jquery.js +18 -0
- data/rdoc/site/0.5.0/js/navigation.js +142 -0
- data/rdoc/site/0.5.0/js/search.js +94 -0
- data/rdoc/site/0.5.0/js/search_index.js +1 -0
- data/rdoc/site/0.5.0/js/searcher.js +228 -0
- data/rdoc/site/0.5.0/rdoc.css +543 -0
- data/rdoc/site/0.5.0/table_of_contents.html +1797 -0
- metadata +171 -3
- data/lib/nucleon/action/cloud/hiera.rb +0 -61
@@ -0,0 +1,259 @@
|
|
1
|
+
|
2
|
+
module Nucleon
|
3
|
+
module Action
|
4
|
+
module Cloud
|
5
|
+
class Config < CORL.plugin_class(:nucleon, :cloud_action)
|
6
|
+
|
7
|
+
include Mixin::Action::Registration
|
8
|
+
|
9
|
+
#-----------------------------------------------------------------------------
|
10
|
+
# Info
|
11
|
+
|
12
|
+
def self.describe
|
13
|
+
super(:cloud, :config, 949)
|
14
|
+
end
|
15
|
+
|
16
|
+
#-----------------------------------------------------------------------------
|
17
|
+
# Settings
|
18
|
+
|
19
|
+
def configure
|
20
|
+
super do
|
21
|
+
codes :configuration_parse_failed,
|
22
|
+
:configuration_save_failed,
|
23
|
+
:configuration_delete_failed
|
24
|
+
|
25
|
+
register_str :name, nil
|
26
|
+
register_array :value
|
27
|
+
|
28
|
+
register_bool :delete
|
29
|
+
register_bool :append
|
30
|
+
|
31
|
+
register_translator :input_format
|
32
|
+
register_translator :load_format, :json
|
33
|
+
register_translator :format, :json
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#---
|
38
|
+
|
39
|
+
def ignore
|
40
|
+
[ :nodes ]
|
41
|
+
end
|
42
|
+
|
43
|
+
def arguments
|
44
|
+
[ :name, :value ]
|
45
|
+
end
|
46
|
+
|
47
|
+
#-----------------------------------------------------------------------------
|
48
|
+
# Operations
|
49
|
+
|
50
|
+
def execute
|
51
|
+
super do |node, network|
|
52
|
+
ensure_network(network) do
|
53
|
+
config_info = parse_config_reference(network, settings[:name])
|
54
|
+
|
55
|
+
unless config_info
|
56
|
+
myself.status = code.configuration_parse_failed
|
57
|
+
end
|
58
|
+
|
59
|
+
if config_info[:property].nil?
|
60
|
+
render_config_properties(network, config_info)
|
61
|
+
|
62
|
+
elsif settings.delete(:delete, false)
|
63
|
+
delete_config_property(network, config_info, sanitize_remote(network, settings[:net_remote]))
|
64
|
+
|
65
|
+
elsif ! settings[:value].empty?
|
66
|
+
set_config_property(network, config_info, settings[:value], sanitize_remote(network, settings[:net_remote]))
|
67
|
+
else
|
68
|
+
render_config_property(network, config_info)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
#-----------------------------------------------------------------------------
|
75
|
+
# Sub operations
|
76
|
+
|
77
|
+
def render_config_properties(network, config_info)
|
78
|
+
if file_labels = config_info[:files]
|
79
|
+
info("Sub configurations available:", { :i18n => false })
|
80
|
+
file_labels.each do |label|
|
81
|
+
info("-> #{yellow(label)}", { :i18n => false })
|
82
|
+
end
|
83
|
+
else
|
84
|
+
format = settings[:format]
|
85
|
+
myself.result = config_info[:config].export
|
86
|
+
render result, :format => format
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
#---
|
91
|
+
|
92
|
+
def render_config_property(network, config_info)
|
93
|
+
format = settings[:format]
|
94
|
+
myself.result = config_info[:value]
|
95
|
+
render result, :format => format
|
96
|
+
end
|
97
|
+
|
98
|
+
#---
|
99
|
+
|
100
|
+
def delete_config_property(network, config_info, remote = nil)
|
101
|
+
name = parse_property_name(config_info[:property])
|
102
|
+
remote_text = remote_message(remote)
|
103
|
+
config_file = config_info[:file].sub(network.directory + File::SEPARATOR, '')
|
104
|
+
|
105
|
+
config_info[:config].delete(config_info[:property])
|
106
|
+
|
107
|
+
if File.exists?(config_info[:file])
|
108
|
+
if Util::Disk.write(config_info[:file], config_info[:translator].generate(config_info[:config].export))
|
109
|
+
if network.save({ :files => config_file, :remote => remote, :message => "Deleting configuration #{name} from #{config_file}", :allow_empty => true })
|
110
|
+
success("Configuration `#{blue(name)}` deleted (#{yellow(remote_text)})", { :i18n => false })
|
111
|
+
else
|
112
|
+
error("Configuration `#{blue(name)}` deletion could not be saved", { :i18n => false })
|
113
|
+
myself.status = code.configuration_save_failed
|
114
|
+
end
|
115
|
+
else
|
116
|
+
error("Configuration file `#{blue(config_file)}` could not be saved", { :i18n => false })
|
117
|
+
myself.status = code.configuration_save_failed
|
118
|
+
end
|
119
|
+
else
|
120
|
+
info("Configuration file `#{blue(config_file)} does not exist so configuration can not be deleted", { :i18n => false })
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
#---
|
125
|
+
|
126
|
+
def set_config_property(network, config_info, values, remote = nil)
|
127
|
+
name = parse_property_name(config_info[:property])
|
128
|
+
remote_text = remote_message(remote)
|
129
|
+
|
130
|
+
config_file = config_info[:file].sub(network.directory + File::SEPARATOR, '')
|
131
|
+
input_format = settings[:input_format]
|
132
|
+
|
133
|
+
values.each_with_index do |value, index|
|
134
|
+
values[index] = render(value, {
|
135
|
+
:format => input_format,
|
136
|
+
:silent => true
|
137
|
+
}) if input_format
|
138
|
+
values[index] = Util::Data.value(values[index])
|
139
|
+
end
|
140
|
+
|
141
|
+
if settings[:append]
|
142
|
+
if prev_value = config_info[:value]
|
143
|
+
prev_value = array(prev_value)
|
144
|
+
|
145
|
+
values.each do |value|
|
146
|
+
prev_value.push(value)
|
147
|
+
end
|
148
|
+
values = prev_value
|
149
|
+
end
|
150
|
+
else
|
151
|
+
if values.size == 1
|
152
|
+
values = values[0]
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
myself.result = values
|
157
|
+
config_info[:config].set(config_info[:property], result)
|
158
|
+
|
159
|
+
FileUtils.mkdir_p(File.dirname(config_info[:file]))
|
160
|
+
|
161
|
+
if Util::Disk.write(config_info[:file], config_info[:translator].generate(config_info[:config].export))
|
162
|
+
if network.save({ :files => config_file, :remote => remote, :message => "Updating configuration #{name} in #{config_file}", :allow_empty => true })
|
163
|
+
success("Configuration `#{blue(name)}` update (#{yellow(remote_text)})", { :i18n => false })
|
164
|
+
else
|
165
|
+
error("Configuration `#{blue(name)}` update could not be saved", { :i18n => false })
|
166
|
+
myself.status = code.configuration_save_failed
|
167
|
+
end
|
168
|
+
else
|
169
|
+
error("Configuration file `#{blue(config_file)}` could not be saved", { :i18n => false })
|
170
|
+
myself.status = code.configuration_save_failed
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
#-----------------------------------------------------------------------------
|
175
|
+
# Utilities
|
176
|
+
|
177
|
+
def parse_config_reference(network, name)
|
178
|
+
info = {}
|
179
|
+
data = {}
|
180
|
+
|
181
|
+
translators = CORL.loaded_plugins(:nucleon, :translator).keys
|
182
|
+
|
183
|
+
# common@php::apache::memory_limit
|
184
|
+
# identity/test@users::user[admin][shell]
|
185
|
+
# servers/development/dev.loc@facts[server_environment]
|
186
|
+
|
187
|
+
config_elements = name.split('@')
|
188
|
+
|
189
|
+
property = config_elements.size > 1 ? config_elements.pop : nil
|
190
|
+
config_elements = config_elements[0].split('/')
|
191
|
+
config_file_name = config_elements.pop
|
192
|
+
config_path = File.join(network.config_directory, *config_elements)
|
193
|
+
|
194
|
+
if config_file_name
|
195
|
+
config_dir = File.join(config_path, config_file_name)
|
196
|
+
config_file = File.join(config_path, "#{config_file_name}." + settings[:load_format].to_s)
|
197
|
+
config_files = nil
|
198
|
+
property = property.gsub(/\]$/, '').split(/\]?\[/) if property
|
199
|
+
|
200
|
+
unless translator = CORL.translator({}, settings[:load_format])
|
201
|
+
error("Translator for #{settings[:format]} could not be loaded", { :i18n => false })
|
202
|
+
return nil
|
203
|
+
end
|
204
|
+
|
205
|
+
if File.exists?(config_file)
|
206
|
+
unless data = Util::Disk.read(config_file)
|
207
|
+
error("Failed to read file: #{config_file}", { :i18n => false })
|
208
|
+
return nil
|
209
|
+
end
|
210
|
+
config = CORL::Config.new(translator.parse(data))
|
211
|
+
elsif File.directory?(config_dir)
|
212
|
+
config_files = Dir.glob("#{config_dir}/**/*").select do |file|
|
213
|
+
is_config = false
|
214
|
+
|
215
|
+
translators.each do |translator_name|
|
216
|
+
is_config = true if file.match(/\.#{translator_name}/)
|
217
|
+
end
|
218
|
+
is_config
|
219
|
+
end
|
220
|
+
config_files.each_with_index do |file, index|
|
221
|
+
config_files[index] = file.sub(/#{network.config_directory + File::SEPARATOR}/, '')
|
222
|
+
config_files[index] = config_files[index].sub(/\.([a-z0-9]+)$/, ' [ ' + blue('\1') + ' ]')
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
config = CORL::Config.new unless config
|
227
|
+
info = {
|
228
|
+
:translator => translator,
|
229
|
+
:file => config_file,
|
230
|
+
:files => config_files,
|
231
|
+
:property => property,
|
232
|
+
:config => config,
|
233
|
+
:value => property ? Util::Data.value(config.get(property)) : nil
|
234
|
+
}
|
235
|
+
end
|
236
|
+
info
|
237
|
+
end
|
238
|
+
|
239
|
+
#---
|
240
|
+
|
241
|
+
def parse_property_name(property)
|
242
|
+
property = property.clone
|
243
|
+
|
244
|
+
if property.size > 1
|
245
|
+
property.shift.to_s + '[' + property.join('][') + ']'
|
246
|
+
else
|
247
|
+
property.shift.to_s
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
#---
|
252
|
+
|
253
|
+
def remote_message(remote)
|
254
|
+
remote ? "#{remote}" : "LOCAL ONLY"
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
258
|
+
end
|
259
|
+
end
|
@@ -47,7 +47,7 @@ class Images < CORL.plugin_class(:nucleon, :cloud_action)
|
|
47
47
|
if node = network.test_node(settings[:node_provider], { :region => settings[:region] })
|
48
48
|
if images = node.images(settings[:search], settings)
|
49
49
|
images.each do |image|
|
50
|
-
|
50
|
+
info(node.render_image(image), { :prefix => false, :i18n => false })
|
51
51
|
end
|
52
52
|
|
53
53
|
myself.result = images
|
@@ -4,6 +4,8 @@ module Action
|
|
4
4
|
module Cloud
|
5
5
|
class Inspect < CORL.plugin_class(:nucleon, :cloud_action)
|
6
6
|
|
7
|
+
include Mixin::Action::Registration
|
8
|
+
|
7
9
|
#-----------------------------------------------------------------------------
|
8
10
|
# Info
|
9
11
|
|
@@ -16,7 +18,10 @@ class Inspect < CORL.plugin_class(:nucleon, :cloud_action)
|
|
16
18
|
|
17
19
|
def configure
|
18
20
|
super do
|
19
|
-
|
21
|
+
codes :configuration_parse_failed
|
22
|
+
|
23
|
+
register_array :elements
|
24
|
+
register_translator :format, :json
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
@@ -37,7 +42,11 @@ class Inspect < CORL.plugin_class(:nucleon, :cloud_action)
|
|
37
42
|
else
|
38
43
|
data = network.config.get(settings[:elements])
|
39
44
|
end
|
40
|
-
|
45
|
+
if network.config.status == code.success
|
46
|
+
render data, :format => settings[:format]
|
47
|
+
else
|
48
|
+
myself.status = code.configuration_parse_failed
|
49
|
+
end
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
@@ -42,7 +42,7 @@ class Machines < CORL.plugin_class(:nucleon, :cloud_action)
|
|
42
42
|
if node = network.test_node(settings[:node_provider])
|
43
43
|
if machine_types = node.machine_types
|
44
44
|
machine_types.each do |machine_type|
|
45
|
-
|
45
|
+
info(node.render_machine_type(machine_type), { :prefix => false, :i18n => false })
|
46
46
|
end
|
47
47
|
|
48
48
|
myself.result = machine_types
|
@@ -42,7 +42,7 @@ class Regions < CORL.plugin_class(:nucleon, :cloud_action)
|
|
42
42
|
if node = network.test_node(settings[:node_provider])
|
43
43
|
if regions = node.regions
|
44
44
|
regions.each do |region|
|
45
|
-
|
45
|
+
info(sprintf("> %s", region), { :prefix => false, :i18n => false })
|
46
46
|
end
|
47
47
|
|
48
48
|
myself.result = regions
|
@@ -0,0 +1,185 @@
|
|
1
|
+
|
2
|
+
module Nucleon
|
3
|
+
module Action
|
4
|
+
module Cloud
|
5
|
+
class Settings < CORL.plugin_class(:nucleon, :cloud_action)
|
6
|
+
|
7
|
+
include Mixin::Action::Registration
|
8
|
+
|
9
|
+
#-----------------------------------------------------------------------------
|
10
|
+
# Info
|
11
|
+
|
12
|
+
def self.describe
|
13
|
+
super(:cloud, :settings, 951)
|
14
|
+
end
|
15
|
+
|
16
|
+
#-----------------------------------------------------------------------------
|
17
|
+
# Settings
|
18
|
+
|
19
|
+
def configure
|
20
|
+
super do
|
21
|
+
codes :settings_save_failed,
|
22
|
+
:settings_delete_failed
|
23
|
+
|
24
|
+
register_str :group
|
25
|
+
register_str :name
|
26
|
+
register_array :value
|
27
|
+
|
28
|
+
register_bool :delete
|
29
|
+
register_bool :append
|
30
|
+
register_bool :groups
|
31
|
+
|
32
|
+
register_translator :input_format
|
33
|
+
register_translator :format, :json
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#---
|
38
|
+
|
39
|
+
def ignore
|
40
|
+
[ :nodes ]
|
41
|
+
end
|
42
|
+
|
43
|
+
def arguments
|
44
|
+
[ :group, :name, :value ]
|
45
|
+
end
|
46
|
+
|
47
|
+
#-----------------------------------------------------------------------------
|
48
|
+
# Operations
|
49
|
+
|
50
|
+
def execute
|
51
|
+
super do |node, network|
|
52
|
+
ensure_network(network) do
|
53
|
+
if settings[:groups]
|
54
|
+
render_groups(network)
|
55
|
+
|
56
|
+
elsif settings[:group].empty?
|
57
|
+
render_settings(network)
|
58
|
+
|
59
|
+
elsif settings[:name].empty?
|
60
|
+
render_settings(network, settings[:group])
|
61
|
+
|
62
|
+
else
|
63
|
+
name = settings[:name].gsub(/\]$/, '').split(/\]?\[/)
|
64
|
+
|
65
|
+
if settings.get(:delete, false)
|
66
|
+
delete_settings(network, name, sanitize_remote(network, settings[:net_remote]))
|
67
|
+
|
68
|
+
elsif ! settings[:value].empty?
|
69
|
+
set_settings(network, name, settings[:value], sanitize_remote(network, settings[:net_remote]))
|
70
|
+
|
71
|
+
else
|
72
|
+
render_settings(network, [ settings[:group], name ])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
#-----------------------------------------------------------------------------
|
80
|
+
# Sub operations
|
81
|
+
|
82
|
+
def render_groups(network)
|
83
|
+
groups = network.config.get(:settings).keys
|
84
|
+
|
85
|
+
info("Currently defined groups:", { :i18n => false })
|
86
|
+
groups.each do |group|
|
87
|
+
info("-> #{green(group)}", { :i18n => false })
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
#---
|
92
|
+
|
93
|
+
def render_settings(network, elements = [])
|
94
|
+
format = settings[:format]
|
95
|
+
|
96
|
+
if elements.size > 0
|
97
|
+
myself.result = network.config.get([ :settings, elements ])
|
98
|
+
else
|
99
|
+
myself.result = network.config.get(:settings)
|
100
|
+
end
|
101
|
+
render result, :format => format
|
102
|
+
end
|
103
|
+
|
104
|
+
#---
|
105
|
+
|
106
|
+
def delete_settings(network, property, remote = nil)
|
107
|
+
group = settings[:group]
|
108
|
+
name = parse_property_name(property)
|
109
|
+
remote_text = remote_message(remote)
|
110
|
+
|
111
|
+
network.config.delete([ :settings, group, property ])
|
112
|
+
|
113
|
+
if network.save({ :remote => remote, :message => "Deleting #{group} setting #{name}", :allow_empty => true })
|
114
|
+
success("Group #{blue(group)} setting `#{blue(name)}` deleted (#{yellow(remote_text)})", { :i18n => false })
|
115
|
+
else
|
116
|
+
error("Group #{blue(group)} setting `#{blue(name)}` deletion could not be saved", { :i18n => false })
|
117
|
+
myself.status = code.settings_delete_failed
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
#---
|
122
|
+
|
123
|
+
def set_settings(network, property, values, remote = nil)
|
124
|
+
group = settings[:group]
|
125
|
+
name = parse_property_name(property)
|
126
|
+
remote_text = remote_message(remote)
|
127
|
+
|
128
|
+
input_format = settings[:input_format]
|
129
|
+
|
130
|
+
values.each_with_index do |value, index|
|
131
|
+
values[index] = render(value, {
|
132
|
+
:format => input_format,
|
133
|
+
:silent => true
|
134
|
+
}) if input_format
|
135
|
+
values[index] = Util::Data.value(values[index])
|
136
|
+
end
|
137
|
+
|
138
|
+
if settings[:append]
|
139
|
+
if prev_value = network.config.get([ :settings, group, property ])
|
140
|
+
prev_value = array(prev_value)
|
141
|
+
|
142
|
+
values.each do |value|
|
143
|
+
prev_value.push(value)
|
144
|
+
end
|
145
|
+
values = prev_value
|
146
|
+
end
|
147
|
+
else
|
148
|
+
if values.size == 1
|
149
|
+
values = values[0]
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
myself.result = values
|
154
|
+
network.config.set([ :settings, group, property ], result)
|
155
|
+
|
156
|
+
if network.save({ :remote => remote, :message => "Updating #{group} setting #{name}", :allow_empty => true })
|
157
|
+
success("Group #{blue(group)} setting `#{blue(name)}` updated (#{yellow(remote_text)})", { :i18n => false })
|
158
|
+
else
|
159
|
+
error("Group #{blue(group)} setting `#{blue(name)}` update could not be saved", { :i18n => false })
|
160
|
+
myself.status = code.settings_save_failed
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
#-----------------------------------------------------------------------------
|
165
|
+
# Utilities
|
166
|
+
|
167
|
+
def parse_property_name(property)
|
168
|
+
property = property.clone
|
169
|
+
|
170
|
+
if property.size > 1
|
171
|
+
property.shift.to_s + '[' + property.join('][') + ']'
|
172
|
+
else
|
173
|
+
property.shift.to_s
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
#---
|
178
|
+
|
179
|
+
def remote_message(remote)
|
180
|
+
remote ? "#{remote}" : "LOCAL ONLY"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
@@ -80,7 +80,7 @@ class Bootstrap < CORL.plugin_class(:nucleon, :cloud_action)
|
|
80
80
|
render_options = { :id => node.id, :hostname => node.hostname }
|
81
81
|
|
82
82
|
info('corl.actions.bootstrap.start', render_options)
|
83
|
-
success = node.bootstrap(network.home, extended_config(:bootstrap, settings))
|
83
|
+
success = node.bootstrap(network.home, extended_config(:bootstrap, settings.clone))
|
84
84
|
if success
|
85
85
|
info('corl.actions.bootstrap.success', render_options)
|
86
86
|
else
|
@@ -0,0 +1,133 @@
|
|
1
|
+
|
2
|
+
module Nucleon
|
3
|
+
module Action
|
4
|
+
module Node
|
5
|
+
class Cache < CORL.plugin_class(:nucleon, :cloud_action)
|
6
|
+
|
7
|
+
include Mixin::Action::Registration
|
8
|
+
|
9
|
+
#-----------------------------------------------------------------------------
|
10
|
+
# Info
|
11
|
+
|
12
|
+
def self.describe
|
13
|
+
super(:node, :cache, 600)
|
14
|
+
end
|
15
|
+
|
16
|
+
#-----------------------------------------------------------------------------
|
17
|
+
# Settings
|
18
|
+
|
19
|
+
def configure
|
20
|
+
super do
|
21
|
+
codes :cache_save_failed
|
22
|
+
|
23
|
+
register_str :name
|
24
|
+
register_str :value
|
25
|
+
|
26
|
+
register_bool :delete
|
27
|
+
register_bool :clear
|
28
|
+
|
29
|
+
register_translator :input_format
|
30
|
+
register_translator :format, :json
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#---
|
35
|
+
|
36
|
+
def arguments
|
37
|
+
[ :name, :value ]
|
38
|
+
end
|
39
|
+
|
40
|
+
#-----------------------------------------------------------------------------
|
41
|
+
# Operations
|
42
|
+
|
43
|
+
def execute
|
44
|
+
super do |node, network|
|
45
|
+
ensure_node(node) do
|
46
|
+
if settings.delete(:clear, false)
|
47
|
+
clear_node_cache(node)
|
48
|
+
elsif ! settings[:name] || settings[:name].empty?
|
49
|
+
render_node_cache(node)
|
50
|
+
else
|
51
|
+
settings[:name] = settings[:name].split('.')
|
52
|
+
settings[:value] = nil if settings[:value].is_a?(String) && settings[:value].empty?
|
53
|
+
|
54
|
+
if settings.delete(:delete, false)
|
55
|
+
delete_node_cache(node, settings[:name])
|
56
|
+
elsif ! settings[:value].nil?
|
57
|
+
set_node_cache(node, settings[:name], settings[:value])
|
58
|
+
else
|
59
|
+
render_node_cache_property(node, settings[:name])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#-----------------------------------------------------------------------------
|
67
|
+
# Sub operations
|
68
|
+
|
69
|
+
def render_node_cache(node)
|
70
|
+
format = settings[:format]
|
71
|
+
myself.result = node.cache_setting([], {}, :hash)
|
72
|
+
render result, :format => format
|
73
|
+
end
|
74
|
+
|
75
|
+
#---
|
76
|
+
|
77
|
+
def render_node_cache_property(node, name)
|
78
|
+
format = settings[:format]
|
79
|
+
myself.result = node.cache_setting(name)
|
80
|
+
render result, :format => format
|
81
|
+
end
|
82
|
+
|
83
|
+
#---
|
84
|
+
|
85
|
+
def delete_node_cache(node, name)
|
86
|
+
node.delete_cache_setting(name)
|
87
|
+
|
88
|
+
if node.cache.status == code.success
|
89
|
+
success("Cached property #{name.join('.')} deleted", { :i18n => false })
|
90
|
+
else
|
91
|
+
error("Cached property #{name.join('.')} deletion could not be saved", { :i18n => false })
|
92
|
+
myself.status = code.cache_save_failed
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
#---
|
97
|
+
|
98
|
+
def set_node_cache(node, name, value)
|
99
|
+
input_format = settings[:input_format]
|
100
|
+
|
101
|
+
value = Util::Data.value(render(value, {
|
102
|
+
:format => input_format,
|
103
|
+
:silent => true
|
104
|
+
})) if input_format
|
105
|
+
|
106
|
+
myself.result = value
|
107
|
+
|
108
|
+
node.set_cache_setting(name, value)
|
109
|
+
|
110
|
+
if node.cache.status == code.success
|
111
|
+
success("Cached property #{name.join('.')} saved", { :i18n => false })
|
112
|
+
else
|
113
|
+
error("Cached property #{name.join('.')} could not be saved", { :i18n => false })
|
114
|
+
myself.status = code.cache_save_failed
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
#---
|
119
|
+
|
120
|
+
def clear_node_cache(node)
|
121
|
+
node.clear_cache
|
122
|
+
|
123
|
+
if node.cache.status == code.success
|
124
|
+
success("Cached properties cleared", { :i18n => false })
|
125
|
+
else
|
126
|
+
error("Cached properties could not be cleared", { :i18n => false })
|
127
|
+
myself.status = code.cache_save_failed
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|