plugins/kernel_v2/config/vm.rb
# Custom merge method since some keys here are merged differently.
Custom merge method since some keys here are merged differently.
Custom merge method since some keys here are merged differently .
def merge(other)
        super.tap do |result|
          other_networks = other.instance_variable_get(:@__networks)
          result.instance_variable_set(:@__networks, @__networks.merge(other_networks))
          other_defined_vm_keys = other.instance_variable_get(:@__defined_vm_keys)
          other_defined_vm_keys -= @__defined_vm_keys
          new_defined_vm_keys   = @__defined_vm_keys + other_defined_vm_keys
          other_defined_vms = other.instance_variable_get(:@__defined_vms)
          new_defined_vms   = {}
          @__defined_vms.each do |key, subvm|
            new_defined_vms[key] = subvm.clone
          end
          other_defined_vms.each do |key, subvm|
            if !new_defined_vms.has_key?(key)
              new_defined_vms[key] = subvm.clone
            else
              new_defined_vms[key].config_procs.concat(subvm.config_procs)
              new_defined_vms[key].options.merge!(subvm.options)
            end
          end
          other_providers = other.instance_variable_get(:@__providers)
          new_providers   = @__providers.dup
          other_providers.each do |key, blocks|
            new_providers[key] ||= []
            new_providers[key] += blocks
          end
          other_overrides = other.instance_variable_get(:@__provider_overrides)
          new_overrides   = @__provider_overrides.dup
          other_overrides.each do |key, blocks|
            new_overrides[key] ||= []
            new_overrides[key] += blocks
          end
          new_provs   = []
          other_provs = other.provisioners.dup
          @provisioners.each do |p|
            if p.id
              other_p = other_provs.find { |o| p.id == o.id }
              if other_p
                other_p.config = p.config.merge(other_p.config)
                next if !other_p.preserve_order
                p = other_p
                other_provs.delete(other_p)
              end
            end
            new_provs << p.dup
          end
          other_provs.each do |p|
            new_provs << p.dup
          end
          result.instance_variable_set(:@provisioners, new_provs)
          other_folders = other.instance_variable_get(:@__synced_folders)
          new_folders = {}
          @__synced_folders.each do |key, value|
            new_folders[key] = value.dup
          end
          other_folders.each do |id, options|
            new_folders[id] ||= {}
            new_folders[id].merge!(options)
          end
          result.instance_variable_set(:@__defined_vm_keys, new_defined_vm_keys)
          result.instance_variable_set(:@__defined_vms, new_defined_vms)
          result.instance_variable_set(:@__providers, new_providers)
          result.instance_variable_set(:@__provider_overrides, new_overrides)
          result.instance_variable_set(:@__synced_folders, new_folders)
        end
      end
def merge ( other ) super . tap do | result | other_networks = other . instance_variable_get ( :@__networks ) result . instance_variable_set ( :@__networks , @__networks . merge ( other_networks ) ) other_defined_vm_keys = other . instance_variable_get ( :@__defined_vm_keys ) other_defined_vm_keys -= @__defined_vm_keys new_defined_vm_keys = @__defined_vm_keys + other_defined_vm_keys other_defined_vms = other . instance_variable_get ( :@__defined_vms ) new_defined_vms = { } @__defined_vms . each do | key , subvm | new_defined_vms [ key ] = subvm . clone end other_defined_vms . each do | key , subvm | if ! new_defined_vms . has_key? ( key ) new_defined_vms [ key ] = subvm . clone else new_defined_vms [ key ] . config_procs . concat ( subvm . config_procs ) new_defined_vms [ key ] . options . merge! ( subvm . options ) end end other_providers = other . instance_variable_get ( :@__providers ) new_providers = @__providers . dup other_providers . each do | key , blocks | new_providers [ key ] ||= [ ] new_providers [ key ] += blocks end other_overrides = other . instance_variable_get ( :@__provider_overrides ) new_overrides = @__provider_overrides . dup other_overrides . each do | key , blocks | new_overrides [ key ] ||= [ ] new_overrides [ key ] += blocks end new_provs = [ ] other_provs = other . provisioners . dup @provisioners . each do | p | if p . id other_p = other_provs . find { | o | p . id == o . id } if other_p other_p . config = p . config . merge ( other_p . config ) next if ! other_p . preserve_order p = other_p other_provs . delete ( other_p ) end end new_provs << p . dup end other_provs . each do | p | new_provs << p . dup end result . instance_variable_set ( :@provisioners , new_provs ) other_folders = other . instance_variable_get ( :@__synced_folders ) new_folders = { } @__synced_folders . each do | key , value | new_folders [ key ] = value . dup end other_folders . each do | id , options | new_folders [ id ] ||= { } new_folders [ id ] . merge! ( options ) end result . instance_variable_set ( :@__defined_vm_keys , new_defined_vm_keys ) result . instance_variable_set ( :@__defined_vms , new_defined_vms ) result . instance_variable_set ( :@__providers , new_providers ) result . instance_variable_set ( :@__provider_overrides , new_overrides ) result . instance_variable_set ( :@__synced_folders , new_folders ) end end
Custom merge method since some keys here are merged differently.
Custom merge method since some keys here are merged differently .
# Merge defined VMs by first merging the defined VM keys, # preserving the order in which they were defined. # Merge the actual defined VMs. # Merge the providers by prepending any configuration blocks we # have for providers onto the new configuration. # Merge the provider overrides by appending them... # Merge provisioners. First we deal with overrides and making # sure the ordering is good there. Then we merge them. # There is an override. Take it. # We're preserving order, delete from other # There is an override, merge it into the # Merge synced folders.
other
<not_specific>