etna 0.1.52 → 0.2.0
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 +4 -4
- data/bin/etna +2 -2
- data/lib/commands.rb +10 -8
- data/lib/etna/application.rb +33 -0
- data/lib/etna/auth.rb +5 -2
- data/lib/etna/client.rb +7 -12
- data/lib/etna/clients/base_client.rb +10 -2
- data/lib/etna/clients/gnomon/client.rb +20 -0
- data/lib/etna/clients/gnomon/models.rb +33 -0
- data/lib/etna/clients/gnomon.rb +2 -0
- data/lib/etna/clients/janus/client.rb +26 -0
- data/lib/etna/clients/janus/models.rb +16 -0
- data/lib/etna/clients/janus/workflows/generate_token_workflow.rb +1 -1
- data/lib/etna/clients/magma/client.rb +126 -6
- data/lib/etna/clients/magma/models.rb +64 -22
- data/lib/etna/clients/magma/workflows/model_synchronization_workflow.rb +2 -4
- data/lib/etna/clients/metis/client.rb +66 -2
- data/lib/etna/clients/metis/models.rb +138 -85
- data/lib/etna/clients/metis/workflows/ingest_metis_data_workflow.rb +15 -5
- data/lib/etna/clients/metis/workflows/metis_upload_workflow.rb +1 -0
- data/lib/etna/clients/models.rb +19 -0
- data/lib/etna/clients/polyphemus/client.rb +96 -0
- data/lib/etna/clients.rb +2 -0
- data/lib/etna/controller.rb +31 -6
- data/lib/etna/cross_origin.rb +1 -1
- data/lib/etna/cwl.rb +1 -1
- data/lib/etna/errors.rb +8 -0
- data/lib/etna/filesystem.rb +5 -170
- data/lib/etna/hmac.rb +4 -4
- data/lib/etna/instrumentation.rb +6 -6
- data/lib/etna/redirect.rb +1 -1
- data/lib/etna/remote.rb +18 -2
- data/lib/etna/route.rb +3 -0
- data/lib/etna/spec/event_log.rb +16 -0
- data/lib/etna/spec/vcr.rb +3 -3
- data/lib/etna/test_auth.rb +1 -1
- data/lib/etna/user.rb +0 -4
- data/lib/helpers.rb +8 -0
- metadata +8 -5
|
@@ -33,6 +33,102 @@ module Etna
|
|
|
33
33
|
yield res
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
def get_config(project_name, config_id, version_number)
|
|
38
|
+
json = nil
|
|
39
|
+
@etna_client.post("/api/workflows/#{project_name}/configs/#{config_id}", version_number: version_number) do |res|
|
|
40
|
+
json = JSON.parse(res.body)
|
|
41
|
+
end
|
|
42
|
+
json
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def get_runtime_config(project_name, config_id)
|
|
46
|
+
json = nil
|
|
47
|
+
@etna_client.get("/api/workflows/#{project_name}/runtime_configs/#{config_id}") do |res|
|
|
48
|
+
json = JSON.parse(res.body)
|
|
49
|
+
end
|
|
50
|
+
json
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def update_run(project_name, run_id, updates)
|
|
54
|
+
payload = {
|
|
55
|
+
run_id: run_id,
|
|
56
|
+
workflow_name: updates[:workflow_name],
|
|
57
|
+
name: updates[:name],
|
|
58
|
+
config_id: updates[:config_id],
|
|
59
|
+
version_number: updates[:version_number],
|
|
60
|
+
state: updates[:state],
|
|
61
|
+
orchestrator_metadata: updates[:orchestrator_metadata],
|
|
62
|
+
output: updates[:output],
|
|
63
|
+
append_output: updates[:append_output]
|
|
64
|
+
}.compact
|
|
65
|
+
|
|
66
|
+
json = nil
|
|
67
|
+
@etna_client.post("/api/workflows/#{project_name}/run/update/#{run_id}", payload) do |res|
|
|
68
|
+
json = JSON.parse(res.body)
|
|
69
|
+
end
|
|
70
|
+
json
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def get_run(project_name, run_id)
|
|
74
|
+
json = nil
|
|
75
|
+
@etna_client.get("/api/workflows/#{project_name}/run/#{run_id}") do |res|
|
|
76
|
+
json = JSON.parse(res.body)
|
|
77
|
+
end
|
|
78
|
+
json
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def get_previous_state(project_name, config_id, state: [], collect: false)
|
|
82
|
+
json = nil
|
|
83
|
+
@etna_client.post("/api/workflows/#{project_name}/run/previous/#{config_id}",
|
|
84
|
+
state: state,
|
|
85
|
+
collect: collect
|
|
86
|
+
) do |res|
|
|
87
|
+
json = JSON.parse(res.body)
|
|
88
|
+
end
|
|
89
|
+
json
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def update_runtime_config(project_name, config_id, updates)
|
|
93
|
+
payload = {
|
|
94
|
+
config_id: updates[:config_id],
|
|
95
|
+
runtime_config: updates[:runtime_config],
|
|
96
|
+
run_interval: updates[:run_interval],
|
|
97
|
+
disabled: updates[:disabled]
|
|
98
|
+
}.compact
|
|
99
|
+
|
|
100
|
+
json = nil
|
|
101
|
+
@etna_client.post("/api/workflows/#{project_name}/runtime_config/#{config_id}", payload) do |res|
|
|
102
|
+
json = JSON.parse(res.body)
|
|
103
|
+
end
|
|
104
|
+
json
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def get_run_metadata(project_name, config_id)
|
|
108
|
+
json = nil
|
|
109
|
+
@etna_client.get("/api/workflows/#{project_name}/runtime_config/#{config_id}") do |res|
|
|
110
|
+
json = JSON.parse(res.body)
|
|
111
|
+
end
|
|
112
|
+
json
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def log(project_name:, user:, event:, message:, payload:, signatory:, consolidate:, application:nil)
|
|
116
|
+
params = {
|
|
117
|
+
project_name: project_name,
|
|
118
|
+
user: user,
|
|
119
|
+
event: event,
|
|
120
|
+
message: message,
|
|
121
|
+
payload: payload,
|
|
122
|
+
consolidate: consolidate,
|
|
123
|
+
application: application,
|
|
124
|
+
signatory: signatory
|
|
125
|
+
}
|
|
126
|
+
json = nil
|
|
127
|
+
@etna_client.log_write(params) do |res|
|
|
128
|
+
json = JSON.parse(res.body)
|
|
129
|
+
end
|
|
130
|
+
json
|
|
131
|
+
end
|
|
36
132
|
end
|
|
37
133
|
end
|
|
38
134
|
end
|
data/lib/etna/clients.rb
CHANGED
data/lib/etna/controller.rb
CHANGED
|
@@ -16,10 +16,25 @@ module Etna
|
|
|
16
16
|
@hmac = @request.env['etna.hmac']
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
def application
|
|
20
|
+
Etna::Application.instance
|
|
21
|
+
end
|
|
22
|
+
|
|
19
23
|
def log(line)
|
|
20
24
|
@logger.warn(request_msg(line))
|
|
21
25
|
end
|
|
22
26
|
|
|
27
|
+
def event_log(params)
|
|
28
|
+
begin
|
|
29
|
+
Etna::Application.instance.event_log(**{
|
|
30
|
+
project_name: @params[:project_name],
|
|
31
|
+
user: @user
|
|
32
|
+
}.compact.merge(params))
|
|
33
|
+
rescue Exception => e
|
|
34
|
+
log("event_log failed with #{e.backtrace} #{e.message}")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
23
38
|
def handle_error(e)
|
|
24
39
|
case e
|
|
25
40
|
when Etna::Error
|
|
@@ -72,7 +87,16 @@ module Etna
|
|
|
72
87
|
@response.close
|
|
73
88
|
else
|
|
74
89
|
@response['Content-Type'] = content_type
|
|
75
|
-
|
|
90
|
+
response = @response
|
|
91
|
+
# Rack::Response is not a full IO object in Rack 3. JSON.dump calls
|
|
92
|
+
# flush after writing, so adapt the non-hijack/test response path to
|
|
93
|
+
# the same small stream interface provided by a hijacked socket.
|
|
94
|
+
stream = Object.new
|
|
95
|
+
stream.define_singleton_method(:write) { |data| response.write(data) }
|
|
96
|
+
stream.define_singleton_method(:<<) { |data| write(data) }
|
|
97
|
+
stream.define_singleton_method(:flush) {}
|
|
98
|
+
|
|
99
|
+
block.call(stream)
|
|
76
100
|
@response.finish
|
|
77
101
|
end
|
|
78
102
|
end
|
|
@@ -86,7 +110,7 @@ Subject: #{subject}
|
|
|
86
110
|
#{content}
|
|
87
111
|
MESSAGE_END
|
|
88
112
|
|
|
89
|
-
unless
|
|
113
|
+
unless application.test?
|
|
90
114
|
Net::SMTP.start('smtp.ucsf.edu') do |smtp|
|
|
91
115
|
smtp.send_message message, 'noreply@janus', to_email
|
|
92
116
|
end
|
|
@@ -108,7 +132,7 @@ MESSAGE_END
|
|
|
108
132
|
def route_url(name, params={})
|
|
109
133
|
path = route_path(name,params)
|
|
110
134
|
return nil unless path
|
|
111
|
-
@request.scheme + '://' +
|
|
135
|
+
@request.scheme + '://' + application.host + path
|
|
112
136
|
end
|
|
113
137
|
|
|
114
138
|
# methods for returning a view
|
|
@@ -133,8 +157,8 @@ MESSAGE_END
|
|
|
133
157
|
end
|
|
134
158
|
|
|
135
159
|
def config_hosts
|
|
136
|
-
[:janus, :magma, :timur, :metis, :vulcan, :polyphemus, :gnomon].map do |host|
|
|
137
|
-
[ :"#{host}_host",
|
|
160
|
+
[:janus, :magma, :timur, :metis, :vulcan, :polyphemus, :gnomon, :vesta].map do |host|
|
|
161
|
+
[ :"#{host}_host", application.config(host)&.dig(:host) ]
|
|
138
162
|
end.to_h.compact
|
|
139
163
|
end
|
|
140
164
|
|
|
@@ -162,8 +186,9 @@ MESSAGE_END
|
|
|
162
186
|
self.class.name.sub("Kernel::", "").sub("Controller", "").downcase
|
|
163
187
|
end
|
|
164
188
|
|
|
165
|
-
def success(msg, content_type='text/plain')
|
|
189
|
+
def success(msg, content_type='text/plain', disposition='not given')
|
|
166
190
|
@response['Content-Type'] = content_type
|
|
191
|
+
@response['Content-Disposition'] = disposition unless disposition=='not given'
|
|
167
192
|
@response.write(msg)
|
|
168
193
|
@response.finish
|
|
169
194
|
end
|
data/lib/etna/cross_origin.rb
CHANGED
|
@@ -27,7 +27,7 @@ module Etna
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def origin_allowed?(request)
|
|
30
|
-
subdomain(URI.parse(header(request, :origin)).host) == subdomain(
|
|
30
|
+
subdomain(URI.parse(header(request, :origin)).host) == subdomain(Etna::Application.instance.host)
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def actual_response(request)
|
data/lib/etna/cwl.rb
CHANGED
|
@@ -240,7 +240,7 @@ module Etna
|
|
|
240
240
|
end
|
|
241
241
|
|
|
242
242
|
PRIMITIVE_TYPE = EnumLoader.new("null", "boolean", "int", "long", "float", "double", "string")
|
|
243
|
-
NOMINAL_TYPE = EnumLoader.new("File")
|
|
243
|
+
NOMINAL_TYPE = EnumLoader.new("File", "MetisFile", "MetisFolder", "MetisPath", "MetisCSVorTSV")
|
|
244
244
|
end
|
|
245
245
|
|
|
246
246
|
class OptionalLoader < Loader
|
data/lib/etna/errors.rb
CHANGED
data/lib/etna/filesystem.rb
CHANGED
|
@@ -70,7 +70,6 @@ module Etna
|
|
|
70
70
|
rd, wd = IO.pipe
|
|
71
71
|
|
|
72
72
|
cmd = mkcommand(rd, wd, file, opts, size_hint: size_hint)
|
|
73
|
-
puts "in mkio: #{cmd}"
|
|
74
73
|
pid = spawn(*cmd)
|
|
75
74
|
q = Queue.new
|
|
76
75
|
|
|
@@ -103,173 +102,6 @@ module Etna
|
|
|
103
102
|
end
|
|
104
103
|
end
|
|
105
104
|
|
|
106
|
-
class AsperaCliFilesystem < Filesystem
|
|
107
|
-
include WithPipeConsumer
|
|
108
|
-
|
|
109
|
-
def initialize(ascli_bin:, ascp_bin:, host:, username:, password: nil, key_file: nil, port: 33001)
|
|
110
|
-
@ascli_bin = ascli_bin
|
|
111
|
-
@ascp_bin = ascp_bin
|
|
112
|
-
@username = username
|
|
113
|
-
@password = password
|
|
114
|
-
@key_file = key_file
|
|
115
|
-
@host = host
|
|
116
|
-
@port = port
|
|
117
|
-
|
|
118
|
-
@config_file = File.join(Dir.mktmpdir, "config.yml")
|
|
119
|
-
config = {}
|
|
120
|
-
config["config"] = {"version" => `#{ascli_bin} --version`.chomp}
|
|
121
|
-
config["default"] = {"server" => "clifilesystem"}
|
|
122
|
-
server_config = config["clifilesystem"] = {
|
|
123
|
-
"url" => "ssh://#{host}:#{port}",
|
|
124
|
-
"username" => username,
|
|
125
|
-
"ssh_options" => {append_all_supported_algorithms: true},
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
if password
|
|
129
|
-
server_config["password"] = password
|
|
130
|
-
elsif key_file
|
|
131
|
-
server_config["ssh_keys"] = key_file
|
|
132
|
-
else
|
|
133
|
-
raise "One of password or key_file must be provided"
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
::File.open(@config_file, "w") do |file|
|
|
137
|
-
file.write(config.to_yaml)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def run_ascli_cmd(cmd, *opts)
|
|
142
|
-
output, status = Open3.capture2(@ascli_bin, "server", cmd, *opts, "--format=json", "--config=#{@config_file}")
|
|
143
|
-
|
|
144
|
-
if status.success?
|
|
145
|
-
return JSON.parse(output)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
nil
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def with_writeable(dest, opts = 'w', size_hint: nil, &block)
|
|
152
|
-
mkio(dest, opts, size_hint: size_hint, &block)
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def with_readable(src, opts = 'r', &block)
|
|
156
|
-
mkio(src, opts, &block)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def mkdir_p(dir)
|
|
160
|
-
raise "Failed to mkdir #{dir}" unless run_ascli_cmd("mkdir", dir)
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
def rm_rf(dir)
|
|
164
|
-
raise "Failed to rm_rf #{dir}" unless run_ascli_cmd("rm", dir)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def tmpdir
|
|
168
|
-
tmpdir = "/Upload/Temp/#{SecureRandom.hex}"
|
|
169
|
-
mkdir_p(tmpdir)
|
|
170
|
-
tmpdir
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def exist?(src)
|
|
174
|
-
!run_ascli_cmd("ls", src).nil?
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def mv(src, dest)
|
|
178
|
-
raise "Failed to mv #{src} to #{dest}" unless run_ascli_cmd("mv", src, dest)
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def mkcommand(rd, wd, file, opts, size_hint: nil)
|
|
182
|
-
env = {}
|
|
183
|
-
cmd = [env, @ascp_bin]
|
|
184
|
-
|
|
185
|
-
if @password
|
|
186
|
-
env['ASPERA_SCP_PASS'] = @password
|
|
187
|
-
else
|
|
188
|
-
cmd << "-i"
|
|
189
|
-
cmd << @key_file
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
cmd << "-O"
|
|
193
|
-
cmd << @port.to_s
|
|
194
|
-
|
|
195
|
-
cmd << "-P"
|
|
196
|
-
cmd << @port.to_s
|
|
197
|
-
|
|
198
|
-
cmd << "-v"
|
|
199
|
-
cmd << "-k"
|
|
200
|
-
cmd << "0"
|
|
201
|
-
cmd << "--file-manifest=text"
|
|
202
|
-
cmd << "--file-manifest-path=/var/tmp"
|
|
203
|
-
cmd << "--file-checksum=md5"
|
|
204
|
-
cmd << "-l"
|
|
205
|
-
cmd << "100m"
|
|
206
|
-
cmd << "--overwrite=always"
|
|
207
|
-
|
|
208
|
-
remote_path = file
|
|
209
|
-
# https://download.asperasoft.com/download/docs/entsrv/3.9.1/es_admin_linux/webhelp/index.html#dita/stdio_2.html
|
|
210
|
-
local_path = "stdio://"
|
|
211
|
-
if size_hint
|
|
212
|
-
local_path += "/?#{size_hint}"
|
|
213
|
-
end
|
|
214
|
-
|
|
215
|
-
if opts.include?('r')
|
|
216
|
-
cmd << '--mode=recv'
|
|
217
|
-
cmd << "--host=#{@host}"
|
|
218
|
-
cmd << "--user=#{@username}"
|
|
219
|
-
cmd << remote_path
|
|
220
|
-
cmd << local_path
|
|
221
|
-
|
|
222
|
-
cmd << {out: wd}
|
|
223
|
-
elsif opts.include?('w')
|
|
224
|
-
cmd << '--mode=send'
|
|
225
|
-
cmd << "--host=#{@host}"
|
|
226
|
-
cmd << "--user=#{@username}"
|
|
227
|
-
cmd << local_path
|
|
228
|
-
cmd << remote_path
|
|
229
|
-
|
|
230
|
-
cmd << {in: rd}
|
|
231
|
-
end
|
|
232
|
-
|
|
233
|
-
puts "end of mkcmd: #{cmd}"
|
|
234
|
-
cmd
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
# Genentech's aspera deployment doesn't support modern commands, unfortunately...
|
|
239
|
-
class GeneAsperaCliFilesystem < AsperaCliFilesystem
|
|
240
|
-
def mkdir_p(dest)
|
|
241
|
-
# Pass through -- this file system creates containing directories by default, womp womp.
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
def mkcommand(rd, wd, file, opts, size_hint: nil)
|
|
245
|
-
if opts.include?('w')
|
|
246
|
-
super.map do |e|
|
|
247
|
-
if e.instance_of?(String) && e.start_with?("stdio://")
|
|
248
|
-
"stdio-tar://"
|
|
249
|
-
elsif e == file
|
|
250
|
-
dir = ::File.dirname(file)
|
|
251
|
-
dir[0] == '/' ? dir : "/#{dir}"
|
|
252
|
-
else
|
|
253
|
-
e
|
|
254
|
-
end
|
|
255
|
-
end.insert(2, "-d")
|
|
256
|
-
else
|
|
257
|
-
super
|
|
258
|
-
end
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
def with_writeable(dest, opts = 'w', size_hint: nil, &block)
|
|
262
|
-
raise "#{self.class.name} requires size_hint in with_writeable" if size_hint.nil?
|
|
263
|
-
|
|
264
|
-
super do |io|
|
|
265
|
-
io.write("File: #{::File.basename(dest)}\n")
|
|
266
|
-
io.write("Size: #{size_hint}\n")
|
|
267
|
-
io.write("\n")
|
|
268
|
-
yield io
|
|
269
|
-
end
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
|
|
273
105
|
class Metis < Filesystem
|
|
274
106
|
attr_reader :project_name, :bucket_name
|
|
275
107
|
|
|
@@ -438,9 +270,11 @@ module Etna
|
|
|
438
270
|
end
|
|
439
271
|
|
|
440
272
|
def sftp_file_from_path(src)
|
|
441
|
-
|
|
273
|
+
files = ls(::File.dirname(src)).split("\n").map do |listing|
|
|
442
274
|
SftpFile.new(listing)
|
|
443
|
-
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
file = files.select do |file|
|
|
444
278
|
file.name == ::File.basename(src)
|
|
445
279
|
end
|
|
446
280
|
|
|
@@ -457,6 +291,7 @@ module Etna
|
|
|
457
291
|
cmd << authn
|
|
458
292
|
cmd << "-o"
|
|
459
293
|
cmd << "-"
|
|
294
|
+
cmd << "-s"
|
|
460
295
|
cmd << "-N"
|
|
461
296
|
cmd << url(file)
|
|
462
297
|
|
data/lib/etna/hmac.rb
CHANGED
|
@@ -46,7 +46,7 @@ module Etna
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def signature
|
|
49
|
-
@application.sign.hmac(text_to_sign, @application.config(
|
|
49
|
+
@application.sign.hmac(text_to_sign, @application.config(@id)[:hmac_key])
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
private
|
|
@@ -60,8 +60,8 @@ module Etna
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def valid_id?
|
|
63
|
-
return false if !@application.config(
|
|
64
|
-
@application.config(
|
|
63
|
+
return false if !@application.config(@id)
|
|
64
|
+
@application.config(@id).key?(:hmac_key)
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
# This scheme is adapted from the Hawk spec
|
|
@@ -79,7 +79,7 @@ module Etna
|
|
|
79
79
|
# these are set as headers or params
|
|
80
80
|
@nonce,
|
|
81
81
|
@id,
|
|
82
|
-
@headers
|
|
82
|
+
JSON.generate(@headers),
|
|
83
83
|
@expiration,
|
|
84
84
|
].join("\n")
|
|
85
85
|
end
|
data/lib/etna/instrumentation.rb
CHANGED
|
@@ -6,8 +6,8 @@ module Etna
|
|
|
6
6
|
orig_method_name = :"#{method_name}_without_time_it"
|
|
7
7
|
self.alias_method orig_method_name, method_name
|
|
8
8
|
|
|
9
|
-
self.define_method method_name do |*args|
|
|
10
|
-
time_it(orig_method_name, args, &metric_block)
|
|
9
|
+
self.define_method method_name do |*args, **kwargs|
|
|
10
|
+
time_it(orig_method_name, args, kwargs, &metric_block)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
|
@@ -20,11 +20,11 @@ module Etna
|
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def time_it(method_name, args, &metric_block)
|
|
23
|
+
def time_it(method_name, args, kwargs = {}, &metric_block)
|
|
24
24
|
if has_yabeda?
|
|
25
25
|
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
26
26
|
begin
|
|
27
|
-
return send(method_name, *args)
|
|
27
|
+
return send(method_name, *args, **kwargs)
|
|
28
28
|
ensure
|
|
29
29
|
dur = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
|
30
30
|
if block_given?
|
|
@@ -37,13 +37,13 @@ module Etna
|
|
|
37
37
|
metric.measure(tags, dur)
|
|
38
38
|
end
|
|
39
39
|
else
|
|
40
|
-
return send(method_name, *args, **
|
|
40
|
+
return send(method_name, *args, **kwargs)
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def with_yabeda_tags(tags, &block)
|
|
45
45
|
if has_yabeda?
|
|
46
|
-
Yabeda.with_tags(tags, &block)
|
|
46
|
+
Yabeda.with_tags(**tags, &block)
|
|
47
47
|
else
|
|
48
48
|
yield
|
|
49
49
|
end
|
data/lib/etna/redirect.rb
CHANGED
data/lib/etna/remote.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require "net/ssh"
|
|
2
|
+
require "net/scp"
|
|
3
|
+
require "tempfile"
|
|
2
4
|
|
|
3
5
|
module Etna
|
|
4
6
|
class RemoteSSH
|
|
@@ -11,6 +13,7 @@ module Etna
|
|
|
11
13
|
@host = host
|
|
12
14
|
@port = port
|
|
13
15
|
@root = root
|
|
16
|
+
raise "RemoteSSH must have host, username and password" unless @host && @username && @password
|
|
14
17
|
end
|
|
15
18
|
|
|
16
19
|
def ssh
|
|
@@ -23,8 +26,8 @@ module Etna
|
|
|
23
26
|
raise RemoteSSHError.new("Unable to mkdir -p, #{output}") unless 0 == output.exitstatus
|
|
24
27
|
end
|
|
25
28
|
|
|
26
|
-
def lftp_get(username:, password:, host:, remote_filename:, &block)
|
|
27
|
-
full_local_path =
|
|
29
|
+
def lftp_get(username:, password:, host:, remote_filename:, local_filename:, &block)
|
|
30
|
+
full_local_path = local_filename
|
|
28
31
|
full_local_dir = ::File.dirname(full_local_path)
|
|
29
32
|
mkdir_p(full_local_dir)
|
|
30
33
|
|
|
@@ -34,5 +37,18 @@ module Etna
|
|
|
34
37
|
raise RemoteSSHError.new("LFTP get failure: #{output}") unless 0 == output.exitstatus
|
|
35
38
|
yield remote_filename if block_given?
|
|
36
39
|
end
|
|
40
|
+
|
|
41
|
+
def file_upload(remote_path, content)
|
|
42
|
+
begin
|
|
43
|
+
Tempfile.create do |temp_file|
|
|
44
|
+
temp_file.binmode
|
|
45
|
+
temp_file.write(content)
|
|
46
|
+
temp_file.flush
|
|
47
|
+
ssh.scp.upload!(temp_file.path, remote_path)
|
|
48
|
+
end
|
|
49
|
+
rescue StandardError => e
|
|
50
|
+
raise RemoteSSHError.new("File upload failed: #{e.message}")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
37
53
|
end
|
|
38
54
|
end
|
data/lib/etna/route.rb
CHANGED
|
@@ -221,6 +221,9 @@ module Etna
|
|
|
221
221
|
# for the project
|
|
222
222
|
return false if user.permissions.keys.include?(params[:project_name])
|
|
223
223
|
|
|
224
|
+
# Only check for a CC if the user is not flagged 'external'
|
|
225
|
+
return false if user.has_flag?('external')
|
|
226
|
+
|
|
224
227
|
!janus.community_projects(user.token).select do |project|
|
|
225
228
|
project.project_name == params[:project_name]
|
|
226
229
|
end.first.nil?
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'webmock/rspec'
|
|
2
|
+
|
|
3
|
+
def stub_event_log(project_name='labors')
|
|
4
|
+
polyphemus_host = Etna::Application.instance.config(:polyphemus)[:host]
|
|
5
|
+
WebMock.stub_request(:post, /#{polyphemus_host}\/api\/log\/#{project_name}/).
|
|
6
|
+
to_return(status: 200, body: { log: 1 }.to_json, headers: {'Content-Type': 'application/json'})
|
|
7
|
+
|
|
8
|
+
WebMock.stub_request(:options, polyphemus_host).
|
|
9
|
+
to_return({
|
|
10
|
+
status: 200,
|
|
11
|
+
headers: { 'Content-Type': "application/json" },
|
|
12
|
+
body: [
|
|
13
|
+
{ :method => "POST", :route => "/api/log/:project_name/write", :name => "log_write", :params => ["project_name"] }
|
|
14
|
+
].to_json
|
|
15
|
+
})
|
|
16
|
+
end
|
data/lib/etna/spec/vcr.rb
CHANGED
|
@@ -71,8 +71,8 @@ def setup_base_vcr(spec_helper_dir, server: nil, application: nil)
|
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
if File.
|
|
75
|
-
c.debug_logger = File.open('log/vcr_debug.log', 'w')
|
|
74
|
+
if ::File.exist?('log')
|
|
75
|
+
c.debug_logger = ::File.open('log/vcr_debug.log', 'w')
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
c.default_cassette_options = {
|
|
@@ -147,4 +147,4 @@ def prepare_vcr_secret
|
|
|
147
147
|
digest = Digest::SHA256.new
|
|
148
148
|
digest.update(secret)
|
|
149
149
|
digest.digest
|
|
150
|
-
end
|
|
150
|
+
end
|
data/lib/etna/test_auth.rb
CHANGED
data/lib/etna/user.rb
CHANGED
data/lib/helpers.rb
CHANGED
|
@@ -51,6 +51,14 @@ module WithEtnaClients
|
|
|
51
51
|
**EtnaApp.instance.config(:magma, environment) || {})
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
+
def gnomon_client(logger: nil)
|
|
55
|
+
@gnomon_client ||= Etna::Clients::Gnomon.new(
|
|
56
|
+
token: token,
|
|
57
|
+
ignore_ssl: EtnaApp.instance.config(:ignore_ssl),
|
|
58
|
+
logger: logger,
|
|
59
|
+
**EtnaApp.instance.config(:magma, environment) || {})
|
|
60
|
+
end
|
|
61
|
+
|
|
54
62
|
def metis_client(logger: nil)
|
|
55
63
|
@metis_client ||= Etna::Clients::Metis.new(
|
|
56
64
|
token: token,
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: etna
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Saurabh Asthana
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rack
|
|
@@ -157,6 +156,9 @@ files:
|
|
|
157
156
|
- lib/etna/clients.rb
|
|
158
157
|
- lib/etna/clients/base_client.rb
|
|
159
158
|
- lib/etna/clients/enum.rb
|
|
159
|
+
- lib/etna/clients/gnomon.rb
|
|
160
|
+
- lib/etna/clients/gnomon/client.rb
|
|
161
|
+
- lib/etna/clients/gnomon/models.rb
|
|
160
162
|
- lib/etna/clients/janus.rb
|
|
161
163
|
- lib/etna/clients/janus/client.rb
|
|
162
164
|
- lib/etna/clients/janus/models.rb
|
|
@@ -193,6 +195,7 @@ files:
|
|
|
193
195
|
- lib/etna/clients/metis/workflows/sync_metis_data_workflow.rb
|
|
194
196
|
- lib/etna/clients/metis/workflows/walk_metis_diff_workflow.rb
|
|
195
197
|
- lib/etna/clients/metis/workflows/walk_metis_workflow.rb
|
|
198
|
+
- lib/etna/clients/models.rb
|
|
196
199
|
- lib/etna/clients/polyphemus.rb
|
|
197
200
|
- lib/etna/clients/polyphemus/client.rb
|
|
198
201
|
- lib/etna/clients/polyphemus/models.rb
|
|
@@ -229,6 +232,7 @@ files:
|
|
|
229
232
|
- lib/etna/sign_service.rb
|
|
230
233
|
- lib/etna/spec.rb
|
|
231
234
|
- lib/etna/spec/auth.rb
|
|
235
|
+
- lib/etna/spec/event_log.rb
|
|
232
236
|
- lib/etna/spec/vcr.rb
|
|
233
237
|
- lib/etna/symbolize_params.rb
|
|
234
238
|
- lib/etna/synchronize_db.rb
|
|
@@ -255,8 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
255
259
|
- !ruby/object:Gem::Version
|
|
256
260
|
version: '0'
|
|
257
261
|
requirements: []
|
|
258
|
-
rubygems_version: 3.
|
|
259
|
-
signing_key:
|
|
262
|
+
rubygems_version: 3.6.9
|
|
260
263
|
specification_version: 4
|
|
261
264
|
summary: Base classes for Mount Etna applications
|
|
262
265
|
test_files: []
|