Class: VagrantPlugins::OneCloud::Commands::AddNetwork
- Inherits:
-
Object
- Object
- VagrantPlugins::OneCloud::Commands::AddNetwork
- Defined in:
- lib/vagrant-1cloud/commands/add_network.rb
Class Method Summary collapse
-
.synopsis ⇒ Object
Show description when ‘vagrant list-commands` is triggered.
Instance Method Summary collapse
Class Method Details
.synopsis ⇒ Object
Show description when ‘vagrant list-commands` is triggered
9 10 11 |
# File 'lib/vagrant-1cloud/commands/add_network.rb', line 9 def self.synopsis "plugin: vagrant-1cloud: adds VPS to specific private network" 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 48 49 50 51 52 53 54 55 |
# File 'lib/vagrant-1cloud/commands/add_network.rb', line 13 def execute = {} optparse = OptionParser.new do |opts| opts. = 'Usage: vagrant add-network [vm-name] [options]' opts.on('-n', '--net NETNAME', 'Network name') do |net| [:Net] = net end [:IP] = nil opts.on('-i', '--ip [IP]', 'Private IP address') do |ip| [:IP] = ip end opts.on('-h', '--help', 'Display this screen') do puts opts exit end end begin optparse.parse! mandatory = [:Net] missing = mandatory.select{ |param| [param].nil? } unless missing.empty? raise OptionParser::MissingArgument.new(missing.join(', ')) end rescue OptionParser::InvalidOption, OptionParser::MissingArgument puts $!.to_s puts optparse exit end argv = (optparse) with_target_vms(argv) do |machine| machine.provider_config.private_net = {[:Net] => [:IP]} machine.action(:addnet) end 0 end |