Class: VagrantPlugins::ProviderVeertu::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderVeertu::Config
- Defined in:
- lib/vagrant-veertu/config.rb
Instance Attribute Summary collapse
-
#auto_nat_dns_proxy ⇒ Boolean
Vagrant by default will make “smart” decisions to enable/disable the NAT DNS proxy.
-
#check_guest_additions ⇒ Boolean
If true, will check if guest additions are installed and up to date.
-
#customizations ⇒ Array
readonly
An array of customizations to make on the VM prior to booting it.
-
#destroy_unused_network_interfaces ⇒ Boolean
If true, unused network interfaces will automatically be deleted.
-
#functional_veertusf ⇒ Boolean
Whether or not this VM has a functional veertusf filesystem module.
-
#gui ⇒ Boolean
If set to ‘true`, then Veertu will be launched with a GUI.
-
#linked_clone ⇒ Boolean
If set to ‘true`, then a linked clone is created from a master VM generated from the specified box.
-
#linked_clone_snapshot ⇒ String
The snapshot to base the linked clone from.
-
#name ⇒ String
This should be set to the name of the machine in the Veertu GUI.
-
#network_adapters ⇒ Hash
readonly
The defined network adapters.
Instance Method Summary collapse
-
#cpus=(count) ⇒ Object
Shortcut for setting CPU count for the virtual machine.
-
#customize(*command) ⇒ Object
Customize the VM by calling ‘VeertuManage` with the given arguments.
-
#finalize! ⇒ Object
This is the hook that is called to finalize the object before it is put into use.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#memory=(size) ⇒ Object
Shortcut for setting memory size for the virtual machine.
- #merge(other) ⇒ Object
-
#network_adapter(slot, type, **opts) ⇒ Object
This defines a network adapter that will be added to the Veertu virtual machine in the given slot.
- #to_s ⇒ Object
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/vagrant-veertu/config.rb', line 68 def initialize @auto_nat_dns_proxy = UNSET_VALUE @check_guest_additions = UNSET_VALUE @customizations = [] @destroy_unused_network_interfaces = UNSET_VALUE @functional_veertusf = false @name = UNSET_VALUE @network_adapters = {} @gui = UNSET_VALUE @linked_clone = UNSET_VALUE @linked_clone_snapshot = UNSET_VALUE # We require that network adapter 1 is a NAT device. network_adapter(1, :nat) end |
Instance Attribute Details
#auto_nat_dns_proxy ⇒ Boolean
Vagrant by default will make “smart” decisions to enable/disable the NAT DNS proxy. If this is set to ‘true`, then the DNS proxy will not be enabled, and it is up to the end user to do it.
10 11 12 |
# File 'lib/vagrant-veertu/config.rb', line 10 def auto_nat_dns_proxy @auto_nat_dns_proxy end |
#check_guest_additions ⇒ Boolean
If true, will check if guest additions are installed and up to date. By default, this is true.
16 17 18 |
# File 'lib/vagrant-veertu/config.rb', line 16 def check_guest_additions @check_guest_additions end |
#customizations ⇒ Array (readonly)
An array of customizations to make on the VM prior to booting it.
21 22 23 |
# File 'lib/vagrant-veertu/config.rb', line 21 def customizations @customizations end |
#destroy_unused_network_interfaces ⇒ Boolean
If true, unused network interfaces will automatically be deleted. This defaults to false because the detection does not work across multiple users, and because on Windows this operation requires administrative privileges.
29 30 31 |
# File 'lib/vagrant-veertu/config.rb', line 29 def destroy_unused_network_interfaces @destroy_unused_network_interfaces end |
#functional_veertusf ⇒ Boolean
Whether or not this VM has a functional veertusf filesystem module. This defaults to true. If you set this to false, then the “veertu” synced folder type won’t be valid.
61 62 63 |
# File 'lib/vagrant-veertu/config.rb', line 61 def functional_veertusf @functional_veertusf end |
#gui ⇒ Boolean
If set to ‘true`, then Veertu will be launched with a GUI.
34 35 36 |
# File 'lib/vagrant-veertu/config.rb', line 34 def gui @gui end |
#linked_clone ⇒ Boolean
If set to ‘true`, then a linked clone is created from a master VM generated from the specified box.
40 41 42 |
# File 'lib/vagrant-veertu/config.rb', line 40 def linked_clone @linked_clone end |
#linked_clone_snapshot ⇒ String
The snapshot to base the linked clone from. If this isn’t set a snapshot will be made with the name of “base” which will be used.
If this is set, then the snapshot must already exist.
48 49 50 |
# File 'lib/vagrant-veertu/config.rb', line 48 def linked_clone_snapshot @linked_clone_snapshot end |
#name ⇒ String
This should be set to the name of the machine in the Veertu GUI.
54 55 56 |
# File 'lib/vagrant-veertu/config.rb', line 54 def name @name end |
#network_adapters ⇒ Hash (readonly)
The defined network adapters.
66 67 68 |
# File 'lib/vagrant-veertu/config.rb', line 66 def network_adapters @network_adapters end |
Instance Method Details
#cpus=(count) ⇒ Object
Shortcut for setting CPU count for the virtual machine. Calls #customize internally.
123 124 125 |
# File 'lib/vagrant-veertu/config.rb', line 123 def cpus=(count) customize("pre-boot", ["modify", :id, "set", "--cpu", count.to_i]) end |
#customize(*command) ⇒ Object
Customize the VM by calling ‘VeertuManage` with the given arguments.
When called multiple times, the customizations will be applied in the order given.
The special ‘:name` parameter in the command will be replaced with the unique ID or name of the virtual machine. This is useful for parameters to `modifyvm` and the like.
VeertuManage.
96 97 98 99 100 |
# File 'lib/vagrant-veertu/config.rb', line 96 def customize(*command) event = command.first.is_a?(String) ? command.shift : "pre-boot" command = command[0] @customizations << [event, command] end |
#finalize! ⇒ Object
This is the hook that is called to finalize the object before it is put into use.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/vagrant-veertu/config.rb', line 137 def finalize! # Default is to auto the DNS proxy @auto_nat_dns_proxy = true if @auto_nat_dns_proxy == UNSET_VALUE if @check_guest_additions == UNSET_VALUE @check_guest_additions = true end if @destroy_unused_network_interfaces == UNSET_VALUE @destroy_unused_network_interfaces = false end if @functional_veertusf == UNSET_VALUE @functional_veertusf = true end # Default is to not show a GUI @gui = false if @gui == UNSET_VALUE # Do not create linked clone by default @linked_clone = false if @linked_clone == UNSET_VALUE @linked_clone_snapshot = nil if @linked_clone_snapshot == UNSET_VALUE # The default name is just nothing, and we default it @name = nil if @name == UNSET_VALUE end |
#memory=(size) ⇒ Object
Shortcut for setting memory size for the virtual machine. Calls #customize internally.
115 116 117 |
# File 'lib/vagrant-veertu/config.rb', line 115 def memory=(size) customize("pre-boot", ["modify", :id, "set", "--ram", size.to_s + "MB"]) end |
#merge(other) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/vagrant-veertu/config.rb', line 127 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
This defines a network adapter that will be added to the Veertu virtual machine in the given slot.
107 108 109 |
# File 'lib/vagrant-veertu/config.rb', line 107 def network_adapter(slot, type, **opts) @network_adapters[slot] = [type, opts] end |
#to_s ⇒ Object
194 195 196 |
# File 'lib/vagrant-veertu/config.rb', line 194 def to_s "Veertu" end |
#validate(machine) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/vagrant-veertu/config.rb', line 164 def validate(machine) errors = _detected_errors valid_events = ["pre-import", "pre-boot", "post-boot", "post-comm"] @customizations.each do |event, _| if !valid_events.include?(event) errors << I18n.t( "vagrant.veertu.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.veertu.config.id_in_pre_import") end end # Verify that internal networks are only on private networks. machine.config.vm.networks.each do |type, data| if data[:veertu__intnet] && type != :private_network errors << I18n.t("vagrant.veertu.config.intnet_on_bad_type") break end end { "Veertu Provider" => errors } end |