aws_minecraft 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/aws_minecraft.gemspec +1 -0
- data/lib/aws_minecraft.rb +2 -1
- data/lib/aws_minecraft/aws_helper.rb +7 -2
- data/lib/aws_minecraft/db_helper.rb +1 -0
- data/lib/aws_minecraft/mine_config.rb +1 -0
- data/lib/aws_minecraft/ssh_helper.rb +3 -5
- data/lib/aws_minecraft/version.rb +1 -1
- data/spec/awsmine_spec.rb +1 -1
- 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: 943506dfdf5fea9a018a5fcd112a707a81a6e9c9cd306df3a440a12bdd3e2b71
|
4
|
+
data.tar.gz: 7c9300442cd09d69f7ddedf675cf01da479e480982b5b1e5648e710b63b9eba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96c1b4e7ec19fe1933bb968effa4000602ac609a985b6ad0e4309aa023d9809872ef02d2d265f1198e36c441521e5a2ce47a6484c50452c9e24c45dbbcee7b13
|
7
|
+
data.tar.gz: ecc49d6f593d97fa792f46098ebceef03cb19bada204d3a7a4cad4649bb0f3466aa15b739c35a48a2a68e6271823ecc9a8268fa951702b2f28a2891ccc61f125
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/aws_minecraft.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.email = 'skarlso777@gmail.com'
|
14
14
|
s.extra_rdoc_files = ['README.md']
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
|
+
s.files << './cfg/minecraft.key'
|
16
17
|
s.homepage = 'https://github.com/Skarlso/aws_minecraft'
|
17
18
|
s.rdoc_options = ['--charset=UTF-8']
|
18
19
|
s.require_paths = ['lib']
|
data/lib/aws_minecraft.rb
CHANGED
@@ -62,7 +62,8 @@ module AWSMine
|
|
62
62
|
@logger.info('WARNING! Terminating an instance will result in dataloss. Make ' \
|
63
63
|
'sure everything is backed up. Do you want to continue? (Y/n):')
|
64
64
|
answer = $stdin.gets.chomp
|
65
|
-
return
|
65
|
+
return unless answer == 'Y'
|
66
|
+
|
66
67
|
ip, id = @db_helper.instance_details
|
67
68
|
@logger.info("Terminating instance #{ip} | #{id}.")
|
68
69
|
@aws_helper.terminate_ec2(id)
|
@@ -8,6 +8,7 @@ module AWSMine
|
|
8
8
|
# Main wrapper for AWS commands
|
9
9
|
class AWSHelper
|
10
10
|
attr_accessor :ec2_client, :ec2_resource
|
11
|
+
|
11
12
|
def initialize
|
12
13
|
# region: AWS_REGION
|
13
14
|
# Credentials are loaded from environment properties
|
@@ -15,7 +16,7 @@ module AWSMine
|
|
15
16
|
credentials = Aws::SharedCredentials.new(profile_name: config.profile)
|
16
17
|
@ec2_client = Aws::EC2::Client.new(credentials: credentials)
|
17
18
|
@ec2_resource = Aws::EC2::Resource.new(client: @ec2_client)
|
18
|
-
@logger = Logger.new(
|
19
|
+
@logger = Logger.new($stdout)
|
19
20
|
@logger.level = Logger.const_get(config.loglevel)
|
20
21
|
end
|
21
22
|
|
@@ -109,7 +110,10 @@ module AWSMine
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def import_keypair
|
112
|
-
|
113
|
+
file = File.join(__dir__, '../../cfg/minecraft.key')
|
114
|
+
raise 'key not found. make sure cfg/minecraft.key exists in the gem' unless File.exist?(file)
|
115
|
+
|
116
|
+
key = Base64.decode64(File.read(file))
|
113
117
|
begin
|
114
118
|
@ec2_client.describe_key_pairs(key_names: ['minecraft_keys'])
|
115
119
|
key_exists = true
|
@@ -117,6 +121,7 @@ module AWSMine
|
|
117
121
|
key_exists = false
|
118
122
|
end
|
119
123
|
return if key_exists
|
124
|
+
|
120
125
|
resp = @ec2_client.import_key_pair(dry_run: false,
|
121
126
|
key_name: 'minecraft_keys',
|
122
127
|
public_key_material: key)
|
@@ -6,7 +6,7 @@ module AWSMine
|
|
6
6
|
class SSHHelper
|
7
7
|
def initialize
|
8
8
|
config = MineConfig.new
|
9
|
-
@logger = Logger.new(
|
9
|
+
@logger = Logger.new($stdout)
|
10
10
|
@logger.level = Logger.const_get(config.loglevel)
|
11
11
|
end
|
12
12
|
|
@@ -33,10 +33,8 @@ module AWSMine
|
|
33
33
|
channel = ssh.open_channel do |ch|
|
34
34
|
@logger.info('Channel opened. Opening pty.')
|
35
35
|
ch.request_pty do |c, success|
|
36
|
-
unless success
|
37
|
-
|
38
|
-
raise
|
39
|
-
end
|
36
|
+
raise 'Failed to request channel' unless success
|
37
|
+
|
40
38
|
c.on_data do |_, data|
|
41
39
|
puts "Received data: #{data}."
|
42
40
|
end
|
data/spec/awsmine_spec.rb
CHANGED
@@ -62,7 +62,7 @@ describe AWSMine::AWSMine, fakefs: true do
|
|
62
62
|
describe '#terminate_instance' do
|
63
63
|
it 'should terminate an instance if it exists and delete it from the db' do
|
64
64
|
expect(db).to receive(:instance_exists?).and_return(true)
|
65
|
-
allow($stdin).to receive(:gets) { '
|
65
|
+
allow($stdin).to receive(:gets) { 'Y' }
|
66
66
|
expect(db).to receive(:instance_details).and_return(['1.2.3.4', 'i-asdf'])
|
67
67
|
expect(aws).to receive(:terminate_ec2).with('i-asdf')
|
68
68
|
expect(db).to receive(:remove_instance)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws_minecraft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gergely Brautigam
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files:
|
75
75
|
- README.md
|
76
76
|
files:
|
77
|
+
- "./cfg/minecraft.key"
|
77
78
|
- ".gitignore"
|
78
79
|
- ".rspec"
|
79
80
|
- ".travis.yml"
|