xpflow 0.1b

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.
Files changed (74) hide show
  1. data/bin/xpflow +96 -0
  2. data/lib/colorado.rb +198 -0
  3. data/lib/json/add/core.rb +243 -0
  4. data/lib/json/add/rails.rb +8 -0
  5. data/lib/json/common.rb +423 -0
  6. data/lib/json/editor.rb +1369 -0
  7. data/lib/json/ext.rb +28 -0
  8. data/lib/json/pure/generator.rb +442 -0
  9. data/lib/json/pure/parser.rb +320 -0
  10. data/lib/json/pure.rb +15 -0
  11. data/lib/json/version.rb +8 -0
  12. data/lib/json.rb +62 -0
  13. data/lib/mime/types.rb +881 -0
  14. data/lib/mime-types.rb +3 -0
  15. data/lib/restclient/abstract_response.rb +106 -0
  16. data/lib/restclient/exceptions.rb +193 -0
  17. data/lib/restclient/net_http_ext.rb +55 -0
  18. data/lib/restclient/payload.rb +235 -0
  19. data/lib/restclient/raw_response.rb +34 -0
  20. data/lib/restclient/request.rb +316 -0
  21. data/lib/restclient/resource.rb +169 -0
  22. data/lib/restclient/response.rb +24 -0
  23. data/lib/restclient.rb +174 -0
  24. data/lib/xpflow/bash.rb +341 -0
  25. data/lib/xpflow/bundle.rb +113 -0
  26. data/lib/xpflow/cmdline.rb +249 -0
  27. data/lib/xpflow/collection.rb +122 -0
  28. data/lib/xpflow/concurrency.rb +79 -0
  29. data/lib/xpflow/data.rb +393 -0
  30. data/lib/xpflow/dsl.rb +816 -0
  31. data/lib/xpflow/engine.rb +574 -0
  32. data/lib/xpflow/ensemble.rb +135 -0
  33. data/lib/xpflow/events.rb +56 -0
  34. data/lib/xpflow/experiment.rb +65 -0
  35. data/lib/xpflow/exts/facter.rb +30 -0
  36. data/lib/xpflow/exts/g5k.rb +931 -0
  37. data/lib/xpflow/exts/g5k_use.rb +50 -0
  38. data/lib/xpflow/exts/gui.rb +140 -0
  39. data/lib/xpflow/exts/model.rb +155 -0
  40. data/lib/xpflow/graph.rb +1603 -0
  41. data/lib/xpflow/graph_xpflow.rb +251 -0
  42. data/lib/xpflow/import.rb +196 -0
  43. data/lib/xpflow/library.rb +349 -0
  44. data/lib/xpflow/logging.rb +153 -0
  45. data/lib/xpflow/manager.rb +147 -0
  46. data/lib/xpflow/nodes.rb +1250 -0
  47. data/lib/xpflow/runs.rb +773 -0
  48. data/lib/xpflow/runtime.rb +125 -0
  49. data/lib/xpflow/scope.rb +168 -0
  50. data/lib/xpflow/ssh.rb +186 -0
  51. data/lib/xpflow/stat.rb +50 -0
  52. data/lib/xpflow/stdlib.rb +381 -0
  53. data/lib/xpflow/structs.rb +369 -0
  54. data/lib/xpflow/taktuk.rb +193 -0
  55. data/lib/xpflow/templates/ssh-config.basic +14 -0
  56. data/lib/xpflow/templates/ssh-config.inria +18 -0
  57. data/lib/xpflow/templates/ssh-config.proxy +13 -0
  58. data/lib/xpflow/templates/taktuk +6590 -0
  59. data/lib/xpflow/templates/utils/batch +4 -0
  60. data/lib/xpflow/templates/utils/bootstrap +12 -0
  61. data/lib/xpflow/templates/utils/hostname +3 -0
  62. data/lib/xpflow/templates/utils/ping +3 -0
  63. data/lib/xpflow/templates/utils/rsync +12 -0
  64. data/lib/xpflow/templates/utils/scp +17 -0
  65. data/lib/xpflow/templates/utils/scp_many +8 -0
  66. data/lib/xpflow/templates/utils/ssh +3 -0
  67. data/lib/xpflow/templates/utils/ssh-interactive +4 -0
  68. data/lib/xpflow/templates/utils/taktuk +19 -0
  69. data/lib/xpflow/threads.rb +187 -0
  70. data/lib/xpflow/utils.rb +569 -0
  71. data/lib/xpflow/visual.rb +230 -0
  72. data/lib/xpflow/with_g5k.rb +7 -0
  73. data/lib/xpflow.rb +349 -0
  74. metadata +135 -0
@@ -0,0 +1,56 @@
1
+
2
+ require 'thread'
3
+
4
+ module XPFlow
5
+
6
+ class EventHandler
7
+
8
+ def initialize(block)
9
+ @block = block
10
+ end
11
+
12
+ def run(*args)
13
+ return @block.call(*args)
14
+ end
15
+
16
+ end
17
+
18
+ class EventRouter
19
+
20
+ def initialize
21
+ @mutex = Mutex.new
22
+ @listeners = Hash.new { |h, key| h[key] = [] }
23
+ end
24
+
25
+ def synchronize(&block)
26
+ return @mutex.synchronize(&block)
27
+ end
28
+
29
+ def listen(event, &block)
30
+ synchronize do
31
+ @listeners[event].push(EventHandler.new(block))
32
+ end
33
+ end
34
+
35
+ def publish(event, args = [])
36
+ hs = synchronize do
37
+ @listeners[event].map { |x| x } # copy
38
+ end
39
+ hs.each do |h|
40
+ h.run(*args)
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
48
+
49
+ if __FILE__ == $0
50
+ r = XPFlow::EventRouter.new
51
+ r.listen(:complete) do |x|
52
+ puts "yo! #{x}"
53
+ end
54
+ r.publish :cze
55
+ r.publish :complete, [ 1, 2 ]
56
+ end
@@ -0,0 +1,65 @@
1
+
2
+ module XPFlow
3
+
4
+ class Experiment
5
+
6
+ attr_reader :results
7
+
8
+ def initialize(name, results_path, parent = nil)
9
+ @name = name
10
+ @parent = parent
11
+ @results = Collection.new(results_path)
12
+ @results.create_path()
13
+ @log_filename = File.join(results_path, "experiment.log")
14
+ @log_file = FileLog.new(@log_filename).open()
15
+ end
16
+
17
+ def create_subexperiment(name)
18
+ new_path = File.join(@results.path, name)
19
+ return Experiment.new(name, new_path, self)
20
+ end
21
+
22
+ def install
23
+ return self
24
+ end
25
+
26
+ def log(*msgs)
27
+ @log_file.log(*msgs)
28
+ @parent.log(*msgs) unless @parent.nil?
29
+ end
30
+
31
+ def store_execution(execution)
32
+ # puts execution
33
+ # here we should store the execution so that it will be solved
34
+ end
35
+
36
+ def store_executions(array)
37
+ array.each { |x| store_execution(x) }
38
+ end
39
+
40
+ end
41
+
42
+ class ExperimentBlackHole
43
+
44
+ # a version of Experiment that consumes eveything it is given
45
+ # used in a testsuite
46
+
47
+ def initialize(*args); end
48
+
49
+ def create_subexperiment(name)
50
+ return ExperimentBlackHole.new()
51
+ end
52
+
53
+ def install
54
+ return self
55
+ end
56
+
57
+ def log(*msgs); end
58
+
59
+ def store_execution(x); end
60
+
61
+ def store_executions(x); end
62
+
63
+ end
64
+
65
+ end
@@ -0,0 +1,30 @@
1
+
2
+ ## runs facter after deployment
3
+
4
+ after_activity :__deployment__ do |nodes|
5
+ execute_many "apt-get update -y", :idempotent => true
6
+ execute_many "apt-get install -y facter", :idempotent => true
7
+ facts = execute_many "facter --yaml", :idempotent => true
8
+ # TODO: collect the facts later or something
9
+
10
+ data = engine.inline_process(facts) do |fs|
11
+ forall fs do |f|
12
+ yaml = (stdout_of f)
13
+ node = (node_of f)
14
+ value [ node, yaml ]
15
+ end
16
+ end
17
+
18
+ facter_facts = { }
19
+ data.each do |node, yaml|
20
+ puts yaml
21
+ facts = YAML.load(yaml)
22
+ facter_facts[node] = facts
23
+ end
24
+ run :"__getset__.set", :facter_facts, facter_facts
25
+ end
26
+
27
+ activity :get_fact do |node, factname|
28
+ facts = run :"__getset__.get", :facter_facts
29
+ facts[node][factname.to_s]
30
+ end