kanrisuru 0.8.23 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/kanrisuru/remote/cluster.rb +33 -1
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/remote/cluster_spec.rb +57 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dda87f43ae0afebc6108a846d459da7ba74168ab011bfc883fff81014360111f
|
4
|
+
data.tar.gz: 3e57869c300218b6b2c2ad01f5a991fd574237b8afcca13c08455defba4d8030
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b1d3be849564df655e1ba9e043c4b2632549c9546a963d5b51cb296d358e1c1f1daa29cb559d73625d8b4a024a613e664221d76e5fffcd5fdfc7ce54502ac46
|
7
|
+
data.tar.gz: ff9e92ccb5b6bd0d45b95a9252955bf442127583a1971febd5c12726b08421519f53b89bdf4e3d807c238f5bcbb47a8fb1867e56a3413c927e6c31427867cdcf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## Kanrisuru 0.9.0 (November 23, 2021)
|
2
|
+
* Add `delete` to `Kanrisuru::Remote::Cluster` class to allow removal of hosts from cluster.
|
3
|
+
* Add functional test cases for remote cluster class.
|
4
|
+
|
1
5
|
## Kanrisuru 0.8.23 (November 19, 2021)
|
2
6
|
* Add functional test cases for `yum` command
|
3
7
|
* Add stub by operating system method, with support for `ubuntu` and `centos` os types.
|
@@ -13,6 +13,10 @@ module Kanrisuru
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
def hosts
|
17
|
+
@hosts.values
|
18
|
+
end
|
19
|
+
|
16
20
|
def [](hostname)
|
17
21
|
@hosts[hostname]
|
18
22
|
end
|
@@ -21,6 +25,10 @@ module Kanrisuru
|
|
21
25
|
add_host(host_opts)
|
22
26
|
end
|
23
27
|
|
28
|
+
def delete(host)
|
29
|
+
remove_host(host)
|
30
|
+
end
|
31
|
+
|
24
32
|
def execute(command)
|
25
33
|
@hosts.map do |host_addr, host|
|
26
34
|
## Need to evaluate each host independently for the command.
|
@@ -81,13 +89,37 @@ module Kanrisuru
|
|
81
89
|
end
|
82
90
|
end
|
83
91
|
|
92
|
+
def remove_host(host)
|
93
|
+
if host.instance_of?(Kanrisuru::Remote::Host)
|
94
|
+
removed = false
|
95
|
+
|
96
|
+
if @hosts.key?(host.host)
|
97
|
+
removed = true
|
98
|
+
@hosts.delete(host.host)
|
99
|
+
end
|
100
|
+
|
101
|
+
removed
|
102
|
+
elsif host.instance_of?(String)
|
103
|
+
removed = false
|
104
|
+
|
105
|
+
if @hosts.key?(host)
|
106
|
+
removed = true
|
107
|
+
@hosts.delete(host)
|
108
|
+
end
|
109
|
+
|
110
|
+
removed
|
111
|
+
else
|
112
|
+
raise ArgumentError, 'Invalid host type'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
84
116
|
def add_host(host_opts)
|
85
117
|
if host_opts.instance_of?(Hash)
|
86
118
|
@hosts[host_opts[:host]] = Kanrisuru::Remote::Host.new(host_opts)
|
87
119
|
elsif host_opts.instance_of?(Kanrisuru::Remote::Host)
|
88
120
|
@hosts[host_opts.host] = host_opts
|
89
121
|
else
|
90
|
-
raise '
|
122
|
+
raise ArgumentError, 'Invalid host option'
|
91
123
|
end
|
92
124
|
end
|
93
125
|
end
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Kanrisuru::Remote::Cluster do
|
6
|
+
before(:all) do
|
7
|
+
StubNetwork.stub!
|
8
|
+
end
|
9
|
+
|
10
|
+
after(:all) do
|
11
|
+
StubNetwork.unstub!
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:host1) do
|
15
|
+
Kanrisuru::Remote::Host.new(
|
16
|
+
host: 'localhost',
|
17
|
+
username: 'ubuntu',
|
18
|
+
keys: ['id_rsa']
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:host2) do
|
23
|
+
Kanrisuru::Remote::Host.new(
|
24
|
+
host: 'ubuntu-host',
|
25
|
+
username: 'ubuntu',
|
26
|
+
keys: ['id_rsa']
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'adds host to a cluster' do
|
31
|
+
cluster = Kanrisuru::Remote::Cluster.new(host1)
|
32
|
+
expect(cluster.hosts.length).to eq(1)
|
33
|
+
expect(cluster.count).to eq(1)
|
34
|
+
expect(cluster[host1.host]).to eq(host1)
|
35
|
+
expect(cluster.hosts).to include(host1)
|
36
|
+
|
37
|
+
cluster << host2
|
38
|
+
expect(cluster.hosts.length).to eq(2)
|
39
|
+
expect(cluster.count).to eq(2)
|
40
|
+
expect(cluster[host2.host]).to eq(host2)
|
41
|
+
expect(cluster.hosts).to include(host1)
|
42
|
+
expect(cluster.hosts).to include(host2)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'removes a host from a cluster' do
|
46
|
+
cluster = Kanrisuru::Remote::Cluster.new(host1, host2)
|
47
|
+
expect(cluster.count).to eq(2)
|
48
|
+
|
49
|
+
cluster.delete(host2)
|
50
|
+
expect(cluster.count).to eq(1)
|
51
|
+
expect(cluster.hosts).not_to include(host2)
|
52
|
+
|
53
|
+
cluster.delete(host1.host)
|
54
|
+
expect(cluster.count).to eq(0)
|
55
|
+
expect(cluster.hosts).not_to include(host1)
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kanrisuru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Mammina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- spec/functional/core/transfer_spec.rb
|
183
183
|
- spec/functional/core/yum_spec.rb
|
184
184
|
- spec/functional/os_package_spec.rb
|
185
|
+
- spec/functional/remote/cluster_spec.rb
|
185
186
|
- spec/helper/expect_helpers.rb
|
186
187
|
- spec/helper/stub_network.rb
|
187
188
|
- spec/helper/test_hosts.rb
|