fog 0.8.0 → 0.8.1

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
@@ -97,6 +97,7 @@ task :release => :build do
97
97
  sh "git push origin master"
98
98
  sh "git push origin v#{version}"
99
99
  sh "gem push pkg/#{name}-#{version}.gem"
100
+ Rake::Task[:docs].invoke
100
101
  end
101
102
 
102
103
  task :build => :gemspec do
@@ -132,6 +133,45 @@ task :validate do
132
133
  end
133
134
  end
134
135
 
136
+ task :changelog do
137
+ timestamp = Time.now.utc.strftime('%m/%d/%Y')
138
+ sha = `git log | head -1`.split(' ').last
139
+ changelog = ["#{version} #{timestamp} #{sha}"]
140
+ changelog << ('=' * changelog[0].length)
141
+ changelog << ''
142
+
143
+ last_sha = `cat changelog.txt | head -1`.split(' ').last
144
+ shortlog = `git shortlog #{last_sha}..HEAD`
145
+ changes = {}
146
+ for line in shortlog.split("\n")
147
+ if line =~ /^\S/
148
+ committer = line.split(' (', 2).first
149
+ elsif line =~ /^\s*(Merge.*)?$/
150
+ # skip empty lines and Merge commits
151
+ else
152
+ unless line[-1..-1] == '.'
153
+ line << '.'
154
+ end
155
+ line.gsub!(/^\s*\[([^\]]*)\] /, '')
156
+ tag = $1 || 'misc'
157
+ changes[tag] ||= []
158
+ changes[tag] << (line << ' thanks ' << committer)
159
+ end
160
+ end
161
+
162
+ for tag in changes.keys.sort
163
+ changelog << ('[' << tag << ']')
164
+ for commit in changes[tag]
165
+ changelog << (' ' << commit)
166
+ end
167
+ changelog << ''
168
+ end
169
+
170
+ for line in changelog
171
+ print(line << "\n")
172
+ end
173
+ end
174
+
135
175
  task :docs do
136
176
  # build the docs locally
137
177
  sh "jekyll docs docs/_site"
@@ -1,5 +1,5 @@
1
- 0.8.0 05/12/2011
2
- ================
1
+ 0.8.0 05/12/2011 27bf76d1f881bec0f900cd11d5c2a10dce4856ca
2
+ =========================================================
3
3
 
4
4
  MVP! ktheory
5
5
 
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  ## If your rubyforge_project name is different, then edit it and comment out
7
7
  ## the sub! line in the Rakefile
8
8
  s.name = 'fog'
9
- s.version = '0.8.0'
10
- s.date = '2011-05-12'
9
+ s.version = '0.8.1'
10
+ s.date = '2011-05-13'
11
11
  s.rubyforge_project = 'fog'
12
12
 
13
13
  ## Make sure your summary is short. The description may be as long
data/lib/fog.rb CHANGED
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'fog', 'core')
3
3
  module Fog
4
4
 
5
5
  unless const_defined?(:VERSION)
6
- VERSION = '0.8.0'
6
+ VERSION = '0.8.1'
7
7
  end
8
8
 
9
9
  end
@@ -58,6 +58,7 @@ module Fog
58
58
  request :detach_volume
59
59
  request :disassociate_address
60
60
  request :get_console_output
61
+ request :get_password_data
61
62
  request :import_key_pair
62
63
  request :modify_image_attributes
63
64
  request :modify_snapshot_attribute
@@ -0,0 +1,26 @@
1
+ module Fog
2
+ module Parsers
3
+ module AWS
4
+ module Compute
5
+
6
+ class GetPasswordData < Fog::Parsers::Base
7
+
8
+ def reset
9
+ @response = {}
10
+ end
11
+
12
+ def end_element(name)
13
+ case name
14
+ when 'instanceId', 'requestId', 'passwordData'
15
+ @response[name] = @value
16
+ when 'timestamp'
17
+ @response[name] = Time.parse(@value)
18
+ end
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -56,9 +56,9 @@ module Fog
56
56
  filters = {'instance-id' => [*filters]}
57
57
  end
58
58
  params = {}
59
- # when seeking single instance id, old param style is most up to date
59
+ # when seeking single instance id, old param style provides more accurate data sooner
60
60
  if filters['instance-id'] && !filters['instance-id'].is_a?(Array)
61
- params.merge('InstanceId' => filters.delete('instance-id'))
61
+ params.merge!('InstanceId' => filters.delete('instance-id'))
62
62
  end
63
63
  params.merge!(AWS.indexed_filters(filters))
64
64
 
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module AWS
3
+ class Compute
4
+ class Real
5
+
6
+ require 'fog/compute/parsers/aws/get_password_data'
7
+
8
+ # Retrieves the encrypted administrator password for an instance running Windows.
9
+ #
10
+ # ==== Parameters
11
+ # * instance_id<~String> - A Windows instance ID
12
+ #
13
+ # ==== Returns
14
+ # # * response<~Excon::Response>:
15
+ # * body<~Hash>:
16
+ # * 'instanceId'<~String> - Id of instance
17
+ # * 'passwordData'<~String> - The encrypted, base64-encoded password of the instance.
18
+ # * 'requestId'<~String> - Id of request
19
+ # * 'timestamp'<~Time> - Timestamp of last update to output
20
+ #
21
+ # See http://docs.amazonwebservices.com/AWSEC2/2010-08-31/APIReference/index.html?ApiReference-query-GetPasswordData.html
22
+ def get_password_data(instance_id)
23
+ request(
24
+ 'Action' => 'GetPasswordData',
25
+ 'InstanceId' => instance_id,
26
+ :idempotent => true,
27
+ :parser => Fog::Parsers::AWS::Compute::GetPasswordData.new
28
+ )
29
+ end
30
+
31
+ end
32
+
33
+ class Mock
34
+
35
+ def get_password_data(instance_id)
36
+ Fog::Mock.not_implemented
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -19,7 +19,7 @@ module Fog
19
19
  # @return [String] The path for configuration_file
20
20
  def self.credentials_path
21
21
  @credential_path ||= begin
22
- path = ENV["FOG_RC"] || (ENV['HOME'] && '~/.fog')
22
+ path = ENV["FOG_RC"] || (ENV['HOME'] && File.directory?(ENV['HOME']) && '~/.fog')
23
23
  File.expand_path(path) if path
24
24
  end
25
25
  end
@@ -11,16 +11,16 @@ Shindo.tests('AWS::Compute | instance requests', ['aws']) do
11
11
  'instanceState' => {'code' => Integer, 'name' => String},
12
12
  'instanceType' => String,
13
13
  # 'ipAddress' => String,
14
- 'kernelId' => String,
15
- # 'keyName' => String,
14
+ 'kernelId' => Fog::Nullable::String,
15
+ 'keyName' => Fog::Nullable::String,
16
16
  'launchTime' => Time,
17
17
  'monitoring' => {'state' => Fog::Boolean},
18
18
  'placement' => {'availabilityZone' => String},
19
19
  'privateDnsName' => NilClass,
20
20
  # 'privateIpAddress' => String,
21
21
  'productCodes' => [],
22
- 'ramdiskId' => String,
23
- 'reason' => NilClass,
22
+ 'ramdiskId' => Fog::Nullable::String,
23
+ 'reason' => Fog::Nullable::String,
24
24
  # 'rootDeviceName' => String,
25
25
  'rootDeviceType' => String,
26
26
  }
@@ -38,12 +38,12 @@ Shindo.tests('AWS::Compute | instance requests', ['aws']) do
38
38
  'groupSet' => [String],
39
39
  'instancesSet' => [@instance_format.merge(
40
40
  'architecture' => String,
41
- 'dnsName' => String,
42
- 'ipAddress' => String,
43
- 'privateDnsName' => String,
44
- 'privateIpAddress' => String,
45
- 'stateReason' => {},
46
- 'tagSet' => {}
41
+ 'dnsName' => Fog::Nullable::String,
42
+ 'ipAddress' => Fog::Nullable::String,
43
+ 'privateDnsName' => Fog::Nullable::String,
44
+ 'privateIpAddress' => Fog::Nullable::String,
45
+ 'stateReason' => Hash,
46
+ 'tagSet' => Hash
47
47
  )],
48
48
  'ownerId' => String,
49
49
  'reservationId' => String
@@ -58,6 +58,14 @@ Shindo.tests('AWS::Compute | instance requests', ['aws']) do
58
58
  'timestamp' => Time
59
59
  }
60
60
 
61
+ @get_password_data_format = {
62
+ 'instanceId' => String,
63
+ 'passwordData' => String,
64
+ 'requestId' => String,
65
+ 'timestamp' => Time
66
+ }
67
+
68
+
61
69
  @terminate_instances_format = {
62
70
  'instancesSet' => [{
63
71
  'currentState' => {'code' => Integer, 'name' => String},
@@ -70,28 +78,64 @@ Shindo.tests('AWS::Compute | instance requests', ['aws']) do
70
78
  tests('success') do
71
79
 
72
80
  @instance_id = nil
81
+ # Use a MS Windows AMI to test #get_password_data
82
+ @windows_ami = 'ami-ee926087' # Microsoft Windows Server 2008 R2 Base 64-bit
83
+
84
+ # Create a keypair for decrypting the password
85
+ key_name = 'fog-test-key'
86
+ key = AWS.key_pairs.create(:name => key_name)
73
87
 
74
- tests("#run_instances('#{GENTOO_AMI}', 1, 1)").formats(@run_instances_format) do
75
- data = AWS[:compute].run_instances(GENTOO_AMI, 1, 1).body
88
+ tests("#run_instances").formats(@run_instances_format) do
89
+ data = AWS[:compute].run_instances(@windows_ami, 1, 1, 'InstanceType' => 't1.micro', 'KeyName' => key_name).body
76
90
  @instance_id = data['instancesSet'].first['instanceId']
77
91
  data
78
92
  end
79
93
 
80
- AWS[:compute].servers.get(@instance_id).wait_for { ready? }
94
+ server = AWS[:compute].servers.get(@instance_id)
95
+ while server.nil? do
96
+ # It may take a moment to get the server after launching it
97
+ sleep 0.1
98
+ server = AWS[:compute].servers.get(@instance_id)
99
+ end
100
+ server.wait_for { ready? }
101
+
102
+ tests("#describe_instances").formats(@describe_instances_format) do
103
+ AWS[:compute].describe_instances.body
104
+ end
81
105
 
82
- # The format changes depending on state of instance, so this would be brittle
83
- # tests("#describe_instances").formats(@describe_instances_format) do
84
- # AWS[:compute].describe_instances.body
85
- # end
106
+ # Launch another instance to test filters
107
+ another_server = AWS[:compute].servers.create
86
108
 
87
109
  tests("#describe_instances('instance-id' => '#{@instance_id}')").formats(@describe_instances_format) do
88
- AWS[:compute].describe_instances('instance-id' => @instance_id).body
110
+ body = AWS[:compute].describe_instances('instance-id' => @instance_id).body
111
+ tests("returns 1 instance").returns(1) { body['reservationSet'].size }
112
+ body
89
113
  end
90
114
 
115
+ another_server.destroy
116
+
91
117
  tests("#get_console_output('#{@instance_id}')").formats(@get_console_output_format) do
92
118
  AWS[:compute].get_console_output(@instance_id).body
93
119
  end
94
120
 
121
+ tests("#get_password_data('#{@instance_id}')").formats(@get_password_data_format) do
122
+ pending if Fog.mock?
123
+ result = nil
124
+ Fog.wait_for do
125
+ result = AWS[:compute].get_password_data(@instance_id).body
126
+ !result['passwordData'].nil?
127
+ end
128
+
129
+ tests("key can decrypt passwordData").returns(true) do
130
+ decoded_password = Base64.decode64(result['passwordData'])
131
+ pkey = OpenSSL::PKey::RSA.new(key.private_key)
132
+ String === pkey.private_decrypt(decoded_password)
133
+ end
134
+ result
135
+ end
136
+
137
+ key.destroy
138
+
95
139
  tests("#reboot_instances('#{@instance_id}')").formats(AWS::Compute::Formats::BASIC) do
96
140
  AWS[:compute].reboot_instances(@instance_id).body
97
141
  end
@@ -108,6 +152,10 @@ Shindo.tests('AWS::Compute | instance requests', ['aws']) do
108
152
  AWS[:compute].get_console_output('i-00000000')
109
153
  end
110
154
 
155
+ tests("#get_password_data('i-00000000')").raises(Fog::AWS::Compute::NotFound) do
156
+ AWS[:compute].get_password_data('i-00000000')
157
+ end
158
+
111
159
  tests("#reboot_instances('i-00000000')").raises(Fog::AWS::Compute::NotFound) do
112
160
  AWS[:compute].reboot_instances('i-00000000')
113
161
  end
@@ -0,0 +1,67 @@
1
+ Shindo.tests('Fog::Parsers', 'core') do
2
+
3
+ class TestParser < Fog::Parsers::Base
4
+ def reset
5
+ super
6
+ reset_my_array
7
+ end
8
+
9
+ def reset_my_array
10
+ @my_array = []
11
+ end
12
+
13
+ def end_element(name)
14
+ case name
15
+ when 'key1', 'key2', 'key3', 'longText'
16
+ @response[name] = value
17
+ when 'myArray'
18
+ @response[name] = @my_array
19
+ reset_my_array
20
+ when 'id'
21
+ @my_array << value.to_i
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ @xml = %{
28
+ <MyResponse>
29
+ <MyObject>
30
+ <key1>value1</key1>
31
+ <key2>value2</key2>
32
+ <myArray>
33
+ <id>1</id>
34
+ <id>2</id>
35
+ <id>3</id>
36
+ </myArray>
37
+ <longText>
38
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
39
+ Donec quis metus arcu, quis cursus turpis.
40
+ Aliquam leo lacus, luctus vel iaculis id,
41
+ posuere eu odio. Donec sodales, ante porta condimentum
42
+ </longText>
43
+ <key3>value3</key3>
44
+ </MyObject>
45
+ <MyResponse>
46
+ }
47
+
48
+ @response = {
49
+ 'key1' => 'value1',
50
+ 'key2' => 'value2',
51
+ 'key3' => 'value3',
52
+ 'myArray' => [1,2,3],
53
+ 'longText' => %{
54
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
55
+ Donec quis metus arcu, quis cursus turpis.
56
+ Aliquam leo lacus, luctus vel iaculis id,
57
+ posuere eu odio. Donec sodales, ante porta condimentum
58
+ }
59
+ }
60
+
61
+
62
+ tests('TestParser').returns(@response) do
63
+ test_parser = TestParser.new
64
+ Nokogiri::XML::SAX::Parser.new(test_parser).parse(@xml)
65
+ test_parser.response
66
+ end
67
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
9
+ - 1
10
+ version: 0.8.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - geemus (Wesley Beary)
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-12 00:00:00 Z
18
+ date: 2011-05-13 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: builder
@@ -626,6 +626,7 @@ files:
626
626
  - lib/fog/compute/parsers/aws/describe_volumes.rb
627
627
  - lib/fog/compute/parsers/aws/detach_volume.rb
628
628
  - lib/fog/compute/parsers/aws/get_console_output.rb
629
+ - lib/fog/compute/parsers/aws/get_password_data.rb
629
630
  - lib/fog/compute/parsers/aws/import_key_pair.rb
630
631
  - lib/fog/compute/parsers/aws/monitor_unmonitor_instances.rb
631
632
  - lib/fog/compute/parsers/aws/register_image.rb
@@ -678,6 +679,7 @@ files:
678
679
  - lib/fog/compute/requests/aws/detach_volume.rb
679
680
  - lib/fog/compute/requests/aws/disassociate_address.rb
680
681
  - lib/fog/compute/requests/aws/get_console_output.rb
682
+ - lib/fog/compute/requests/aws/get_password_data.rb
681
683
  - lib/fog/compute/requests/aws/import_key_pair.rb
682
684
  - lib/fog/compute/requests/aws/modify_image_attributes.rb
683
685
  - lib/fog/compute/requests/aws/modify_snapshot_attribute.rb
@@ -1318,6 +1320,7 @@ files:
1318
1320
  - tests/compute/requests/voxel/server_tests.rb
1319
1321
  - tests/core/attribute_tests.rb
1320
1322
  - tests/core/credential_tests.rb
1323
+ - tests/core/parser_tests.rb
1321
1324
  - tests/dns/helper.rb
1322
1325
  - tests/dns/models/record_tests.rb
1323
1326
  - tests/dns/models/records_tests.rb
@@ -1521,6 +1524,7 @@ test_files:
1521
1524
  - tests/compute/requests/voxel/server_tests.rb
1522
1525
  - tests/core/attribute_tests.rb
1523
1526
  - tests/core/credential_tests.rb
1527
+ - tests/core/parser_tests.rb
1524
1528
  - tests/dns/helper.rb
1525
1529
  - tests/dns/models/record_tests.rb
1526
1530
  - tests/dns/models/records_tests.rb