Class: VagrantPlugins::StartCloud::Command
- Inherits:
-
Object
- Object
- VagrantPlugins::StartCloud::Command
- Defined in:
- lib/vagrant-startcloud/command.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv, env) ⇒ Command
constructor
A new instance of Command.
Constructor Details
#initialize(argv, env) ⇒ Command
Returns a new instance of Command.
8 9 10 11 |
# File 'lib/vagrant-startcloud/command.rb', line 8 def initialize(argv, env) super @env = env end |
Instance Method Details
#execute ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vagrant-startcloud/command.rb', line 13 def execute config_file = 'Hosts.yml' unless File.exist?(config_file) @env.ui.error(I18n.t('vagrant_startcloud.config.config_not_found', path: config_file)) return 1 end begin config = YAML.load_file(config_file) return 1 unless config && config['hosts'] config['hosts'].each do |host| name = "#{host['settings']['server_id']}--#{host['settings']['hostname']}.#{host['settings']['domain']}" @env.ui.info(I18n.t('vagrant_startcloud.command.configuring', name: name)) with_target_vms([name]) do |vm| vm.config.startcloud.settings = host['settings'] vm.config.startcloud.networks = host['networks'] vm.config.startcloud.disks = host['disks'] vm.config.startcloud.provisioning = host['provisioning'] vm.config.startcloud.folders = host['folders'] vm.config.startcloud.roles = host['roles'] vm.config.startcloud.vars = host['vars'] vm.config.startcloud.plugins = host['plugins'] vm.config.startcloud.zones = host['zones'] end end 0 rescue StandardError => e @env.ui.error(I18n.t('vagrant_startcloud.config.yaml_error', error: e.)) 1 end end |