junos-ez-stdlib 0.0.12 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG.md +17 -3
  2. data/README.md +10 -0
  3. data/docs/Providers/IPports.md +61 -0
  4. data/docs/Providers/L1ports.md +29 -0
  5. data/docs/Providers/L2ports.md +43 -0
  6. data/docs/Providers/StaticHosts.md +26 -0
  7. data/docs/Providers/StaticRoutes.md +37 -0
  8. data/docs/Providers/UserAuths.md +32 -0
  9. data/docs/{Users.md → Providers/Users.md} +17 -0
  10. data/docs/Providers/Vlans.md +43 -0
  11. data/docs/Providers_Resources.md +24 -0
  12. data/docs/README_FIRST.md +27 -0
  13. data/docs/Utils/Config.md +161 -0
  14. data/docs/Utils/Filesystem.md +78 -0
  15. data/docs/Utils/Routing-Engine.md +248 -0
  16. data/examples/re_upgrade.rb +1 -1
  17. data/examples/re_utils.rb +1 -0
  18. data/examples/vlans.rb +7 -1
  19. data/lib/junos-ez/ip_ports.rb +3 -1
  20. data/lib/junos-ez/ip_ports/classic.rb +49 -14
  21. data/lib/junos-ez/l1_ports.rb +51 -11
  22. data/lib/junos-ez/l2_ports.rb +1 -1
  23. data/lib/junos-ez/l2_ports/vlan.rb +176 -60
  24. data/lib/junos-ez/provider.rb +4 -1
  25. data/lib/junos-ez/system/st_hosts.rb +0 -0
  26. data/lib/junos-ez/system/st_routes.rb +0 -0
  27. data/lib/junos-ez/system/userauths.rb +0 -0
  28. data/lib/junos-ez/system/users.rb +0 -0
  29. data/lib/junos-ez/utils/config.rb +33 -2
  30. data/lib/junos-ez/utils/re.rb +22 -3
  31. data/lib/junos-ez/vlans.rb +5 -3
  32. data/lib/junos-ez/vlans/vlan.rb +6 -0
  33. metadata +14 -13
  34. data/docs/Config_Utils.md +0 -3
  35. data/docs/Filesys_Utils.md +0 -3
  36. data/docs/IPports.md +0 -3
  37. data/docs/L1ports.md +0 -3
  38. data/docs/L2ports.md +0 -3
  39. data/docs/RE_utils.md +0 -3
  40. data/docs/StaticHosts.md +0 -3
  41. data/docs/StaticRoutes.md +0 -3
  42. data/docs/Vlans.md +0 -3
  43. data/lib/junos-ez/system/user_ssh_keys.rb +0 -113
@@ -46,7 +46,7 @@ class Junos::Ez::RE::Provider < Junos::Ez::Provider::Parent
46
46
  status_h = {}
47
47
  got.xpath('//route-engine').each do |re|
48
48
  re_h = {}
49
- slot_id = re.xpath('slot').text.to_i
49
+ slot_id = "re" + re.xpath('slot').text
50
50
  status_h[slot_id] = re_h
51
51
 
52
52
  re_h[:model] = re.xpath('model').text.strip
@@ -173,6 +173,7 @@ class Junos::Ez::RE::Provider < Junos::Ez::Provider::Parent
173
173
  user_h[:from] = user.xpath('from').text.strip
174
174
  user_h[:login_time] = user.xpath('login-time').text.strip
175
175
  user_h[:idle_time] = user.xpath('idel-time').text.strip
176
+ user_h[:idle_time] = nil if user_h[:idle_time].empty?
176
177
  user_h[:command] = user.xpath('command').text.strip
177
178
  end
178
179
  users_a
@@ -224,7 +225,16 @@ class Junos::Ez::RE::Provider < Junos::Ez::Provider::Parent
224
225
  ### ---------------------------------------------------------------
225
226
 
226
227
  def reboot!( opts = {} )
227
- got = @ndev.rpc.request_reboot
228
+ arg_options = [:in, :at]
229
+ args = {}
230
+ opts.each do |k,v|
231
+ if arg_options.include? k
232
+ args[k] = v
233
+ else
234
+ raise ArgumentError, "unrecognized option #{k}"
235
+ end
236
+ end
237
+ got = @ndev.rpc.request_reboot( args )
228
238
  got.xpath('request-reboot-status').text.strip
229
239
  end
230
240
 
@@ -233,10 +243,19 @@ class Junos::Ez::RE::Provider < Junos::Ez::Provider::Parent
233
243
  ### ---------------------------------------------------------------
234
244
 
235
245
  def shutdown!( opts = {} )
246
+ arg_options = [:in, :at]
247
+ args = {}
248
+ opts.each do |k,v|
249
+ if arg_options.include? k
250
+ args[k] = v
251
+ else
252
+ raise ArgumentError, "unrecognized option #{k}"
253
+ end
254
+ end
236
255
  ## some Junos devices will throw an RPC error exception which is really
237
256
  ## a warning, and some do not. So we need to trap that here.
238
257
  begin
239
- got = @ndev.rpc.request_power_off
258
+ got = @ndev.rpc.request_power_off( args )
240
259
  rescue => e
241
260
  retmsg = e.rsp.xpath('//error-message').text.strip + "\n"
242
261
  return retmsg + e.rsp.xpath('//request-reboot-status').text.strip
@@ -3,9 +3,10 @@ require "junos-ez/provider"
3
3
  module Junos::Ez::Vlans
4
4
 
5
5
  PROPERTIES = [
6
- :vlan_id,
7
- :description,
8
- :no_mac_learning
6
+ :vlan_id, # Fixnum, [ 1 .. 4094 ]
7
+ :description, # String, description
8
+ :no_mac_learning, # [ true | nil ] - used to disable MAC-address learning
9
+ :interfaces, # READ-ONLY, array of bound interface names
9
10
  ]
10
11
 
11
12
  def self.Provider( ndev, varsym )
@@ -21,6 +22,7 @@ module Junos::Ez::Vlans
21
22
 
22
23
  class Provider < Junos::Ez::Provider::Parent
23
24
  # common parenting goes here ...
25
+
24
26
  end
25
27
 
26
28
  end
@@ -25,6 +25,12 @@ class Junos::Ez::Vlans::Provider::VLAN < Junos::Ez::Vlans::Provider
25
25
  as_hash[:vlan_id] = as_xml.xpath('vlan-id').text.to_i
26
26
  xml_when_item(as_xml.xpath('description')){ |i| as_hash[:description] = i.text }
27
27
  xml_when_item(as_xml.xpath('no-mac-learning')){ as_hash[:no_mac_learning] = true }
28
+
29
+ # get a brief list of the interfaces on this vlan
30
+ got = @ndev.rpc.get_vlan_information( :vlan_name => @name || as_xml.xpath('name').text )
31
+ as_hash[:interfaces] = got.xpath('//vlan-member-interface').collect{|ifs| ifs.text.strip }
32
+ as_hash[:interfaces] = nil if as_hash[:interfaces][0] == "None"
33
+
28
34
  return true
29
35
  end
30
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: junos-ez-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-27 00:00:00.000000000 Z
12
+ date: 2013-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: netconf
@@ -59,7 +59,6 @@ files:
59
59
  - lib/junos-ez/system/syscfg.rb
60
60
  - lib/junos-ez/system/userauths.rb
61
61
  - lib/junos-ez/system/users.rb
62
- - lib/junos-ez/system/user_ssh_keys.rb
63
62
  - lib/junos-ez/system.rb
64
63
  - lib/junos-ez/utils/config.rb
65
64
  - lib/junos-ez/utils/fs.rb
@@ -78,18 +77,20 @@ files:
78
77
  - examples/st_hosts.rb
79
78
  - examples/user.rb
80
79
  - examples/vlans.rb
81
- - docs/Config_Utils.md
82
80
  - docs/Facts.md
83
- - docs/Filesys_Utils.md
84
- - docs/IPports.md
85
- - docs/L1ports.md
86
- - docs/L2ports.md
81
+ - docs/Providers/IPports.md
82
+ - docs/Providers/L1ports.md
83
+ - docs/Providers/L2ports.md
84
+ - docs/Providers/StaticHosts.md
85
+ - docs/Providers/StaticRoutes.md
86
+ - docs/Providers/UserAuths.md
87
+ - docs/Providers/Users.md
88
+ - docs/Providers/Vlans.md
87
89
  - docs/Providers_Resources.md
88
- - docs/RE_utils.md
89
- - docs/StaticHosts.md
90
- - docs/StaticRoutes.md
91
- - docs/Users.md
92
- - docs/Vlans.md
90
+ - docs/README_FIRST.md
91
+ - docs/Utils/Config.md
92
+ - docs/Utils/Filesystem.md
93
+ - docs/Utils/Routing-Engine.md
93
94
  homepage: https://github.com/jeremyschulman/ruby-junos-ez-stdlib
94
95
  licenses: []
95
96
  post_install_message:
data/docs/Config_Utils.md DELETED
@@ -1,3 +0,0 @@
1
- # Configuration Utilities
2
-
3
- Docs comming soon ...
@@ -1,3 +0,0 @@
1
- # Filesystem Utilities
2
-
3
- Docs coming soon ...
data/docs/IPports.md DELETED
@@ -1,3 +0,0 @@
1
- # IP v4 Port Provider
2
-
3
- Docs comming soon...
data/docs/L1ports.md DELETED
@@ -1,3 +0,0 @@
1
- # Layer 1 Physical Port Provider
2
-
3
- Docs comming soon ...
data/docs/L2ports.md DELETED
@@ -1,3 +0,0 @@
1
- # Layer 2 Switching Port Provider
2
-
3
- Docs comming soon ...
data/docs/RE_utils.md DELETED
@@ -1,3 +0,0 @@
1
- # Routing-Engine Utilities
2
-
3
- Docs comming soon ...
data/docs/StaticHosts.md DELETED
@@ -1,3 +0,0 @@
1
- # Static Host Entry Provider
2
-
3
- Docs comming soon ...
data/docs/StaticRoutes.md DELETED
@@ -1,3 +0,0 @@
1
- # Static Routes Provider
2
-
3
- Docs comming soon ...
data/docs/Vlans.md DELETED
@@ -1,3 +0,0 @@
1
- # VLANs Provider
2
-
3
- Docs comming soon ...
@@ -1,113 +0,0 @@
1
- =begin
2
- * Puppet Module : junos-stdlib
3
- * Author : Jeremy Schulman
4
- * File : junos_user.rb
5
- * Version : 2013-03-20
6
- * Platform : All
7
- * Description :
8
- *
9
- *
10
- * Copyright (c) 2013 Juniper Networks. All Rights Reserved.
11
- *
12
- * YOU MUST ACCEPT THE TERMS OF THIS DISCLAIMER TO USE THIS SOFTWARE,
13
- * IN ADDITION TO ANY OTHER LICENSES AND TERMS REQUIRED BY JUNIPER NETWORKS.
14
- *
15
- * JUNIPER IS WILLING TO MAKE THE INCLUDED SCRIPTING SOFTWARE AVAILABLE TO YOU
16
- * ONLY UPON THE CONDITION THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS
17
- * DISCLAIMER. PLEASE READ THE TERMS AND CONDITIONS OF THIS DISCLAIMER
18
- * CAREFULLY.
19
- *
20
- * THE SOFTWARE CONTAINED IN THIS FILE IS PROVIDED "AS IS." JUNIPER MAKES NO
21
- * WARRANTIES OF ANY KIND WHATSOEVER WITH RESPECT TO SOFTWARE. ALL EXPRESS OR
22
- * IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY WARRANTY
23
- * OF NON-INFRINGEMENT OR WARRANTY OF MERCHANTABILITY OR FITNESS FOR A
24
- * PARTICULAR PURPOSE, ARE HEREBY DISCLAIMED AND EXCLUDED TO THE EXTENT
25
- * ALLOWED BY APPLICABLE LAW.
26
- *
27
- * IN NO EVENT WILL JUNIPER BE LIABLE FOR ANY DIRECT OR INDIRECT DAMAGES,
28
- * INCLUDING BUT NOT LIMITED TO LOST REVENUE, PROFIT OR DATA, OR
29
- * FOR DIRECT, SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES
30
- * HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY ARISING OUT OF THE
31
- * USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF JUNIPER HAS BEEN ADVISED OF
32
- * THE POSSIBILITY OF SUCH DAMAGES.
33
- =end
34
-
35
- require 'puppet/provider/junos/junos_parent'
36
-
37
- class Puppet::Provider::Junos::SSH_auth_key < Puppet::Provider::Junos
38
-
39
- ### --------------------------------------------------------------------
40
- ### triggered by provider #exists?
41
- ### --------------------------------------------------------------------
42
-
43
- def netdev_res_exists?
44
-
45
- # cannot manage the 'active' parameter from the puppet manifest since the
46
- # type definition is compiled on the server, and doesn't include this :-(
47
- # so fake it here, set to true always. this way if someone deactivated
48
- # it apriori, then this puppet-run will make it active again.
49
-
50
- return false unless (auth = get_junos_config)
51
-
52
- got_key = auth.text.strip
53
- got_key_skip = got_key.index(' ') + 1
54
- got_key = got_key[ got_key_skip .. -1 ]
55
-
56
- @ndev_res[:key] = got_key
57
- @ndev_res[:user] = resource[:user]
58
- @ndev_res[:type] = resource[:type]
59
- @ndev_res[:target] = resource[:target]
60
- @ndev_res[:options] = resource[:options]
61
-
62
- return true
63
- end
64
-
65
- ### ---------------------------------
66
- ### ---> override parent method <----
67
- ### ---------------------------------
68
-
69
- def netdev_resxml_top( xml )
70
- xml.user {
71
- xml.name resource[:user]
72
- xml.authentication {
73
- xml.send(:'ssh-rsa') {
74
- xml.name 'ssh-rsa ' + resource[:key]
75
- return xml
76
- }
77
- }
78
- }
79
- end
80
-
81
- def get_junos_config
82
-
83
- @ndev_res ||= NetdevJunos::Resource.new( self, 'system/login', 'user' )
84
- @ndev_res[:unmanaged_active] = true
85
-
86
- return nil unless (ndev_config = @ndev_res.getconfig)
87
- return nil unless auth_config = ndev_config.xpath("//user/authentication/ssh-rsa")[0]
88
- @ndev_res.set_active_state( auth_config )
89
-
90
- return auth_config
91
- end
92
-
93
-
94
- ##### ------------------------------------------------------------
95
- ##### XML builder routines, one for each property
96
- ##### ------------------------------------------------------------
97
-
98
- def xml_change_type( xml )
99
- end
100
-
101
- def xml_change_key( xml )
102
- end
103
-
104
- def xml_change_user( xml )
105
- end
106
-
107
- def xml_change_target( xml )
108
- end
109
-
110
- def xml_change_options( xml )
111
- end
112
-
113
- end