cantemo-portal-agent 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cantemo/portal/agent/version.rb +1 -1
- data/lib/cantemo/portal/api/client.rb +75 -0
- data/lib/envoi/mam/agent.rb +8 -3
- data/lib/envoi/mam/cantemo/agent.rb +3 -51
- data/lib/envoi/mam/cantemo/agent/watch_folder_manager.rb +4 -4
- data/lib/envoi/watch_folder_utility/watch_folder.rb +2 -0
- data/lib/envoi/watch_folder_utility/watch_folder/handler/listen.rb +2 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e171c53876f59041d8c032a5ec5603b5f25a962b
|
4
|
+
data.tar.gz: 19e7b87575175471a9484439aee1d23b8b211491
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e72d5bfc3ed43872318954bacf30bbc140d2f884bd67419c64fc8568dc2fdd78c628f25a4b95fb942b33494b41d09afaa46ea4798e1b303271337178c966f296
|
7
|
+
data.tar.gz: 1e211ac9951ad604a900068e0b4d85b5d36fcc685660c9288d25855da209cf787145940d87c4673fedfc2b3ca93c72b220c4e4fe526819ed40b8d32d0be62b93
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'vidispine/api/utilities'
|
2
|
+
require 'cantemo/portal/agent/version'
|
3
|
+
|
4
|
+
module Cantemo
|
5
|
+
module Portal
|
6
|
+
module API
|
7
|
+
|
8
|
+
class Client
|
9
|
+
|
10
|
+
def initialize(args = { })
|
11
|
+
api_host = args[:host]
|
12
|
+
api_port = args[:port]
|
13
|
+
api_host_use_ssl = args[:ssl]
|
14
|
+
api_username = args[:username]
|
15
|
+
api_password = args[:password]
|
16
|
+
api_auth_token = args[:api_auth_token]
|
17
|
+
api_base_path = args[:api_base_path]
|
18
|
+
api_default_query_data = args[:default_query_data]
|
19
|
+
|
20
|
+
api_url = args[:url] || args[:uri]
|
21
|
+
if api_url
|
22
|
+
api_uri = URI(api_url)
|
23
|
+
api_host ||= api_uri.host
|
24
|
+
api_port ||= api_uri.port
|
25
|
+
api_userinfo = api_uri.userinfo
|
26
|
+
if api_userinfo
|
27
|
+
_api_username, _api_password = api_userinfo.split(':')
|
28
|
+
api_username ||= _api_username
|
29
|
+
api_password ||= _api_password
|
30
|
+
end
|
31
|
+
api_host_use_ssl = api_uri.scheme == 'https' if api_host_use_ssl.nil?
|
32
|
+
api_uri_query = api_uri.query
|
33
|
+
api_default_query_data ||= Hash[api_uri_query.split('&').map { |kp| kp.split('=') }]
|
34
|
+
api_base_path ||= api_uri.path
|
35
|
+
end
|
36
|
+
|
37
|
+
api_port ||= (api_host_use_ssl ? 443 : 80)
|
38
|
+
api_base_path ||= '/'
|
39
|
+
|
40
|
+
api_endpoint_prefix = 'VSAPI'
|
41
|
+
api_noauth_endpoint_prefix = 'APInoauth'
|
42
|
+
|
43
|
+
client_args = {}
|
44
|
+
client_args[:http_host_address] = api_host if api_host
|
45
|
+
client_args[:http_host_port] = api_port if api_port
|
46
|
+
client_args[:http_host_use_ssl] = api_host_use_ssl if api_host_use_ssl
|
47
|
+
client_args[:username] = api_username if api_username
|
48
|
+
client_args[:password] = api_password if api_password
|
49
|
+
client_args[:default_base_path] = api_base_path if api_base_path
|
50
|
+
client_args[:default_query_data] = api_default_query_data if api_default_query_data
|
51
|
+
client_args[:api_endpoint_prefix] = api_endpoint_prefix
|
52
|
+
client_args[:api_noauth_endpoint_prefix] = api_noauth_endpoint_prefix
|
53
|
+
|
54
|
+
if api_auth_token
|
55
|
+
# Cantemo Portal supports an auth token for authentication, replace basic auth with auth-token
|
56
|
+
client_args[:authorization_header_key] = 'Auth-Token'
|
57
|
+
client_args[:authorization_header_value] = api_auth_token
|
58
|
+
end
|
59
|
+
_client = ::Vidispine::API::Utilities.new(client_args)
|
60
|
+
_client.http_client.user_agent = "Cantemo Portal Agent v#{Cantemo::Portal::Agent::VERSION} - #{_client.http_client.user_agent}"
|
61
|
+
_client
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# Client
|
66
|
+
end
|
67
|
+
|
68
|
+
# API
|
69
|
+
end
|
70
|
+
|
71
|
+
# Portal
|
72
|
+
end
|
73
|
+
|
74
|
+
# Cantemo
|
75
|
+
end
|
data/lib/envoi/mam/agent.rb
CHANGED
@@ -36,7 +36,13 @@ module Envoi
|
|
36
36
|
return if @notifiers.empty?
|
37
37
|
args[:level] ||= :info
|
38
38
|
args[:message] ||= message
|
39
|
-
@notifiers.each
|
39
|
+
@notifiers.each do |notifier|
|
40
|
+
begin
|
41
|
+
notifier.notify(args) rescue nil
|
42
|
+
rescue => e
|
43
|
+
logger.warn { "Notification Failed: #{e.message} "}
|
44
|
+
end
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
# @param [Hash] args {}
|
@@ -82,8 +88,7 @@ module Envoi
|
|
82
88
|
|
83
89
|
def self.load_config_from_file(args)
|
84
90
|
config_file_path = args[:config_file_path]
|
85
|
-
config_file_path = File.expand_path(
|
86
|
-
config_file_path = config_file_path.find { |v| File.exists?(v) } if config_file_path.is_a?(Array)
|
91
|
+
config_file_path = [*config_file_path].find { |v| File.exists?(File.expand_path(v)) }
|
87
92
|
raise "Missing Config File. '#{config_file_path}'" unless config_file_path && !config_file_path.empty? && File.exists?(config_file_path)
|
88
93
|
|
89
94
|
begin
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cantemo/portal/api/client'
|
1
2
|
require 'envoi/mam/agent/transfer_client/aspera'
|
2
3
|
require 'envoi/mam/agent/transfer_client/s3'
|
3
4
|
|
@@ -42,57 +43,8 @@ module Envoi
|
|
42
43
|
def initialize_api_client(args = {})
|
43
44
|
api_config = agent_config
|
44
45
|
@api_client = args[:api_client] || begin
|
45
|
-
|
46
|
-
|
47
|
-
api_port = api_config['port']
|
48
|
-
api_host_use_ssl = api_config['ssl']
|
49
|
-
api_username = api_config['username']
|
50
|
-
api_password = api_config['password']
|
51
|
-
api_auth_token = api_config['api_auth_token']
|
52
|
-
api_base_path = api_config['api_base_path']
|
53
|
-
api_default_query_data = api_config['default_query_data']
|
54
|
-
|
55
|
-
api_url = api_config['url'] || api_config['uri']
|
56
|
-
if api_url
|
57
|
-
api_uri = URI(api_url)
|
58
|
-
api_host ||= api_uri.host
|
59
|
-
api_port ||= api_uri.port
|
60
|
-
api_userinfo = api_uri.userinfo
|
61
|
-
if api_userinfo
|
62
|
-
_api_username, _api_password = api_userinfo.split(':')
|
63
|
-
api_username ||= _api_username
|
64
|
-
api_password ||= _api_password
|
65
|
-
end
|
66
|
-
api_host_use_ssl = api_uri.scheme == 'https' if api_host_use_ssl.nil?
|
67
|
-
api_uri_query = api_uri.query
|
68
|
-
api_default_query_data ||= Hash[api_uri_query.split('&').map { |kp| kp.split('=') }]
|
69
|
-
api_base_path ||= api_uri.path
|
70
|
-
end
|
71
|
-
|
72
|
-
api_port ||= (api_host_use_ssl ? 443 : 80)
|
73
|
-
api_base_path ||= '/'
|
74
|
-
|
75
|
-
api_endpoint_prefix = 'VSAPI'
|
76
|
-
api_noauth_endpoint_prefix = 'APInoauth'
|
77
|
-
|
78
|
-
client_args = {}
|
79
|
-
client_args[:http_host_address] = api_host if api_host
|
80
|
-
client_args[:http_host_port] = api_port if api_port
|
81
|
-
client_args[:http_host_use_ssl] = api_host_use_ssl if api_host_use_ssl
|
82
|
-
client_args[:username] = api_username if api_username
|
83
|
-
client_args[:password] = api_password if api_password
|
84
|
-
client_args[:default_base_path] = api_base_path if api_base_path
|
85
|
-
client_args[:default_query_data] = api_default_query_data if api_default_query_data
|
86
|
-
client_args[:api_endpoint_prefix] = api_endpoint_prefix
|
87
|
-
client_args[:api_noauth_endpoint_prefix] = api_noauth_endpoint_prefix
|
88
|
-
|
89
|
-
if api_auth_token
|
90
|
-
# Cantemo Portal supports an auth token for authentication, replace basic auth with auth-token
|
91
|
-
client_args[:authorization_header_key] = 'Auth-Token'
|
92
|
-
client_args[:authorization_header_value] = api_auth_token
|
93
|
-
end
|
94
|
-
|
95
|
-
_client = ::Vidispine::API::Utilities.new(client_args)
|
46
|
+
client_args = Hash[api_config.map { |k,v| [ k.respond_to?(:to_sym) ? k.to_sym.downcase : k, v ]}]
|
47
|
+
_client = Cantemo::Portal::API::Client.new(client_args)
|
96
48
|
|
97
49
|
begin
|
98
50
|
_client.version
|
@@ -207,14 +207,14 @@ module Envoi::Mam::Cantemo
|
|
207
207
|
if includes && !includes.empty?
|
208
208
|
should_include = find_in_patterns(includes, file)
|
209
209
|
unless should_include
|
210
|
-
add_to_ignore(
|
210
|
+
add_to_ignore(file)
|
211
211
|
next
|
212
212
|
end
|
213
213
|
end
|
214
214
|
|
215
215
|
should_exclude = find_in_patterns(excludes, file)
|
216
216
|
if should_exclude
|
217
|
-
add_to_ignore(
|
217
|
+
add_to_ignore(file)
|
218
218
|
next
|
219
219
|
end
|
220
220
|
|
@@ -226,7 +226,7 @@ module Envoi::Mam::Cantemo
|
|
226
226
|
end
|
227
227
|
t = Thread.new(wf, file) do |wf, file|
|
228
228
|
begin
|
229
|
-
process_file(
|
229
|
+
process_file(file)
|
230
230
|
rescue => e
|
231
231
|
logger.error { "Exception '#{e.message}' in thread for `#{wf.name || wf.paths}` `#{file.path}`. " }
|
232
232
|
raise e
|
@@ -237,7 +237,7 @@ module Envoi::Mam::Cantemo
|
|
237
237
|
t.join
|
238
238
|
active_processors[file] = t if file.processing
|
239
239
|
else
|
240
|
-
process_file(
|
240
|
+
process_file(file)
|
241
241
|
end
|
242
242
|
|
243
243
|
end
|
@@ -222,6 +222,8 @@ module Envoi
|
|
222
222
|
logger.debug { "Initializing parameter 'import args'." }
|
223
223
|
import_args = watch_folder_def['import_args'] || { }
|
224
224
|
import_options = watch_folder_def['import_options'] || { }
|
225
|
+
import_args = Hash[import_args.map { |k,v| [ k.respond_to?(:to_sym) ? k.to_sym.downcase : k, v ] }]
|
226
|
+
import_options = Hash[import_options.map { |k,v| [ k.respond_to?(:to_sym) ? k.to_sym.downcase : k, v ] }]
|
225
227
|
|
226
228
|
add_item_to_collection = import_options.fetch(:add_item_to_collection, import_args[:add_item_to_collection])
|
227
229
|
if add_item_to_collection.nil? || add_item_to_collection
|
@@ -92,6 +92,7 @@ module Envoi
|
|
92
92
|
process_definition(@definition)
|
93
93
|
initialize_listener
|
94
94
|
logger.debug ( "Watch Folder Handler '#{self.class.name}' Initialized. ")
|
95
|
+
perform_initial_inventory
|
95
96
|
end
|
96
97
|
|
97
98
|
def initialize_logger(args = { })
|
@@ -187,7 +188,7 @@ module Envoi
|
|
187
188
|
end
|
188
189
|
|
189
190
|
def add_to_ignore(file)
|
190
|
-
|
191
|
+
ignored_files_map[file.path] = file
|
191
192
|
end
|
192
193
|
|
193
194
|
# Really this is just for debugging as polling isn't used to determine file stability
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cantemo-portal-agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Whitson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asperalm
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '1.
|
89
|
+
version: '1.6'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '1.
|
96
|
+
version: '1.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: bundler
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/cantemo/portal/agent/cli/commands/watch_folders-working.rb
|
152
152
|
- lib/cantemo/portal/agent/cli/commands/watch_folders.rb
|
153
153
|
- lib/cantemo/portal/agent/version.rb
|
154
|
+
- lib/cantemo/portal/api/client.rb
|
154
155
|
- lib/envoi/aspera/watch_service/client.rb
|
155
156
|
- lib/envoi/aspera/watch_service/snapshot.rb
|
156
157
|
- lib/envoi/aspera/watch_service/subscription.rb
|