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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24a8ad8f09bc4177e646a96732a902ef5a60e317
4
- data.tar.gz: 5698fb4cd71d990c6b4330d3a7f10fb39ccd6d31
3
+ metadata.gz: f50d8ce432ff0875df7190d20f00fad39cc39cdf
4
+ data.tar.gz: c0c9c19a0e901089695bcbabce288a31b48471a1
5
5
  SHA512:
6
- metadata.gz: 91829299b65a698bea482d94a3d9cd100934571737540d45eb170cf8ebee015fce897a825d3ae699435ba67bd8943828ce3bfb4996db07a72d2abce6f212e4b2
7
- data.tar.gz: a6ebbabd913d863acfc27617fc20d893b131757f6b0d6706ae4715480391b87705628255e19d9038db119f95a6a4691bdb0bee1222c1a65dc9945c885561b143
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
@@ -43,4 +43,4 @@ class EasyE
43
43
  def options
44
44
  @options ||= OpenStruct.new
45
45
  end
46
- end
46
+ end
@@ -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.volume_id}"
8
+ logger.debug "Snapping #{vol.id}"
11
9
  snapshot = compute.snapshots.new
12
- snapshot.volume_id = vol.volume_id
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
- Fog.mock! if options[:mock]
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
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_e
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Conrad