Sha256: 37a965ee3563ccff1b69a0f75d5497c4c77d00c980ab66a753761909a8477ae3

Contents?: true

Size: 528 Bytes

Versions: 4

Compression:

Stored size: 528 Bytes

Contents

# -*- coding: utf-8 -*-

module Dcmgr::Models
  # MAC address lease information
  class MacLease < BaseNew

    inheritable_schema do
      String :mac_addr, :size=>12, :fixed=>true, :null=>false
      
      index :mac_addr, {:unique=>true}
    end
    with_timestamps

    # dynamically assign new MAC address.
    def self.lease(vendor_id='00ff01')
      begin
        m = vendor_id + ("%02x%02x%02x" % [rand(0xff),rand(0xff),rand(0xff)])
      end while self.find(:mac_addr=> m)
      create(:mac_addr=>m)
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
wakame-vdc-agents-11.06.0 lib/dcmgr/models/mac_lease.rb
wakame-vdc-dcmgr-11.06.0 lib/dcmgr/models/mac_lease.rb
wakame-vdc-dcmgr-10.12.0 lib/dcmgr/models/mac_lease.rb
wakame-vdc-agents-10.12.0 lib/dcmgr/models/mac_lease.rb