Class: Distem::Resource::VIface::VTraffic
- Inherits:
-
Object
- Object
- Distem::Resource::VIface::VTraffic
- Defined in:
- lib/distem/resource/viface.rb
Overview
Abstract representation of virtual network traffic
Defined Under Namespace
Instance Attribute Summary (collapse)
-
- (Object) direction
readonly
The direction of this VTraffic.
-
- (Object) properties
readonly
The properties that are describing this VTraffic.
-
- (Object) viface
readonly
The VIface associated to this VTraffic.
Instance Method Summary (collapse)
-
- (Object) add_properties(properties)
Add new properties to the VTraffic ==== Attributes *
properties
An Array of Property objects. -
- (Object) add_property(prop)
Add a new property to the VTraffic ==== Attributes *
prop
The Property object. -
- (Object) get_property(typename)
Get a Property specifying it's type ==== Attributes *
typename
The name of the type, e.g. -
- (VTraffic) initialize(viface, direction, properties = {})
constructor
Create a new VTraffic ==== Attributes *
direction
The direction of this VTraffic (“INPUT” or “OUTPUT”, see Direction class) *viface
The VIface associated to this VTraffic *properties
Hash representing the properties in the form { “propertyname” => { prop1 => val, prop2 => val } }, e.g. -
- (Object) parse_properties(hash)
Parse a Hash of properties ==== Attributes *
hash
Hash representing the properties in the form { “propertyname” => { prop1 => val, prop2 => val }, e.g. {“Bandwidth” => { “rate” => “100mbps” } }..
Constructor Details
- (VTraffic) initialize(viface, direction, properties = {})
Create a new VTraffic
Attributes
-
direction
The direction of this VTraffic (“INPUT” or “OUTPUT”, see Direction class) -
viface
The VIface associated to this VTraffic -
properties
Hash representing the properties in the form { “propertyname” => { prop1 => val, prop2 => val } }, e.g. {“Bandwidth” => { “rate” => “100mbps” } }.
46 47 48 49 50 51 |
# File 'lib/distem/resource/viface.rb', line 46 def initialize(viface, direction, properties = {}) @viface = viface @direction = direction @properties = {} parse_properties(properties) end |
Instance Attribute Details
- (Object) direction (readonly)
The direction of this VTraffic
36 37 38 |
# File 'lib/distem/resource/viface.rb', line 36 def direction @direction end |
- (Object) properties (readonly)
The properties that are describing this VTraffic
38 39 40 |
# File 'lib/distem/resource/viface.rb', line 38 def properties @properties end |
- (Object) viface (readonly)
The VIface associated to this VTraffic
34 35 36 |
# File 'lib/distem/resource/viface.rb', line 34 def viface @viface end |
Instance Method Details
- (Object) add_properties(properties)
Add new properties to the VTraffic
Attributes
-
properties
An Array of Property objects
67 68 69 70 |
# File 'lib/distem/resource/viface.rb', line 67 def add_properties(properties) raise unless properties.is_a?(Array) properties.each { |prop| add_property(prop) } end |
- (Object) add_property(prop)
Add a new property to the VTraffic
Attributes
-
prop
The Property object
58 59 60 61 |
# File 'lib/distem/resource/viface.rb', line 58 def add_property(prop) raise unless prop.is_a?(Property) @properties[prop.class.name] = prop end |
- (Object) get_property(typename)
Get a Property specifying it's type
Attributes
-
typename
The name of the type, e.g. “Bandwidth”
76 77 78 |
# File 'lib/distem/resource/viface.rb', line 76 def get_property(typename) return properties[typename] end |
- (Object) parse_properties(hash)
Parse a Hash of properties
Attributes
-
hash
Hash representing the properties in the form { “propertyname” => { prop1 => val, prop2 => val }, e.g. {“Bandwidth” => { “rate” => “100mbps” } }.
83 84 85 86 |
# File 'lib/distem/resource/viface.rb', line 83 def parse_properties(hash) add_property(Bandwidth.new(hash['bandwidth'])) if hash['bandwidth'] add_property(Latency.new(hash['latency'])) if hash['latency'] end |