easy_e 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/easy_e/options.rb +1 -1
- data/lib/easy_e/snapshotter.rb +26 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f50d8ce432ff0875df7190d20f00fad39cc39cdf
|
4
|
+
data.tar.gz: c0c9c19a0e901089695bcbabce288a31b48471a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7864b3d11abeb3fe63578b4c9d94c05f8d246afd4fd994847dc184346c3d900a65b7179dccc430875d4c7b5dc85df09d365f437fb7fdbc998148cbeac18c21c
|
7
|
+
data.tar.gz: 700f6e967d96b39594193a3f47486832aecdd16740e9b477bdc7ac6214f7a34067d2f40937aef4133b09aeca9cf59ad7797a21489e938c638a5c3ff1612b29f3
|
data/README.md
CHANGED
@@ -18,6 +18,21 @@ Some specific goals and how they are achieved:
|
|
18
18
|
|
19
19
|
Install
|
20
20
|
===
|
21
|
+
|
22
|
+
Dependencies - Amazon Linux
|
23
|
+
---
|
24
|
+
|
25
|
+
```
|
26
|
+
sudo yum install build-essential \
|
27
|
+
gcc \
|
28
|
+
glibc-devel \
|
29
|
+
make \
|
30
|
+
mysql-devel \
|
31
|
+
ruby-devel \
|
32
|
+
patch \
|
33
|
+
zlib-devel
|
34
|
+
```
|
35
|
+
|
21
36
|
```
|
22
37
|
gem install easy-ec2-ebs-automatic-consistent-snapshot
|
23
38
|
crontab -e
|
data/lib/easy_e/options.rb
CHANGED
data/lib/easy_e/snapshotter.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'csv'
|
2
2
|
require 'httparty'
|
3
|
-
require 'pp'
|
4
3
|
module EasyE::Snapshotter
|
5
4
|
AWS_INSTANCE_ID_URL = 'http://169.254.169.254/latest/dynamic/instance-identity/document'
|
6
5
|
|
7
|
-
attr_writer :storage, :compute, :instance_id
|
8
6
|
def take_snapshots
|
9
7
|
attached_volumes.collect do |vol|
|
10
|
-
logger.debug "Snapping #{vol.
|
8
|
+
logger.debug "Snapping #{vol.id}"
|
11
9
|
snapshot = compute.snapshots.new
|
12
|
-
snapshot.volume_id = vol.
|
10
|
+
snapshot.volume_id = vol.id
|
11
|
+
snapshot.description = snapshot_name(vol)
|
13
12
|
snapshot.save
|
14
13
|
snapshot
|
15
14
|
end
|
@@ -18,10 +17,17 @@ module EasyE::Snapshotter
|
|
18
17
|
# lazy loaders
|
19
18
|
def compute
|
20
19
|
require 'fog/aws'
|
21
|
-
|
20
|
+
if options[:mock]
|
21
|
+
Fog.mock!
|
22
|
+
@region = 'us-east-1'
|
23
|
+
@instance_id = 'i-deadbeef'
|
24
|
+
@instance_name = 'totally-not-the-cia'
|
25
|
+
end
|
26
|
+
|
22
27
|
@compute ||= Fog::Compute.new({
|
23
28
|
:aws_access_key_id => access_key,
|
24
29
|
:aws_secret_access_key => secret_key,
|
30
|
+
:region => region,
|
25
31
|
:provider => "AWS"
|
26
32
|
})
|
27
33
|
end
|
@@ -45,4 +51,18 @@ module EasyE::Snapshotter
|
|
45
51
|
def instance_id
|
46
52
|
@instance_id ||= JSON.parse(HTTParty.get(AWS_INSTANCE_ID_URL))["instanceId"]
|
47
53
|
end
|
48
|
-
|
54
|
+
|
55
|
+
def instance_name
|
56
|
+
@instance_name ||= compute.servers.get(instance_id).tags['Name']
|
57
|
+
end
|
58
|
+
|
59
|
+
def region
|
60
|
+
@region ||= JSON.parse(HTTParty.get(AWS_INSTANCE_ID_URL))["region"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def snapshot_name vol
|
64
|
+
id = instance_name
|
65
|
+
id = instance_id if id.nil? or id.empty?
|
66
|
+
"#{Time.now.strftime "%Y%m%d%H%M%S"}-#{id}-#{vol.device}"
|
67
|
+
end
|
68
|
+
end
|