Class: Network
- Inherits:
-
Object
- Object
- Network
- Defined in:
- lib/rbvppc/network.rb
Overview
Authors: Christopher M Wood (<[email protected]>) John F Hutchinson (<[email protected]) © Copyright IBM Corporation 2015.
LICENSE: MIT (opensource.org/licenses/MIT)
Instance Attribute Summary collapse
-
#dns ⇒ Object
Returns the value of attribute dns.
-
#gateway ⇒ Object
Returns the value of attribute gateway.
-
#given_name ⇒ Object
Returns the value of attribute given_name.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#is_primary ⇒ Object
Returns the value of attribute is_primary.
-
#subnet_mask ⇒ Object
Returns the value of attribute subnet_mask.
-
#vlan_id ⇒ Object
Returns the value of attribute vlan_id.
Instance Method Summary collapse
-
#initialize(options_hash) ⇒ Network
constructor
A new instance of Network.
- #update_dns(new_dns, old_dns = nil) ⇒ Object
- #update_gateway(new_gateway) ⇒ Object
- #update_given_name(new_name) ⇒ Object
Constructor Details
#initialize(options_hash) ⇒ Network
Returns a new instance of Network.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rbvppc/network.rb', line 11 def initialize() #Test for the explicitly required parameters raise StandardError.new("A Network cannot be defined without a IP Address") if [:ip_address].nil? raise StandardError.new("A Network cannot be defined without a Subnet Mask") if [:subnet_mask].nil? raise StandardError.new("A Network cannot be defined without specifying if it is the primary network or not") if [:is_primary].nil? or ([:is_primary] != "false" and [:is_primary] != "true") raise StandardError.new("A Network cannot be defined without specifying a VLAN ID") if [:vlan_id].nil? #Test for optional parameters warn ("Warning: Gateway not defined") if [:gateway].nil? warn ("Warning: DNS not defined") if [:dns].nil? warn ("Warning: Given Name not defined") if [:given_name].nil? #Parameters @ip_address = [:ip_address] @is_primary = [:is_primary] @subnet_mask = [:subnet_mask] @gateway = [:gateway] @dns = [:dns] @given_name = [:given_name] @vlan_id = [:vlan_id] end |
Instance Attribute Details
#dns ⇒ Object
Returns the value of attribute dns.
9 10 11 |
# File 'lib/rbvppc/network.rb', line 9 def dns @dns end |
#gateway ⇒ Object
Returns the value of attribute gateway.
9 10 11 |
# File 'lib/rbvppc/network.rb', line 9 def gateway @gateway end |
#given_name ⇒ Object
Returns the value of attribute given_name.
9 10 11 |
# File 'lib/rbvppc/network.rb', line 9 def given_name @given_name end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
9 10 11 |
# File 'lib/rbvppc/network.rb', line 9 def ip_address @ip_address end |
#is_primary ⇒ Object
Returns the value of attribute is_primary.
9 10 11 |
# File 'lib/rbvppc/network.rb', line 9 def is_primary @is_primary end |
#subnet_mask ⇒ Object
Returns the value of attribute subnet_mask.
9 10 11 |
# File 'lib/rbvppc/network.rb', line 9 def subnet_mask @subnet_mask end |
#vlan_id ⇒ Object
Returns the value of attribute vlan_id.
9 10 11 |
# File 'lib/rbvppc/network.rb', line 9 def vlan_id @vlan_id end |
Instance Method Details
#update_dns(new_dns, old_dns = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rbvppc/network.rb', line 33 def update_dns(new_dns,old_dns=nil) if old_dns.nil? if new_dns.is_array? @dns = new_dns else @dns = [new_dns] end else #find index of old_entry in @dns i = @dns.index(old_dns) @dns[i] = new_entry end end |
#update_gateway(new_gateway) ⇒ Object
47 48 49 |
# File 'lib/rbvppc/network.rb', line 47 def update_gateway(new_gateway) @gateway = new_gateway end |
#update_given_name(new_name) ⇒ Object
51 52 53 |
# File 'lib/rbvppc/network.rb', line 51 def update_given_name(new_name) @vlan_id = new_name end |