lib/testlab/container/generators.rb in testlab-0.2.1 vs lib/testlab/container/generators.rb in testlab-0.3.0
- old
+ new
@@ -1,10 +1,16 @@
class TestLab
class Container
module Generators
+ # Generate IP address
+ #
+ # Generates an RFC compliant private IP address.
+ #
+ # @return [String] A random, private IP address in the 192.168.0.1/24
+ # range.
def generate_ip
octets = [ 192..192,
168..168,
0..254,
1..254 ]
@@ -13,9 +19,14 @@
ip << octets[x-1].to_a[rand(octets[x-1].count)].to_s
end
ip.join(".")
end
+ # Generate MAC address
+ #
+ # Generates an RFC compliant private MAC address.
+ #
+ # @return [String] A random, private MAC address.
def generate_mac
digits = [ %w(0),
%w(0),
%w(0),
%w(0),