Class: VagrantPlugins::AVF::Model::MachineMetadata
- Inherits:
-
Object
- Object
- VagrantPlugins::AVF::Model::MachineMetadata
- Defined in:
- lib/vagrant_provider_avf/model/machine_metadata.rb
Constant Summary collapse
- VALID_STATES =
[:running, :stopped].freeze
Instance Attribute Summary collapse
-
#boot_config ⇒ Object
readonly
Returns the value of attribute boot_config.
-
#guest_ssh_info ⇒ Object
readonly
Returns the value of attribute guest_ssh_info.
-
#machine_id ⇒ Object
readonly
Returns the value of attribute machine_id.
-
#machine_requirements ⇒ Object
readonly
Returns the value of attribute machine_requirements.
-
#process_id ⇒ Object
readonly
Returns the value of attribute process_id.
-
#ssh_forwarder_process_id ⇒ Object
readonly
Returns the value of attribute ssh_forwarder_process_id.
-
#ssh_info ⇒ Object
readonly
Returns the value of attribute ssh_info.
-
#ssh_port ⇒ Object
readonly
Returns the value of attribute ssh_port.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
- .from_h(attributes) ⇒ Object
- .running(machine_id, process_id:, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil, ssh_forwarder_process_id: nil) ⇒ Object
- .stopped(machine_id, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(machine_id:, state:, process_id: nil, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil, ssh_forwarder_process_id: nil) ⇒ MachineMetadata
constructor
A new instance of MachineMetadata.
- #running? ⇒ Boolean
- #to_h ⇒ Object
Constructor Details
#initialize(machine_id:, state:, process_id: nil, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil, ssh_forwarder_process_id: nil) ⇒ MachineMetadata
Returns a new instance of MachineMetadata.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 58 def initialize( machine_id:, state:, process_id: nil, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil, ssh_forwarder_process_id: nil ) @machine_id = normalize_machine_id(machine_id) @state = normalize_state(state) @process_id = normalize_process_id(process_id, @state) @ssh_info = normalize_ssh_info(ssh_info) @guest_ssh_info = normalize_ssh_info(guest_ssh_info) @machine_requirements = normalize_machine_requirements(machine_requirements) @boot_config = normalize_boot_config(boot_config) @ssh_port = normalize_ssh_port(ssh_port) @ssh_forwarder_process_id = normalize_ssh_forwarder_process_id(ssh_forwarder_process_id, @state) end |
Instance Attribute Details
#boot_config ⇒ Object (readonly)
Returns the value of attribute boot_config.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def boot_config @boot_config end |
#guest_ssh_info ⇒ Object (readonly)
Returns the value of attribute guest_ssh_info.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def guest_ssh_info @guest_ssh_info end |
#machine_id ⇒ Object (readonly)
Returns the value of attribute machine_id.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def machine_id @machine_id end |
#machine_requirements ⇒ Object (readonly)
Returns the value of attribute machine_requirements.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def machine_requirements @machine_requirements end |
#process_id ⇒ Object (readonly)
Returns the value of attribute process_id.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def process_id @process_id end |
#ssh_forwarder_process_id ⇒ Object (readonly)
Returns the value of attribute ssh_forwarder_process_id.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def ssh_forwarder_process_id @ssh_forwarder_process_id end |
#ssh_info ⇒ Object (readonly)
Returns the value of attribute ssh_info.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def ssh_info @ssh_info end |
#ssh_port ⇒ Object (readonly)
Returns the value of attribute ssh_port.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def ssh_port @ssh_port end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 7 def state @state end |
Class Method Details
.from_h(attributes) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 44 def self.from_h(attributes) new( machine_id: attributes.fetch("machine_id"), state: attributes.fetch("state"), process_id: attributes["process_id"], ssh_info: attributes["ssh_info"], guest_ssh_info: attributes["guest_ssh_info"], machine_requirements: attributes["machine_requirements"], boot_config: attributes["boot_config"] || attributes["linux_boot_config"], ssh_port: attributes["ssh_port"], ssh_forwarder_process_id: attributes["ssh_forwarder_process_id"] ) end |
.running(machine_id, process_id:, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil, ssh_forwarder_process_id: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 9 def self.running( machine_id, process_id:, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil, ssh_forwarder_process_id: nil ) new( machine_id: machine_id, state: :running, process_id: process_id, ssh_info: ssh_info, guest_ssh_info: guest_ssh_info, machine_requirements: machine_requirements, boot_config: boot_config, ssh_port: ssh_port, ssh_forwarder_process_id: ssh_forwarder_process_id ) end |
.stopped(machine_id, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 32 def self.stopped(machine_id, ssh_info: nil, guest_ssh_info: nil, machine_requirements: nil, boot_config: nil, ssh_port: nil) new( machine_id: machine_id, state: :stopped, ssh_info: ssh_info, guest_ssh_info: guest_ssh_info, machine_requirements: machine_requirements, boot_config: boot_config, ssh_port: ssh_port ) end |
Instance Method Details
#running? ⇒ Boolean
80 81 82 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 80 def running? @state == :running end |
#to_h ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/vagrant_provider_avf/model/machine_metadata.rb', line 84 def to_h { "machine_id" => @machine_id, "state" => @state.to_s, "process_id" => @process_id, "ssh_info" => @ssh_info && stringify_keys(@ssh_info.to_h), "guest_ssh_info" => @guest_ssh_info && stringify_keys(@guest_ssh_info.to_h), "machine_requirements" => @machine_requirements && @machine_requirements.to_h, "boot_config" => @boot_config && @boot_config.to_h, "ssh_port" => @ssh_port, "ssh_forwarder_process_id" => @ssh_forwarder_process_id } end |