odlgem 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +73 -0
- data/Rakefile +2 -0
- data/lib/odlgem/version.rb +3 -0
- data/lib/odlgem.rb +70 -0
- data/odlgem.gemspec +23 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 28002684e282083fdbd09d5a342013c6de94fc6e
|
4
|
+
data.tar.gz: ae791643390847d65bae61a6fb8c1c0b5b12fdf3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5659bc818ca04a2e07cba188fdf85e4e2c6ad63f4f2f94e70e4af650ef92c125ad15752371fb21c20018972e4b74d3f223cfb07b3ac398c4e4e627ceb04647bd
|
7
|
+
data.tar.gz: 43600edd8e0fe7bc443ae0e71ea6e1c4f63fecedba986c1f45be9c3c4019ffec1a76022d5b4730bed8f28222c50ced4ad22369c802c572e4c788689dd7bff68f
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 rickpr
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Odlgem
|
2
|
+
|
3
|
+
This gem is made as a ruby wrapper for OpenDaylight's FlowProgrammer api
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'odlgem'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install odlgem
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Configure with an initializer in config/initializers as follows:
|
22
|
+
|
23
|
+
Odlgem.configure do |config|
|
24
|
+
config.username = "your_username"
|
25
|
+
config.password = "your_password"
|
26
|
+
config.url = "http://yourserver.com:port/"
|
27
|
+
end
|
28
|
+
|
29
|
+
Then make a call to Odlgem's OpenDaylight.makeflow:
|
30
|
+
|
31
|
+
For example:
|
32
|
+
|
33
|
+
Odlgem::OpenDaylight.makeflow(id: "00:00:00:00:00:00:00:02", name: "flow1", actions: "DROP")
|
34
|
+
|
35
|
+
Here are the possible arguments for makeflow. All the arguments default to nil unless otherwise specified:
|
36
|
+
|
37
|
+
#Server information
|
38
|
+
url #Your controller's web url, usually "http://yourserver.com:8080/" (defaults to config url in initializer)
|
39
|
+
username #OpenDaylight login username (defaults to config username in initializer)
|
40
|
+
password #OpenDaylight login password (defaults to config password in initializer)
|
41
|
+
|
42
|
+
#Flow Parameters
|
43
|
+
id #Node ID (usually MAC address) *REQUIRED*
|
44
|
+
name #Flow Name *REQUIRED*
|
45
|
+
actions #OpenDaylight OpenFlow Action *REQUIRED*
|
46
|
+
ingressPort #Layer 1 (physical) Source Port
|
47
|
+
dlSrc #Layer 2 (MAC address) source
|
48
|
+
dlDst #Layer 2 (MAC address) Destination
|
49
|
+
nwSrc #Layer 3 (IP address) source
|
50
|
+
nwDst #Layer 3 (IP address) destination
|
51
|
+
tpSrc #Layer 4 (Network Socket Port) Source
|
52
|
+
tpDst #Layer 4 (Network Socket Port) destination
|
53
|
+
installInHW #Make the flow installed and active (default "true")
|
54
|
+
type #Node Type (default "OF")
|
55
|
+
protocol #IP Protocol Number (default "6")
|
56
|
+
etherType #Ethertype field (default "0x800")
|
57
|
+
vlanId #Virtual LAN ID
|
58
|
+
vlanPriority #Virtual LAN QoS Priotity
|
59
|
+
idleTimeout #Flow Idle Timeout
|
60
|
+
priority #Flow Priority
|
61
|
+
tosBits #Type of Service Bits
|
62
|
+
hardTimeout #Flow Hard Timeout
|
63
|
+
cookie #Cookie enhancements
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
## Contributing
|
68
|
+
|
69
|
+
1. Fork it ( https://github.com/[my-github-username]/odlgem/fork )
|
70
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
71
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
72
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
73
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/odlgem.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require "odlgem/version"
|
2
|
+
|
3
|
+
module Odlgem
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :username, :password, :url
|
6
|
+
def initialize
|
7
|
+
username = nil
|
8
|
+
password = nil
|
9
|
+
url = nil
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
attr_accessor :configuration
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.configure
|
18
|
+
self.configuration ||= Configuration.new
|
19
|
+
yield(configuration) if block_given?
|
20
|
+
end
|
21
|
+
|
22
|
+
class OpenDaylight
|
23
|
+
def self.makeflow(tpSrc: nil, protocol: "6", vlanId: nil, id: nil, type: "OF", vlanPriority: nil, idleTimeout: nil, priority: nil, ingressPort: nil, tosBits: nil, name: nil, hardTimeout: nil, dlDst: nil, installInHW: "true", etherType: "0x800", actions: nil, cookie: nil, dlSrc: nil, nwSrc: nil, nwDst: nil, tpDst: nil, username: Odlgem.configuration.username, password: Odlgem.configuration.password, url: Odlgem.configuration.url, containerName: "default")
|
24
|
+
auth = {username: username, password: password}
|
25
|
+
options = {
|
26
|
+
headers: {"Content-Type" => "application/json"},
|
27
|
+
body: {
|
28
|
+
"tpSrc" => tpSrc,
|
29
|
+
"protocol" => protocol,
|
30
|
+
"vlanId" => vlanId,
|
31
|
+
"node" => {
|
32
|
+
"id" => id,
|
33
|
+
"type" => type
|
34
|
+
},
|
35
|
+
"vlanPriority" => vlanPriority,
|
36
|
+
"idleTimeout" => idleTimeout,
|
37
|
+
"priority" => priority,
|
38
|
+
"ingressPort" => ingressPort,
|
39
|
+
"tosBits" => tosBits,
|
40
|
+
"name" => name,
|
41
|
+
"hardTimeout" => hardTimeout,
|
42
|
+
"dlDst" => dlDst,
|
43
|
+
"installInHW" => installInHW,
|
44
|
+
"etherType" => etherType,
|
45
|
+
"actions" => [actions],
|
46
|
+
"cookie" => cookie,
|
47
|
+
"dlSrc" => dlSrc,
|
48
|
+
"nwSrc" => nwSrc,
|
49
|
+
"nwDst" => nwDst,
|
50
|
+
"tpDst" => tpDst
|
51
|
+
}.to_json,
|
52
|
+
basic_auth: auth
|
53
|
+
}
|
54
|
+
HTTParty.put("#{url}controller/nb/v2/flowprogrammer/#{containerName}/node/#{type}/#{id}/staticFlow/#{name}",options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def username
|
58
|
+
Odlgem.configuration.username
|
59
|
+
end
|
60
|
+
|
61
|
+
def password
|
62
|
+
Odlgem.configuration.password
|
63
|
+
end
|
64
|
+
|
65
|
+
def url
|
66
|
+
Odlgem.configuration.url
|
67
|
+
end
|
68
|
+
end
|
69
|
+
Odlgem.configure
|
70
|
+
end
|
data/odlgem.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'odlgem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "odlgem"
|
8
|
+
spec.version = Odlgem::VERSION
|
9
|
+
spec.authors = ["rickpr"]
|
10
|
+
spec.email = ["fdisk@fdisk.co"]
|
11
|
+
spec.summary = "Ruby Wrapper for OpenDaylight FlowProgrammer"
|
12
|
+
spec.description = "Makes Programming flows with Ruby easy"
|
13
|
+
spec.homepage = "http://fdisk.co"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: odlgem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rickpr
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Makes Programming flows with Ruby easy
|
42
|
+
email:
|
43
|
+
- fdisk@fdisk.co
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/odlgem.rb
|
54
|
+
- lib/odlgem/version.rb
|
55
|
+
- odlgem.gemspec
|
56
|
+
homepage: http://fdisk.co
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.1
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: Ruby Wrapper for OpenDaylight FlowProgrammer
|
80
|
+
test_files: []
|