fog 0.0.30 → 0.0.31

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.30
1
+ 0.0.31
data/bin/fog CHANGED
@@ -5,7 +5,11 @@ require 'yaml'
5
5
 
6
6
  def credentials
7
7
  @credentials ||= begin
8
- YAML.load(File.open(File.expand_path('~/.fog')).read)
8
+ if ARGV[0] && File.exists?(File.expand_path(ARGV[0]))
9
+ YAML.load(File.open(File.expand_path(ARGV[0])).read)
10
+ elsif File.exists?(File.expand_path('~/.fog'))
11
+ YAML.load(File.open(File.expand_path('~/.fog')).read)
12
+ end
9
13
  end
10
14
  end
11
15
 
@@ -72,20 +76,9 @@ module Rackspace
72
76
  end
73
77
  end
74
78
 
75
- if ARGV[0]
76
- result = eval(ARGV[0])
77
- result = case result
78
- when Fog::Collection
79
- result.map {|model| model.attributes.reject {|key, value| key == :owner}}
80
- when Fog::Model
81
- result.attributes
82
- end
83
- print(Marshal.dump(result))
84
- else
85
- ARGV.clear # Avoid passing args to IRB
86
- IRB.setup(nil)
87
- @irb = IRB::Irb.new(nil)
88
- IRB.conf[:MAIN_CONTEXT] = @irb.context
89
- @irb.context.workspace = IRB::WorkSpace.new(binding)
90
- catch(:IRB_EXIT) { @irb.eval_input }
91
- end
79
+ ARGV.clear # Avoid passing args to IRB
80
+ IRB.setup(nil)
81
+ @irb = IRB::Irb.new(nil)
82
+ IRB.conf[:MAIN_CONTEXT] = @irb.context
83
+ @irb.context.workspace = IRB::WorkSpace.new(binding)
84
+ catch(:IRB_EXIT) { @irb.eval_input }
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fog}
8
- s.version = "0.0.30"
8
+ s.version = "0.0.31"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["geemus (Wesley Beary)"]
12
- s.date = %q{2009-11-14}
12
+ s.date = %q{2009-11-16}
13
13
  s.default_executable = %q{fog}
14
14
  s.description = %q{brings clouds to you}
15
15
  s.email = %q{me@geemus.com}
@@ -135,6 +135,8 @@ Gem::Specification.new do |s|
135
135
  "lib/fog/parser.rb",
136
136
  "lib/fog/rackspace.rb",
137
137
  "lib/fog/rackspace/files.rb",
138
+ "lib/fog/rackspace/models/servers/flavor.rb",
139
+ "lib/fog/rackspace/models/servers/flavors.rb",
138
140
  "lib/fog/rackspace/models/servers/server.rb",
139
141
  "lib/fog/rackspace/models/servers/servers.rb",
140
142
  "lib/fog/rackspace/requests/files/delete_container.rb",
@@ -149,6 +151,7 @@ Gem::Specification.new do |s|
149
151
  "lib/fog/rackspace/requests/servers/create_server.rb",
150
152
  "lib/fog/rackspace/requests/servers/delete_image.rb",
151
153
  "lib/fog/rackspace/requests/servers/delete_server.rb",
154
+ "lib/fog/rackspace/requests/servers/get_flavor_details.rb",
152
155
  "lib/fog/rackspace/requests/servers/get_server_details.rb",
153
156
  "lib/fog/rackspace/requests/servers/list_addresses.rb",
154
157
  "lib/fog/rackspace/requests/servers/list_flavors.rb",
@@ -242,6 +245,7 @@ Gem::Specification.new do |s|
242
245
  "spec/rackspace/requests/servers/create_server_spec.rb",
243
246
  "spec/rackspace/requests/servers/delete_image_spec.rb",
244
247
  "spec/rackspace/requests/servers/delete_server_spec.rb",
248
+ "spec/rackspace/requests/servers/get_flavor_details_spec.rb",
245
249
  "spec/rackspace/requests/servers/get_server_details_spec.rb",
246
250
  "spec/rackspace/requests/servers/list_addresses_spec.rb",
247
251
  "spec/rackspace/requests/servers/list_flavors_detail_spec.rb",
@@ -343,6 +347,7 @@ Gem::Specification.new do |s|
343
347
  "spec/rackspace/requests/servers/create_server_spec.rb",
344
348
  "spec/rackspace/requests/servers/delete_image_spec.rb",
345
349
  "spec/rackspace/requests/servers/delete_server_spec.rb",
350
+ "spec/rackspace/requests/servers/get_flavor_details_spec.rb",
346
351
  "spec/rackspace/requests/servers/get_server_details_spec.rb",
347
352
  "spec/rackspace/requests/servers/list_addresses_spec.rb",
348
353
  "spec/rackspace/requests/servers/list_flavors_detail_spec.rb",
data/lib/fog.rb CHANGED
@@ -2,6 +2,7 @@ require 'rubygems'
2
2
  require 'base64'
3
3
  require 'cgi'
4
4
  require 'digest/md5'
5
+ require 'excon'
5
6
  require 'hmac-sha1'
6
7
  require 'hmac-sha2'
7
8
  require 'json'
@@ -1,9 +1,3 @@
1
- require 'rubygems'
2
- require 'excon'
3
-
4
- require "fog/errors"
5
- require "fog/response"
6
-
7
1
  unless Fog.mocking?
8
2
 
9
3
  module Fog
@@ -0,0 +1,18 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Servers
4
+
5
+ class Flavor < Fog::Model
6
+
7
+ identity :id
8
+
9
+ attribute :disk
10
+ attribute :id
11
+ attribute :name
12
+ attribute :ram
13
+
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Rackspace
3
+ class Servers
4
+
5
+ def flavors
6
+ Fog::Rackspace::Servers::Flavors.new(:connection => self)
7
+ end
8
+
9
+ class Flavors < Fog::Collection
10
+
11
+ model Fog::Rackspace::Servers::Flavor
12
+
13
+ def all
14
+ data = connection.list_flavors_detail.body
15
+ flavors = Fog::Rackspace::Servers::Flavors.new({
16
+ :connection => connection
17
+ })
18
+ for flavor in data['flavors']
19
+ flavors << Fog::Rackspace::Servers::Flavor.new({
20
+ :collection => flavors,
21
+ :connection => connection
22
+ }.merge!(flavor))
23
+ end
24
+ flavors
25
+ end
26
+
27
+ def get(flavor_id)
28
+ connection.get_flavor_details(flavor_id)
29
+ rescue Excon::Errors::NotFound
30
+ nil
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -24,8 +24,8 @@ module Fog
24
24
  servers
25
25
  end
26
26
 
27
- def get(id)
28
- connection.get_server_details(id)
27
+ def get(server_id)
28
+ connection.get_server_details(server_id)
29
29
  rescue Excon::Errors::NotFound
30
30
  nil
31
31
  end
@@ -0,0 +1,41 @@
1
+ unless Fog.mocking?
2
+
3
+ module Fog
4
+ module Rackspace
5
+ class Servers
6
+
7
+ # Get details for flavor by id
8
+ #
9
+ # ==== Returns
10
+ # * response<~Excon::Response>:
11
+ # * body<~Hash>:
12
+ # * 'id'<~Integer> - Id of the flavor
13
+ # * 'name'<~String> - Name of the flavor
14
+ # * 'ram'<~Integer> - Amount of ram for the flavor
15
+ # * 'disk'<~Integer> - Amount of diskspace for the flavor
16
+ def get_flavor_details(flavor_id)
17
+ request(
18
+ :expects => [200, 203],
19
+ :method => 'GET',
20
+ :path => "flavors/#{flavor_id}.json"
21
+ )
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
+ else
29
+
30
+ module Fog
31
+ module Rackspace
32
+ class Servers
33
+
34
+ def get_flavor_details(flavor_id)
35
+ end
36
+
37
+ end
38
+ end
39
+ end
40
+
41
+ end
@@ -4,7 +4,7 @@ unless Fog.mocking?
4
4
  module Rackspace
5
5
  class Servers
6
6
 
7
- # List all images (IDs and names only)
7
+ # List all flavors (IDs and names only)
8
8
  #
9
9
  # ==== Returns
10
10
  # * response<~Excon::Response>:
@@ -4,7 +4,7 @@ unless Fog.mocking?
4
4
  module Rackspace
5
5
  class Servers
6
6
 
7
- # List all images (IDs and names only)
7
+ # List all flavors
8
8
  #
9
9
  # ==== Returns
10
10
  # * response<~Excon::Response>:
@@ -15,7 +15,7 @@ unless Fog.mocking?
15
15
  # * 'disk'<~Integer> - Amount of diskspace for the flavor
16
16
  def list_flavors_detail
17
17
  request(
18
- :expects => 200,
18
+ :expects => [200, 203],
19
19
  :method => 'GET',
20
20
  :path => 'flavors/detail.json'
21
21
  )
@@ -15,6 +15,8 @@ module Fog
15
15
  end
16
16
 
17
17
  def self.reload
18
+ load "fog/rackspace/models/servers/flavor.rb"
19
+ load "fog/rackspace/models/servers/flavors.rb"
18
20
  load "fog/rackspace/models/servers/server.rb"
19
21
  load "fog/rackspace/models/servers/servers.rb"
20
22
 
@@ -22,6 +24,7 @@ module Fog
22
24
  load "fog/rackspace/requests/servers/create_server.rb"
23
25
  load "fog/rackspace/requests/servers/delete_image.rb"
24
26
  load "fog/rackspace/requests/servers/delete_server.rb"
27
+ load "fog/rackspace/requests/servers/get_flavor_details.rb"
25
28
  load "fog/rackspace/requests/servers/get_server_details.rb"
26
29
  load "fog/rackspace/requests/servers/list_addresses.rb"
27
30
  load "fog/rackspace/requests/servers/list_private_addresses.rb"
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe 'Rackspace::Servers.get_flavor_details' do
4
+ describe 'success' do
5
+
6
+ it "should return proper attributes" do
7
+ actual = servers.get_flavor_details(1).body['flavor']
8
+ actual['disk'].should be_an(Integer)
9
+ actual['id'].should be_an(Integer)
10
+ actual['name'].should be_a(String)
11
+ actual['ram'].should be_an(Integer)
12
+ end
13
+
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus (Wesley Beary)
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-14 00:00:00 -08:00
12
+ date: 2009-11-16 00:00:00 -08:00
13
13
  default_executable: fog
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -178,6 +178,8 @@ files:
178
178
  - lib/fog/parser.rb
179
179
  - lib/fog/rackspace.rb
180
180
  - lib/fog/rackspace/files.rb
181
+ - lib/fog/rackspace/models/servers/flavor.rb
182
+ - lib/fog/rackspace/models/servers/flavors.rb
181
183
  - lib/fog/rackspace/models/servers/server.rb
182
184
  - lib/fog/rackspace/models/servers/servers.rb
183
185
  - lib/fog/rackspace/requests/files/delete_container.rb
@@ -192,6 +194,7 @@ files:
192
194
  - lib/fog/rackspace/requests/servers/create_server.rb
193
195
  - lib/fog/rackspace/requests/servers/delete_image.rb
194
196
  - lib/fog/rackspace/requests/servers/delete_server.rb
197
+ - lib/fog/rackspace/requests/servers/get_flavor_details.rb
195
198
  - lib/fog/rackspace/requests/servers/get_server_details.rb
196
199
  - lib/fog/rackspace/requests/servers/list_addresses.rb
197
200
  - lib/fog/rackspace/requests/servers/list_flavors.rb
@@ -285,6 +288,7 @@ files:
285
288
  - spec/rackspace/requests/servers/create_server_spec.rb
286
289
  - spec/rackspace/requests/servers/delete_image_spec.rb
287
290
  - spec/rackspace/requests/servers/delete_server_spec.rb
291
+ - spec/rackspace/requests/servers/get_flavor_details_spec.rb
288
292
  - spec/rackspace/requests/servers/get_server_details_spec.rb
289
293
  - spec/rackspace/requests/servers/list_addresses_spec.rb
290
294
  - spec/rackspace/requests/servers/list_flavors_detail_spec.rb
@@ -407,6 +411,7 @@ test_files:
407
411
  - spec/rackspace/requests/servers/create_server_spec.rb
408
412
  - spec/rackspace/requests/servers/delete_image_spec.rb
409
413
  - spec/rackspace/requests/servers/delete_server_spec.rb
414
+ - spec/rackspace/requests/servers/get_flavor_details_spec.rb
410
415
  - spec/rackspace/requests/servers/get_server_details_spec.rb
411
416
  - spec/rackspace/requests/servers/list_addresses_spec.rb
412
417
  - spec/rackspace/requests/servers/list_flavors_detail_spec.rb