yetis_node 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/bin/yetis_cmd_list.rb +28 -0
- data/lib/yetis_node/client.rb +36 -0
- data/lib/yetis_node/cmd/base.rb +20 -0
- data/lib/yetis_node/cmd/request.rb +23 -0
- data/lib/yetis_node/cmd/set.rb +11 -0
- data/lib/yetis_node/cmd/show.rb +87 -0
- data/lib/yetis_node/error.rb +4 -0
- data/lib/yetis_node/version.rb +3 -0
- data/lib/yetis_node.rb +11 -0
- data/yetis_node.gemspec +23 -0
- metadata +89 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 12ec6ee193e09c26408b79916cba7e05957f1d25
|
4
|
+
data.tar.gz: 6a7a41c5941489b3511646c6188fa904fbd829a9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a73e234eb4557dfeb3abe409ce7a8d98b52daa4e481aa548851c2597cffc474683418610c4403ede2d8e1f8a0fdde9e2ec80260cda31815bb20e159b8f5d471
|
7
|
+
data.tar.gz: c200fc6878c0b9899e1894325bac3bb7960b45514e5c3865d6de2b005f9ff89ed7967ff746570f3dea882ba9c895f096d02305d59f37e3ed927d75b56518c129
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Igor Fedoronchuk
|
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,37 @@
|
|
1
|
+
# YetisNode
|
2
|
+
|
3
|
+
```ruby
|
4
|
+
node = YetisNode::Client.new('http://10.10.10.10:8090')
|
5
|
+
<YetisNode::Client:0x007f9d8b8b46f8 @uri="http://10.10.10.10:8090", @options={}>
|
6
|
+
node.calls_count
|
7
|
+
=> "10"
|
8
|
+
```
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'yetis_node'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install yetis_node
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
TODO: Write usage instructions here
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it ( https://github.com/[my-github-username]/yetis_node/fork )
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require "xmlrpc/client"
|
4
|
+
|
5
|
+
if(ARGV.empty?)
|
6
|
+
puts "usage: #{$0} host:port"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
(host,port) = ARGV[0].split(':')
|
11
|
+
$s = XMLRPC::Client.new(host, "/", port)
|
12
|
+
|
13
|
+
def f(*args)
|
14
|
+
puts args.take(args.size-1).join(' ')
|
15
|
+
r = $s.call("di","yeti", *args)
|
16
|
+
return if !r.kind_of?(Array)
|
17
|
+
r.each do |e|
|
18
|
+
if e.kind_of?(Array)
|
19
|
+
f(*args.first(args.size - 1), e[0],'_list')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
f '_list'
|
26
|
+
rescue XMLRPC::FaultException => e
|
27
|
+
puts "Error: #{e.faultCode} #{e.faultString}"
|
28
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'xmlrpc/client'
|
2
|
+
module YetisNode
|
3
|
+
|
4
|
+
|
5
|
+
# node = YetisNode::Client.new('http://10.10.10.10:8090')
|
6
|
+
# <YetisNode::Client:0x007f9d8b8b46f8 @uri="http://10.10.10.10:8090", @options={}>
|
7
|
+
# node.calls_count
|
8
|
+
# => "10"
|
9
|
+
class Client
|
10
|
+
attr_reader :uri
|
11
|
+
|
12
|
+
DEFAULT_TIMEOUT = 10
|
13
|
+
|
14
|
+
def initialize(uri, options = {})
|
15
|
+
@uri = uri
|
16
|
+
@options = options
|
17
|
+
end
|
18
|
+
|
19
|
+
include Cmd::Base
|
20
|
+
include Cmd::Show
|
21
|
+
include Cmd::Request
|
22
|
+
include Cmd::Set
|
23
|
+
|
24
|
+
|
25
|
+
protected :invoke_show, :invoke_request, :invoke_set
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def xml_rpc
|
30
|
+
@xml_rpc ||= XMLRPC::Client.new2(uri, @options.fetch(:proxy, nil), @options.fetch(:timeout, DEFAULT_TIMEOUT))
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module YetisNode
|
2
|
+
module Cmd
|
3
|
+
module Base
|
4
|
+
|
5
|
+
|
6
|
+
def invoke(method, prefix, args = [])
|
7
|
+
rpc_send(*([prefix] + method.to_s.split("_") + args.compact))
|
8
|
+
end
|
9
|
+
|
10
|
+
def rpc_send(*args)
|
11
|
+
begin
|
12
|
+
xml_rpc.call_async('di', 'yeti', *args)
|
13
|
+
rescue XMLRPC::FaultException => e
|
14
|
+
raise Error.new(e.message)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module YetisNode
|
2
|
+
module Cmd
|
3
|
+
module Request
|
4
|
+
|
5
|
+
def resolver_clear
|
6
|
+
invoke_request
|
7
|
+
end
|
8
|
+
|
9
|
+
def router_clear_cache
|
10
|
+
invoke_request
|
11
|
+
end
|
12
|
+
|
13
|
+
def call_disconnect(*args)
|
14
|
+
invoke_request(args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def invoke_request(args = [])
|
18
|
+
invoke(caller_locations(1, 1)[0].label, 'request', args)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module YetisNode
|
2
|
+
module Cmd
|
3
|
+
module Show
|
4
|
+
|
5
|
+
# show calls
|
6
|
+
# show calls <LOCAL-TAG>
|
7
|
+
# show calls count
|
8
|
+
# show calls filtered <field1> <field2> ...
|
9
|
+
# show configuration
|
10
|
+
# show interfaces
|
11
|
+
# show media streams
|
12
|
+
# show registrations
|
13
|
+
# show registrations <id>
|
14
|
+
# show registrations count
|
15
|
+
# show resource state <type>/all <id>/all
|
16
|
+
# show resource state used
|
17
|
+
# show resource state used handler <handler_id>
|
18
|
+
# show resource state used owner_tag <onwer_local_tag>
|
19
|
+
# show resource state used resource_id <resource_id>
|
20
|
+
# show resource types
|
21
|
+
# show router cache
|
22
|
+
# show router cdrwriter
|
23
|
+
# show router cdrwriter opened-files
|
24
|
+
# show sensors
|
25
|
+
# show stats
|
26
|
+
# show system alarms
|
27
|
+
# show system log-level
|
28
|
+
# show system session-limit
|
29
|
+
# show system status
|
30
|
+
# show version
|
31
|
+
|
32
|
+
def registrations_count
|
33
|
+
registrations('count')
|
34
|
+
end
|
35
|
+
|
36
|
+
def registrations(*args)
|
37
|
+
invoke_show(args)
|
38
|
+
end
|
39
|
+
|
40
|
+
def calls_filtered(only = [])
|
41
|
+
calls('filtered', *only)
|
42
|
+
end
|
43
|
+
|
44
|
+
def calls_count
|
45
|
+
calls('count')
|
46
|
+
end
|
47
|
+
|
48
|
+
def calls(*args)
|
49
|
+
invoke_show(args)
|
50
|
+
end
|
51
|
+
|
52
|
+
def media_streams
|
53
|
+
invoke_show
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def system_status
|
58
|
+
invoke_show
|
59
|
+
end
|
60
|
+
|
61
|
+
def stats
|
62
|
+
invoke_show
|
63
|
+
end
|
64
|
+
|
65
|
+
def configuration
|
66
|
+
invoke_show
|
67
|
+
end
|
68
|
+
|
69
|
+
def interfaces
|
70
|
+
invoke_show
|
71
|
+
end
|
72
|
+
|
73
|
+
def version
|
74
|
+
invoke_show
|
75
|
+
end
|
76
|
+
|
77
|
+
def resource_state(type_id, id = nil)
|
78
|
+
invoke_show([type_id, id || :all])
|
79
|
+
end
|
80
|
+
|
81
|
+
def invoke_show(args = [])
|
82
|
+
invoke(caller_locations(1, 1)[0].label, 'show', args)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/yetis_node.rb
ADDED
data/yetis_node.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 'yetis_node/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "yetis_node"
|
8
|
+
spec.version = YetisNode::VERSION
|
9
|
+
spec.authors = ["Igor Fedoronchuk"]
|
10
|
+
spec.email = ["igor.f@didww.com"]
|
11
|
+
spec.summary = %q{XMLRPC client for YETI switch.}
|
12
|
+
spec.description = %q{XMLRPC client for YETI switch. http://yeti-switch.org }
|
13
|
+
spec.homepage = "http://yeti-switch.org"
|
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.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yetis_node
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Igor Fedoronchuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-14 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: 'XMLRPC client for YETI switch. http://yeti-switch.org '
|
42
|
+
email:
|
43
|
+
- igor.f@didww.com
|
44
|
+
executables:
|
45
|
+
- yetis_cmd_list.rb
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/yetis_cmd_list.rb
|
55
|
+
- lib/yetis_node.rb
|
56
|
+
- lib/yetis_node/client.rb
|
57
|
+
- lib/yetis_node/cmd/base.rb
|
58
|
+
- lib/yetis_node/cmd/request.rb
|
59
|
+
- lib/yetis_node/cmd/set.rb
|
60
|
+
- lib/yetis_node/cmd/show.rb
|
61
|
+
- lib/yetis_node/error.rb
|
62
|
+
- lib/yetis_node/version.rb
|
63
|
+
- yetis_node.gemspec
|
64
|
+
homepage: http://yeti-switch.org
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.2.2
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: XMLRPC client for YETI switch.
|
88
|
+
test_files: []
|
89
|
+
has_rdoc:
|