Class: IPParse

Inherits:
Object
  • Object
show all
Defined in:
lib/ipparse.rb

Overview

VMware Continuent Tungsten Replicator Copyright © 2015 VMware, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Initial developer(s): Jeff Mace

Constant Summary collapse

IPV4 =
:ipv4
IPV6 =
:ipv6

Instance Method Summary collapse

Constructor Details

#initializeIPParse

Returns a new instance of IPParse.



22
23
24
25
# File 'lib/ipparse.rb', line 22

def initialize
  @klass = get_platform_klass().new()
  @parsed = nil
end

Instance Method Details

#get_interface_address(interface, type = IPV4) ⇒ Object



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

def get_interface_address(interface, type = IPV4)
  parse()
  
  unless @parsed.has_key?(interface)
    return nil
  end
  
  unless @parsed[interface].has_key?(type)
    return nil
  end
  
  return @parsed[interface][type]
end

#get_interfacesObject

Return a nested array of the parsed interface information {

"eth0" => {
  :ipv4 => { :address => "1.2.3.4", :netmask => "255.255.255.0" },
  :ipv6 => { :address => "fe80::a00:27ff:fe1f:84a5", :netmask => "64" }
}

}



34
35
36
37
# File 'lib/ipparse.rb', line 34

def get_interfaces
  parse()
  return @parsed
end