ebs-attach 0.0.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 +7 -0
- data/bin/ebs-attach.rb +52 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e6421ff7ad32c21352aeec10feb95713eb9adf92
|
4
|
+
data.tar.gz: 936a83db6877259f9fea69189373df1734a0e3a7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a56acf3a6b91c699c69da9eff00b425bb5027d42bd28b517cbd12dc5a6dc1b6c53cd0279e88bf1fde3dd38250a1c811c7afb94b83b6e72b808b94d73416bc66
|
7
|
+
data.tar.gz: 564d48e6833fd1552434a902bc7bb73dd841dc7287d15b3e60cfaca39bac7106bdc2eec0c612b4fa83722c910ff7a28d9f692a21164d7872c670b26e26364885
|
data/bin/ebs-attach.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "aws-sdk-v1"
|
4
|
+
require 'socket'
|
5
|
+
|
6
|
+
volume = ARGV[0] or raise "Must pass EBS volume to attach.\n"
|
7
|
+
device = ARGV[1] or raise "Must pass device name to attach as.\n"
|
8
|
+
|
9
|
+
ip = UDPSocket.open {|s| s.connect('64.233.187.99', 1); s.addr.last}
|
10
|
+
|
11
|
+
ec2 = AWS::EC2.new()
|
12
|
+
AWS.memoize()
|
13
|
+
instance_id = String.new
|
14
|
+
ec2.instances.each do |instance|
|
15
|
+
if instance.private_ip_address == ip
|
16
|
+
instance_id = instance.id
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
if instance_id.length == 0
|
21
|
+
raise "Could not get instance id."
|
22
|
+
end
|
23
|
+
|
24
|
+
vol = ec2.volumes[ volume ]
|
25
|
+
|
26
|
+
unless vol.status == :available
|
27
|
+
raise "Volume #{vol} not in available state\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
status = vol.attach_to( ec2.instances[ instance_id ], "/dev/#{device}")
|
32
|
+
rescue
|
33
|
+
ap $!
|
34
|
+
raise "We received some failure doing the attachment"
|
35
|
+
end
|
36
|
+
|
37
|
+
counter = 0
|
38
|
+
while ( status.exists? && status.status != :attached )
|
39
|
+
counter = counter + 1
|
40
|
+
if counter == 80
|
41
|
+
raise "Failed to attach volume"
|
42
|
+
end
|
43
|
+
sleep 10
|
44
|
+
end
|
45
|
+
|
46
|
+
output = `e2label /dev/xvdm`
|
47
|
+
unless $?.success? then
|
48
|
+
`mkfs.ext4 /dev/xvdm`
|
49
|
+
end
|
50
|
+
|
51
|
+
exit 0
|
52
|
+
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ebs-attach
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Schrock
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Script to attach an EBS volume to an instance.
|
14
|
+
email: bschrock@manta.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- bin/ebs-attach.rb
|
20
|
+
homepage: http://github.com/mantacode/ebs-attach
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.4.5
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: EBS attachment script
|
44
|
+
test_files: []
|