Class: Vagrant::Hostmaster::VM
- Inherits:
-
Object
- Object
- Vagrant::Hostmaster::VM
- Extended by:
- Forwardable
- Defined in:
- lib/vagrant/hostmaster/vm.rb
Instance Method Summary collapse
- #add(options = {}) ⇒ Object
-
#initialize(vm) ⇒ VM
constructor
A new instance of VM.
- #list(options = {}) ⇒ Object
- #remove(options = {}) ⇒ Object
- #update(options = {}) ⇒ Object
Constructor Details
#initialize(vm) ⇒ VM
Returns a new instance of VM.
10 11 12 |
# File 'lib/vagrant/hostmaster/vm.rb', line 10 def initialize(vm) @vm = vm end |
Instance Method Details
#add(options = {}) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/vagrant/hostmaster/vm.rb', line 14 def add( = {}) if process_local?() env.ui.info("Adding host entry for #{name} VM. Administrator privileges will be required...") unless [:quiet] sudo add_command end with_other_vms { |vm| channel.sudo vm.add_command(uuid) } if process_guests?() end |
#list(options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vagrant/hostmaster/vm.rb', line 23 def list( = {}) if process_local?() output = `#{list_command}`.chomp env.ui.info("Local host entry for #{name}...\n#{output}\n\n", :prefix => false) unless output.empty? end if process_guests?() entries = [] with_other_vms do |vm| entry = "" channel.execute(vm.list_command(uuid), :error_check => false) do |type, data| entry << data if type == :stdout end entry.chomp! entries << entry unless entry.empty? end env.ui.info("Guest host #{entries.size > 1 ? 'entries' : 'entry'} on #{name}...\n#{entries.join("\n")}\n\n", :prefix => false) unless entries.empty? end end |
#remove(options = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/vagrant/hostmaster/vm.rb', line 43 def remove( = {}) if process_local?() env.ui.info("Removing host entry for #{name} VM. Administrator privileges will be required...") unless [:quiet] sudo remove_command end with_other_vms { |vm| channel.sudo vm.remove_command(uuid) } if process_guests?() end |
#update(options = {}) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/vagrant/hostmaster/vm.rb', line 51 def update( = {}) if process_local?() env.ui.info("Updating host entry for #{name} VM. Administrator privileges will be required...") unless [:quiet] sudo(remove_command) && sudo(add_command) end with_other_vms { |vm| channel.sudo(vm.remove_command(uuid)) && channel.sudo(vm.add_command(uuid)) } if process_guests?() end |