junos-space-api 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -1
- data/examples/add_device.rb +1 -1
- data/examples/addresses.rb +4 -4
- data/examples/jobs.rb +3 -3
- data/examples/sec_device.rb +2 -2
- data/examples/services.rb +4 -4
- data/junos-space-api-0.2.0.gem +0 -0
- data/junos-space-api.gemspec +1 -1
- data/lib/junos-space-api/platform/device.rb +4 -6
- data/lib/junos-space-api/platform/job.rb +4 -4
- data/lib/junos-space-api/sd/address.rb +11 -10
- data/lib/junos-space-api/sd/device.rb +5 -5
- data/lib/junos-space-api/sd/service.rb +8 -8
- metadata +3 -2
data/README.md
CHANGED
@@ -36,6 +36,13 @@ Check out the [Wiki][1] for documentation on the different Classes and their res
|
|
36
36
|
|
37
37
|
Check out the `examples` directory to browse through some samples of what this API can do!
|
38
38
|
|
39
|
+
### Credits
|
40
|
+
|
41
|
+
Thanks to [Jeremy Schulman][3] for inspiration and help with all the automation-goodness! And thanks
|
42
|
+
to [Juniper Networks][4] for creating such great products :)
|
43
|
+
|
39
44
|
|
40
45
|
[1]: https://github.com/scottdware/junos-ruby-space-api/wiki
|
41
|
-
[2]: http://www.juniper.net/techpubs/en_US/junos-space13.1/information-products/topic-collections/junos-space-security-designer/security-director-api.pdf
|
46
|
+
[2]: http://www.juniper.net/techpubs/en_US/junos-space13.1/information-products/topic-collections/junos-space-security-designer/security-director-api.pdf
|
47
|
+
[3]: https://github.com/jeremyschulman
|
48
|
+
[4]: http://www.juniper.net
|
data/examples/add_device.rb
CHANGED
data/examples/addresses.rb
CHANGED
@@ -17,13 +17,13 @@ data = {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
# Will get a list of all of the address objects.
|
20
|
-
pp addrs.
|
20
|
+
pp addrs.list
|
21
21
|
|
22
22
|
# Will add a new address object to Junos Space.
|
23
|
-
pp addrs.
|
23
|
+
pp addrs.add(data)
|
24
24
|
|
25
25
|
# Will return information about the address object.
|
26
|
-
pp addrs.
|
26
|
+
pp addrs.info('my-home-network')
|
27
27
|
|
28
28
|
# Will delete the address object.
|
29
|
-
pp addrs.
|
29
|
+
pp addrs.delete('my-home-network')
|
data/examples/jobs.rb
CHANGED
@@ -9,10 +9,10 @@ JunosSpace.open('user', 'pass', 'server')
|
|
9
9
|
jobs = JunosSpace::Platform::Job.new
|
10
10
|
|
11
11
|
# Will return all jobs with a status of SUCCESS
|
12
|
-
pp jobs.
|
12
|
+
pp jobs.list('success')
|
13
13
|
|
14
14
|
# Will return all jobs with a status of FAILURE
|
15
|
-
pp jobs.
|
15
|
+
pp jobs.list('failure')
|
16
16
|
|
17
17
|
# Will return information about the job ID 9990001
|
18
|
-
pp jobs.
|
18
|
+
pp jobs.info('9990001')
|
data/examples/sec_device.rb
CHANGED
@@ -6,7 +6,7 @@ pass = 'somepass'
|
|
6
6
|
server = 'space.company.com'
|
7
7
|
|
8
8
|
JunosSpace.open('user', 'pass', 'server')
|
9
|
-
|
9
|
+
security = JunosSpace::SD::Device.new
|
10
10
|
|
11
11
|
# Will return the security device information (i.e. zones, interfaces, etc.)
|
12
|
-
pp
|
12
|
+
pp security.info('corporate-firewall')
|
data/examples/services.rb
CHANGED
@@ -14,13 +14,13 @@ data = {
|
|
14
14
|
}
|
15
15
|
|
16
16
|
# Will get a list of all of the services.
|
17
|
-
pp services.
|
17
|
+
pp services.list
|
18
18
|
|
19
19
|
# Will add a new service object to Junos Space.
|
20
|
-
pp services.
|
20
|
+
pp services.add(data)
|
21
21
|
|
22
22
|
# Will return information about the service object.
|
23
|
-
pp services.
|
23
|
+
pp services.info('my-custom-service')
|
24
24
|
|
25
25
|
# Will delete the service object.
|
26
|
-
pp services.
|
26
|
+
pp services.delete('my-custom-service')
|
Binary file
|
data/junos-space-api.gemspec
CHANGED
@@ -3,7 +3,7 @@ require 'rake'
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.license = 'MIT'
|
5
5
|
s.name = 'junos-space-api'
|
6
|
-
s.version = '0.2.
|
6
|
+
s.version = '0.2.1'
|
7
7
|
s.summary = 'Interact with the Junos Space REST API.'
|
8
8
|
s.description = 'This gem is used to interact with Juniper Networks Junos Space management platform using the REST API.'
|
9
9
|
s.authors = ["Scott Ware"]
|
@@ -12,17 +12,15 @@ class JunosSpace::Platform::Device
|
|
12
12
|
@@queue_headers = {
|
13
13
|
:content_type => 'application/hornetq.jms.queue+xml'
|
14
14
|
}
|
15
|
-
@@ucase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
16
|
-
@@dcase = 'abcdefghijklmnopqrstuvwxyz'
|
17
15
|
|
18
|
-
#
|
16
|
+
# list
|
19
17
|
#
|
20
18
|
# Returns a Hash of all of the devices in the Junos Space database. The
|
21
19
|
# device name is the key, and value is an array of the following:
|
22
20
|
# device id, family, Junos version, platform, serial number,
|
23
21
|
# connection status, IP address, and managed status.
|
24
22
|
#
|
25
|
-
def
|
23
|
+
def list
|
26
24
|
result = {}
|
27
25
|
|
28
26
|
begin
|
@@ -51,7 +49,7 @@ class JunosSpace::Platform::Device
|
|
51
49
|
end
|
52
50
|
end
|
53
51
|
|
54
|
-
#
|
52
|
+
# add(data)
|
55
53
|
#
|
56
54
|
# Add a new device to the Junos Space database, with the given information
|
57
55
|
# in 'data'. 'data' is a Hash table with the following structure:
|
@@ -63,7 +61,7 @@ class JunosSpace::Platform::Device
|
|
63
61
|
#
|
64
62
|
# Returns a Hash with 'status' as the key, and the job ID as the value.
|
65
63
|
#
|
66
|
-
def
|
64
|
+
def add(data)
|
67
65
|
result = {}
|
68
66
|
|
69
67
|
begin
|
@@ -7,14 +7,14 @@ class JunosSpace::Platform::Job
|
|
7
7
|
@@ucase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
8
8
|
@@dcase = 'abcdefghijklmnopqrstuvwxyz'
|
9
9
|
|
10
|
-
#
|
10
|
+
# list(status)
|
11
11
|
#
|
12
12
|
# Returns a Hash of all of the jobs in Space with the status
|
13
13
|
# 'status'. Where 'status' can be one of: 'success', 'failure',
|
14
14
|
# 'inprogress', or 'cancelled'. If no status is given, then all of the jobs are
|
15
15
|
# returned. The name of the job is the key, and the ID is the value.
|
16
16
|
#
|
17
|
-
def
|
17
|
+
def list(status)
|
18
18
|
result = {}
|
19
19
|
|
20
20
|
begin
|
@@ -49,13 +49,13 @@ class JunosSpace::Platform::Job
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
#
|
52
|
+
# info(job)
|
53
53
|
#
|
54
54
|
# Returns information about the job 'job'. This information is returned in a Hash
|
55
55
|
# with the job ID, name, percentage complete, status, job type, summary, user
|
56
56
|
# who issued the job, and the time the job was started.
|
57
57
|
#
|
58
|
-
def
|
58
|
+
def info(job)
|
59
59
|
result = {}
|
60
60
|
|
61
61
|
begin
|
@@ -10,12 +10,12 @@ class JunosSpace::SD::Address
|
|
10
10
|
@@ucase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
11
11
|
@@dcase = 'abcdefghijklmnopqrstuvwxyz'
|
12
12
|
|
13
|
-
#
|
13
|
+
# list
|
14
14
|
#
|
15
15
|
# Returns a Hash of all of the address objects in Space. The name
|
16
16
|
# of the object is the key, and the ID is the value.
|
17
17
|
#
|
18
|
-
def
|
18
|
+
def list
|
19
19
|
result = {}
|
20
20
|
|
21
21
|
begin
|
@@ -37,14 +37,14 @@ class JunosSpace::SD::Address
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
#
|
40
|
+
# info(name)
|
41
41
|
#
|
42
42
|
# Searches for address object 'name' and returns a Hash with the address
|
43
43
|
# object(s) name as the key, and the IP address as the value.
|
44
44
|
# If the address object(s) are a group, then the value within
|
45
45
|
# the Hash is an array of the address object names within the group(s).
|
46
46
|
#
|
47
|
-
def
|
47
|
+
def info(name)
|
48
48
|
result = {}
|
49
49
|
|
50
50
|
begin
|
@@ -88,7 +88,7 @@ class JunosSpace::SD::Address
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
#
|
91
|
+
# add(data)
|
92
92
|
#
|
93
93
|
# This method will add a new address object to Space give the information
|
94
94
|
# in 'data'. This information is a Hash with the following structure:
|
@@ -99,10 +99,11 @@ class JunosSpace::SD::Address
|
|
99
99
|
# `desc => Description (optional)`,
|
100
100
|
# `version => Either 'v4' or 'v6'`
|
101
101
|
#
|
102
|
-
def
|
103
|
-
|
104
|
-
|
102
|
+
def add(data)
|
103
|
+
result = {}
|
104
|
+
type = data['type'] == 'address' ? 'IPADDRESS' : 'NETWORK'
|
105
105
|
version = data['version'] == 'v4' ? 'IPV4' : 'IPV6'
|
106
|
+
|
106
107
|
if data['desc']
|
107
108
|
desc = data['desc']
|
108
109
|
else
|
@@ -133,13 +134,13 @@ class JunosSpace::SD::Address
|
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
136
|
-
#
|
137
|
+
# delete(name)
|
137
138
|
#
|
138
139
|
# Deletes the object matching the name 'name'. If more than one address object
|
139
140
|
# is found during the search, then send a warning to refine the search (i.e.
|
140
141
|
# use the exact name if possible).
|
141
142
|
#
|
142
|
-
def
|
143
|
+
def delete(name)
|
143
144
|
result = {}
|
144
145
|
|
145
146
|
begin
|
@@ -5,12 +5,12 @@ require 'junos-space-api/space'
|
|
5
5
|
class JunosSpace::SD::Device
|
6
6
|
@@device_uri = '/api/juniper/sd/device-management/devices'
|
7
7
|
|
8
|
-
#
|
8
|
+
# list
|
9
9
|
#
|
10
10
|
# Returns a Hash of all of the device objects in Space. The name
|
11
11
|
# of the device is the key, and the ID is the value.
|
12
12
|
#
|
13
|
-
def
|
13
|
+
def list
|
14
14
|
result = {}
|
15
15
|
|
16
16
|
begin
|
@@ -32,7 +32,7 @@ class JunosSpace::SD::Device
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
#
|
35
|
+
# info(name)
|
36
36
|
#
|
37
37
|
# Returns a Hash of resultrmation about the given device 'name'. For zones,
|
38
38
|
# it returns Hash where the zone name is the key, and an array of interfaces
|
@@ -41,9 +41,9 @@ class JunosSpace::SD::Device
|
|
41
41
|
# For interfaces, it returns a Hash where the interface name is the key, and
|
42
42
|
# the IP address of that interface is the value.
|
43
43
|
#
|
44
|
-
def
|
44
|
+
def info(name)
|
45
45
|
result = {}
|
46
|
-
devices = self.
|
46
|
+
devices = self.list
|
47
47
|
|
48
48
|
begin
|
49
49
|
res = RestClient.get("#{JunosSpace.base_uri}#{@@device_uri}/#{devices[name]}")
|
@@ -10,12 +10,12 @@ class JunosSpace::SD::Service
|
|
10
10
|
@@ucase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
11
11
|
@@dcase = 'abcdefghijklmnopqrstuvwxyz'
|
12
12
|
|
13
|
-
#
|
13
|
+
# list
|
14
14
|
#
|
15
15
|
# Returns a Hash of all of the individual service objects in Space.
|
16
16
|
# The name of the service is the key, and the ID is the value.
|
17
17
|
#
|
18
|
-
def
|
18
|
+
def list
|
19
19
|
result = {}
|
20
20
|
|
21
21
|
begin
|
@@ -37,14 +37,14 @@ class JunosSpace::SD::Service
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
#
|
40
|
+
# info(name)
|
41
41
|
#
|
42
42
|
# Searches for the service 'name' and returns a Hash with the service
|
43
43
|
# object(s) name as the key, and the ID as the value.
|
44
44
|
# If the service object(s) are a group, then the value within
|
45
45
|
# the Hash is an array of the service object names within the group(s).
|
46
46
|
#
|
47
|
-
def
|
47
|
+
def info(name)
|
48
48
|
result = {}
|
49
49
|
|
50
50
|
begin
|
@@ -90,7 +90,7 @@ class JunosSpace::SD::Service
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
#
|
93
|
+
# add(data)
|
94
94
|
#
|
95
95
|
# This method will add a new service object to Space give the information
|
96
96
|
# in 'data'. This information is a Hash table, with the following structure:
|
@@ -99,7 +99,7 @@ class JunosSpace::SD::Service
|
|
99
99
|
# `port => Port number`
|
100
100
|
# `desc => Description (optional)`
|
101
101
|
#
|
102
|
-
def
|
102
|
+
def add(data)
|
103
103
|
result = {}
|
104
104
|
|
105
105
|
if data['desc']
|
@@ -135,13 +135,13 @@ class JunosSpace::SD::Service
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
-
#
|
138
|
+
# delete(name)
|
139
139
|
#
|
140
140
|
# Deletes the object matching the name 'name'. If more than one service object
|
141
141
|
# is found during the search, then send a warning to refine the search (i.e.
|
142
142
|
# use the exact name if possible).
|
143
143
|
#
|
144
|
-
def
|
144
|
+
def delete(name)
|
145
145
|
result = {}
|
146
146
|
|
147
147
|
begin
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junos-space-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
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-07-
|
12
|
+
date: 2013-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This gem is used to interact with Juniper Networks Junos Space management
|
15
15
|
platform using the REST API.
|
@@ -18,6 +18,7 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
+
- junos-space-api-0.2.0.gem
|
21
22
|
- junos-space-api.gemspec
|
22
23
|
- LICENSE
|
23
24
|
- README.md
|