fluent-plugin-swift-sweep 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7eb98fc312888473404f3e39c21c40e503d92858
4
+ data.tar.gz: a8227b875c7f008ea866b35f03df7cac3af53940
5
+ SHA512:
6
+ metadata.gz: 5babdc86027cd29d1896baeea3a2f67d0684291796d55a93155924238f13fc700f61c63adc00a2bafee22f8d2ecda0ee3085eb01fa6b7fd09f06404827fbd199
7
+ data.tar.gz: afd48f1cfb3cbf0934adfe9b3d9720148c8c97ca0eb96dbcd1d28c5a3aced4554637bc93661fbfb70bc1c2f27f14cbf4613a2faa2a730792c8cc43eedc77ac32
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # 0.0.1
2
+
3
+ Enhancements:
4
+
5
+ * Initial (debug log)
6
+
7
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-swift-sweep.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 deepak.arumugham
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # fluent-plugin-swift-sweep
2
+
3
+
4
+ Fluentd plugin to read data from files and move it Swift object storage as is.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'fluent-plugin-swift-sweep'
12
+ ```
13
+
14
+ Or install it yourself as:
15
+
16
+ $ gem install fluent-plugin-swift-sweep
17
+
18
+ ## Basic Behavior
19
+
20
+ Assume your files are inside `/tmp/test` directory as
21
+
22
+ ```
23
+ tmp/test
24
+ ├── core.files1.log
25
+ ├── core.files2.log
26
+ └── core.files2.log
27
+ ```
28
+
29
+
30
+
31
+ This plugin watches the directory (`file_path_with_glob tmp/test/*.log`), and reads the contents and sends the files to swift storage and removes the file, after sending them to swift.
32
+
33
+ The files will be moved to swift container as:
34
+ tmp/test/core.files1.log
35
+ tmp/test/core.files2.log
36
+ tmp/test/core.files3.log
37
+
38
+ ## Configuration
39
+
40
+ ```
41
+ <source>
42
+ type swift_swwep
43
+
44
+ # Required. process files that match this pattern using glob.
45
+ file_path_with_glob /tmp/imp/*.log
46
+
47
+ # Required. Authentication URL
48
+ auth_url <Authentication url>
49
+
50
+ # Required. Authenticated User Name
51
+ auth_user <User name>
52
+
53
+ # Required. Password
54
+ auth_api_key <Password>
55
+
56
+ # Required. The name of the openstack tenant
57
+ auth_tenant <Openstack Tenant>
58
+
59
+ # Required. The name of the swift container
60
+ swift_container <Container Name>
61
+
62
+ ssl_verify false
63
+ </source>
64
+ ```
65
+
66
+ ## ChangeLog
67
+
68
+ [CHANGELOG.md](CHANGELOG.md)
69
+
70
+ ## Warning
71
+ * This plugin supports fluentd from v0.12.33
72
+
73
+ ## Contributing
74
+
75
+ 1. Fork it ( https://github.com/deepakarumugham/fluent-plugin-swift-sweep/fork )
76
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
77
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
78
+ 4. Push to the branch (`git push origin my-new-feature`)
79
+ 5. Create a new Pull Request
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-swift-sweep"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Deepak Arumugham"]
9
+ spec.email = ["deepak.arumugham@gmail.com"]
10
+
11
+ spec.summary = %q{Fluentd plugin to move files to swift container}
12
+ spec.description = spec.summary
13
+ spec.homepage = "https://github.com/deepakarumugham/fluent-plugin-swift-sweep"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `find .`.split("\n")
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_runtime_dependency "fluentd", "~> 0.12.0"
20
+ spec.add_dependency "fog", "~> 1.15.0"
21
+ end
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+
4
+ gem 'fluentd', '~> 0.12.0'
5
+ gemspec :path => "../"
@@ -0,0 +1,105 @@
1
+ module Fluent
2
+ class SwiftSweepInput < Input
3
+ Plugin.register_input('swift_sweep', self)
4
+
5
+ def initialize
6
+ super
7
+ require 'fog'
8
+ require 'time'
9
+ require 'open3'
10
+ end
11
+
12
+ config_param :file_path_with_glob, :string
13
+ config_param :auth_url, :string
14
+ config_param :auth_user, :string
15
+ config_param :auth_tenant, :string
16
+ config_param :auth_api_key, :string
17
+ config_param :swift_container, :string
18
+ config_param :auto_create_container, :bool, :default => true
19
+ config_param :ssl_verify, :bool, :default => false
20
+
21
+
22
+ def configure(conf)
23
+ super
24
+
25
+ if @file_path_with_glob.empty?
26
+ raise Fluent::ConfigError, "in_swift_sweep: `@file_path_with_glob` must has a valid path."
27
+ end
28
+
29
+ if @auth_url.empty?
30
+ raise Fluent::ConfigError, "in_swift_sweep: `@auth_url` is empty."
31
+ end
32
+
33
+ if @auth_user.empty?
34
+ raise Fluent::ConfigError, "in_swift_sweep: `@auth_user` is empty."
35
+ end
36
+
37
+ if @auth_tenant.empty?
38
+ raise Fluent::ConfigError, "in_swift_sweep: `@auth_tenant` is empty."
39
+ end
40
+
41
+ if @auth_api_key.empty?
42
+ raise Fluent::ConfigError, "in_swift_sweep: `@auth_api_key` is empty."
43
+ end
44
+
45
+ if @swift_container.empty?
46
+ raise Fluent::ConfigError, "in_swift_sweep: `@swift_container` is empty."
47
+ end
48
+
49
+ end
50
+
51
+ def start
52
+ super
53
+
54
+ Excon.defaults[:ssl_verify_peer] = false
55
+
56
+ $log.debug "openstack_auth_url: #{@auth_url}"
57
+ $log.debug "openstack_username: #{@auth_user}"
58
+ $log.debug "openstack_tenant: #{@auth_tenant}"
59
+ $log.debug "openstack_auth_key: #{@auth_api_key}"
60
+ @storage = Fog::Storage.new :provider => 'OpenStack',
61
+ :openstack_auth_url => @auth_url,
62
+ :openstack_username => @auth_user,
63
+ :openstack_tenant => @auth_tenant,
64
+ :openstack_api_key => @auth_api_key
65
+
66
+ check_container
67
+
68
+ @processing = true
69
+ @thread = Thread.new(&method(:run_periodic))
70
+ end
71
+
72
+ def shutdown
73
+ @processing = false
74
+ @thread.join
75
+ end
76
+
77
+ def run_periodic
78
+ while @processing
79
+ Dir.glob(@file_path_with_glob).map do |filename|
80
+ File.open(filename) do |file|
81
+ @storage.put_object(@swift_container, filename, file)
82
+ log.info "File #{filename} sent to swift"
83
+ FileUtils.rm(filename)
84
+ log.info "File #{filename} deleted"
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+
91
+ def check_container
92
+ begin
93
+ @storage.get_container(@swift_container)
94
+ rescue Fog::Storage::OpenStack::NotFound
95
+ if @auto_create_container
96
+ $log.info "Creating container #{@swift_container} on #{@auth_url}, #{@swift_account}"
97
+ @storage.put_container(@swift_container)
98
+ else
99
+ raise "The specified container does not exist: container = #{swift_container}"
100
+ end
101
+ end
102
+ end
103
+
104
+ end
105
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-swift-sweep
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Deepak Arumugham
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.12.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.12.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: fog
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.15.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.15.0
41
+ description: Fluentd plugin to move files to swift container
42
+ email:
43
+ - deepak.arumugham@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - "./CHANGELOG.md"
49
+ - "./Gemfile"
50
+ - "./LICENSE.txt"
51
+ - "./README.md"
52
+ - "./fluent-plugin-swift-sweep.gemspec"
53
+ - "./gemfiles/Gemfile.fluentd.0.12"
54
+ - "./lib/fluent/plugin/in_swift_sweep.rb"
55
+ homepage: https://github.com/deepakarumugham/fluent-plugin-swift-sweep
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.6.8
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: Fluentd plugin to move files to swift container
79
+ test_files: []