Class: ConfigBuilder::Model::VM

Inherits:
Base
  • Object
show all
Defined in:
lib/config_builder/model/vm.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#attr, #attrs=, #call, #configure!, def_model_attribute, def_model_delegator, def_model_id, def_model_option, #eval_models, #instance_id, #instance_options, model_attributes, model_delegators, #model_delegators, model_options, new_from_hash, #with_attr

Constructor Details

#initializeVM

Returns a new instance of VM.



232
233
234
235
236
237
238
239
240
241
242
# File 'lib/config_builder/model/vm.rb', line 232

def initialize
  @defaults = {
    :providers        => [],
    :provisioners     => [],
    :forwarded_ports  => [],
    :private_networks => [],
    :public_networks  => [],
    :synced_folders   => [],
    :autostart        => true,
  }
end

Instance Attribute Details

#allowed_synced_folder_typesArray<String>

Returns:

  • (Array<String>)


104
# File 'lib/config_builder/model/vm.rb', line 104

def_model_attribute :allowed_synced_folder_types

#autostartFixnum

Returns The time in seconds that Vagrant will wait for the machine to boot and be accessible. By default this is 300 seconds.

Returns:

  • (Fixnum)

    The time in seconds that Vagrant will wait for the machine to boot and be accessible. By default this is 300 seconds.



94
# File 'lib/config_builder/model/vm.rb', line 94

def_model_option :autostart

#base_macString

Returns MAC address of the NAT device.

Returns:

  • (String)

    MAC address of the NAT device.



108
# File 'lib/config_builder/model/vm.rb', line 108

def_model_attribute :base_mac

#boxString

Returns This configures what box the machine will be brought up against. The value here should be the name of an installed box or a shorthand name of a box in Vagrant Cloud.

Returns:

  • (String)

    This configures what box the machine will be brought up against. The value here should be the name of an installed box or a shorthand name of a box in Vagrant Cloud.



119
# File 'lib/config_builder/model/vm.rb', line 119

def_model_attribute :box

#box_check_updateBoolean

Returns If true, Vagrant will check for updates to the configured box on every vagrant up. If an update is found, Vagrant will tell the user. By default this is true. Updates will only be checked for boxes that properly support updates (boxes from Vagrant Cloud or some other versioned box).

Returns:

  • (Boolean)

    If true, Vagrant will check for updates to the configured box on every vagrant up. If an update is found, Vagrant will tell the user. By default this is true. Updates will only be checked for boxes that properly support updates (boxes from Vagrant Cloud or some other versioned box).



127
# File 'lib/config_builder/model/vm.rb', line 127

def_model_attribute :box_check_update

#box_download_ca_certString

Returns Path to a CA cert bundle to use when downloading a box directly. By default, Vagrant will use the Mozilla CA cert bundle.

Returns:

  • (String)

    Path to a CA cert bundle to use when downloading a box directly. By default, Vagrant will use the Mozilla CA cert bundle.



158
# File 'lib/config_builder/model/vm.rb', line 158

def_model_attribute :box_download_ca_cert

#box_download_ca_pathString

Returns Path to a directory containing CA certificates for downloading a box directly. By default, Vagrant will use the Mozilla CA cert bundle.

Returns:

  • (String)

    Path to a directory containing CA certificates for downloading a box directly. By default, Vagrant will use the Mozilla CA cert bundle.



164
# File 'lib/config_builder/model/vm.rb', line 164

def_model_attribute :box_download_ca_path

#box_download_checksumString

Returns The checksum of the box specified by box_url. If not specified, no checksum comparison will be done. If specified, Vagrant will compare the checksum of the downloaded box to this value and error if they do not match. Checksum checking is only done when Vagrant must download the box.

If this is specified, then box_download_checksum_type must also be specified.

Returns:

  • (String)

    The checksum of the box specified by box_url. If not specified, no checksum comparison will be done. If specified, Vagrant will compare the checksum of the downloaded box to this value and error if they do not match. Checksum checking is only done when Vagrant must download the box.

    If this is specified, then box_download_checksum_type must also be specified.



175
# File 'lib/config_builder/model/vm.rb', line 175

def_model_attribute :box_download_checksum

#box_download_checksum_typeString

Returns The type of checksum specified by box_download_checksum (if any). Supported values are currently md5, sha1, and sha256.

Returns:

  • (String)

    The type of checksum specified by box_download_checksum (if any). Supported values are currently md5, sha1, and sha256.



181
# File 'lib/config_builder/model/vm.rb', line 181

def_model_attribute :box_download_checksum_type

#box_download_client_certString

Returns Path to a client certificate to use when downloading the box, if it is necessary. By default, no client certificate is used to download the box.

Returns:

  • (String)

    Path to a client certificate to use when downloading the box, if it is necessary. By default, no client certificate is used to download the box.



187
# File 'lib/config_builder/model/vm.rb', line 187

def_model_attribute :box_download_client_cert

#box_download_insecureBoolean

Returns If true, then SSL certificates from the server will not be verified. By default, if the URL is an HTTPS URL, then SSL certs will be verified.

Returns:

  • (Boolean)

    If true, then SSL certificates from the server will not be verified. By default, if the URL is an HTTPS URL, then SSL certs will be verified.



193
# File 'lib/config_builder/model/vm.rb', line 193

def_model_attribute :box_download_insecure

#box_download_location_trustedBoolean

Returns If ´true´, then all HTTP redirects will be treated as trusted. That means credentials used for initial URL will be used for all subsequent redirects. By default, redirect locations are untrusted so credentials (if specified) used only for initial HTTP request.

Returns:

  • (Boolean)

    If ´true´, then all HTTP redirects will be treated as trusted. That means credentials used for initial URL will be used for all subsequent redirects. By default, redirect locations are untrusted so credentials (if specified) used only for initial HTTP request.



200
# File 'lib/config_builder/model/vm.rb', line 200

def_model_attribute :box_download_location_trusted

#box_server_urlString

Returns:

  • (String)


145
# File 'lib/config_builder/model/vm.rb', line 145

def_model_attribute :box_server_url

#box_urlString+

Returns The URL that the configured box can be found at. If box is a shorthand to a box in Vagrant Cloud then this value doesn't need to be specified. Otherwise, it should point to the proper place where the box can be found if it isn't installed.

This can also be an array of multiple URLs. The URLs will be tried in order. Note that any client certificates, insecure download settings, and so on will apply to all URLs in this list.

The URLs can also be local files by using the file:// scheme. For example: "file:///tmp/test.box".

Returns:

  • (String, Array<String>)

    The URL that the configured box can be found at. If box is a shorthand to a box in Vagrant Cloud then this value doesn't need to be specified. Otherwise, it should point to the proper place where the box can be found if it isn't installed.

    This can also be an array of multiple URLs. The URLs will be tried in order. Note that any client certificates, insecure download settings, and so on will apply to all URLs in this list.

    The URLs can also be local files by using the file:// scheme. For example: "file:///tmp/test.box".



141
# File 'lib/config_builder/model/vm.rb', line 141

def_model_attribute :box_url

#box_versionString

Returns The version of the box to use. This defaults to ">= 0" (the latest version available). This can contain an arbitrary list of constraints, separated by commas, such as: >= 1.0, < 1.5. When constraints are given, Vagrant will use the latest available box satisfying these constraints.

Returns:

  • (String)

    The version of the box to use. This defaults to ">= 0" (the latest version available). This can contain an arbitrary list of constraints, separated by commas, such as: >= 1.0, < 1.5. When constraints are given, Vagrant will use the latest available box satisfying these constraints.



153
# File 'lib/config_builder/model/vm.rb', line 153

def_model_attribute :box_version

#communicatorString

commands to this box. Set to 'winrm' for Windows VMs.

Returns:

  • (String)

    The name of the communicator to use when sending



205
# File 'lib/config_builder/model/vm.rb', line 205

def_model_attribute :communicator

#forwarded_portsArray<Hash<Symbol, Object>>

Returns A collection of port mappings.

Examples:

>> vm.forwarded_ports
=> [
      {:guest => 80, :host  => 20080},
      {:guest => 443, :host => 20443},
   ]

Returns:

  • (Array<Hash<Symbol, Object>>)

    A collection of port mappings



51
# File 'lib/config_builder/model/vm.rb', line 51

def_model_delegator :forwarded_ports

#graceful_halt_timeoutFixnum

Returns The time in seconds that Vagrant will wait for the machine.

Returns:

  • (Fixnum)

    The time in seconds that Vagrant will wait for the machine



# File 'lib/config_builder/model/vm.rb', line 207

#guestString

Returns The guest type to use for this VM.

Returns:

  • (String)

    The guest type to use for this VM.



215
# File 'lib/config_builder/model/vm.rb', line 215

def_model_attribute :guest

#hostnameString

Returns The hostname the machine should have.

Returns:

  • (String)

    The hostname the machine should have.



219
# File 'lib/config_builder/model/vm.rb', line 219

def_model_attribute :hostname

#nameString

Returns The name of the instantiated box in this environment.

Returns:

  • (String)

    The name of the instantiated box in this environment.



88
# File 'lib/config_builder/model/vm.rb', line 88

def_model_id :name

#post_up_messageString

Returns A message to show after vagrant up. This will be shown to the user and is useful for containing instructions such as how to access various components of the development environment.

Returns:

  • (String)

    A message to show after vagrant up. This will be shown to the user and is useful for containing instructions such as how to access various components of the development environment.



225
# File 'lib/config_builder/model/vm.rb', line 225

def_model_attribute :post_up_message

#primaryBoolean

a specific machine in a multi-machine environment is not specified. If false, vagrant must be given the box name explicitly for some commands.

Returns:

  • (Boolean)

    If true, the box will be the default machine used when



100
# File 'lib/config_builder/model/vm.rb', line 100

def_model_option :primary

#private_networksArray<Hash<Symbol, Object>>

Returns A collection of IP address network settings.

Examples:

>> vm.private_networks
=> [
      {:ip => '10.20.4.1'},
      {:ip => '192.168.100.5', :netmask => '255.255.255.128'},
   ]

Returns:

  • (Array<Hash<Symbol, Object>>)

    A collection of IP address network settings.



62
# File 'lib/config_builder/model/vm.rb', line 62

def_model_delegator :private_networks

#providerHash<Symbol, Object>

Deprecated.

Use #providers instead.

Returns The provider configuration for this VM.

Examples:

>> vm.provider
=> {
      :type => 'virtualbox',
      :name => 'tiny-tina',
      :gui  => false,
   }

Returns:

  • (Hash<Symbol, Object>)

    The provider configuration for this VM



15
# File 'lib/config_builder/model/vm.rb', line 15

def_model_delegator :provider

#providersArray<Hash{String, Symbol => Object}>

Returns A collection of provider parameters that should be applied to a VM.

Examples:

>> vm.providers
=> [
     {:type => 'virtualbox', :customize => ['modifyvm', :id, '--memory', 1024]},
     {:type => 'vmware_fusion', :vmx => {:memsize => 1024}},
   ]

Returns:

  • (Array<Hash{String, Symbol => Object}>)

    A collection of provider parameters that should be applied to a VM.



26
# File 'lib/config_builder/model/vm.rb', line 26

def_model_delegator :providers

#provisionersArray<Hash<Symbol, Object>>

Returns A collection of provisioner parameters in the order that they should be applied of provisioner types, and a list of provisioner instances for each type.

Examples:

>> vm.provisioners
=> [
      {:type => :shell, :path   => '/vagrant/bin/magic.sh'},
      {:type => :shell, :inline => '/bin/echo hello world'},

      {:type => :puppet, :manifest => 'foo.pp'},
      {:type => :puppet, :manifest => 'bar.pp', :modulepath => '/vagrant/modules'},
   ]

Returns:

  • (Array<Hash<Symbol, Object>>)

    A collection of provisioner parameters in the order that they should be applied of provisioner types, and a list of provisioner instances for each type



41
# File 'lib/config_builder/model/vm.rb', line 41

def_model_delegator :provisioners

#public_networksArray<Hash<Symbol, Object>>

Returns A collection of IP address network settings.

Examples:

>> vm.public_networks
=> [
      {:ip => '10.20.4.1'},
      {:bridge: "en1: Wi-Fi (AirPort)"},
   ]

Returns:

  • (Array<Hash<Symbol, Object>>)

    A collection of IP address network settings.



73
# File 'lib/config_builder/model/vm.rb', line 73

def_model_delegator :public_networks

#synced_foldersArray<Hash<Symbol, Object>>

Examples:

>> vm.synced_folders
=> [
      {:host_path => 'manifests/', :guest_path => '/root/manifests', :disabled => false},
      {:host_path => 'modules/', :guest_path => '/root/modules'},
   ]

Returns:

  • (Array<Hash<Symbol, Object>>)


84
# File 'lib/config_builder/model/vm.rb', line 84

def_model_delegator :synced_folders

#usable_port_rangeString

Returns A range of ports Vagrant can use for handling port collisions and such. Defaults to 2200..2250.

Returns:

  • (String)

    A range of ports Vagrant can use for handling port collisions and such. Defaults to 2200..2250.



230
# File 'lib/config_builder/model/vm.rb', line 230

def_model_attribute :usable_port_range

Instance Method Details

#configure_usable_port_range(config, val) ⇒ Object



255
256
257
# File 'lib/config_builder/model/vm.rb', line 255

def configure_usable_port_range(config, val)
  config.usable_port_range = Range.new(*val.split('..').map(&:to_i))
end

#to_procObject



244
245
246
247
248
249
250
251
# File 'lib/config_builder/model/vm.rb', line 244

def to_proc
  Proc.new do |config|
    vm_config = config.vm

    configure!(vm_config)
    eval_models(vm_config)
  end
end