fog 0.0.99 → 0.0.100

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.
data/Rakefile CHANGED
@@ -79,6 +79,12 @@ end
79
79
  #
80
80
  #############################################################################
81
81
 
82
+ require 'spec/rake/spectask'
83
+ Spec::Rake::SpecTask.new(:spec) do |spec|
84
+ spec.libs << 'lib' << 'spec'
85
+ spec.spec_opts = ['--colour', "--format", "specdoc"]
86
+ spec.spec_files = FileList['spec/**/*_spec.rb']
87
+ end
82
88
 
83
89
 
84
90
  #############################################################################
data/bin/fog CHANGED
@@ -2,20 +2,20 @@
2
2
  require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
3
3
  require 'irb'
4
4
  require 'yaml'
5
- require 'fog/credentials'
6
- require 'fog/bin'
5
+ require File.join('fog', 'credentials')
6
+ require File.join('fog', 'bin')
7
7
 
8
8
  Fog.credential = (ARGV.first && :"#{ARGV.first}") || :default
9
9
  unless Fog.credentials
10
10
  exit
11
11
  end
12
12
 
13
- require 'fog/aws/bin'
14
- require 'fog/local/bin'
15
- require 'fog/rackspace/bin'
16
- require 'fog/slicehost/bin'
17
- require 'fog/terremark/bin'
18
- require 'fog/vcloud/bin'
13
+ require File.join('fog', 'aws', 'bin')
14
+ require File.join('fog', 'local', 'bin')
15
+ require File.join('fog', 'rackspace', 'bin')
16
+ require File.join('fog', 'slicehost', 'bin')
17
+ require File.join('fog', 'terremark', 'bin')
18
+ require File.join('fog', 'vcloud', 'bin')
19
19
 
20
20
  if ARGV.length > 1
21
21
  print(instance_eval(ARGV[1..-1].join(' ')).to_json)
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'fog'
10
- s.version = '0.0.99'
11
- s.date = '2010-05-14'
10
+ s.version = '0.0.100'
11
+ s.date = '2010-05-18'
12
12
  s.rubyforge_project = 'fog'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
data/lib/fog.rb CHANGED
@@ -35,7 +35,7 @@ require 'fog/vcloud'
35
35
  module Fog
36
36
 
37
37
  unless const_defined?(:VERSION)
38
- VERSION = '0.0.99'
38
+ VERSION = '0.0.100'
39
39
  end
40
40
 
41
41
  module Mock
@@ -6,10 +6,13 @@ require 'fog/aws/simpledb'
6
6
  module Fog
7
7
  module AWS
8
8
 
9
- def self.indexed_param(key, values)
9
+ def self.indexed_param(key, values, offset = 0)
10
10
  params = {}
11
+ unless key.include?('%d')
12
+ key << '.%d'
13
+ end
11
14
  [*values].each_with_index do |value, index|
12
- params["#{key}.#{index}"] = value
15
+ params[format(key, index + offset)] = value
13
16
  end
14
17
  params
15
18
  end
@@ -115,28 +115,18 @@ module Fog
115
115
  def save
116
116
  requires :image_id
117
117
 
118
- options = {'InstanceType' => flavor.id}
119
- if @availability_zone
120
- options['Placement.AvailabilityZone'] = @availability_zone
121
- end
122
- unless @groups.empty?
123
- options.merge!(AWS.indexed_param("SecurityGroup", @groups))
124
- end
125
- if @kernel_id
126
- options['KernelId'] = @kernel_id
127
- end
128
- if @key_name
129
- options['KeyName'] = @key_name
130
- end
131
- if @monitoring
132
- options['Monitoring.Enabled'] = @monitoring
133
- end
134
- if @ramdisk_id
135
- options['RamdiskId'] = @ramdisk_id
136
- end
137
- if @user_data
138
- options['UserData'] = @user_data
139
- end
118
+ options = {
119
+ 'BlockDeviceMapping' => @block_device_mapping,
120
+ 'InstanceType' => flavor.id,
121
+ 'KernelId' => @kernel_id,
122
+ 'KeyName' => @key_name,
123
+ 'Monitoring.Enabled' => @monitoring,
124
+ 'Placement.AvailabilityZone' => @availability_zone,
125
+ 'RamdiskId' => @ramdisk_id,
126
+ 'SecurityGroup' => @groups,
127
+ 'UserData' => @user_data
128
+ }
129
+
140
130
  data = connection.run_instances(@image_id, 1, 1, options)
141
131
  merge_attributes(data.body['instancesSet'].first)
142
132
  true
@@ -51,8 +51,9 @@ module Fog
51
51
  def describe_instances(instance_id = [])
52
52
  params = AWS.indexed_param('InstanceId', instance_id)
53
53
  request({
54
- 'Action' => 'DescribeInstances',
55
- :parser => Fog::Parsers::AWS::EC2::DescribeInstances.new
54
+ 'Action' => 'DescribeInstances',
55
+ :idempotent => true,
56
+ :parser => Fog::Parsers::AWS::EC2::DescribeInstances.new
56
57
  }.merge!(params))
57
58
  end
58
59
 
@@ -18,12 +18,13 @@ module Fog
18
18
  # (by default the maximum for an account is 20)
19
19
  # * options<~Hash>:
20
20
  # * 'Placement.AvailabilityZone'<~String> - Placement constraint for instances
21
- # * 'BlockDeviceMapping.n.DeviceName'<~String> - where the volume will be exposed to instance
22
- # * 'BlockDeviceMapping.n.VirtualName'<~String> - volume virtual device name
23
- # * 'BlockDeviceMapping.n.Ebs.SnapshotId'<~String> - id of snapshot to boot volume from
24
- # * 'BlockDeviceMapping.n.Ebs.VolumeSize'<~String> - size of volume in GiBs required unless snapshot is specified
25
- # * 'BlockDeviceMapping.n.Ebs.DeleteOnTermination'<~String> - specifies whether or not to delete the volume on instance termination
26
- # * 'SecurityGroup.n'<~String> - Indexed names of security groups for instances
21
+ # * 'BlockDeviceMapping'<~Array>: array of hashes
22
+ # * 'DeviceName'<~String> - where the volume will be exposed to instance
23
+ # * 'VirtualName'<~String> - volume virtual device name
24
+ # * 'Ebs.SnapshotId'<~String> - id of snapshot to boot volume from
25
+ # * 'Ebs.VolumeSize'<~String> - size of volume in GiBs required unless snapshot is specified
26
+ # * 'Ebs.DeleteOnTermination'<~String> - specifies whether or not to delete the volume on instance termination
27
+ # * 'SecurityGroup'<~Array> or <~String> - Name of security group(s) for instances
27
28
  # * 'InstanceInitiatedShutdownBehaviour'<~String> - specifies whether volumes are stopped or terminated when instance is shutdown
28
29
  # * 'InstanceType'<~String> - Type of instance to boot. Valid options
29
30
  # in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge', 'm2.2xlarge', 'm2.4xlarge']
@@ -76,6 +77,16 @@ module Fog
76
77
  # * 'requestId'<~String> - Id of request
77
78
  # * 'reservationId'<~String> - Id of reservation
78
79
  def run_instances(image_id, min_count, max_count, options = {})
80
+ if block_device_mapping = options.delete('BlockDeviceMapping')
81
+ block_device_mapping.each_with_index do |mapping, index|
82
+ for key, value in mapping
83
+ options.merge!({ format("BlockDeviceMapping.%d.#{key}", index) => value })
84
+ end
85
+ end
86
+ end
87
+ if security_groups = [*options.delete('SecurityGroup')]
88
+ options.merge!(AWS.indexed_param('SecurityGroup', security_groups))
89
+ end
79
90
  if options['UserData']
80
91
  options['UserData'] = Base64.encode64(options['UserData'])
81
92
  end
@@ -10,6 +10,8 @@ module Fog
10
10
 
11
11
  attribute :name
12
12
  attribute :status
13
+ attribute :OperatingSystem
14
+ attribute :VirtualHardware
13
15
 
14
16
  def destroy
15
17
  requires :id
@@ -13,15 +13,22 @@ module Fog
13
13
  attribute :result, 'Result'
14
14
  attribute :start_time, 'startTime'
15
15
  attribute :status
16
+ attribute :link, 'Link'
17
+ attribute :error, 'Error'
16
18
 
17
19
  def initialize(attributes = {})
18
20
  new_owner = attributes.delete('Owner')
19
21
  new_result = attributes.delete('Result')
22
+ new_error = attributes.delete('Error')
23
+ new_cancel_link = attributes.delete('Link')
24
+
20
25
  super
21
26
  @owner = connection.parse(new_owner)
22
27
  if new_result
23
28
  @result = connection.parse(new_result)
24
29
  end
30
+ @error = connection.parse(new_error) if new_error
31
+ @cancel_link = connection.parse(new_cancel_link) if new_cancel_link
25
32
  end
26
33
 
27
34
  def ready?
@@ -18,6 +18,10 @@ module Fog
18
18
  connection.addresses(:vdc_id => @id)
19
19
  end
20
20
 
21
+ def servers
22
+ connection.servers(:vdc_id => @id)
23
+ end
24
+
21
25
  private
22
26
 
23
27
  def href=(new_href)
@@ -12,7 +12,7 @@ module Fog
12
12
  def start_element(name, attributes)
13
13
  super
14
14
  case name
15
- when 'Owner', 'Result'
15
+ when 'Owner', 'Result', 'Link', 'Error'
16
16
  data = {}
17
17
  until attributes.empty?
18
18
  data[attributes.shift] = attributes.shift
@@ -278,7 +278,7 @@ module Fog
278
278
  end
279
279
 
280
280
  if mod = credentials[:module]
281
- instance.extend eval "#{mod}"
281
+ instance.extend eval("#{mod}")
282
282
  end
283
283
 
284
284
  instance
@@ -25,14 +25,14 @@ module Vcloud
25
25
  false
26
26
  end
27
27
 
28
- if Vcloud.services.all? { |service| Vcloud.complete_service_options?(service) }
28
+ if Vcloud.services.any? && Vcloud.services.all? { |service| Vcloud.complete_service_options?(service) }
29
29
 
30
30
  def initialized?
31
31
  true
32
32
  end
33
33
 
34
34
  def startup_notice
35
- puts "You have acess to the following Vcloud services: #{Vcloud.registered_services}."
35
+ puts "You have access to the following vCloud services: #{Vcloud.registered_services}."
36
36
  end
37
37
 
38
38
  def [](service)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 99
9
- version: 0.0.99
8
+ - 100
9
+ version: 0.0.100
10
10
  platform: ruby
11
11
  authors:
12
12
  - geemus (Wesley Beary)
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-14 00:00:00 -07:00
17
+ date: 2010-05-18 00:00:00 -07:00
18
18
  default_executable: fog
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency