euca 0.0.8 → 0.0.9
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 +8 -8
- data/lib/euca/api.rb +2 -0
- data/lib/euca/api/instance.rb +1 -8
- data/lib/euca/api/tag.rb +29 -0
- data/lib/euca/filterable.rb +21 -0
- data/lib/euca/model.rb +3 -0
- data/lib/euca/version.rb +1 -1
- data/spec/instance_spec.rb +4 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzIyNGI5YWY5NDllMzI0M2E3NzM5M2NlMmEwOTU3MDhkNzE4MWJjZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ODFmYWY5YjZlYTM5YjliMDZlZjYwNDRhNjAxNDBjN2FkZTAyMDkwMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjI3YWQzNGFhOTEyNDZiOWYxOWE3YTMxZjMyNTlkNjlhZGZlYTBlMmQ1YzA2
|
10
|
+
YzZmNmY4YmVkYzBhMTNjNzE5MTJhZTMzZDNkYTE2MmE2YTM0ODQ2Zjk1NjFi
|
11
|
+
MGE1MjAwMGExZDc1ZWFkM2Y4MTdhOTNjNTA5YmIyYzVkZDNkNDY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDAzNTY3NWJhYmFjMTc1ZDBlZGRiZGE3NmZiMWRmYjc0NTI0MWNlZWRlMzY4
|
14
|
+
MWE0M2JjYmEzZTlhOGRhZjYwNTcwNWUyYjUyZDU3NjNkZGFkODdjYjM4NTMx
|
15
|
+
OTY4ZWE2MDljYmQ1NmY4MGMzOTc3NTJkMmRiNzA3ZmZiOWUwNGE=
|
data/lib/euca/api.rb
CHANGED
data/lib/euca/api/instance.rb
CHANGED
@@ -2,6 +2,7 @@ module Euca
|
|
2
2
|
class Instance
|
3
3
|
|
4
4
|
include Euca::Model
|
5
|
+
include Euca::Filterable
|
5
6
|
|
6
7
|
TYPE_ID = "instance"
|
7
8
|
TYPE_ATTRS = %w(type_id id image public_dns_name private_dns_name status group
|
@@ -18,14 +19,6 @@ module Euca
|
|
18
19
|
euca("terminate-instances",id).first
|
19
20
|
end
|
20
21
|
|
21
|
-
def self.where *args
|
22
|
-
describe "--filter", *args
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.find_by *args
|
26
|
-
where(*args).first
|
27
|
-
end
|
28
|
-
|
29
22
|
end
|
30
23
|
end
|
31
24
|
|
data/lib/euca/api/tag.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Euca
|
2
|
+
class Tag
|
3
|
+
|
4
|
+
include Euca::Model
|
5
|
+
include Euca::Filterable
|
6
|
+
|
7
|
+
TYPE_ID = "tag"
|
8
|
+
TYPE_ATTRS = %w(type owner_id owner_type key value)
|
9
|
+
|
10
|
+
def self.create key, value, instance_id = nil
|
11
|
+
if key.is_a? Hash
|
12
|
+
euca("create-tags", key.map{|key,value| "--tag #{key}=#{value}" }.join(" ") , value).first
|
13
|
+
else
|
14
|
+
return nil if instance_id.nil?
|
15
|
+
euca("create-tags", "--tag #{key}=#{value}", instance_id).first
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.destroy key, value, instance_id = nil
|
20
|
+
if key.is_a? Hash
|
21
|
+
euca("delete-tags", key.map{|key,value| "--tag #{key}=#{value}" }.join(" ") , value).first
|
22
|
+
else
|
23
|
+
return nil if instance_id.nil?
|
24
|
+
euca("delete-tags", "--tag #{key}=#{value}", instance_id).first
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Euca
|
2
|
+
module Filterable
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
def where args
|
7
|
+
args = args.map{|key,value| "--filter #{key}=#{value}" }
|
8
|
+
describe *args
|
9
|
+
end
|
10
|
+
|
11
|
+
def find_by args
|
12
|
+
where(args).first
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.included(base)
|
17
|
+
base.extend ClassMethods
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/euca/model.rb
CHANGED
@@ -19,12 +19,15 @@ module Euca
|
|
19
19
|
s.values.sort == query.values.sort
|
20
20
|
}
|
21
21
|
end
|
22
|
+
|
22
23
|
def find_by query = {}
|
23
24
|
where(query).first
|
24
25
|
end
|
26
|
+
|
25
27
|
def find id
|
26
28
|
describe(id).first
|
27
29
|
end
|
30
|
+
|
28
31
|
def describe *args
|
29
32
|
euca("describe-#{self.describer}",*args)
|
30
33
|
end
|
data/lib/euca/version.rb
CHANGED
data/spec/instance_spec.rb
CHANGED
@@ -16,6 +16,10 @@ module Euca
|
|
16
16
|
instance = Instance.create "-t", Euca::T1_NANO, Euca::UBUNTU_13_10
|
17
17
|
|
18
18
|
instance["public_dns_name"].must_equal "i-46-149-29-252.compute.is-1.greenqloud.com"
|
19
|
+
|
20
|
+
mock.expect :run, fixture, [ "describe-instances", "--filter instance-id=i-6e13180f" ]
|
21
|
+
finded = Instance.find_by({"instance-id" => instance["id"]})
|
22
|
+
finded["public_dns_name"].must_equal instance["public_dns_name"]
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: euca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Onur Uyar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,6 +99,8 @@ files:
|
|
99
99
|
- lib/euca/api/address.rb
|
100
100
|
- lib/euca/api/instance.rb
|
101
101
|
- lib/euca/api/keypair.rb
|
102
|
+
- lib/euca/api/tag.rb
|
103
|
+
- lib/euca/filterable.rb
|
102
104
|
- lib/euca/model.rb
|
103
105
|
- lib/euca/version.rb
|
104
106
|
- lib/euca/wrapper.rb
|