fucking_shell_scripts 1.0 → 1.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/README.md +2 -2
- data/lib/fucking_shell_scripts/server.rb +21 -15
- data/lib/fucking_shell_scripts/version.rb +1 -1
- data/spec/fucking_shell_scripts/server_spec.rb +87 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfaa228c38443797804d539ab63ad3a197e7ebce
|
4
|
+
data.tar.gz: ea89afabcdd4f99e2bbd6a8044eae1ac2f4de1f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06191dd2a421a302608dab1ad2e8cd307cf8145d1a2c14cba9caf678dde92822137f0e3a2bfb27b04f9392f9d423fdbbbbbb24071c9123ad5cda9515c3a8da33
|
7
|
+
data.tar.gz: 354e24319fb9afe6bee357c39b52f8749acb8433c4a4e2874ec9f82789c985eba03531b5b50f16ec896380d03c4c97309ce4bf2f73ebab8c4921d1533d62612d
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -108,8 +108,8 @@ availability_zone: us-east-1d
|
|
108
108
|
key_name: global-key
|
109
109
|
cloud:
|
110
110
|
provider: AWS
|
111
|
-
aws_access_key_id:
|
112
|
-
aws_secret_access_key: <%= ENV[AWS_SECRET_ACCESS_KEY] %>
|
111
|
+
aws_access_key_id: <%= ENV["AWS_ACCESS_KEY"] %>
|
112
|
+
aws_secret_access_key: <%= ENV["AWS_SECRET_ACCESS_KEY"] %>
|
113
113
|
region: us-east-1
|
114
114
|
|
115
115
|
```
|
@@ -15,33 +15,38 @@ module FuckingShellScripts
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def build
|
18
|
-
|
19
|
-
image_id:
|
20
|
-
flavor_id:
|
21
|
-
key_name:
|
22
|
-
tags:
|
23
|
-
groups:
|
18
|
+
create_server_options = {
|
19
|
+
image_id: options.fetch(:image),
|
20
|
+
flavor_id: options.fetch(:size),
|
21
|
+
key_name: options.fetch(:key_name),
|
22
|
+
tags: { "Name" => name },
|
23
|
+
groups: options.fetch(:security_groups),
|
24
24
|
private_key_path: options.fetch(:private_key_path)
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
}
|
26
|
+
|
27
|
+
create_server_options.merge!({subnet_id: options[:subnet]}) if options.has_key?(:subnet)
|
28
|
+
create_server_options.merge!({block_device_mapping: options[:block_device_mapping]}) if options.has_key?(:block_device_mapping)
|
29
|
+
|
30
|
+
@server = connection.servers.create(create_server_options)
|
31
|
+
@server.username = options.fetch(:username) if options[:username]
|
32
|
+
$stdout.print "Creating #{options.fetch(:size)} from #{options.fetch(:image)}"
|
28
33
|
|
29
34
|
server.wait_for do
|
30
|
-
print "."
|
35
|
+
$stdout.print "."
|
31
36
|
ready?
|
32
37
|
end
|
33
38
|
|
34
|
-
puts "ready!"
|
35
|
-
puts ""
|
39
|
+
$stdout.puts "ready!"
|
40
|
+
$stdout.puts ""
|
36
41
|
|
37
|
-
print "Waiting for ssh access"
|
42
|
+
$stdout.print "Waiting for ssh access"
|
38
43
|
|
39
44
|
server.wait_for do
|
40
|
-
print "."
|
45
|
+
$stdout.print "."
|
41
46
|
sshable?
|
42
47
|
end
|
43
48
|
|
44
|
-
puts "#{server.dns_name} ready!"
|
49
|
+
$stdout.puts "#{server.dns_name} ready!"
|
45
50
|
end
|
46
51
|
|
47
52
|
def configure
|
@@ -60,6 +65,7 @@ module FuckingShellScripts
|
|
60
65
|
raise FuckingShellScripts::Server::MissingInstanceID , "Please specify the instance ID using the --instance-id option." if instance_id.nil?
|
61
66
|
@server = connection.servers.get(instance_id)
|
62
67
|
@server.private_key_path = options.fetch(:private_key_path)
|
68
|
+
@server.username = options.fetch(:username) if options[:username]
|
63
69
|
@server
|
64
70
|
end
|
65
71
|
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fog/aws/models/compute/server'
|
3
|
+
require 'fog/aws/models/compute/servers'
|
4
|
+
|
5
|
+
module FuckingShellScripts
|
6
|
+
describe Server do
|
7
|
+
describe '#build' do
|
8
|
+
|
9
|
+
let(:image) { 'some image' }
|
10
|
+
let(:size) { 'some size' }
|
11
|
+
let(:name) { 'some name' }
|
12
|
+
let(:key_name) { 'some key_name' }
|
13
|
+
let(:security_groups) { 'some security_groups' }
|
14
|
+
let(:private_key_path) { 'some private_key_path' }
|
15
|
+
let(:connection) { double(Fog::Compute) }
|
16
|
+
let!(:time) { Time.now }
|
17
|
+
|
18
|
+
let(:options) do
|
19
|
+
{
|
20
|
+
image: image,
|
21
|
+
size: size,
|
22
|
+
name: name,
|
23
|
+
key_name: key_name,
|
24
|
+
security_groups: security_groups,
|
25
|
+
private_key_path: private_key_path
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:expected_options) do
|
30
|
+
{
|
31
|
+
image_id: image,
|
32
|
+
flavor_id: size,
|
33
|
+
key_name: key_name,
|
34
|
+
tags: { "Name" => "#{name.downcase.sub(/ /, '-')}-#{time.strftime("%y-%m-%d-%H-%M")}" },
|
35
|
+
groups: security_groups,
|
36
|
+
private_key_path: private_key_path
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
subject { Server.new(connection, options).build }
|
41
|
+
|
42
|
+
let(:servers) { double(Fog::Compute::AWS::Servers) }
|
43
|
+
let(:server) { double(Fog::Compute::AWS::Server, wait_for: nil, dns_name: nil) }
|
44
|
+
|
45
|
+
before(:each) do
|
46
|
+
allow(connection).to receive(:servers).and_return(servers)
|
47
|
+
allow(Time).to receive(:now).and_return(time)
|
48
|
+
allow($stdout).to receive(:puts)
|
49
|
+
allow($stdout).to receive(:print)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'creates a server with the passed in options' do
|
53
|
+
expect(servers).to receive(:create).with(expected_options).and_return(server)
|
54
|
+
|
55
|
+
subject
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when options include subnet' do
|
59
|
+
it 'creates a server with the passed in options including the subnet' do
|
60
|
+
options.merge!({subnet: 'some subnet'})
|
61
|
+
expect(servers).to receive(:create).with(hash_including({subnet_id: 'some subnet'})).and_return(server)
|
62
|
+
|
63
|
+
Server.new(connection, options).build
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'when options include block_device_mapping' do
|
68
|
+
it 'creates a server with the passed in options including the block_device_mapping' do
|
69
|
+
block_device_mapping = {
|
70
|
+
block_device_mapping: [
|
71
|
+
{
|
72
|
+
'DeviceName' => '/dev/sda1',
|
73
|
+
'Ebs.VolumeSize' => '20',
|
74
|
+
'Ebs.VolumeType' => 'gp2'
|
75
|
+
}
|
76
|
+
]
|
77
|
+
}
|
78
|
+
options.merge!(block_device_mapping)
|
79
|
+
expect(servers).to receive(:create).with(hash_including(block_device_mapping)).and_return(server)
|
80
|
+
|
81
|
+
Server.new(connection, options).build
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fucking_shell_scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.1'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Hilkert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- spec/core_ext/hash_spec.rb
|
110
110
|
- spec/fucking_shell_scripts/cli_spec.rb
|
111
111
|
- spec/fucking_shell_scripts/connection_spec.rb
|
112
|
+
- spec/fucking_shell_scripts/server_spec.rb
|
112
113
|
- spec/spec_helper.rb
|
113
114
|
- spec/support/servers/test-server.yml
|
114
115
|
homepage: https://github.com/brandonhilkert/fucking_shell_scripts
|
@@ -140,5 +141,6 @@ test_files:
|
|
140
141
|
- spec/core_ext/hash_spec.rb
|
141
142
|
- spec/fucking_shell_scripts/cli_spec.rb
|
142
143
|
- spec/fucking_shell_scripts/connection_spec.rb
|
144
|
+
- spec/fucking_shell_scripts/server_spec.rb
|
143
145
|
- spec/spec_helper.rb
|
144
146
|
- spec/support/servers/test-server.yml
|