diff options
Diffstat (limited to 'lib/leap_cli/config')
-rw-r--r-- | lib/leap_cli/config/manager.rb | 15 | ||||
-rw-r--r-- | lib/leap_cli/config/object.rb | 14 | ||||
-rw-r--r-- | lib/leap_cli/config/object_list.rb | 5 |
3 files changed, 34 insertions, 0 deletions
diff --git a/lib/leap_cli/config/manager.rb b/lib/leap_cli/config/manager.rb index 88f21be..00b4ec5 100644 --- a/lib/leap_cli/config/manager.rb +++ b/lib/leap_cli/config/manager.rb @@ -113,6 +113,13 @@ module LeapCli nodes[name] end + # + # yields each node, in sorted order + # + def each_node(&block) + nodes.each_node &block + end + private def load_all_json(pattern) @@ -232,6 +239,14 @@ module LeapCli end end + # + # TODO: apply JSON spec + # + PRIVATE_IP_RANGES = /(^127\.0\.0\.1)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^192\.168\.)/ + def validate_provider(provider) + Util::assert! provider.vagrant.network =~ PRIVATE_IP_RANGES, 'provider.json error: vagrant.network is not a local private network' + end + end end end diff --git a/lib/leap_cli/config/object.rb b/lib/leap_cli/config/object.rb index ad32f54..731f3ff 100644 --- a/lib/leap_cli/config/object.rb +++ b/lib/leap_cli/config/object.rb @@ -145,6 +145,20 @@ module LeapCli end ## + ## NODE SPECIFIC + ## maybe these should be moved to a Node class. + ## + + # + # returns true if this node has an ip address in the range of the vagrant network + # + def vagrant? + vagrant_range = IPAddr.new @manager.provider.vagrant.network + ip_address = IPAddr.new @node.ip_address + vagrant_range.include?(ip_address) + end + + ## ## MACROS ## these are methods used when eval'ing a value in the .json configuration ## diff --git a/lib/leap_cli/config/object_list.rb b/lib/leap_cli/config/object_list.rb index 708afc1..b0839ca 100644 --- a/lib/leap_cli/config/object_list.rb +++ b/lib/leap_cli/config/object_list.rb @@ -46,6 +46,11 @@ module LeapCli end end + def each_node(&block) + self.keys.sort.each do |node_name| + yield self[node_name] + end + end # def <<(object) # if object.is_a? Config::ObjectList |