opendaylight 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14e0b3d76e3c585cf331d04943bbbb08f09bcdf8
4
- data.tar.gz: 57c1cca1a743f733e7dc90b9809c80c0acc3a44b
3
+ metadata.gz: a88cd37374d57c95ad16235e25947a09cc47edfa
4
+ data.tar.gz: a4ee428b6d23a7b516075773485dddd254de1d9d
5
5
  SHA512:
6
- metadata.gz: 47ff984ccb589125e575a77b0bbc8bf6581fcef146a1cf0020251e6e899a975b2e8c677cd14b157478f74fd6be7648a9ab7ec4dc4b3181e78ac69d5ac29cbd1d
7
- data.tar.gz: 25cc2ee49647f940c81fae52d651e2a356e1069d1dd2c9692981ed68864f87f42e58fb5be3c0cc746c30450030e0c5669801669500ae3332d55f6998452d800c
6
+ metadata.gz: ea951566525a9ed8c1a23054c7d30fc47e6c2d048e07c1e1ac9b62252c6ac84cf0a1d03e262cc5b7e649745a7a21403095de946071af759f9a399fb394944c60
7
+ data.tar.gz: 87e81b3a64ac7464f727f4e60eb174bb235113b9f53e843286966325b6248ca6477b82ab5e65818e7584c0cd768cf673670466aca9b92976687b7e60b44a62c1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/opendaylight.svg)](http://badge.fury.io/rb/opendaylight)
4
4
 
5
- This gem is made as a ruby wrapper for OpenDayligh's FlowProgrammer API
5
+ This gem is made as a ruby wrapper for OpenDaylight MD-SAL and AD-SAL APIs, including FlowProgrammer.
6
6
 
7
7
  ## Installation
8
8
 
@@ -28,6 +28,32 @@ Configure with an initializer in config/initializers as follows:
28
28
  config.url = "http://yourserver.com:port/"
29
29
  end
30
30
 
31
+ ### Model-Driven Service Abstraction Layer (MD-SAL)
32
+
33
+ Consult the Yang UI from the DLux interfarce, and construct method calls similar to how they're structured in that UI:
34
+
35
+ odl = Opendaylight::ModelDriven.new
36
+
37
+ data = %q| { "flow-node-inventory:flow": [ { "flow-node-inventory:id": "foobarbaz", "flow-node-inventory:match": { . . . |
38
+ # POST
39
+ result = odl.inventory.config.nodes.node("openflow:1").table('0').create data
40
+ puts "result: " + result.class.to_s
41
+
42
+ # GET
43
+ result = odl.inventory.config.nodes.node("openflow:1").table('0').flow("foobarbaz").resource
44
+ puts "result: " + JSON.pretty_generate JSON.parse(result.body)
45
+
46
+ data = %q| { "flow-node-inventory:flow": [ { "flow-node-inventory:id": "foobardee", "flow-node-inventory:match": { . . . |
47
+ # PUT
48
+ result = odl.inventory.config.nodes.node("openflow:1").table('0').flow('foobardee').update data
49
+ puts "result: " + JSON.pretty_generate JSON.parse(result.body)
50
+
51
+ # DELETE
52
+ result = odl.inventory.config.nodes.node("openflow:1").table('0').flow("foobarbaz").delete
53
+ puts "result: " + result.class.to_s
54
+
55
+ ### Application-Driven Service Abstraction Layer (AD-SAL)
56
+
31
57
  Then make a call to Opendaylight's API.makeflow:
32
58
 
33
59
  For example:
@@ -1,4 +1,5 @@
1
1
  require "opendaylight/version"
2
+ require "opendaylight/model_driven"
2
3
  require "httparty"
3
4
 
4
5
  module Opendaylight
@@ -0,0 +1,84 @@
1
+ require "httparty"
2
+
3
+ module Opendaylight
4
+
5
+ class ModelDriven
6
+ def initialize(resource_chain = nil)
7
+ @resource_chain = resource_chain ? resource_chain : Array.new
8
+ @auth = {:username => Opendaylight.configuration.username, :password => Opendaylight.configuration.password}
9
+ end
10
+
11
+ def create(post_data)
12
+ h = HTTParty.post(form_url_from_method_calls, { :basic_auth => @auth, :body => post_data, headers: {"Content-Type" => "application/json", "Accept" => "application/json"} } )
13
+
14
+ h.response
15
+ end
16
+
17
+ def delete
18
+ h = HTTParty.delete(form_url_from_method_calls, { :basic_auth => @auth } )
19
+
20
+ h.response
21
+ end
22
+
23
+ def method_missing(sym, *args, &block)
24
+ @resource_chain << sym
25
+ args.each do |arg|
26
+ @resource_chain << arg.to_s.to_sym
27
+ end
28
+ md = ModelDriven.new(@resource_chain)
29
+ @resource_chain = Array.new
30
+
31
+ return md
32
+
33
+ super(sym, *args, &block)
34
+ end
35
+
36
+ def update(object)
37
+ h = HTTParty.put(form_url_from_method_calls, { :basic_auth => @auth, :body => object, headers: {"Content-Type" => "application/json", "Accept" => "application/json"} } )
38
+
39
+ h.response
40
+ end
41
+
42
+ def respond_to?(sym, include_private = false)
43
+ @resource_chain << sym.to_s.to_sym
44
+ call_exists_in_mdsal? || super(sym, include_private)
45
+ end
46
+
47
+ def resource
48
+ url = form_url_from_method_calls
49
+ h = HTTParty.get(url, { :basic_auth => @auth, headers: {"Accept" => "application/json"} } )
50
+ h.response
51
+ end
52
+
53
+ private
54
+
55
+ def call_exists_in_mdsal?
56
+ h = HTTParty.head(form_url_from_method_calls, :basic_auth => @auth)
57
+ h.response.code.to_i < 400
58
+ end
59
+
60
+ def map_method_to_module(method)
61
+ case method
62
+ when :nodes
63
+ return "opendaylight-inventory:" + method.to_s
64
+ else
65
+ return method.to_s
66
+ end
67
+
68
+ end
69
+
70
+ def form_url_from_method_calls
71
+ path = Array.new
72
+ path << "restconf"
73
+ @resource_chain[1,@resource_chain.size].each do |resource|
74
+ path << map_method_to_module(resource)
75
+ end
76
+
77
+ p = URI::Parser.new
78
+ u = p.parse Opendaylight.configuration.url
79
+ u.path = '/' + path.join('/')
80
+ u.to_s
81
+ end
82
+
83
+ end
84
+ end
@@ -1,3 +1,3 @@
1
1
  module Opendaylight
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -6,8 +6,8 @@ require 'opendaylight/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "opendaylight"
8
8
  spec.version = Opendaylight::VERSION
9
- spec.authors = ["rickpr"]
10
- spec.email = ["fdisk@fdisk.co"]
9
+ spec.authors = ["rickpr", "aburnheimer"]
10
+ spec.email = ["fdisk@fdisk.co", "aburnheimer@gmail.com"]
11
11
  spec.summary = "Ruby Wrapper for OpenDaylight"
12
12
  spec.description = "Makes writing Ruby apps for OpenDaylight easy"
13
13
  spec.homepage = "http://fdisk.co"
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opendaylight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rickpr
8
+ - aburnheimer
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
12
+ date: 2015-10-16 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
@@ -55,6 +56,7 @@ dependencies:
55
56
  description: Makes writing Ruby apps for OpenDaylight easy
56
57
  email:
57
58
  - fdisk@fdisk.co
59
+ - aburnheimer@gmail.com
58
60
  executables: []
59
61
  extensions: []
60
62
  extra_rdoc_files: []
@@ -65,6 +67,7 @@ files:
65
67
  - README.md
66
68
  - Rakefile
67
69
  - lib/opendaylight.rb
70
+ - lib/opendaylight/model_driven.rb
68
71
  - lib/opendaylight/version.rb
69
72
  - opendaylight.gemspec
70
73
  homepage: http://fdisk.co