lib/network.rb in forj-0.0.19 vs lib/network.rb in forj-0.0.20
- old
+ new
@@ -1,6 +1,7 @@
#!/usr/bin/env ruby
+# encoding: UTF-8
# (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,10 +18,13 @@
require 'require_relative'
require_relative 'connection.rb'
include Connection
+#
+# Network module
+#
module Network
def create_network(name)
Connection.network.networks.create(:name => name)
end
@@ -81,11 +85,12 @@
def get_next_subnet
subnet_values = Array.new
subnets = Connection.network.subnets.all
- for s in subnets do
+
+ subnets.each do|s|
subnet_values.push(s.cidr)
end
gap = false
count = 0
@@ -93,15 +98,15 @@
new_subnet = 0
new_cidr = ''
subnet_values = subnet_values.sort!
- for value in subnet_values
+ subnet_values.each do|value|
range_used.push(value[5])
end
- for n in range_used
+ range_used.each do |n|
if count.to_i == n.to_i
else
new_subnet = count
gap = true
break
@@ -115,7 +120,6 @@
max_value = range_used.max
new_subnet = max_value.to_i + 1
new_cidr = '10.0.%s.0/24' % [new_subnet]
end
new_cidr
-
-end
\ No newline at end of file
+end