elasticsearch_update 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/elasticsearch_update.gemspec +2 -0
- data/lib/elasticsearch_update/cli.rb +13 -1
- data/lib/elasticsearch_update/downloader.rb +95 -1
- data/lib/elasticsearch_update/elasticsearch.rb +105 -1
- data/lib/elasticsearch_update/installer.rb +65 -1
- data/lib/elasticsearch_update/version.rb +1 -1
- data/lib/elasticsearch_update/wizard.rb +144 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3df537b4bd6bc80e4eb1120c60e39a8fa5f324df
|
4
|
+
data.tar.gz: 5959d7922c84ab8059edab8ef1f093957725541a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a43c31b14e97b06724b2d0da9dc308b30d155bc4934067f7c22e5f43cbfa8e46b601fe631408a1b16f034c1991097feac29b9127d1a58db8d2dc2e3dba0538c
|
7
|
+
data.tar.gz: 1a2285449eef6fd531687878da4ab6944cfac4b4a244bdbe8001209cf5b09290fdc75bd3fb926b89d868ccf9601b7e88a68aee7a8d91163658c53452052c5bce
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[![Build Status](https://travis-ci.org/kkirsche/elasticsearch_update.svg?branch=master)](https://travis-ci.org/kkirsche/elasticsearch_update) [![Code Climate](https://codeclimate.com/github/kkirsche/elasticsearch_update/badges/gpa.svg)](https://codeclimate.com/github/kkirsche/elasticsearch_update) [![Test Coverage](https://codeclimate.com/github/kkirsche/elasticsearch_update/badges/coverage.svg)](https://codeclimate.com/github/kkirsche/elasticsearch_update) [![Dependency Status](https://gemnasium.com/kkirsche/elasticsearch_update.svg)](https://gemnasium.com/kkirsche/elasticsearch_update)
|
2
|
-
# Elasticsearch Update
|
1
|
+
[![Build Status](https://travis-ci.org/kkirsche/elasticsearch_update.svg?branch=master)](https://travis-ci.org/kkirsche/elasticsearch_update) [![Code Climate](https://codeclimate.com/github/kkirsche/elasticsearch_update/badges/gpa.svg)](https://codeclimate.com/github/kkirsche/elasticsearch_update) [![Test Coverage](https://codeclimate.com/github/kkirsche/elasticsearch_update/badges/coverage.svg)](https://codeclimate.com/github/kkirsche/elasticsearch_update) [![Dependency Status](https://gemnasium.com/kkirsche/elasticsearch_update.svg)](https://gemnasium.com/kkirsche/elasticsearch_update) [![Gem Version](https://badge.fury.io/rb/elasticsearch_update.svg)](http://badge.fury.io/rb/elasticsearch_update)
|
2
|
+
# Elasticsearch Update
|
3
3
|
|
4
4
|
This gem allows users to easily update their 1.0 and later Elasticsearch instance on the local machine from one of the following formats.
|
5
5
|
|
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "https://github.com/kkirsche/elasticsearch_update"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
|
+
spec.required_ruby_version = '>= 2.0.0'
|
17
|
+
|
16
18
|
spec.files = `git ls-files -z`.split("\x0")
|
17
19
|
spec.executables << 'elasticsearch_update'
|
18
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
@@ -1,8 +1,20 @@
|
|
1
1
|
require 'logger'
|
2
2
|
|
3
3
|
module ElasticsearchUpdate
|
4
|
-
#
|
4
|
+
# == CLI
|
5
|
+
# ElasticsearchUpdate::Cli class is used to begin application execution
|
6
|
+
# and walks the user through the update process
|
7
|
+
#
|
8
|
+
# == Parameters
|
9
|
+
#
|
10
|
+
# Start takes no parameters or options.
|
5
11
|
class Cli
|
12
|
+
# Start the command line update process which calls all necessary
|
13
|
+
# methods and classes to complete an Elasticsearch update.
|
14
|
+
#
|
15
|
+
# ==== Example
|
16
|
+
#
|
17
|
+
# ElasticsearchUpdate::Cli.start
|
6
18
|
def self.start
|
7
19
|
@log = Logger.new(STDOUT)
|
8
20
|
@log.level = Logger::INFO
|
@@ -4,10 +4,42 @@ require 'tempfile'
|
|
4
4
|
require 'open-uri'
|
5
5
|
|
6
6
|
module ElasticsearchUpdate
|
7
|
-
#
|
7
|
+
# == Downloader
|
8
|
+
# ElasticsearchUpdate::Downloader class is used to download the
|
9
|
+
# Elasticsearch update file
|
10
|
+
#
|
11
|
+
# == Parameters
|
12
|
+
#
|
13
|
+
# Initilization requires a +hash+ and optional +test+ parameter.
|
14
|
+
#
|
15
|
+
# +hash+ is a ruby hash in the following format:
|
16
|
+
# { host: String, port: Integer }
|
17
|
+
#
|
18
|
+
# +test+ is a boolean identifying whether or not we are in a test
|
19
|
+
# if we are, we set the Logger to logging FATAL errors only.
|
20
|
+
#
|
21
|
+
# == Example
|
22
|
+
#
|
23
|
+
# ElasticsearchUpdate::Downloader.new({ host: 'localhost', port: 9200 })
|
8
24
|
class Downloader
|
9
25
|
attr_reader :extension, :base, :version, :download_url, :verify_url
|
10
26
|
attr_accessor :update_file
|
27
|
+
# == initialize
|
28
|
+
# Allows us to create an instance of the Downloader
|
29
|
+
#
|
30
|
+
# == Parameters
|
31
|
+
#
|
32
|
+
# initialize requires a +hash+ and optional +test+ parameter.
|
33
|
+
#
|
34
|
+
# +hash+ is a ruby hash in the following format:
|
35
|
+
# { host: String, port: Integer }
|
36
|
+
#
|
37
|
+
# +test+ is a boolean identifying whether or not we are in a test
|
38
|
+
# if we are, we set the Logger to logging FATAL errors only.
|
39
|
+
#
|
40
|
+
# == Example
|
41
|
+
#
|
42
|
+
# ElasticsearchUpdate::Downloader.new({ host: 'localhost', port: 9200 })
|
11
43
|
def initialize(hash, test = false)
|
12
44
|
@log = Logger.new(STDOUT)
|
13
45
|
if test
|
@@ -29,6 +61,21 @@ module ElasticsearchUpdate
|
|
29
61
|
@extension + '.sha1.txt'
|
30
62
|
end
|
31
63
|
|
64
|
+
# == write_file_from_url
|
65
|
+
# Allows us to write data from a URL to a file.
|
66
|
+
#
|
67
|
+
# == Parameters
|
68
|
+
#
|
69
|
+
# write_file_from_url requires a +file+ to write to and a +url+ from which
|
70
|
+
# to download the file from.
|
71
|
+
#
|
72
|
+
# +file+ is a ruby File or Tempfile object
|
73
|
+
#
|
74
|
+
# +url+ is a string for the URL.
|
75
|
+
#
|
76
|
+
# == Example
|
77
|
+
#
|
78
|
+
# write_file_from_url(Tempfile.new('example'), http://foo.bar/file.zip)
|
32
79
|
def write_file_from_url(file, url)
|
33
80
|
Net::HTTP.start(@base) do |http|
|
34
81
|
begin
|
@@ -43,6 +90,22 @@ module ElasticsearchUpdate
|
|
43
90
|
end
|
44
91
|
end
|
45
92
|
|
93
|
+
# == download_file
|
94
|
+
# Begins the download process of the Elasticsearch update file.
|
95
|
+
#
|
96
|
+
# == Parameters
|
97
|
+
#
|
98
|
+
# download_file takes an optional boolean argument, named +test+.
|
99
|
+
#
|
100
|
+
# +test+ is an optional boolean which allows us to avoid actually writing to
|
101
|
+
# a file while running our tests.
|
102
|
+
#
|
103
|
+
# == Example
|
104
|
+
#
|
105
|
+
# # Not a test
|
106
|
+
# download_file
|
107
|
+
# # Test
|
108
|
+
# download_file(true)
|
46
109
|
def download_file(test = false)
|
47
110
|
@update_file = Tempfile.new(['elasticsearch_update_file', @extension])
|
48
111
|
|
@@ -53,6 +116,21 @@ module ElasticsearchUpdate
|
|
53
116
|
@update_file
|
54
117
|
end
|
55
118
|
|
119
|
+
# == verify_update_file
|
120
|
+
# Begins the verification process the Elasticsearch update file by
|
121
|
+
# using the instance variables of the file and the downloaded SHA1 value.
|
122
|
+
#
|
123
|
+
# == Parameters
|
124
|
+
#
|
125
|
+
# verify_update_file takes no parameters.
|
126
|
+
#
|
127
|
+
# == Requires
|
128
|
+
#
|
129
|
+
# verify_update_file requires @update_file to be set as a file.
|
130
|
+
#
|
131
|
+
# == Example
|
132
|
+
#
|
133
|
+
# verify_update_file
|
56
134
|
def verify_update_file
|
57
135
|
@log.info('Beginning integrity check of downloaded file .')
|
58
136
|
@file_sha1 = Digest::SHA1.file(@update_file.path).hexdigest
|
@@ -67,6 +145,22 @@ module ElasticsearchUpdate
|
|
67
145
|
end
|
68
146
|
end
|
69
147
|
|
148
|
+
# == download_remote_sha1
|
149
|
+
# Begins the download of the Elasticsearch update file SHA1 text file.
|
150
|
+
# It then separates the SHA1 value from the filename.
|
151
|
+
#
|
152
|
+
# == Parameters
|
153
|
+
#
|
154
|
+
# download_remote_sha1 takes no parameters.
|
155
|
+
#
|
156
|
+
# == Requires
|
157
|
+
#
|
158
|
+
# download_remote_sha1 requires @verify_url to be set as a string to a
|
159
|
+
# .txt file.
|
160
|
+
#
|
161
|
+
# == Example
|
162
|
+
#
|
163
|
+
# download_remote_sha1
|
70
164
|
def download_remote_sha1
|
71
165
|
@log.info('Downloading Elasticsearch SHA1.')
|
72
166
|
|
@@ -3,9 +3,46 @@ require 'json'
|
|
3
3
|
require 'net/http'
|
4
4
|
|
5
5
|
module ElasticsearchUpdate
|
6
|
-
#
|
6
|
+
# == Elasticsearch
|
7
|
+
# ElasticsearchUpdate::Elasticsearch class is used to interact with
|
8
|
+
# the local Elasticsearch instance.
|
9
|
+
#
|
10
|
+
# == Parameters
|
11
|
+
#
|
12
|
+
# Initilization takes an optional +hash+ and optional +test+ parameter.
|
13
|
+
#
|
14
|
+
# +hash+ is a ruby hash in the following format:
|
15
|
+
# { host: String, port: Integer }
|
16
|
+
#
|
17
|
+
# +test+ is a boolean identifying whether or not we are in a test
|
18
|
+
# if we are, we set the Logger to logging FATAL errors only.
|
19
|
+
#
|
20
|
+
# == Example
|
21
|
+
#
|
22
|
+
# ElasticsearchUpdate::Elasticsearch.new({ host: 'localhost', port: 9200 })
|
7
23
|
class Elasticsearch
|
8
24
|
attr_reader :es_host, :es_port
|
25
|
+
# == initialize
|
26
|
+
# Allows us to create an instance of the Elasticsearch interaction client.
|
27
|
+
#
|
28
|
+
# == Parameters
|
29
|
+
#
|
30
|
+
# initialize takes an optional +hash+ and optional +test+ parameter.
|
31
|
+
#
|
32
|
+
# +hash+ is a ruby hash in the following format:
|
33
|
+
# { host: String, port: Integer }
|
34
|
+
#
|
35
|
+
# +test+ is a boolean identifying whether or not we are in a test
|
36
|
+
# if we are, we set the Logger to logging FATAL errors only.
|
37
|
+
#
|
38
|
+
# == Example
|
39
|
+
#
|
40
|
+
# # Not a test, default host and port
|
41
|
+
# ElasticsearchUpdate::Elasticsearch.new
|
42
|
+
# # Not a test, manually set host and port
|
43
|
+
# ElasticsearchUpdate::Elasticsearch.new({ host: 'localhost', port: 9200 })
|
44
|
+
# # Test
|
45
|
+
# ElasticsearchUpdate::Elasticsearch.new({ host: 'localhost', port: 9200 }, true)
|
9
46
|
def initialize(hash = { host: 'localhost', port: 9200 }, test = false)
|
10
47
|
@log = Logger.new(STDOUT)
|
11
48
|
if test
|
@@ -20,6 +57,27 @@ module ElasticsearchUpdate
|
|
20
57
|
@es_port = hash[:port]
|
21
58
|
end
|
22
59
|
|
60
|
+
# == cluster_routing_allocation
|
61
|
+
# Allows us to enable or disable Elasticsearch's cluster routing allocation
|
62
|
+
# setting via the HTTP API. Learn more in Elasticsearch's documentation:
|
63
|
+
# http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-cluster.html
|
64
|
+
#
|
65
|
+
# == Parameters
|
66
|
+
#
|
67
|
+
# cluster_routing_allocation takes an optional +type+.
|
68
|
+
#
|
69
|
+
# +type+ is a String. Possible values include:
|
70
|
+
# 'all' -- (default) Allows shard allocation for all kinds of shards.
|
71
|
+
# 'primaries' -- Allows shard allocation only for primary shards.
|
72
|
+
# 'new_primaries' -- Allows shard allocation only for primary shards for new indices.
|
73
|
+
# 'none' -- No shard allocations of any kind are allowed for all indices.
|
74
|
+
#
|
75
|
+
# == Example
|
76
|
+
#
|
77
|
+
# # Disabling shard allocation
|
78
|
+
# cluster_routing_allocation('none')
|
79
|
+
# # Allowing shard allocation
|
80
|
+
# cluster_routing_allocation('all')
|
23
81
|
def cluster_routing_allocation(type)
|
24
82
|
@log.info('Disabling cluster routing allocation')
|
25
83
|
|
@@ -38,6 +96,19 @@ module ElasticsearchUpdate
|
|
38
96
|
response
|
39
97
|
end
|
40
98
|
|
99
|
+
# == shutdown_local_node
|
100
|
+
# Allows us to shutdown a the local Elasticsearch node via the HTTP API.
|
101
|
+
# Requires @es_host and @es_port which were set during initialization.
|
102
|
+
# Learn more in Elasticsearch's documentation:
|
103
|
+
# http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-nodes-shutdown.html
|
104
|
+
#
|
105
|
+
# == Parameters
|
106
|
+
#
|
107
|
+
# shutdown_local_node takes no parameters
|
108
|
+
#
|
109
|
+
# == Example
|
110
|
+
#
|
111
|
+
# shutdown_local_node
|
41
112
|
def shutdown_local_node
|
42
113
|
@log.info('Shutting down local node')
|
43
114
|
@shutdown_uri = URI('http://' + @es_host + ':' + @es_port.to_s + '/_cluster/nodes/_local/_shutdown')
|
@@ -46,16 +117,49 @@ module ElasticsearchUpdate
|
|
46
117
|
response
|
47
118
|
end
|
48
119
|
|
120
|
+
# == start_elasticsearch_service
|
121
|
+
# Allows us to begin the Linux Elasticsearch service
|
122
|
+
#
|
123
|
+
# == Parameters
|
124
|
+
#
|
125
|
+
# start_elasticsearch_service takes a sudo +password+ parameter as a String.
|
126
|
+
#
|
127
|
+
# == Example
|
128
|
+
#
|
129
|
+
# start_elasticsearch_service('test_password')
|
49
130
|
def start_elasticsearch_service(password)
|
50
131
|
@log.info('Starting elasticsearch service')
|
51
132
|
system('echo ' + password + ' | sudo -S service elasticsearch start')
|
52
133
|
end
|
53
134
|
|
135
|
+
# == start_elasticsearch_binary
|
136
|
+
# Allows us to begin a Unix / Linux binary instance of Elasticsearch
|
137
|
+
# Windows users require a slightly different command.
|
138
|
+
#
|
139
|
+
# == Parameters
|
140
|
+
#
|
141
|
+
# start_elasticsearch_binary takes a +path+ parameter as a String.
|
142
|
+
#
|
143
|
+
# == Example
|
144
|
+
#
|
145
|
+
# start_elasticsearch_binary('/path/to/elasticsearch')
|
54
146
|
def start_elasticsearch_binary(path)
|
55
147
|
@log.info('Starting elasticsearch binary')
|
56
148
|
system(path + 'bin/elasticsearch')
|
57
149
|
end
|
58
150
|
|
151
|
+
# == start_elasticsearch
|
152
|
+
# Allows us to use the proper command when starting Elasticsearch.
|
153
|
+
#
|
154
|
+
# == Parameters
|
155
|
+
#
|
156
|
+
# start_elasticsearch takes a +installer+ parameter which is an instance of
|
157
|
+
# ElasticsearchUpdate::Installer.
|
158
|
+
#
|
159
|
+
# == Example
|
160
|
+
#
|
161
|
+
# installer = ElasticsearchUpdate::Installer.new('test_password', '.deb')
|
162
|
+
# start_elasticsearch(installer)
|
59
163
|
def start_elasticsearch(installer_obj)
|
60
164
|
case installer_obj.extension
|
61
165
|
when '.zip'
|
@@ -1,9 +1,43 @@
|
|
1
1
|
require 'logger'
|
2
2
|
|
3
3
|
module ElasticsearchUpdate
|
4
|
-
#
|
4
|
+
# == Installer
|
5
|
+
# ElasticsearchUpdate::Installer class is used to install the downloaded
|
6
|
+
# Elasticsearch update file.
|
7
|
+
#
|
8
|
+
# == Parameters
|
9
|
+
#
|
10
|
+
# Initilization requires a sudo +password+, file +extension+, and optional +test+ parameter.
|
11
|
+
#
|
12
|
+
# +password+ is String. Ex. 'test_password'
|
13
|
+
#
|
14
|
+
# +extension+ is String. Ex. '.deb'
|
15
|
+
#
|
16
|
+
# +test+ is a boolean identifying whether or not we are in a test
|
17
|
+
# if we are, we set the Logger to logging FATAL errors only.
|
18
|
+
#
|
19
|
+
# == Example
|
20
|
+
#
|
21
|
+
# ElasticsearchUpdate::Installer.new('test_password', '.deb')
|
5
22
|
class Installer
|
6
23
|
attr_accessor :sudo_password, :extension
|
24
|
+
# == initialize
|
25
|
+
# Allows us to create an instance of the Installer.
|
26
|
+
#
|
27
|
+
# == Parameters
|
28
|
+
#
|
29
|
+
# Initilization requires a sudo +password+, file +extension+, and optional +test+ parameter.
|
30
|
+
#
|
31
|
+
# +password+ is String. Ex. 'test_password'
|
32
|
+
#
|
33
|
+
# +extension+ is String. Ex. '.deb'
|
34
|
+
#
|
35
|
+
# +test+ is a boolean identifying whether or not we are in a test
|
36
|
+
# if we are, we set the Logger to logging FATAL errors only.
|
37
|
+
#
|
38
|
+
# == Example
|
39
|
+
#
|
40
|
+
# ElasticsearchUpdate::Installer.new('test_password', '.deb')
|
7
41
|
def initialize(password, extension, test = false)
|
8
42
|
@log = Logger.new(STDOUT)
|
9
43
|
if test
|
@@ -18,6 +52,19 @@ module ElasticsearchUpdate
|
|
18
52
|
@extension = extension
|
19
53
|
end
|
20
54
|
|
55
|
+
# == install_file
|
56
|
+
# Uses the extension found in the @extension variable set on initilization
|
57
|
+
# to determine what command should be used to install the update file.
|
58
|
+
#
|
59
|
+
# == Parameters
|
60
|
+
#
|
61
|
+
# install_file requires the update +file+ as a parameter.
|
62
|
+
#
|
63
|
+
# +file+ is File or Tempfile object. Ex. Tempfile.new('es_update_file')
|
64
|
+
#
|
65
|
+
# == Example
|
66
|
+
#
|
67
|
+
# install_file(Tempfile.new('es_update_file'))
|
21
68
|
def install_file(file)
|
22
69
|
case @extension
|
23
70
|
when '.zip'
|
@@ -31,6 +78,21 @@ module ElasticsearchUpdate
|
|
31
78
|
end
|
32
79
|
end
|
33
80
|
|
81
|
+
# == install_update_file
|
82
|
+
# Uses the given file and extension to install the service version of
|
83
|
+
# Elasticsearch from an RPM or DEB file.
|
84
|
+
#
|
85
|
+
# == Parameters
|
86
|
+
#
|
87
|
+
# install_update_file requires the update +file+ and +extension+ as a parameter.
|
88
|
+
#
|
89
|
+
# +file+ is File or Tempfile object. Ex. Tempfile.new('es_update_file')
|
90
|
+
#
|
91
|
+
# +extension+ is String. Ex. '.deb'
|
92
|
+
#
|
93
|
+
# == Example
|
94
|
+
#
|
95
|
+
# install_update_file(Tempfile.new('es_update_file'), '.deb')
|
34
96
|
def install_update_file(file, extension)
|
35
97
|
@log.info('Installing' + extension + 'file.')
|
36
98
|
command = 'echo ' + @sudo_password + ' | '
|
@@ -43,6 +105,8 @@ module ElasticsearchUpdate
|
|
43
105
|
Kernel.system(command)
|
44
106
|
end
|
45
107
|
|
108
|
+
# == unzip_file
|
109
|
+
# In development. Nothing occurs.
|
46
110
|
def unzip_file(file)
|
47
111
|
end
|
48
112
|
end
|
@@ -1,8 +1,36 @@
|
|
1
1
|
require 'highline/import'
|
2
2
|
|
3
3
|
module ElasticsearchUpdate
|
4
|
-
#
|
4
|
+
# == Wizard
|
5
|
+
# ElasticsearchUpdate::Wizard class is used to ask questions
|
6
|
+
# to the user using the highline gem.
|
7
|
+
#
|
8
|
+
# == Parameters
|
9
|
+
#
|
10
|
+
# Initilization requires no parameters.
|
11
|
+
#
|
12
|
+
# == Example
|
13
|
+
#
|
14
|
+
# ElasticsearchUpdate::Wizard.new
|
5
15
|
class Wizard
|
16
|
+
# == extension
|
17
|
+
# extension is used to provide a menu to the user asking which file
|
18
|
+
# type they would like to use when updating Elasticsearch
|
19
|
+
#
|
20
|
+
# == Parameters
|
21
|
+
#
|
22
|
+
# Requires no parameters.
|
23
|
+
#
|
24
|
+
# == Returns
|
25
|
+
#
|
26
|
+
# Returns +@choice+ which is a string containing either:
|
27
|
+
# 1. '.deb'
|
28
|
+
# 2. '.rpm'
|
29
|
+
#
|
30
|
+
# == Example
|
31
|
+
#
|
32
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
33
|
+
# extension = wizard.extension
|
6
34
|
def extension
|
7
35
|
choose do |menu|
|
8
36
|
menu.prompt = 'Which type of upgrade are we doing? '
|
@@ -16,10 +44,42 @@ module ElasticsearchUpdate
|
|
16
44
|
@choice
|
17
45
|
end
|
18
46
|
|
47
|
+
# == version
|
48
|
+
# version is used to ask the user which version of Elasticsearch
|
49
|
+
# they would like to use.
|
50
|
+
#
|
51
|
+
# == Parameters
|
52
|
+
#
|
53
|
+
# Requires no parameters.
|
54
|
+
#
|
55
|
+
# == Returns
|
56
|
+
#
|
57
|
+
# Returns a string containing a version number. Ex: '1.4.3'
|
58
|
+
#
|
59
|
+
# == Example
|
60
|
+
#
|
61
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
62
|
+
# version = wizard.version
|
19
63
|
def version
|
20
64
|
ask('What version of Elasticsearch should we update to? (major.minor.path) ', String) { |q| q.validate = /\d\.\d\.\d/ }
|
21
65
|
end
|
22
66
|
|
67
|
+
# == host
|
68
|
+
# host is used to ask the user the hostname of Elasticsearch so we
|
69
|
+
# can interact with it over it's HTTP API.
|
70
|
+
#
|
71
|
+
# == Parameters
|
72
|
+
#
|
73
|
+
# Requires no parameters.
|
74
|
+
#
|
75
|
+
# == Returns
|
76
|
+
#
|
77
|
+
# Returns a string containing the hostname. Ex: 'localhost'
|
78
|
+
#
|
79
|
+
# == Example
|
80
|
+
#
|
81
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
82
|
+
# host = wizard.host
|
23
83
|
def host
|
24
84
|
response = ask('What is your Elasticsearch hostname? (Default: localhost) ', String)
|
25
85
|
response = 'localhost' if response == ''
|
@@ -27,6 +87,22 @@ module ElasticsearchUpdate
|
|
27
87
|
response
|
28
88
|
end
|
29
89
|
|
90
|
+
# == port
|
91
|
+
# port is used to ask the user the port of Elasticsearch so we
|
92
|
+
# can interact with it over it's HTTP API.
|
93
|
+
#
|
94
|
+
# == Parameters
|
95
|
+
#
|
96
|
+
# Requires no parameters.
|
97
|
+
#
|
98
|
+
# == Returns
|
99
|
+
#
|
100
|
+
# Returns a string containing the port. Ex: '9200'
|
101
|
+
#
|
102
|
+
# == Example
|
103
|
+
#
|
104
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
105
|
+
# port = wizard.port
|
30
106
|
def port
|
31
107
|
response = ask('What is your Elasticsearch port? (Default: 9200) ', String)
|
32
108
|
|
@@ -35,6 +111,23 @@ module ElasticsearchUpdate
|
|
35
111
|
response
|
36
112
|
end
|
37
113
|
|
114
|
+
# == es_location_hash
|
115
|
+
# es_location_hash is used construct the location hash used by other
|
116
|
+
# gem classes.
|
117
|
+
#
|
118
|
+
# == Parameters
|
119
|
+
#
|
120
|
+
# Requires no parameters.
|
121
|
+
#
|
122
|
+
# == Returns
|
123
|
+
#
|
124
|
+
# Returns a hash containing the host and port.
|
125
|
+
# Ex: { host: 'localhost', port: 9200 }
|
126
|
+
#
|
127
|
+
# == Example
|
128
|
+
#
|
129
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
130
|
+
# location_hash = wizard.es_location_hash
|
38
131
|
def es_location_hash
|
39
132
|
{
|
40
133
|
host: host,
|
@@ -42,14 +135,64 @@ module ElasticsearchUpdate
|
|
42
135
|
}
|
43
136
|
end
|
44
137
|
|
138
|
+
# == elasticsearch_fs_location
|
139
|
+
# elasticsearch_fs_location is used to find where the Elasticsearch
|
140
|
+
# binary file is so that we can update from .zip or .tar.gz and
|
141
|
+
# successfully start elasticsearch after the update
|
142
|
+
#
|
143
|
+
# == Parameters
|
144
|
+
#
|
145
|
+
# Requires no parameters.
|
146
|
+
#
|
147
|
+
# == Returns
|
148
|
+
#
|
149
|
+
# Returns a string containing path.
|
150
|
+
# Ex: '/path/to/elasticsearch/'
|
151
|
+
#
|
152
|
+
# == Example
|
153
|
+
#
|
154
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
155
|
+
# fs_location = wizard.elasticsearch_fs_location
|
45
156
|
def elasticsearch_fs_location
|
46
157
|
ask('In what directory does Elasticsearch run? ', String)
|
47
158
|
end
|
48
159
|
|
160
|
+
# == sudo_password
|
161
|
+
# sudo_password is used to get the sudo password for use while installing
|
162
|
+
# the updated Elasticsearch files. Echo's "x" for each keypress.
|
163
|
+
#
|
164
|
+
# == Parameters
|
165
|
+
#
|
166
|
+
# Requires no parameters.
|
167
|
+
#
|
168
|
+
# == Returns
|
169
|
+
#
|
170
|
+
# Returns a string containing the password.
|
171
|
+
# Ex: 'example_password'
|
172
|
+
#
|
173
|
+
# == Example
|
174
|
+
#
|
175
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
176
|
+
# password = wizard.sudo_password
|
49
177
|
def sudo_password
|
50
178
|
ask('What password should be used while updating Elasticsearch? ') { |q| q.echo = "x" }
|
51
179
|
end
|
52
180
|
|
181
|
+
# == download_hash
|
182
|
+
# download_hash is used to construct the hash used by the Downloader
|
183
|
+
#
|
184
|
+
# == Parameters
|
185
|
+
#
|
186
|
+
# Requires no parameters.
|
187
|
+
#
|
188
|
+
# == Returns
|
189
|
+
#
|
190
|
+
# Returns a hash containing the base_url, version, and extension.
|
191
|
+
#
|
192
|
+
# == Example
|
193
|
+
#
|
194
|
+
# wizard = ElasticsearchUpdate::Wizard.new
|
195
|
+
# hash = wizard.download_hash
|
53
196
|
def download_hash
|
54
197
|
{
|
55
198
|
base_url: 'download.elasticsearch.org',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: elasticsearch_update
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin Kirsche
|
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
requirements:
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version:
|
111
|
+
version: 2.0.0
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ">="
|