t2-server 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.rdoc +17 -0
- data/README.rdoc +32 -13
- data/bin/t2-run-workflow +10 -7
- data/bin/t2-server-info +4 -4
- data/lib/t2-server.rb +2 -0
- data/lib/t2-server/admin.rb +17 -15
- data/lib/t2-server/exceptions.rb +10 -0
- data/lib/t2-server/net/connection.rb +60 -120
- data/lib/t2-server/net/parameters.rb +4 -0
- data/lib/t2-server/port.rb +3 -3
- data/lib/t2-server/run.rb +125 -151
- data/lib/t2-server/server.rb +130 -161
- data/lib/t2-server/util.rb +39 -0
- data/t2-server.gemspec +1 -1
- data/test/tc_admin.rb +5 -2
- data/test/tc_run.rb +11 -0
- data/test/tc_server.rb +2 -2
- data/test/tc_util.rb +44 -0
- data/test/ts_t2server.rb +1 -0
- data/test/workflows/no-ports.t2flow +76 -0
- data/version.yml +1 -1
- metadata +3 -2
@@ -79,6 +79,8 @@ module T2Server
|
|
79
79
|
# If the connection is over SSL then the peer will be verified using the
|
80
80
|
# underlying OS's certificate store.
|
81
81
|
class DefaultConnectionParameters < ConnectionParameters
|
82
|
+
# Create connection parameters that are secure by default and verify the
|
83
|
+
# server that is being connected to.
|
82
84
|
def initialize
|
83
85
|
super
|
84
86
|
self[:verify_peer] = true
|
@@ -88,6 +90,8 @@ module T2Server
|
|
88
90
|
# Connection parameters that specifically turn off peer verification when
|
89
91
|
# using SSL.
|
90
92
|
class InsecureSSLConnectionParameters < ConnectionParameters
|
93
|
+
# Create connection parameters that are insecure by default and do not
|
94
|
+
# verify the server that is connected to.
|
91
95
|
def initialize
|
92
96
|
super
|
93
97
|
self[:verify_peer] = false
|
data/lib/t2-server/port.rb
CHANGED
@@ -283,8 +283,8 @@ module T2Server
|
|
283
283
|
end
|
284
284
|
|
285
285
|
# :stopdoc:
|
286
|
-
def download(
|
287
|
-
@run.download_output_data(
|
286
|
+
def download(uri, range = nil)
|
287
|
+
@run.download_output_data(uri, range)
|
288
288
|
end
|
289
289
|
# :startdoc:
|
290
290
|
|
@@ -342,7 +342,7 @@ module T2Server
|
|
342
342
|
# :stopdoc:
|
343
343
|
def initialize(port, ref, error, type = "", size = 0)
|
344
344
|
@port = port
|
345
|
-
@reference = ref
|
345
|
+
@reference = URI.parse(ref)
|
346
346
|
@type = type
|
347
347
|
@size = size
|
348
348
|
@value = nil
|
data/lib/t2-server/run.rb
CHANGED
@@ -100,9 +100,10 @@ module T2Server
|
|
100
100
|
BACLAVA_FILE = "out.xml"
|
101
101
|
|
102
102
|
# New is private but rdoc does not get it right! Hence :stopdoc: section.
|
103
|
-
def initialize(server,
|
103
|
+
def initialize(server, uri, credentials = nil)
|
104
104
|
@server = server
|
105
|
-
@
|
105
|
+
@uri = uri
|
106
|
+
@identifier = Util.get_path_leaf_from_uri(@uri)
|
106
107
|
@workflow = ""
|
107
108
|
@baclava_in = false
|
108
109
|
@baclava_out = false
|
@@ -139,13 +140,13 @@ module T2Server
|
|
139
140
|
# This method will _yield_ the newly created Run if a block is given.
|
140
141
|
def Run.create(server, workflow, *rest)
|
141
142
|
credentials = nil
|
142
|
-
|
143
|
+
uri = nil
|
143
144
|
conn_params = nil
|
144
145
|
|
145
146
|
rest.each do |param|
|
146
147
|
case param
|
147
|
-
when
|
148
|
-
|
148
|
+
when URI
|
149
|
+
uri = param
|
149
150
|
when ConnectionParameters
|
150
151
|
conn_params = param
|
151
152
|
when HttpCredentials
|
@@ -157,11 +158,11 @@ module T2Server
|
|
157
158
|
server = Server.new(server, conn_params)
|
158
159
|
end
|
159
160
|
|
160
|
-
if
|
161
|
-
|
161
|
+
if uri.nil?
|
162
|
+
uri = server.initialize_run(workflow, credentials)
|
162
163
|
end
|
163
164
|
|
164
|
-
run = new(server,
|
165
|
+
run = new(server, uri, credentials)
|
165
166
|
yield(run) if block_given?
|
166
167
|
run
|
167
168
|
end
|
@@ -190,7 +191,7 @@ module T2Server
|
|
190
191
|
#
|
191
192
|
# Delete this run from the server.
|
192
193
|
def delete
|
193
|
-
@server.
|
194
|
+
@server.delete(@uri, @credentials)
|
194
195
|
end
|
195
196
|
|
196
197
|
# :stopdoc:
|
@@ -282,8 +283,7 @@ module T2Server
|
|
282
283
|
#
|
283
284
|
# Return the expiry time of this run as an instance of class Time.
|
284
285
|
def expiry
|
285
|
-
Time.parse(@server.
|
286
|
-
"text/plain", @credentials))
|
286
|
+
Time.parse(@server.read(links[:expiry], "text/plain", @credentials))
|
287
287
|
end
|
288
288
|
|
289
289
|
# :call-seq:
|
@@ -302,8 +302,7 @@ module T2Server
|
|
302
302
|
# parse timezone offsets with a colon (eg +00:00)
|
303
303
|
date_str = time.xmlschema(2)
|
304
304
|
date_str = date_str[0..-4] + date_str[-2..-1]
|
305
|
-
@server.
|
306
|
-
"text/plain", @credentials)
|
305
|
+
@server.update(links[:expiry], date_str, "text/plain", @credentials)
|
307
306
|
end
|
308
307
|
|
309
308
|
# :call-seq:
|
@@ -312,8 +311,8 @@ module T2Server
|
|
312
311
|
# Get the workflow that this run represents.
|
313
312
|
def workflow
|
314
313
|
if @workflow == ""
|
315
|
-
@workflow = @server.
|
316
|
-
|
314
|
+
@workflow = @server.read(links[:workflow], "application/xml",
|
315
|
+
@credentials)
|
317
316
|
end
|
318
317
|
@workflow
|
319
318
|
end
|
@@ -324,8 +323,7 @@ module T2Server
|
|
324
323
|
# Get the status of this run. Status can be one of :initialized,
|
325
324
|
# :running or :finished.
|
326
325
|
def status
|
327
|
-
text_to_state(@server.
|
328
|
-
"text/plain", @credentials))
|
326
|
+
text_to_state(@server.read(links[:status], "text/plain", @credentials))
|
329
327
|
end
|
330
328
|
|
331
329
|
# :call-seq:
|
@@ -341,8 +339,8 @@ module T2Server
|
|
341
339
|
# set all the inputs
|
342
340
|
_check_and_set_inputs unless baclava_input?
|
343
341
|
|
344
|
-
@server.
|
345
|
-
|
342
|
+
@server.update(links[:status], state_to_text(:running), "text/plain",
|
343
|
+
@credentials)
|
346
344
|
end
|
347
345
|
|
348
346
|
# :call-seq:
|
@@ -379,8 +377,7 @@ module T2Server
|
|
379
377
|
#
|
380
378
|
# Get the return code of the run. Zero indicates success.
|
381
379
|
def exitcode
|
382
|
-
@server.
|
383
|
-
@credentials).to_i
|
380
|
+
@server.read(links[:exitcode], "text/plain", @credentials).to_i
|
384
381
|
end
|
385
382
|
|
386
383
|
# :call-seq:
|
@@ -388,8 +385,7 @@ module T2Server
|
|
388
385
|
#
|
389
386
|
# Get anything that the run printed to the standard out stream.
|
390
387
|
def stdout
|
391
|
-
@server.
|
392
|
-
@credentials)
|
388
|
+
@server.read(links[:stdout], "text/plain", @credentials)
|
393
389
|
end
|
394
390
|
|
395
391
|
# :call-seq:
|
@@ -397,8 +393,7 @@ module T2Server
|
|
397
393
|
#
|
398
394
|
# Get anything that the run printed to the standard error stream.
|
399
395
|
def stderr
|
400
|
-
@server.
|
401
|
-
@credentials)
|
396
|
+
@server.read(links[:stderr], "text/plain", @credentials)
|
402
397
|
end
|
403
398
|
|
404
399
|
# :call-seq:
|
@@ -408,16 +403,8 @@ module T2Server
|
|
408
403
|
# could be used to store input data.
|
409
404
|
def mkdir(dir)
|
410
405
|
dir = Util.strip_path_slashes(dir)
|
411
|
-
|
412
|
-
|
413
|
-
# end and add the rest of the path to the wdir link
|
414
|
-
leaf = dir.split("/")[-1]
|
415
|
-
path = dir[0...-(leaf.length + 1)]
|
416
|
-
@server.create_dir(@identifier, "#{links[:wdir]}/#{path}", leaf,
|
417
|
-
@credentials)
|
418
|
-
else
|
419
|
-
@server.create_dir(@identifier, links[:wdir], dir, @credentials)
|
420
|
-
end
|
406
|
+
|
407
|
+
@server.mkdir(links[:wdir], dir, @credentials)
|
421
408
|
end
|
422
409
|
|
423
410
|
# :call-seq:
|
@@ -432,10 +419,10 @@ module T2Server
|
|
432
419
|
# The name of the file on the server is returned.
|
433
420
|
def upload_file(filename, params={})
|
434
421
|
location = params[:dir] || ""
|
435
|
-
|
422
|
+
uri = Util.append_to_uri_path(links[:wdir], location)
|
436
423
|
rename = params[:rename] || ""
|
437
|
-
@server.upload_file(
|
438
|
-
|
424
|
+
file_uri = @server.upload_file(filename, uri, rename, @credentials)
|
425
|
+
Util.get_path_leaf_from_uri(file_uri)
|
439
426
|
end
|
440
427
|
|
441
428
|
# :call-seq:
|
@@ -445,9 +432,8 @@ module T2Server
|
|
445
432
|
# remote directory to put this file in can also be specified, but if it is
|
446
433
|
# it must first have been created by a call to Run#mkdir.
|
447
434
|
def upload_data(data, remote_name, remote_directory = "")
|
448
|
-
|
449
|
-
@server.upload_data(
|
450
|
-
@credentials)
|
435
|
+
location_uri = Util.append_to_uri_path(links[:wdir], remote_directory)
|
436
|
+
@server.upload_data(data, remote_name, location_uri, @credentials)
|
451
437
|
end
|
452
438
|
|
453
439
|
# :stopdoc:
|
@@ -469,9 +455,8 @@ module T2Server
|
|
469
455
|
state = status
|
470
456
|
raise RunStateError.new(state, :initialized) if state != :initialized
|
471
457
|
|
472
|
-
|
473
|
-
result = @server.
|
474
|
-
"text/plain", @credentials)
|
458
|
+
file = upload_file(filename)
|
459
|
+
result = @server.update(links[:baclava], file, "text/plain", @credentials)
|
475
460
|
|
476
461
|
@baclava_in = true if result
|
477
462
|
|
@@ -502,8 +487,8 @@ module T2Server
|
|
502
487
|
state = status
|
503
488
|
raise RunStateError.new(state, :initialized) if state != :initialized
|
504
489
|
|
505
|
-
@baclava_out = @server.
|
506
|
-
|
490
|
+
@baclava_out = @server.update(links[:output], BACLAVA_FILE, "text/plain",
|
491
|
+
@credentials)
|
507
492
|
end
|
508
493
|
|
509
494
|
# :stopdoc:
|
@@ -541,8 +526,9 @@ module T2Server
|
|
541
526
|
raise RunStateError.new(state, :finished) if state != :finished
|
542
527
|
|
543
528
|
raise AccessForbiddenError.new("baclava output") if !@baclava_out
|
544
|
-
|
545
|
-
|
529
|
+
|
530
|
+
baclava_uri = Util.append_to_uri_path(links[:wdir], BACLAVA_FILE)
|
531
|
+
@server.read(baclava_uri, "*/*", @credentials)
|
546
532
|
end
|
547
533
|
|
548
534
|
# :stopdoc:
|
@@ -562,8 +548,8 @@ module T2Server
|
|
562
548
|
state = status
|
563
549
|
raise RunStateError.new(state, :finished) if state != :finished
|
564
550
|
|
565
|
-
|
566
|
-
|
551
|
+
output_uri = Util.append_to_uri_path(links[:wdir], "out")
|
552
|
+
@server.read(output_uri, "application/zip", @credentials)
|
567
553
|
end
|
568
554
|
|
569
555
|
# :call-seq:
|
@@ -595,8 +581,7 @@ module T2Server
|
|
595
581
|
#
|
596
582
|
# Get the creation time of this run as an instance of class Time.
|
597
583
|
def create_time
|
598
|
-
Time.parse(@server.
|
599
|
-
"text/plain", @credentials))
|
584
|
+
Time.parse(@server.read(links[:createtime], "text/plain", @credentials))
|
600
585
|
end
|
601
586
|
|
602
587
|
# :call-seq:
|
@@ -604,8 +589,7 @@ module T2Server
|
|
604
589
|
#
|
605
590
|
# Get the start time of this run as an instance of class Time.
|
606
591
|
def start_time
|
607
|
-
Time.parse(@server.
|
608
|
-
"text/plain", @credentials))
|
592
|
+
Time.parse(@server.read(links[:starttime], "text/plain", @credentials))
|
609
593
|
end
|
610
594
|
|
611
595
|
# :call-seq:
|
@@ -613,8 +597,7 @@ module T2Server
|
|
613
597
|
#
|
614
598
|
# Get the finish time of this run as an instance of class Time.
|
615
599
|
def finish_time
|
616
|
-
Time.parse(@server.
|
617
|
-
"text/plain", @credentials))
|
600
|
+
Time.parse(@server.read(links[:finishtime], "text/plain", @credentials))
|
618
601
|
end
|
619
602
|
|
620
603
|
# :call-seq:
|
@@ -640,8 +623,7 @@ module T2Server
|
|
640
623
|
return unless owner?
|
641
624
|
|
642
625
|
value = XML::Fragments::PERM_UPDATE % [username, permission.to_s]
|
643
|
-
@server.
|
644
|
-
"application/xml", @credentials)
|
626
|
+
@server.create(links[:sec_perms], value, "application/xml", @credentials)
|
645
627
|
end
|
646
628
|
|
647
629
|
# :call-seq:
|
@@ -654,8 +636,8 @@ module T2Server
|
|
654
636
|
return unless owner?
|
655
637
|
|
656
638
|
perms = {}
|
657
|
-
doc = xml_document(@server.
|
658
|
-
|
639
|
+
doc = xml_document(@server.read(links[:sec_perms], "application/xml",
|
640
|
+
@credentials))
|
659
641
|
|
660
642
|
xpath_find(doc, XPaths[:sec_perm]).each do |p|
|
661
643
|
user = xml_node_content(xpath_first(p, XPaths[:sec_uname]))
|
@@ -687,22 +669,22 @@ module T2Server
|
|
687
669
|
def revoke_permission(username)
|
688
670
|
return unless owner?
|
689
671
|
|
690
|
-
|
691
|
-
@server.
|
672
|
+
uri = Util.append_to_uri_path(links[:sec_perms], username)
|
673
|
+
@server.delete(uri, @credentials)
|
692
674
|
end
|
693
675
|
|
694
676
|
# :call-seq:
|
695
|
-
# add_password_credential(service_uri, username, password) ->
|
677
|
+
# add_password_credential(service_uri, username, password) -> URI
|
696
678
|
#
|
697
679
|
# Provide a username and password credential for the secure service at the
|
698
|
-
# specified URI. The
|
680
|
+
# specified URI. The URI of the credential on the server is returned. Only
|
699
681
|
# the owner of a run may supply credentials for it. +nil+ is returned if a
|
700
682
|
# user other than the owner uses this method.
|
701
683
|
def add_password_credential(uri, username, password)
|
702
684
|
return unless owner?
|
703
685
|
|
704
686
|
# Is this a new credential, or an update?
|
705
|
-
|
687
|
+
cred_uri = credential(uri)
|
706
688
|
|
707
689
|
# basic uri checks
|
708
690
|
uri = _check_cred_uri(uri)
|
@@ -710,24 +692,22 @@ module T2Server
|
|
710
692
|
cred = XML::Fragments::USERPASS_CRED % [uri, username, password]
|
711
693
|
value = XML::Fragments::CREDENTIAL % cred
|
712
694
|
|
713
|
-
if
|
714
|
-
@server.
|
715
|
-
"application/xml", @credentials)
|
716
|
-
else
|
717
|
-
path = "#{links[:sec_creds]}/#{id}"
|
718
|
-
@server.set_run_attribute(@identifier, path, value, "application/xml",
|
695
|
+
if cred_uri.nil?
|
696
|
+
@server.create(links[:sec_creds], value, "application/xml",
|
719
697
|
@credentials)
|
698
|
+
else
|
699
|
+
@server.update(cred_uri, value, "application/xml", @credentials)
|
720
700
|
end
|
721
701
|
end
|
722
702
|
|
723
703
|
# :call-seq:
|
724
704
|
# add_keypair_credential(service_uri, filename, password,
|
725
|
-
# alias = "Imported Certificate", type = :pkcs12) ->
|
705
|
+
# alias = "Imported Certificate", type = :pkcs12) -> URI
|
726
706
|
#
|
727
707
|
# Provide a client certificate credential for the secure service at the
|
728
708
|
# specified URI. You will need to provide the password to unlock the
|
729
709
|
# private key. You will also need to provide the 'alias' or 'friendlyName'
|
730
|
-
# of the key you wish to use if it differs from the default. The
|
710
|
+
# of the key you wish to use if it differs from the default. The URI of the
|
731
711
|
# credential on the server is returned. Only the owner of a run may supply
|
732
712
|
# credentials for it. +nil+ is returned if a user other than the owner uses
|
733
713
|
# this method.
|
@@ -745,36 +725,35 @@ module T2Server
|
|
745
725
|
type, password]
|
746
726
|
value = XML::Fragments::CREDENTIAL % cred
|
747
727
|
|
748
|
-
@server.
|
749
|
-
"application/xml", @credentials)
|
728
|
+
@server.create(links[:sec_creds], value, "application/xml", @credentials)
|
750
729
|
end
|
751
730
|
|
752
731
|
# :call-seq:
|
753
732
|
# credentials -> Hash
|
754
733
|
#
|
755
|
-
# Return a hash (service_uri =>
|
756
|
-
# for this run. Only the owner of a run may query its credentials.
|
757
|
-
# returned if a user other than the owner uses this method.
|
734
|
+
# Return a hash (service_uri => credential_uri) of all the credentials
|
735
|
+
# provided for this run. Only the owner of a run may query its credentials.
|
736
|
+
# +nil+ is returned if a user other than the owner uses this method.
|
758
737
|
def credentials
|
759
738
|
return unless owner?
|
760
739
|
|
761
740
|
creds = {}
|
762
|
-
doc = xml_document(@server.
|
763
|
-
|
741
|
+
doc = xml_document(@server.read(links[:sec_creds], "application/xml",
|
742
|
+
@credentials))
|
764
743
|
|
765
744
|
xpath_find(doc, XPaths[:sec_cred]).each do |c|
|
766
|
-
uri = xml_node_content(xpath_first(c, XPaths[:sec_suri]))
|
767
|
-
|
768
|
-
creds[uri] =
|
745
|
+
uri = URI.parse(xml_node_content(xpath_first(c, XPaths[:sec_suri])))
|
746
|
+
cred_uri = URI.parse(xml_node_attribute(c, "href"))
|
747
|
+
creds[uri] = cred_uri
|
769
748
|
end
|
770
749
|
|
771
750
|
creds
|
772
751
|
end
|
773
752
|
|
774
753
|
# :call-seq:
|
775
|
-
# credential(service_uri) ->
|
754
|
+
# credential(service_uri) -> URI
|
776
755
|
#
|
777
|
-
# Return the
|
756
|
+
# Return the URI of the credential set for the supplied service, if
|
778
757
|
# any. Only the owner of a run may query its credentials. +nil+ is
|
779
758
|
# returned if a user other than the owner uses this method.
|
780
759
|
def credential(uri)
|
@@ -792,8 +771,7 @@ module T2Server
|
|
792
771
|
def delete_credential(uri)
|
793
772
|
return unless owner?
|
794
773
|
|
795
|
-
|
796
|
-
@server.delete_run_attribute(@identifier, path, @credentials)
|
774
|
+
@server.delete(credentials[uri], @credentials)
|
797
775
|
end
|
798
776
|
|
799
777
|
# :call-seq:
|
@@ -805,15 +783,14 @@ module T2Server
|
|
805
783
|
def delete_all_credentials
|
806
784
|
return unless owner?
|
807
785
|
|
808
|
-
@server.
|
809
|
-
@credentials)
|
786
|
+
@server.delete(links[:sec_creds], @credentials)
|
810
787
|
end
|
811
788
|
|
812
789
|
# :call-seq:
|
813
|
-
# add_trust(filename, type = :x509) ->
|
790
|
+
# add_trust(filename, type = :x509) -> URI
|
814
791
|
#
|
815
792
|
# Add a trusted identity (server public key) to verify peers when using
|
816
|
-
# https connections to Web Services. The
|
793
|
+
# https connections to Web Services. The URI of the trust on the server is
|
817
794
|
# returned. Only the owner of a run may add a trust. +nil+ is returned if
|
818
795
|
# a user other than the owner uses this method.
|
819
796
|
def add_trust(filename, type = :x509)
|
@@ -824,43 +801,41 @@ module T2Server
|
|
824
801
|
contents = Base64.encode64(IO.read(filename))
|
825
802
|
|
826
803
|
value = XML::Fragments::TRUST % [contents, type]
|
827
|
-
@server.
|
828
|
-
"application/xml", @credentials)
|
804
|
+
@server.create(links[:sec_trusts], value, "application/xml", @credentials)
|
829
805
|
end
|
830
806
|
|
831
807
|
# :call-seq:
|
832
808
|
# trusts -> Array
|
833
809
|
#
|
834
|
-
# Return a list of all the
|
835
|
-
# run. At present there is no way to differentiate between trusts
|
836
|
-
# noting the
|
837
|
-
# may query its trusts. +nil+ is returned if a user other than the
|
838
|
-
# uses this method.
|
810
|
+
# Return a list of all the URIs of trusts that have been registered for
|
811
|
+
# this run. At present there is no way to differentiate between trusts
|
812
|
+
# without noting the URI returned when originally uploaded. Only the owner
|
813
|
+
# of a run may query its trusts. +nil+ is returned if a user other than the
|
814
|
+
# owner uses this method.
|
839
815
|
def trusts
|
840
816
|
return unless owner?
|
841
817
|
|
842
|
-
|
843
|
-
doc = xml_document(@server.
|
844
|
-
|
818
|
+
t_uris = []
|
819
|
+
doc = xml_document(@server.read(links[:sec_trusts], "application/xml",
|
820
|
+
@credentials))
|
845
821
|
|
846
822
|
xpath_find(doc, XPaths[:sec_trust]). each do |t|
|
847
|
-
|
823
|
+
t_uris << URI.parse(xml_node_attribute(t, "href"))
|
848
824
|
end
|
849
825
|
|
850
|
-
|
826
|
+
t_uris
|
851
827
|
end
|
852
828
|
|
853
829
|
# :call-seq:
|
854
|
-
# delete_trust(
|
830
|
+
# delete_trust(URI) -> bool
|
855
831
|
#
|
856
|
-
# Delete the trust with the provided
|
832
|
+
# Delete the trust with the provided URI. Only the owner of a run may
|
857
833
|
# delete its trusts. +nil+ is returned if a user other than the owner uses
|
858
834
|
# this method.
|
859
|
-
def delete_trust(
|
835
|
+
def delete_trust(uri)
|
860
836
|
return unless owner?
|
861
837
|
|
862
|
-
|
863
|
-
@server.delete_run_attribute(@identifier, path, @credentials)
|
838
|
+
@server.delete(uri, @credentials)
|
864
839
|
end
|
865
840
|
|
866
841
|
# :call-seq:
|
@@ -872,17 +847,15 @@ module T2Server
|
|
872
847
|
def delete_all_trusts
|
873
848
|
return unless owner?
|
874
849
|
|
875
|
-
@server.
|
876
|
-
@credentials)
|
850
|
+
@server.delete(links[:sec_trusts], @credentials)
|
877
851
|
end
|
878
852
|
|
879
853
|
# :stopdoc:
|
880
854
|
# Outputs are represented as a directory structure with the eventual list
|
881
855
|
# items (leaves) as files. This method (not part of the public API)
|
882
856
|
# downloads a file from the run's working directory.
|
883
|
-
def download_output_data(
|
884
|
-
@server.
|
885
|
-
range, @credentials)
|
857
|
+
def download_output_data(uri, range = nil)
|
858
|
+
@server.read(uri, "application/octet-stream", range, @credentials)
|
886
859
|
end
|
887
860
|
# :startdoc:
|
888
861
|
|
@@ -923,16 +896,14 @@ module T2Server
|
|
923
896
|
end
|
924
897
|
|
925
898
|
xml_value = xml_text_node(port.file)
|
926
|
-
|
927
|
-
@server.
|
928
|
-
|
929
|
-
@credentials)
|
899
|
+
uri = Util.append_to_uri_path(links[:inputs], "input/#{port.name}")
|
900
|
+
@server.update(uri, XML::Fragments::RUNINPUTFILE % xml_value,
|
901
|
+
"application/xml", @credentials)
|
930
902
|
else
|
931
903
|
xml_value = xml_text_node(port.value)
|
932
|
-
|
933
|
-
@server.
|
934
|
-
|
935
|
-
@credentials)
|
904
|
+
uri = Util.append_to_uri_path(links[:inputs], "input/#{port.name}")
|
905
|
+
@server.update(uri, XML::Fragments::RUNINPUTVALUE % xml_value,
|
906
|
+
"application/xml", @credentials)
|
936
907
|
end
|
937
908
|
end
|
938
909
|
end
|
@@ -960,8 +931,7 @@ module T2Server
|
|
960
931
|
# Create and upload the baclava data.
|
961
932
|
baclava = Taverna::Baclava::Writer.write(data_map)
|
962
933
|
upload_data(baclava, "in.baclava")
|
963
|
-
@server.
|
964
|
-
"text/plain", @credentials)
|
934
|
+
@server.update(links[:baclava], "in.baclava", "text/plain", @credentials)
|
965
935
|
end
|
966
936
|
|
967
937
|
# Check that the uri passed in is suitable for credential use:
|
@@ -987,8 +957,8 @@ module T2Server
|
|
987
957
|
# returned as a list of two lists, "lists" and "values" respectively.
|
988
958
|
def _ls_ports(dir="", top=true)
|
989
959
|
dir = Util.strip_path_slashes(dir)
|
990
|
-
|
991
|
-
|
960
|
+
uri = Util.append_to_uri_path(links[:wdir], dir)
|
961
|
+
dir_list = @server.read(uri, "*/*", @credentials)
|
992
962
|
|
993
963
|
# compile a list of directory entries stripping the
|
994
964
|
# directory name from the front of each filename
|
@@ -1030,8 +1000,8 @@ module T2Server
|
|
1030
1000
|
return "#{@server.uri}/rest/runs/#{@identifier}/" +
|
1031
1001
|
"#{links[:wdir]}/out/#{output}"
|
1032
1002
|
else
|
1033
|
-
|
1034
|
-
|
1003
|
+
out_uri = Util.append_to_uri_path(links[:wdir], "out/#{output}")
|
1004
|
+
return @server.read(out_uri, "application/octet-stream",
|
1035
1005
|
@credentials)
|
1036
1006
|
end
|
1037
1007
|
end
|
@@ -1054,9 +1024,10 @@ module T2Server
|
|
1054
1024
|
result << "#{@server.uri}/rest/runs/#{@identifier}/" +
|
1055
1025
|
"#{links[:wdir]}/out/#{output}/#{item}"
|
1056
1026
|
else
|
1057
|
-
|
1058
|
-
"
|
1059
|
-
|
1027
|
+
out_uri = Util.append_to_uri_path(links[:wdir],
|
1028
|
+
"out/#{output}/#{item}")
|
1029
|
+
result << @server.read(out_uri, "application/octet-stream",
|
1030
|
+
@credentials)
|
1060
1031
|
end
|
1061
1032
|
end
|
1062
1033
|
|
@@ -1065,8 +1036,8 @@ module T2Server
|
|
1065
1036
|
|
1066
1037
|
def _get_input_port_info
|
1067
1038
|
ports = {}
|
1068
|
-
port_desc = @server.
|
1069
|
-
|
1039
|
+
port_desc = @server.read(links[:inputexp], "application/xml",
|
1040
|
+
@credentials)
|
1070
1041
|
|
1071
1042
|
doc = xml_document(port_desc)
|
1072
1043
|
|
@@ -1080,8 +1051,12 @@ module T2Server
|
|
1080
1051
|
|
1081
1052
|
def _get_output_port_info
|
1082
1053
|
ports = {}
|
1083
|
-
|
1084
|
-
|
1054
|
+
|
1055
|
+
begin
|
1056
|
+
port_desc = @server.read(links[:output], "application/xml", @credentials)
|
1057
|
+
rescue AttributeNotFoundError => anfe
|
1058
|
+
return ports
|
1059
|
+
end
|
1085
1060
|
|
1086
1061
|
doc = xml_document(port_desc)
|
1087
1062
|
|
@@ -1095,8 +1070,8 @@ module T2Server
|
|
1095
1070
|
|
1096
1071
|
def _get_run_description
|
1097
1072
|
if @run_doc.nil?
|
1098
|
-
@run_doc = xml_document(@server.
|
1099
|
-
|
1073
|
+
@run_doc = xml_document(@server.read(@uri, "application/xml",
|
1074
|
+
@credentials))
|
1100
1075
|
end
|
1101
1076
|
|
1102
1077
|
@run_doc
|
@@ -1116,34 +1091,33 @@ module T2Server
|
|
1116
1091
|
|
1117
1092
|
[:expiry, :workflow, :status, :createtime, :starttime, :finishtime,
|
1118
1093
|
:wdir, :inputs, :output, :securectx, :listeners].each do |key|
|
1119
|
-
links[key] = xpath_attr(doc, XPaths[key], "href")
|
1094
|
+
links[key] = URI.parse(xpath_attr(doc, XPaths[key], "href"))
|
1120
1095
|
end
|
1121
1096
|
|
1122
1097
|
# get inputs
|
1123
|
-
inputs = @server.
|
1124
|
-
"application/xml",@credentials)
|
1098
|
+
inputs = @server.read(links[:inputs], "application/xml",@credentials)
|
1125
1099
|
doc = xml_document(inputs)
|
1126
1100
|
|
1127
|
-
links[:baclava] =
|
1128
|
-
|
1129
|
-
links[:inputexp] = "#{links[:inputs]}/" +
|
1130
|
-
xpath_attr(doc, XPaths[:inputexp], "href").split('/')[-1]
|
1101
|
+
links[:baclava] = URI.parse(xpath_attr(doc, XPaths[:baclava], "href"))
|
1102
|
+
links[:inputexp] = URI.parse(xpath_attr(doc, XPaths[:inputexp], "href"))
|
1131
1103
|
|
1132
1104
|
# set io properties
|
1133
|
-
links[:io] =
|
1134
|
-
links[:stdout] =
|
1135
|
-
links[:stderr] =
|
1136
|
-
links[:exitcode] =
|
1105
|
+
links[:io] = Util.append_to_uri_path(links[:listeners], "io")
|
1106
|
+
links[:stdout] = Util.append_to_uri_path(links[:io], "properties/stdout")
|
1107
|
+
links[:stderr] = Util.append_to_uri_path(links[:io], "properties/stderr")
|
1108
|
+
links[:exitcode] = Util.append_to_uri_path(links[:io], "properties/exitcode")
|
1137
1109
|
|
1138
1110
|
# security properties - only available to the owner of a run
|
1139
1111
|
if owner?
|
1140
|
-
securectx = @server.
|
1141
|
-
|
1112
|
+
securectx = @server.read(links[:securectx], "application/xml",
|
1113
|
+
@credentials)
|
1142
1114
|
doc = xml_document(securectx)
|
1143
1115
|
|
1144
1116
|
[:sec_creds, :sec_perms, :sec_trusts].each do |key|
|
1145
|
-
links[key] = "#{links[:securectx]}/" + xpath_attr(doc, XPaths[key],
|
1146
|
-
|
1117
|
+
#links[key] = "#{links[:securectx]}/" + xpath_attr(doc, XPaths[key],
|
1118
|
+
# "href").split('/')[-1]
|
1119
|
+
links[key] = Util.append_to_uri_path(links[:securectx],
|
1120
|
+
xpath_attr(doc, XPaths[key], "href").split('/')[-1])
|
1147
1121
|
end
|
1148
1122
|
end
|
1149
1123
|
|