Class: VagrantPlugins::Parallels::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Parallels::Config
- Defined in:
- lib/vagrant-parallels/config.rb
Instance Attribute Summary collapse
-
#check_guest_tools ⇒ Object
Returns the value of attribute check_guest_tools.
-
#customizations ⇒ Object
readonly
Returns the value of attribute customizations.
-
#destroy_unused_network_interfaces ⇒ Object
Returns the value of attribute destroy_unused_network_interfaces.
-
#functional_psf ⇒ Object
Returns the value of attribute functional_psf.
-
#linked_clone ⇒ Object
Returns the value of attribute linked_clone.
-
#linked_clone_snapshot ⇒ Object
Returns the value of attribute linked_clone_snapshot.
-
#name ⇒ Object
Returns the value of attribute name.
-
#network_adapters ⇒ Object
readonly
Returns the value of attribute network_adapters.
-
#optimize_power_consumption ⇒ Object
Returns the value of attribute optimize_power_consumption.
-
#regen_src_uuid ⇒ Object
Returns the value of attribute regen_src_uuid.
-
#update_guest_tools ⇒ Object
Returns the value of attribute update_guest_tools.
Instance Method Summary collapse
- #cpus=(count) ⇒ Object
- #customize(*command) ⇒ Object
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #memory=(size) ⇒ Object
- #merge(other) ⇒ Object
- #network_adapter(slot, type, **opts) ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-parallels/config.rb', line 19 def initialize @check_guest_tools = UNSET_VALUE @customizations = [] @destroy_unused_network_interfaces = UNSET_VALUE @functional_psf = UNSET_VALUE @linked_clone = UNSET_VALUE @linked_clone_snapshot = UNSET_VALUE @network_adapters = {} @name = UNSET_VALUE @regen_src_uuid = UNSET_VALUE @update_guest_tools = UNSET_VALUE network_adapter(0, :shared) end |
Instance Attribute Details
#check_guest_tools ⇒ Object
Returns the value of attribute check_guest_tools.
4 5 6 |
# File 'lib/vagrant-parallels/config.rb', line 4 def check_guest_tools @check_guest_tools end |
#customizations ⇒ Object (readonly)
Returns the value of attribute customizations.
5 6 7 |
# File 'lib/vagrant-parallels/config.rb', line 5 def customizations @customizations end |
#destroy_unused_network_interfaces ⇒ Object
Returns the value of attribute destroy_unused_network_interfaces.
6 7 8 |
# File 'lib/vagrant-parallels/config.rb', line 6 def destroy_unused_network_interfaces @destroy_unused_network_interfaces end |
#functional_psf ⇒ Object
Returns the value of attribute functional_psf.
7 8 9 |
# File 'lib/vagrant-parallels/config.rb', line 7 def functional_psf @functional_psf end |
#linked_clone ⇒ Object
Returns the value of attribute linked_clone.
9 10 11 |
# File 'lib/vagrant-parallels/config.rb', line 9 def linked_clone @linked_clone end |
#linked_clone_snapshot ⇒ Object
Returns the value of attribute linked_clone_snapshot.
10 11 12 |
# File 'lib/vagrant-parallels/config.rb', line 10 def linked_clone_snapshot @linked_clone_snapshot end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/vagrant-parallels/config.rb', line 11 def name @name end |
#network_adapters ⇒ Object (readonly)
Returns the value of attribute network_adapters.
12 13 14 |
# File 'lib/vagrant-parallels/config.rb', line 12 def network_adapters @network_adapters end |
#optimize_power_consumption ⇒ Object
Returns the value of attribute optimize_power_consumption.
8 9 10 |
# File 'lib/vagrant-parallels/config.rb', line 8 def optimize_power_consumption @optimize_power_consumption end |
#regen_src_uuid ⇒ Object
Returns the value of attribute regen_src_uuid.
13 14 15 |
# File 'lib/vagrant-parallels/config.rb', line 13 def regen_src_uuid @regen_src_uuid end |
#update_guest_tools ⇒ Object
Returns the value of attribute update_guest_tools.
14 15 16 |
# File 'lib/vagrant-parallels/config.rb', line 14 def update_guest_tools @update_guest_tools end |
Instance Method Details
#cpus=(count) ⇒ Object
49 50 51 |
# File 'lib/vagrant-parallels/config.rb', line 49 def cpus=(count) customize('pre-boot', ['set', :id, '--cpus', count.to_i]) end |
#customize(*command) ⇒ Object
34 35 36 37 38 |
# File 'lib/vagrant-parallels/config.rb', line 34 def customize(*command) event = command.first.is_a?(String) ? command.shift : 'pre-boot' command = command[0] @customizations << [event, command] end |
#finalize! ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/vagrant-parallels/config.rb', line 61 def finalize! if @check_guest_tools == UNSET_VALUE @check_guest_tools = true end if @destroy_unused_network_interfaces == UNSET_VALUE @destroy_unused_network_interfaces = true end if @functional_psf == UNSET_VALUE @functional_psf = true end @linked_clone = true if @linked_clone == UNSET_VALUE @linked_clone_snapshot = nil if @linked_clone_snapshot == UNSET_VALUE @name = nil if @name == UNSET_VALUE @regen_src_uuid = true if @regen_src_uuid == UNSET_VALUE if @update_guest_tools == UNSET_VALUE @update_guest_tools = false end end |
#memory=(size) ⇒ Object
45 46 47 |
# File 'lib/vagrant-parallels/config.rb', line 45 def memory=(size) customize('pre-boot', ['set', :id, '--memsize', size.to_s]) end |
#merge(other) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/vagrant-parallels/config.rb', line 53 def merge(other) super.tap do |result| c = customizations.dup c += other.customizations result.instance_variable_set(:@customizations, c) end end |
#network_adapter(slot, type, **opts) ⇒ Object
40 41 42 |
# File 'lib/vagrant-parallels/config.rb', line 40 def network_adapter(slot, type, **opts) @network_adapters[slot] = [type, opts] end |
#validate(machine) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/vagrant-parallels/config.rb', line 86 def validate(machine) errors = _detected_errors valid_events = ['pre-import', 'post-import', 'pre-boot', 'post-boot', 'post-comm'] @customizations.each do |event, _| if !valid_events.include?(event) errors << I18n.t('vagrant_parallels.config.invalid_event', event: event.to_s, valid_events: valid_events.join(', ')) end end @customizations.each do |event, command| if event == 'pre-import' && command.index(:id) errors << I18n.t('vagrant_parallels.config.id_in_pre_import') end end { 'Parallels Provider' => errors } end |