eltex-lte 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 +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/Rakefile +1 -0
- data/eltex-lte.gemspec +34 -0
- data/lib/eltex/lte.rb +2 -0
- data/lib/eltex/lte/session.rb +79 -0
- data/lib/eltex/lte/version.rb +5 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f4f27159653840445c7d5c25396b0eea4c7a5ec7
|
4
|
+
data.tar.gz: e50ad8372d8dc128b5548c62b8c9528a4d4a06e9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a12b3252a7cb1c4797053ee9dd85ea45f9632198edc4f00176ee151f30e8b27d9ae71e7a88fc11fc0b0b9409962fbce92b97a8e4200a1f9ac2e7f1c176507d2c
|
7
|
+
data.tar.gz: 2fddb3b51e5562d0bb47754a17a8507cf628b173a94b6cd9581be08acac34e429084c9d19ab14a557f8d67023b47257ee22663fa39cb4f8e5ab6e58040ffbad9
|
data/.gitignore
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Alexey Gordienko
|
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,86 @@
|
|
1
|
+
# Eltex::Lte
|
2
|
+
|
3
|
+
This gem for easy communication with Eltex LTE devices. It currently allows you to execute commands on a device and get back the output of those commands.
|
4
|
+
|
5
|
+
Eltex LTE-8X central office node terminal is designed to provide a broadband access over Passive Optical Network (PON). Access to provider transport network is realized by 10 Gigabit and combo Gigabit uplink interfaces. GPON interfaces are used for connection to Passive Optical distribution Network (PON). It is possible to connect up to 128 subscriber optical terminals to each interface by one fiber. Dynamic Bandwidth Allocation (DBA) enables to provide downstream rate up to 2.5 Gbps.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install from githib:
|
10
|
+
|
11
|
+
git clone git@github.com:gordienko/eltex-lte.git
|
12
|
+
cd eltex-lte
|
13
|
+
gem build eltex-lte.gemspec
|
14
|
+
gem install eltex-lte-<version>.gem
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
gem 'eltex-lte'
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install eltex-lte
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
### This library is used as follows:
|
31
|
+
|
32
|
+
require 'eltex/lte'
|
33
|
+
|
34
|
+
lte = Lte::Session.new(:host => "10.0.0.1", :user => "username", :password => "accesspass")
|
35
|
+
output = lte.cmd "add ont config XX:XX:XX:XX:XX:XX", :get_result => true
|
36
|
+
lte.cmd "ont_mac XX:XX:XX:XX:XX:XX"
|
37
|
+
lte.cmd "set description Petr Ivanov"
|
38
|
+
lte.cmd "set profile rules 1"
|
39
|
+
lte.cmd "set profile ipmc 2"
|
40
|
+
output = lte.cmd "reconfigure", :get_result => true
|
41
|
+
|
42
|
+
if output =~ /successfully reconfigured/m
|
43
|
+
puts "OK!"
|
44
|
+
else
|
45
|
+
puts "ERROR!"
|
46
|
+
end
|
47
|
+
|
48
|
+
lte.cmd "exit"
|
49
|
+
|
50
|
+
### Additional Connection Parameters
|
51
|
+
|
52
|
+
:password_pat => %r/Password:/io - Pattern password prompt string device
|
53
|
+
:prompt_pat => %r/^LTE-8X/io - Pattern prompt string device
|
54
|
+
:debug => true - Enable debug mode
|
55
|
+
|
56
|
+
### Additional examples of the use of library
|
57
|
+
|
58
|
+
Get data from the device in a list:
|
59
|
+
|
60
|
+
lte.cmd("show profile rules list", :get_result => true, :result_array => true).each do |l|
|
61
|
+
puts l.split(/\s+/)
|
62
|
+
end
|
63
|
+
|
64
|
+
Get data from the device in a list (way shorter):
|
65
|
+
|
66
|
+
lte.get_list("show ont list verbose all").each do |l|
|
67
|
+
puts l
|
68
|
+
end
|
69
|
+
|
70
|
+
Setting profiles ONT followed reconfiguration:
|
71
|
+
|
72
|
+
lte.set_ont_profile_and_reconfigure(:ont_mac => "XX:XX:XX:XX:XX:XX", :profile_index => 2, :profile_name => "ipmc")
|
73
|
+
|
74
|
+
Reconfiguration ONT:
|
75
|
+
|
76
|
+
if lte.ont_reconfigure("0E:00:02:00:27:28")
|
77
|
+
puts "ONT uccessfully reconfigured"
|
78
|
+
end
|
79
|
+
|
80
|
+
## Contributing
|
81
|
+
|
82
|
+
1. Fork it ( http://github.com/gordienko/eltex-lte/fork )
|
83
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
84
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
85
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
86
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/eltex-lte.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'eltex/lte/version'
|
5
|
+
require 'eltex/lte/session'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "eltex-lte"
|
9
|
+
spec.version = Eltex::Lte::VERSION
|
10
|
+
spec.authors = ["Alexey Gordienko"]
|
11
|
+
spec.email = ["alx@anadyr.org"]
|
12
|
+
spec.summary = %q{Ruby gem for management Eltex LTE via SSH}
|
13
|
+
spec.description = %q{This gem aims to provide transport-flexible functionality, for easy communication with Eltex LTE devices}
|
14
|
+
spec.homepage = "http://github.com/gordienko/eltex-lte"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = [
|
18
|
+
".gitignore",
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"eltex-lte.gemspec",
|
23
|
+
"lib/eltex/lte.rb",
|
24
|
+
"lib/eltex/lte/version.rb",
|
25
|
+
"lib/eltex/lte/session.rb"
|
26
|
+
]
|
27
|
+
|
28
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
29
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
30
|
+
spec.require_paths = ["lib"]
|
31
|
+
|
32
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
33
|
+
spec.add_development_dependency "rake"
|
34
|
+
end
|
data/lib/eltex/lte.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'pty'
|
2
|
+
require 'expect'
|
3
|
+
|
4
|
+
module Lte
|
5
|
+
class Session
|
6
|
+
|
7
|
+
def initialize(options = {}, &blk)
|
8
|
+
@host = options[:host]
|
9
|
+
@user = options[:user]
|
10
|
+
@password = options[:password]
|
11
|
+
@password_pat = options[:password_pat] || %r/Password:/io
|
12
|
+
@prompt_pat = options[:prompt_pat] || %r/^LTE-8X/io
|
13
|
+
$expect_verbose = true if options[:debug] == true
|
14
|
+
begin
|
15
|
+
@o, @i = PTY.spawn("ssh -oStrictHostKeyChecking=no #{@user}@#{@host}")
|
16
|
+
@i.sync = true
|
17
|
+
@o.expect(@password_pat){ @i.puts @password }
|
18
|
+
@o.expect(/#{@password_pat}|#{@prompt_pat}/io) do |output|
|
19
|
+
abort "Incorrect username or password!" if output.first =~ @password_pat
|
20
|
+
@i.puts
|
21
|
+
end
|
22
|
+
rescue
|
23
|
+
abort "Could not connect to device #{@host}!"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Run command
|
28
|
+
def cmd(command, options = {})
|
29
|
+
@o.expect(@prompt_pat){ @i.puts command }
|
30
|
+
get_result(:array => options[:result_array]) if options[:get_result] == true
|
31
|
+
end
|
32
|
+
|
33
|
+
# Getting results in a list
|
34
|
+
def get_list(command)
|
35
|
+
out = []
|
36
|
+
cmd(command)
|
37
|
+
get_result(:array => true).each do |line|
|
38
|
+
out << line.split(/\s+/)
|
39
|
+
end
|
40
|
+
out
|
41
|
+
end
|
42
|
+
|
43
|
+
# Reconfigure ONT
|
44
|
+
def ont_reconfigure(ont_mac)
|
45
|
+
cmd "ont_mac #{ont_mac}"
|
46
|
+
cmd "reconfigure"
|
47
|
+
ret_val = (get_result =~ /successfully reconfigured/m ? true : false)
|
48
|
+
cmd "exit"
|
49
|
+
return ret_val
|
50
|
+
end
|
51
|
+
|
52
|
+
# Setting ONT profile and reconfigure
|
53
|
+
def set_ont_profile_and_reconfigure(options = {})
|
54
|
+
ont_mac = options[:ont_mac]
|
55
|
+
profile_index = options[:profile_index] || 0
|
56
|
+
profile_name = options[:profile_name] || "ipmc"
|
57
|
+
cmd "ont_mac #{ont_mac}"
|
58
|
+
cmd "set profile #{profile_name} #{profile_index}"
|
59
|
+
cmd "reconfigure"
|
60
|
+
ret_val = (get_result =~ /successfully reconfigured/m ? true : false)
|
61
|
+
cmd "exit"
|
62
|
+
return ret_val
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
# Getting result
|
68
|
+
def get_result(options = {})
|
69
|
+
array = options[:array] || false
|
70
|
+
out = []
|
71
|
+
@o.expect(@prompt_pat) do |output|
|
72
|
+
out = output.first.split(/\n/)
|
73
|
+
@i.puts
|
74
|
+
end
|
75
|
+
array ? out[1..-2] : out[1..-2].join("\n")
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eltex-lte
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexey Gordienko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-22 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.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
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: This gem aims to provide transport-flexible functionality, for easy communication
|
42
|
+
with Eltex LTE devices
|
43
|
+
email:
|
44
|
+
- alx@anadyr.org
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- eltex-lte.gemspec
|
54
|
+
- lib/eltex/lte.rb
|
55
|
+
- lib/eltex/lte/session.rb
|
56
|
+
- lib/eltex/lte/version.rb
|
57
|
+
homepage: http://github.com/gordienko/eltex-lte
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.3.0
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Ruby gem for management Eltex LTE via SSH
|
81
|
+
test_files: []
|