Sha256: 07d4ce314759d163034abdb2f3fd71ffe50e2a0cf098ad19c3b6485e1732d580

Contents?: true

Size: 861 Bytes

Versions: 3

Compression:

Stored size: 861 Bytes

Contents

module VagrantPlugins
  module Parallels
    module Action
      class MatchMACAddress
        def initialize(app, env)
          @app = app
        end

        def call(env)
          raise Vagrant::Errors::VMBaseMacNotSpecified if !env[:machine].config.vm.base_mac

          env[:ui].info I18n.t("vagrant_parallels.actions.vm.match_mac.matching")

          base_mac = env[:machine].config.vm.base_mac
          # Generate new base mac if the specified address is already in use
          if env[:machine].provider.driver.mac_in_use?(base_mac)
            env[:ui].info I18n.t("vagrant_parallels.actions.vm.match_mac.generate")
            env[:machine].provider.driver.set_mac_address('auto')
          else
            env[:machine].provider.driver.set_mac_address(base_mac)
          end

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-parallels-0.2.1 lib/vagrant-parallels/action/match_mac_address.rb
vagrant-parallels-0.2.0 lib/vagrant-parallels/action/match_mac_address.rb
vagrant-parallels-0.1.3 lib/vagrant-parallels/action/match_mac_address.rb