Class: OpenNebula::VirtualNetwork

Inherits:
Object
  • Object
show all
Defined in:
service/objects/vn.rb

Overview

Extensions for OpenNebula::VirtualNetwork

Instance Method Summary collapse

Instance Method Details

#ar_poolArray<Hash>

Returns Address Range pool

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'service/objects/vn.rb', line 39

def ar_pool
  info!
  pool = to_hash['VNET']['AR_POOL']['AR']
  if pool.class == Hash then
    return [pool]
  elsif pool.nil? then
    return []
  else
    return pool
  end
rescue
  return []
end

#ar_record(ar_id, per) ⇒ String|Symbol, Float

Calculate amount of Public Addresses and bill them with `PUBLIC_IP_COST`

Parameters:

  • ar (Integer)
    • AddressRange ID

  • per (Integer)
    • Billing periods amount

Returns:

  • (String|Symbol, Float)
    • IP address or note and its cost



57
58
59
60
61
62
63
64
65
66
67
# File 'service/objects/vn.rb', line 57

def ar_record(ar_id, per)
  info!
  ar = ar_pool.select { |o| o['AR_ID'].to_i == ar_id.to_i }.first
  if ar.nil? && per > 0 then
    return :deleted_ip, per * IONe::Settings['PUBLIC_IP_COST']
  elsif ar.nil? then
    return :trash, 0
  else
    return ar['IP'], per * IONe::Settings['PUBLIC_IP_COST']
  end
end

#typeString

Returns Network Type: Private or Public

Returns:



30
31
32
# File 'service/objects/vn.rb', line 30

def type
  info! || self['TEMPLATE/TYPE']
end