petasos 0.4.3 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0abd063cdacfb24b5876edc9608043694df00a102f143cc49b688b0e2678728e
4
- data.tar.gz: f1393df6f212332660f6acb72cef96562270e9f326e105086ae2a8dc5bc350bc
3
+ metadata.gz: 4ff98d0ee0f69c09a8436007524d6650b8ed5e82c4f2ced088b0a8da72ac31cd
4
+ data.tar.gz: 4e16bc991db6f87baa0f056e64834251749c290b3e6aba9db66586ff6850a2fb
5
5
  SHA512:
6
- metadata.gz: ef0d35c61eb1de183ea9638a7ac526bf18e87d48cef269eba38ab369a510f9c6d452d058f489dd673916eebf8876e287b79846c82d217e925f449cf3642a9ef8
7
- data.tar.gz: 2c6d55f20670cb8000f9d26f22eb5838597d13fe92db650c84db57b3b17a485aea9bea8792f7abd45f39b27562bb9971f6c5c145e284ae6acefd0de7e6f8addc
6
+ metadata.gz: d0cc807729014a25f679cfadddcc8ee6851b2312438790e193ebd4b38ce9182d1a4ee4a0d0da07685eee1b125671841f1b7758b1708699d6b2328bd8ea74bab8
7
+ data.tar.gz: 9b44f27902559d5b0d3df48ab822186d3de4f28627b86a0f1288000e4d1e61ad7985348ea6efaf03bb94d9ba654941b48ec72a2febe6d851d5825b83753c3f46
data/bin/petasos CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'petasos'
3
+ require "petasos"
4
4
 
5
- Petasos.new.run
5
+ Petasos.new.run(ARGV[0])
@@ -50,7 +50,7 @@ class Petasos::Distributor
50
50
  @manifests.each_pair do |node_name, manifest_list|
51
51
  manifest_list.each do |manifest|
52
52
  manifest["imports"].each_pair do |pool_name, import_hash|
53
- @pools[pool_name]["import_paths"] << [node_name, import_hash["import_path"]]
53
+ @pools[pool_name]["import_paths"] << [node_name, manifest["name"], import_hash["import_path"]]
54
54
  @pools[pool_name]["backfill_import_paths"] << [node_name, manifest["name"], import_hash["import_path"]] if import_hash["backfill"]
55
55
  end
56
56
  manifest["exports"].each_pair do |pool_name, export_hash|
@@ -62,6 +62,7 @@ class Petasos::Distributor
62
62
  # {"wow-ah"=>
63
63
  # {"import_paths"=>
64
64
  # [["petasos-node-b",
65
+ # "linux-laptop-storage",
65
66
  # "/home/justin/play/petasos/test/sandbox/node_b/location_a/data"]],
66
67
  # "backfill_import_paths"=>
67
68
  # [["petasos-node-b",
@@ -77,11 +78,17 @@ class Petasos::Distributor
77
78
  export_filename = File.basename(exports_file_path, ".*")
78
79
  label, location_name, pool_name, datetime = export_filename.split("_")
79
80
  export_paths = YAML.load_file(exports_file_path)
80
- export_paths.each do |export_path|
81
- @pools[pool_name]["import_paths"].each do |pool_storage|
82
- to_node = find_node(pool_storage.first)
83
- `scp #{from_node.host}:#{export_path}* #{to_node.host}:#{pool_storage.last}`
81
+ @pools[pool_name]["import_paths"].each do |pool_storage|
82
+ to_node = find_node(pool_storage.first)
83
+ destination_seen_file_hash = get_seen_file_hash(pool_storage.first, pool_storage[1], pool_name)
84
+ export_paths.each do |export_path|
85
+ unless destination_seen_file_hash[File.basename(export_path)]
86
+ puts "exporting #{File.basename(export_path)} from #{from_node.name} to #{to_node.name}"
87
+ `scp #{from_node.host}:#{export_path}* #{to_node.host}:#{pool_storage.last}`
88
+ end
84
89
  end
90
+ puts "Running `petasos locations` on #{to_node.name} after export from #{from_node.name}"
91
+ `ssh #{to_node.host} \"cd #{to_node.path} && petasos locations\"`
85
92
  end
86
93
  # mark it as completed
87
94
  completed_export_file_path = File.join(Dir.pwd, "completed-#{File.basename(exports_file_path)}")
@@ -89,6 +96,8 @@ class Petasos::Distributor
89
96
  # and then put it back where it came from
90
97
  `scp #{completed_export_file_path} #{from_node.host}:#{from_node.path}`
91
98
  `rm #{completed_export_file_path}`
99
+ puts "Running `petasos locations` on #{from_node.name} after completing its exports"
100
+ `ssh #{from_node.host} \"cd #{from_node.path} && petasos locations\"`
92
101
  end
93
102
 
94
103
  # {"wow-ah"=>
@@ -102,39 +111,43 @@ class Petasos::Distributor
102
111
  # "canonical_exporters"=>[["petasos-node-a", "linux-laptop-source"]]}}
103
112
 
104
113
  # Process the backfills.
105
- # grab the seen files on the canonical exporters
106
114
  @pools.each_pair do |pool_name, manifest_hash|
107
- manifest_hash["canonical_exporters"].each do |canonical_exporter_details|
108
- find_node(canonical_exporter_details.first).grab_seen_file_for_location(canonical_exporter_details.last, pool_name)
109
- end
110
-
111
- # grab the seen files on the backfill importers
112
- manifest_hash["backfill_import_paths"].each do |backfill_importer_details|
113
- find_node(backfill_importer_details.first).grab_seen_file_for_location(backfill_importer_details[1], pool_name)
114
- end
115
-
116
115
  # for each canonical exporter loop through the backfill lists, identify files that need moving and move them
117
116
  manifest_hash["canonical_exporters"].each do |canonical_exporter_details|
118
- exporter_seen_files = {}
119
- exporter_file_list = YAML.load_file("seen_#{canonical_exporter_details.last}_#{pool_name}.yaml")
120
- exporter_file_list.each { |f| exporter_seen_files[File.basename(f)] = f }
117
+ exporter_seen_files = get_seen_file_hash(canonical_exporter_details.first, canonical_exporter_details.last, pool_name)
121
118
  manifest_hash["backfill_import_paths"].each do |backfill_importer_details|
122
- backfill_importer_files = {}
123
- backfill_file_list = YAML.load_file("seen_#{backfill_importer_details[1]}_#{pool_name}.yaml")
124
- backfill_file_list.each { |f| backfill_importer_files[File.basename(f)] = f }
119
+ backfill_importer_files = get_seen_file_hash(backfill_importer_details.first, backfill_importer_details[1], pool_name)
120
+
121
+ from_node = find_node(canonical_exporter_details.first)
122
+ to_node = find_node(backfill_importer_details.first)
125
123
 
126
124
  exporter_seen_files.each_pair do |file_name, file_path|
127
125
  unless backfill_importer_files[file_name]
128
- from_node = find_node(canonical_exporter_details.first)
129
- to_node = find_node(backfill_importer_details.first)
126
+ puts "Backfilling #{file_name} to #{to_node.name} from #{from_node.name}"
130
127
  `scp #{from_node.host}:#{file_path} #{to_node.host}:#{backfill_importer_details.last}`
131
128
  end
132
129
  end
130
+
131
+ puts "Running `petasos locations` on #{to_node.name} after backfill from #{from_node.name}"
132
+ `ssh #{to_node.host} \"cd #{to_node.path} && petasos locations\"`
133
133
  end
134
134
  end
135
- # clear the seen files locally.
136
- `rm seen_*`
137
135
  end
136
+ # clear the seen files locally.
137
+ `rm seen_*`
138
+ end
139
+
140
+ def get_seen_file_hash(node_name, location_name, pool_name)
141
+ find_node(node_name).grab_seen_file_for_location(location_name, pool_name)
142
+ seen_file_hash = {}
143
+ # some locations/pools do not generate a seen file.
144
+ if File.file?("seen_#{location_name}_#{pool_name}.yaml")
145
+ seen_file_list = YAML.load_file("seen_#{location_name}_#{pool_name}.yaml")
146
+ else
147
+ seen_file_list = []
148
+ end
149
+ seen_file_list.each { |f| seen_file_hash[File.basename(f)] = f }
150
+ seen_file_hash
138
151
  end
139
152
 
140
153
  def find_node(node_name)
data/lib/petasos/node.rb CHANGED
@@ -10,16 +10,24 @@ class Petasos::Node
10
10
  @config = config
11
11
  @manifests = []
12
12
  `mkdir -p #{config["name"]}`
13
+
14
+ puts "Running `petasos locations` on #{name} before distribution begins"
15
+ `ssh #{host} \"cd #{path} && petasos locations\"`
16
+
13
17
  grab_manifest_and_exports
14
18
  parse_manifests
15
19
  end
16
20
 
21
+ def name
22
+ config["name"]
23
+ end
24
+
17
25
  def host
18
- @config["host"]
26
+ config["host"]
19
27
  end
20
28
 
21
29
  def path
22
- @config["path"]
30
+ config["path"]
23
31
  end
24
32
 
25
33
  def grab_manifest_and_exports
data/lib/petasos.rb CHANGED
@@ -6,9 +6,16 @@ require "yaml"
6
6
  class Petasos
7
7
  class Error < StandardError; end
8
8
 
9
- def run
10
- process_locations
11
- process_distribution if File.file?(File.join(Dir.pwd, "petasos_distribution-config.yaml"))
9
+ def run(mode = "")
10
+ unless File.file?("petasos_is_running")
11
+ `touch petasos_is_running`
12
+ process_locations
13
+ unless mode == "locations"
14
+ process_distribution if File.file?(File.join(Dir.pwd, "petasos_distribution-config.yaml"))
15
+ process_locations
16
+ end
17
+ `rm petasos_is_running`
18
+ end
12
19
  end
13
20
 
14
21
  def process_locations
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petasos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Myers