couchdb-replicator 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,48 +1,44 @@
|
|
1
|
-
requires "
|
1
|
+
requires "../couch"
|
2
2
|
module VagrantPlugins
|
3
3
|
module CouchDB
|
4
4
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
5
5
|
def provision
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
firstCouch.post("/_replicate", replicateJSON.to_json)
|
40
|
-
end
|
41
|
-
end
|
6
|
+
couchHosts = config.dbHosts
|
7
|
+
|
8
|
+
firstDB = true
|
9
|
+
couchHosts.each do |couchHost|
|
10
|
+
|
11
|
+
firstCouch = Couch::Server.new(couchHost, "5984")
|
12
|
+
if firstDB
|
13
|
+
#res = firstCouch.get("/ss")
|
14
|
+
#raise
|
15
|
+
#json = res.body
|
16
|
+
#puts json
|
17
|
+
#firstCouch.put("/sofa/", "")
|
18
|
+
#firstDB = false
|
19
|
+
end
|
20
|
+
|
21
|
+
replicateFromURL = "http://" + couchHost + ":5984/sofa"
|
22
|
+
puts "createServer:" + couchHost + ":5984/sofa"
|
23
|
+
|
24
|
+
couchHosts.each do |replicateTo|
|
25
|
+
if replicateTo != couchHost
|
26
|
+
|
27
|
+
#secondCouch = Couch::Server.new(replicateTo, "5984")
|
28
|
+
|
29
|
+
replicateToURL = "http://" + replicateTo + ":5984/sofa"
|
30
|
+
payload = '{ "source":' + '"' + replicateFromURL + '"' + ',' +
|
31
|
+
' "target":' + '"' + replicateToURL + '"' + ',' +
|
32
|
+
' "continuous": true,' +
|
33
|
+
' "create_target": true' +
|
34
|
+
'}'
|
35
|
+
replicateJSON = JSON.parse(payload)
|
36
|
+
puts replicateJSON
|
37
|
+
|
38
|
+
firstCouch.post("/_replicate", replicateJSON.to_json)
|
42
39
|
end
|
43
|
-
rescue
|
44
|
-
puts 'I am rescued.'
|
45
40
|
end
|
41
|
+
end
|
46
42
|
|
47
43
|
end
|
48
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchdb-replicator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This is a couchdb replicator
|
15
15
|
email:
|
@@ -38,7 +38,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
38
38
|
version: '0'
|
39
39
|
segments:
|
40
40
|
- 0
|
41
|
-
hash:
|
41
|
+
hash: 1332916954806387323
|
42
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
43
|
none: false
|
44
44
|
requirements:
|
@@ -47,7 +47,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
47
47
|
version: '0'
|
48
48
|
segments:
|
49
49
|
- 0
|
50
|
-
hash:
|
50
|
+
hash: 1332916954806387323
|
51
51
|
requirements: []
|
52
52
|
rubyforge_project:
|
53
53
|
rubygems_version: 1.8.23
|