Class: Distem::Resource::VRoute

Inherits:
Object
  • Object
show all
Defined in:
lib/distem/resource/vroute.rb

Overview

Abstract representation of a virtual route used to link two virtual networks

Constant Summary

@@ids =
0

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (VRoute) initialize(srcnet, dstnet, gwaddr)

Create a new VRoute

Attributes

  • srcnet The source VNetwork object

  • dstnet The destination VNetwork object

  • gwaddr The IPAddress object describing the IP address of the VNode/VIface used to get from source to destination



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/distem/resource/vroute.rb', line 22

def initialize(srcnet,dstnet,gwaddr)
  raise unless srcnet.is_a?(VNetwork)
  raise unless dstnet.is_a?(VNetwork)
  raise unless gwaddr.is_a?(IPAddress)
  raise Lib::InvalidParameterError, gwaddr.to_string \
    unless srcnet.address.include?(gwaddr)

  @srcnet = srcnet
  @dstnet = dstnet
  @gw = gwaddr
  @id = @@ids
  @@ids += 1
end

Instance Attribute Details

- (Object) dstnet (readonly)

The destination VNetwork



10
11
12
# File 'lib/distem/resource/vroute.rb', line 10

def dstnet
  @dstnet
end

- (Object) gw (readonly)

The IPAddress object describing the IP address of the VNode/VIface used to get from source to destination



12
13
14
# File 'lib/distem/resource/vroute.rb', line 12

def gw
  @gw
end

- (Object) id (readonly)

The unique identifier of the virtual route



14
15
16
# File 'lib/distem/resource/vroute.rb', line 14

def id
  @id
end

- (Object) srcnet (readonly)

The source VNetwork



8
9
10
# File 'lib/distem/resource/vroute.rb', line 8

def srcnet
  @srcnet
end

Instance Method Details

- (Object) ==(vroute)

Compares two virtual routes

Returns

Boolean value



40
41
42
43
# File 'lib/distem/resource/vroute.rb', line 40

def ==(vroute)
  vroute.is_a?(VRoute) and (@srcnet == vroute.srcnet) \
    and (@dstnet == vroute.dstnet) # and (@gw == vroute.gw)
end

- (Object) to_s



45
46
47
# File 'lib/distem/resource/vroute.rb', line 45

def to_s()
  return "#{@srcnet.address.to_string} to #{@dstnet.address.to_string} via #{@gw.to_s}"
end