Class: ConfigBuilder::Model::VM

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigBuilder::ModelDelegator

#eval_models, included, #model_delegators

Methods inherited from Base

#attrs=, #call, def_model_attribute, model_attributes, new_from_hash

Constructor Details

#initializeVM

Returns a new instance of VM.



158
159
160
161
162
163
164
165
166
# File 'lib/config_builder/model/vm.rb', line 158

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

Instance Attribute Details

#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.



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

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).



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

def_model_attribute :box_check_update

#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.



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

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.



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

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.



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

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.



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

def_model_attribute :box_download_insecure

#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".



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

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.



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

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



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

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



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

def_model_delegator :forwarded_ports

#guestString

Returns The guest type to use for this VM.

Returns:

  • (String)

    The guest type to use for this VM



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

def_model_attribute :guest

#hostnameString

Returns The hostname the machine should have.

Returns:

  • (String)

    The hostname the machine should have.



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

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



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

def_model_attribute :name

#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.



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

def_model_delegator :private_networks

#providerHash<Symbol, Object>

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



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

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.



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

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



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

def_model_delegator :provisioners

#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>>)


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

def_model_delegator :synced_folders

Instance Method Details

#to_procObject



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/config_builder/model/vm.rb', line 168

def to_proc
  Proc.new do |global_config|
    global_config.vm.define(attr(:name)) do |config|
      vm_config = config.vm

      with_attr(:box)                        { |val| vm_config.box = val }
      with_attr(:box_url)                    { |val| vm_config.box_url = val }
      with_attr(:box_download_checksum)      { |val| vm_config.box_download_checksum = val }
      with_attr(:box_download_checksum_type) { |val| vm_config.box_download_checksum_type = val }
      with_attr(:box_download_client_cert)   { |val| vm_config.box_download_client_cert = val }
      with_attr(:box_download_insecure)      { |val| vm_config.box_download_insecure = val }
      with_attr(:box_check_update)           { |val| vm_config.box_check_update = val }
      with_attr(:box_version)                { |val| vm_config.box_version = val }

      with_attr(:hostname) { |val| vm_config.hostname = attr(:hostname) }
      with_attr(:guest)    { |val| vm_config.guest    = attr(:guest)    }

      with_attr(:communicator) { |val| vm_config.communicator = attr(:communicator) }

      eval_models(vm_config)
    end
  end
end