Class: VLANLease

Inherits:
Object
  • Object
show all
Defined in:
models/VLANManager.rb

Overview

Table of VLAN IDs leases Model Class

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_with_meta(id = nil) ⇒ Array<Hash>

Returns all VLANLease or all VLANLease for given VLAN pool if id is given

Parameters:

  • id (Integer) (defaults to: nil)
    • VLAN pool ID

Returns:



57
58
59
60
61
# File 'models/VLANManager.rb', line 57

def self.all_with_meta id = nil
  (id ? VLANLease.where(pool_id: id) : VLANLease).all.map do | vl |
    vl.hash_with_meta
  end
end

Instance Method Details

#hash_with_metaHash

Returns VLANLease as Hash with additional data If VLAN ID is provisioned to VNet, :vn_name key will be added

Returns:



66
67
68
69
70
71
72
# File 'models/VLANManager.rb', line 66

def hash_with_meta
  if vn then
    to_hash.merge(vn_name: $db[:network_pool].where(oid: vn).select(:name).first[:name])
  else
    to_hash
  end
end

#to_json(*args) ⇒ Object

Needed for serialization



50
51
52
# File 'models/VLANManager.rb', line 50

def to_json *args
  @values.without(:key).to_json(*args)
end