Class: VagrantPlugins::QEMU::Provider
- Inherits:
-
Object
- Object
- VagrantPlugins::QEMU::Provider
- Defined in:
- lib/vagrant-qemu/provider.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
Instance Method Summary collapse
- #action(name) ⇒ Object
-
#initialize(machine) ⇒ Provider
constructor
A new instance of Provider.
- #machine_id_changed ⇒ Object
- #ssh_info ⇒ Object
- #state ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(machine) ⇒ Provider
Returns a new instance of Provider.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/vagrant-qemu/provider.rb', line 11 def initialize(machine) @machine = machine # TODO support NFS @machine.config.nfs.functional = false # This method will load in our driver, so we call it now to # initialize it. machine_id_changed end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
9 10 11 |
# File 'lib/vagrant-qemu/provider.rb', line 9 def driver @driver end |
Instance Method Details
#action(name) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/vagrant-qemu/provider.rb', line 22 def action(name) # Attempt to get the action method from the Action class if it # exists, otherwise return nil to show that we don't support the # given action. action_method = "action_#{name}" return Action.send(action_method) if Action.respond_to?(action_method) nil end |
#machine_id_changed ⇒ Object
31 32 33 |
# File 'lib/vagrant-qemu/provider.rb', line 31 def machine_id_changed @driver = Driver.new(@machine.id, @machine.data_dir, @machine.env.tmp_path) end |
#ssh_info ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/vagrant-qemu/provider.rb', line 35 def ssh_info # If the VM is not running that we can't possibly SSH into it return nil if state.id != :running return { host: "127.0.0.1", port: @machine.provider_config.ssh_port } end |
#state ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/vagrant-qemu/provider.rb', line 45 def state state_id = nil state_id = :not_created if !@machine.id if !state_id # Run a custom action we define called "read_state" which does # what it says. It puts the state in the `:machine_state_id` # key in the environment. env = @machine.action(:read_state) state_id = env[:machine_state_id] end # Get the short and long description short = state_id.to_s long = "" # If we're not created, then specify the special ID flag if state_id == :not_created state_id = Vagrant::MachineState::NOT_CREATED_ID end # Return the MachineState object Vagrant::MachineState.new(state_id, short, long) end |
#to_s ⇒ Object
70 71 72 73 |
# File 'lib/vagrant-qemu/provider.rb', line 70 def to_s id = @machine.id.nil? ? "new" : @machine.id "QEMU (#{id})" end |