nephophobia 0.1.2 → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,4 @@
1
+ "THE BEER-WARE LICENSE" (Revision 42):
2
+ <john@dewey.ws> wrote this file. As long as you retain this notice you
3
+ can do whatever you want with this stuff. If we meet some day, and you think
4
+ this stuff is worth it, you can buy me a beer in return John-B Dewey Jr.
@@ -12,13 +12,12 @@ module Nephophobia
12
12
  @port = options[:port] || 8773
13
13
 
14
14
  @connection = Hugs::Client.new(
15
- :host => options[:host],
16
- :scheme => options[:scheme] || "http",
17
- :port => @port,
18
- :type => options[:type] || :xml
15
+ :host => options[:host],
16
+ :scheme => options[:scheme] || "http",
17
+ :port => @port,
18
+ :type => options[:type] || :xml,
19
+ :raise_errors => true
19
20
  )
20
- @connection.raise_4xx = true
21
- @connection.raise_5xx = true
22
21
 
23
22
  @aws = AWS.new(
24
23
  :host => options[:host],
@@ -27,6 +27,14 @@ module Nephophobia
27
27
  end
28
28
  end
29
29
 
30
+ class VncData
31
+ attr_reader :url
32
+
33
+ def initialize attributes
34
+ @url = attributes['url']
35
+ end
36
+ end
37
+
30
38
  class Compute
31
39
  def initialize client
32
40
  @client = client
@@ -147,5 +155,21 @@ module Nephophobia
147
155
 
148
156
  ResponseData.new response.body
149
157
  end
158
+
159
+ ##
160
+ # Returns the VNC browser URL. Used by the Portal.
161
+ # __Must__ have an +admin+ role to use.
162
+ #
163
+ # +instance_id+: A String representing the ID of the instance.
164
+
165
+ def vnc_url instance_id
166
+ params = {
167
+ "InstanceId" => instance_id
168
+ }
169
+
170
+ response = @client.action "GetVncConsole", params
171
+
172
+ VncData.new response.body['GetVncConsoleResponse']
173
+ end
150
174
  end
151
175
  end
@@ -1,3 +1,3 @@
1
1
  module Nephophobia
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
data/nephophobia.gemspec CHANGED
@@ -19,10 +19,10 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_dependency "hugs", "~> 2.5.2"
22
+ s.add_dependency "hugs", "~> 2.6.0"
23
23
 
24
24
  s.add_development_dependency "fakeweb", "~> 1.3.0"
25
- s.add_development_dependency "minitest", "~> 2.0.2"
25
+ s.add_development_dependency "minitest", "~> 2.1.0"
26
26
  s.add_development_dependency "nokogiri", "~> 1.4.4"
27
27
  s.add_development_dependency "rake", "~> 0.8.7"
28
28
  s.add_development_dependency "vcr", "1.5.0"
@@ -0,0 +1,82 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :get
5
+ uri: http://10.3.170.35:8773/services/Cloud?AWSAccessKeyId=2ea76797-229c-4e52-a21b-f30513cb91a6%3Asandbox&Action=RunInstances&ImageId=ami-00000002&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=1999-12-31T19%3A59%3A59Z&Version=2010-11-15&Signature=tPz8K7mYsXFNuGeGmQCf3JFCOWsQ5iGKP%2B4CU1PUoOI%3D
6
+ body:
7
+ headers:
8
+ accept:
9
+ - application/xml
10
+ connection:
11
+ - keep-alive
12
+ keep-alive:
13
+ - 30
14
+ response: !ruby/struct:VCR::Response
15
+ status: !ruby/struct:VCR::ResponseStatus
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ content-type:
20
+ - text/xml
21
+ content-length:
22
+ - "838"
23
+ date:
24
+ - Tue, 17 May 2011 22:54:02 GMT
25
+ connection:
26
+ - keep-alive
27
+ body: <?xml version="1.0" ?><RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-11-15/"><requestId>UQI84EDZKAJCI9OD6P7-</requestId><ownerId>sandbox</ownerId><groupSet><item><groupId>default</groupId></item></groupSet><reservationId>r-g3dtl3nz</reservationId><instancesSet><item><displayDescription/><displayName>Server 44</displayName><keyName>None (sandbox, None)</keyName><instanceId>i-0000002c</instanceId><instanceState><code>0</code><name>scheduling</name></instanceState><publicDnsName/><imageId>ami-00000002</imageId><productCodesSet/><privateDnsName/><dnsName/><launchTime>2011-05-17T22:54:02Z</launchTime><amiLaunchIndex>0</amiLaunchIndex><placement><availabilityZone>unknown zone</availabilityZone></placement><ipAddress/><instanceType>m1.small</instanceType><privateIpAddress/></item></instancesSet></RunInstancesResponse>
28
+ http_version: "1.1"
29
+ - !ruby/struct:VCR::HTTPInteraction
30
+ request: !ruby/struct:VCR::Request
31
+ method: :get
32
+ uri: http://10.3.170.35:8773/services/Cloud?AWSAccessKeyId=2ea76797-229c-4e52-a21b-f30513cb91a6%3Asandbox&Action=GetVncConsole&InstanceId=i-0000002c&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=1999-12-31T19%3A59%3A59Z&Version=2010-11-15&Signature=CTnwl8XghsgR%2BvLufr6apb%2F7CxBRHWXMDzbVqARIvM0%3D
33
+ body:
34
+ headers:
35
+ accept:
36
+ - application/xml
37
+ connection:
38
+ - keep-alive
39
+ keep-alive:
40
+ - 30
41
+ response: !ruby/struct:VCR::Response
42
+ status: !ruby/struct:VCR::ResponseStatus
43
+ code: 200
44
+ message: OK
45
+ headers:
46
+ content-type:
47
+ - text/xml
48
+ content-length:
49
+ - "292"
50
+ date:
51
+ - Tue, 17 May 2011 22:55:08 GMT
52
+ connection:
53
+ - keep-alive
54
+ body: <?xml version="1.0" ?><GetVncConsoleResponse xmlns="http://ec2.amazonaws.com/doc/2010-11-15/"><requestId>MQGGGBRZT52RW30-Q0HC</requestId><url>http://10.3.170.35:6080/vnc_auto.html?token=43d60f5f-b4d6-406a-a4ec-c6ff8e8a741e&amp;host=hostignore&amp;port=portignore</url></GetVncConsoleResponse>
55
+ http_version: "1.1"
56
+ - !ruby/struct:VCR::HTTPInteraction
57
+ request: !ruby/struct:VCR::Request
58
+ method: :get
59
+ uri: http://10.3.170.35:8773/services/Cloud?AWSAccessKeyId=2ea76797-229c-4e52-a21b-f30513cb91a6%3Asandbox&Action=TerminateInstances&InstanceId.1=i-0000002c&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=1999-12-31T19%3A59%3A59Z&Version=2010-11-15&Signature=jM8GDD%2B9KoSnyC2CgqXhvp2FXKlZriKt6ZVEU1w38Fk%3D
60
+ body:
61
+ headers:
62
+ accept:
63
+ - application/xml
64
+ connection:
65
+ - keep-alive
66
+ keep-alive:
67
+ - 30
68
+ response: !ruby/struct:VCR::Response
69
+ status: !ruby/struct:VCR::ResponseStatus
70
+ code: 200
71
+ message: OK
72
+ headers:
73
+ content-type:
74
+ - text/xml
75
+ content-length:
76
+ - "192"
77
+ date:
78
+ - Tue, 17 May 2011 22:55:19 GMT
79
+ connection:
80
+ - keep-alive
81
+ body: <?xml version="1.0" ?><TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-11-15/"><requestId>3JEB2L90CZG-HQ6-KDG5</requestId><return>true</return></TerminateInstancesResponse>
82
+ http_version: "1.1"
@@ -1,15 +1,13 @@
1
1
  require "test_helper"
2
2
 
3
- describe Hashify do
4
- #TODO: *WAY* more testing
3
+ #describe Hashify do
4
+ # describe "::convert" do
5
+ # it "creates a hash from a Nokogiri::XML::Document" do
6
+ # xml = cassette_for "compute_all", 1
7
+ # hash = Hashify.convert xml.root
5
8
 
6
- describe "::convert" do
7
- it "creates a hash from a Nokogiri::XML::Document" do
8
- xml = cassette_for "compute_all", 1
9
- hash = Hashify.convert xml.root
10
-
11
- assert_equal "Server 42", hash['DescribeInstancesResponse']['reservationSet']['item'].first['instancesSet']['item'].first['displayName']
12
- assert_equal "Server 46", hash['DescribeInstancesResponse']['reservationSet']['item'].first['instancesSet']['item'].last['displayName']
13
- end
14
- end
15
- end
9
+ # assert_equal "Server 42", hash['DescribeInstancesResponse']['reservationSet']['item'].first['instancesSet']['item'].first['displayName']
10
+ # assert_equal "Server 46", hash['DescribeInstancesResponse']['reservationSet']['item'].first['instancesSet']['item'].last['displayName']
11
+ # end
12
+ # end
13
+ #end
@@ -32,7 +32,7 @@ describe Nephophobia::Compute do
32
32
  @response.size.must_be :>=, 1
33
33
  end
34
34
  end
35
-
35
+
36
36
  describe "#all with filter" do
37
37
  before do
38
38
  VCR.use_cassette "compute_all_with_filter" do
@@ -157,4 +157,33 @@ describe Nephophobia::Compute do
157
157
  @response.return.must_equal true
158
158
  end
159
159
  end
160
+ describe "#vnc_url" do
161
+ before do
162
+ VCR.use_cassette "compute_vnc_url" do
163
+ ##
164
+ # Pointing to the nova trunk version.
165
+
166
+ @compute = ::Client.with(:admin,
167
+ :access_key => "2ea76797-229c-4e52-a21b-f30513cb91a6",
168
+ :secret_key => "3d16b391-820f-4f5c-893b-0f65d5f35312",
169
+ :host => "10.3.170.35",
170
+ :project => "sandbox"
171
+ ).compute
172
+
173
+ @instance_id = @compute.create(@image_id).instance_id
174
+
175
+ @response = @compute.vnc_url @instance_id
176
+ end
177
+ end
178
+
179
+ after do
180
+ VCR.use_cassette "compute_vnc_url" do
181
+ @compute.destroy @instance_id
182
+ end
183
+ end
184
+
185
+ it "has a vnc url for the given 'instance_id'" do
186
+ @response.url.must_match %r{/vnc_auto.html\?token=[a-z0-9-]+}
187
+ end
188
+ end
160
189
  end
data/test/test_helper.rb CHANGED
@@ -10,6 +10,7 @@ require "vcr"
10
10
  class MiniTest::Unit::TestCase
11
11
  def cassette_for cassette, interaction = 0
12
12
  c = VCR::Cassette.new(cassette).send :recorded_interactions
13
+ VCR.eject_cassette
13
14
 
14
15
  Nokogiri::XML::Document.parse c[interaction].response.body
15
16
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nephophobia
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.2
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Dewey
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-04-21 00:00:00 -07:00
14
+ date: 2011-05-17 00:00:00 -07:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  requirements:
23
23
  - - ~>
24
24
  - !ruby/object:Gem::Version
25
- version: 2.5.2
25
+ version: 2.6.0
26
26
  type: :runtime
27
27
  version_requirements: *id001
28
28
  - !ruby/object:Gem::Dependency
@@ -44,7 +44,7 @@ dependencies:
44
44
  requirements:
45
45
  - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: 2.0.2
47
+ version: 2.1.0
48
48
  type: :development
49
49
  version_requirements: *id003
50
50
  - !ruby/object:Gem::Dependency
@@ -94,6 +94,7 @@ files:
94
94
  - .gitignore
95
95
  - .rvmrc
96
96
  - Gemfile
97
+ - LICENSE
97
98
  - README.md
98
99
  - Rakefile
99
100
  - lib/aws.rb
@@ -115,6 +116,7 @@ files:
115
116
  - test/cassettes/compute_destroy.yml
116
117
  - test/cassettes/compute_find.yml
117
118
  - test/cassettes/compute_reboot.yml
119
+ - test/cassettes/compute_vnc_url.yml
118
120
  - test/cassettes/credential_all.yml
119
121
  - test/cassettes/credential_all_without_keys.yml
120
122
  - test/cassettes/credential_create.yml
@@ -194,6 +196,7 @@ test_files:
194
196
  - test/cassettes/compute_destroy.yml
195
197
  - test/cassettes/compute_find.yml
196
198
  - test/cassettes/compute_reboot.yml
199
+ - test/cassettes/compute_vnc_url.yml
197
200
  - test/cassettes/credential_all.yml
198
201
  - test/cassettes/credential_all_without_keys.yml
199
202
  - test/cassettes/credential_create.yml