lib/testlab/providers/vagrant.rb in testlab-0.4.4 vs lib/testlab/providers/vagrant.rb in testlab-0.4.5
- old
+ new
@@ -132,10 +132,16 @@
def identity
(@config[:vagrant][:identity] || File.join(ENV['HOME'], ".vagrant.d", "insecure_private_key"))
end
def ip
- (@config[:vagrant][:ip] || "192.168.33.10")
+ (@config[:vagrant][:ip] || "192.168.33.#{last_octet}")
+ end
+
+ def last_octet
+ hash = instance_id.hash
+ hash = (hash < 0 ? (hash * -1) : hash)
+ (hash.modulo(254) + 1)
end
def port
(@config[:vagrant][:port] || 22)
end