Sha256: 943cca67235f1b2c87e46eb34df5f97766d2fd0705953184bde0a24f64b78c8c

Contents?: true

Size: 669 Bytes

Versions: 16

Compression:

Stored size: 669 Bytes

Contents

require 'mkit/status'
require 'mkit/exceptions'
require 'mkit/app/helpers/interface_helper'

class Lease < ActiveRecord::Base
  belongs_to :pool
  belongs_to :service

  before_destroy :down

  def confirm
    self.status = MKIt::PoolStatus::IN_USE
  end

  def up
    MKIt::InterfaceHelper.create(name: interface_name, ctype: interface_type)
    MKIt::InterfaceHelper.up(name: interface_name, ip: ip, mask: pool.netmask)
    self.status = MKIt::PoolStatus::IN_USE
  end

  def down
    MKIt::InterfaceHelper.down(name: interface_name)
    MKIt::InterfaceHelper.remove(name: interface_name, ctype: interface_type)
    self.status = MKIt::PoolStatus::RESERVED
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mkit-0.9.0 lib/mkit/app/model/lease.rb
mkit-0.8.0 lib/mkit/app/model/lease.rb
mkit-0.7.2 lib/mkit/app/model/lease.rb
mkit-0.7.1 lib/mkit/app/model/lease.rb
mkit-0.7.0 lib/mkit/app/model/lease.rb
mkit-0.6.3 lib/mkit/app/model/lease.rb
mkit-0.6.2 lib/mkit/app/model/lease.rb
mkit-0.6.1 lib/mkit/app/model/lease.rb
mkit-0.6.0 lib/mkit/app/model/lease.rb
mkit-0.5.0 lib/mkit/app/model/lease.rb
mkit-0.4.3 lib/mkit/app/model/lease.rb
mkit-0.4.2 lib/mkit/app/model/lease.rb
mkit-0.4.1 lib/mkit/app/model/lease.rb
mkit-0.4.0 lib/mkit/app/model/lease.rb
mkit-0.3.0 lib/mkit/app/model/lease.rb
mkit-0.2.0 lib/mkit/app/model/lease.rb