class Network
Authors: Christopher M Wood (<woodc@us.ibm.com>)
John F Hutchinson (<jfhutchi@us.ibm.com)
© Copyright IBM Corporation 2015.
LICENSE: MIT (opensource.org/licenses/MIT)
Attributes
dns[RW]
gateway[RW]
given_name[RW]
ip_address[RW]
is_primary[RW]
subnet_mask[RW]
vlan_id[RW]
Public Class Methods
new(options_hash)
click to toggle source
# File lib/rbvppc/network.rb, line 11 def initialize(options_hash) #Test for the explicitly required parameters raise StandardError.new("A Network cannot be defined without a IP Address") if options_hash[:ip_address].nil? raise StandardError.new("A Network cannot be defined without a Subnet Mask") if options_hash[:subnet_mask].nil? raise StandardError.new("A Network cannot be defined without specifying if it is the primary network or not") if options_hash[:is_primary].nil? or (options_hash[:is_primary] != "false" and options_hash[:is_primary] != "true") raise StandardError.new("A Network cannot be defined without specifying a VLAN ID") if options_hash[:vlan_id].nil? #Test for optional parameters warn ("Warning: Gateway not defined") if options_hash[:gateway].nil? warn ("Warning: DNS not defined") if options_hash[:dns].nil? warn ("Warning: Given Name not defined") if options_hash[:given_name].nil? #Parameters @ip_address = options_hash[:ip_address] @is_primary = options_hash[:is_primary] @subnet_mask = options_hash[:subnet_mask] @gateway = options_hash[:gateway] @dns = options_hash[:dns] @given_name = options_hash[:given_name] @vlan_id = options_hash[:vlan_id] end
Public Instance Methods
update_dns(new_dns,old_dns=nil)
click to toggle source
# 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)
click to toggle source
# File lib/rbvppc/network.rb, line 47 def update_gateway(new_gateway) @gateway = new_gateway end
update_given_name(new_name)
click to toggle source
# File lib/rbvppc/network.rb, line 51 def update_given_name(new_name) @vlan_id = new_name end