fog 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/Gemfile +8 -8
  2. data/Gemfile.lock +3 -3
  3. data/bin/fog +2 -10
  4. data/fog.gemspec +45 -20
  5. data/lib/fog.rb +2 -1
  6. data/lib/fog/attributes.rb +48 -8
  7. data/lib/fog/aws/ec2.rb +5 -2
  8. data/lib/fog/aws/elb.rb +5 -2
  9. data/lib/fog/aws/models/ec2/server.rb +1 -1
  10. data/lib/fog/aws/requests/simpledb/put_attributes.rb +43 -12
  11. data/lib/fog/aws/s3.rb +2 -2
  12. data/lib/fog/aws/simpledb.rb +15 -3
  13. data/lib/fog/bin.rb +11 -2
  14. data/lib/fog/bluebox.rb +5 -1
  15. data/lib/fog/connection.rb +9 -1
  16. data/lib/fog/credentials.rb +3 -0
  17. data/lib/fog/new_servers.rb +89 -0
  18. data/lib/fog/new_servers/bin.rb +30 -0
  19. data/lib/fog/new_servers/requests/add_server.rb +39 -0
  20. data/lib/fog/new_servers/requests/cancel_server.rb +36 -0
  21. data/lib/fog/new_servers/requests/get_server.rb +42 -0
  22. data/lib/fog/new_servers/requests/list_images.rb +33 -0
  23. data/lib/fog/new_servers/requests/list_plans.rb +36 -0
  24. data/lib/fog/new_servers/requests/list_servers.rb +43 -0
  25. data/lib/fog/new_servers/requests/reboot_server.rb +30 -0
  26. data/lib/fog/parser.rb +6 -0
  27. data/lib/fog/rackspace/files.rb +8 -2
  28. data/lib/fog/rackspace/models/servers/server.rb +5 -0
  29. data/lib/fog/rackspace/servers.rb +5 -1
  30. data/lib/fog/service.rb +6 -1
  31. data/lib/fog/slicehost.rb +5 -1
  32. data/lib/fog/terremark/ecloud.rb +1 -0
  33. data/lib/fog/terremark/shared.rb +4 -1
  34. data/lib/fog/terremark/vcloud.rb +1 -0
  35. data/lib/fog/vcloud.rb +150 -141
  36. data/lib/fog/vcloud/bin.rb +2 -2
  37. data/lib/fog/vcloud/collection.rb +3 -84
  38. data/lib/fog/vcloud/extension.rb +44 -0
  39. data/lib/fog/vcloud/generators.rb +33 -0
  40. data/lib/fog/vcloud/model.rb +5 -38
  41. data/lib/fog/vcloud/models/vdc.rb +14 -24
  42. data/lib/fog/vcloud/models/vdcs.rb +13 -8
  43. data/lib/fog/vcloud/requests/get_network.rb +4 -11
  44. data/lib/fog/vcloud/requests/get_organization.rb +4 -11
  45. data/lib/fog/vcloud/requests/get_vdc.rb +4 -12
  46. data/lib/fog/vcloud/requests/get_versions.rb +4 -13
  47. data/lib/fog/vcloud/requests/login.rb +4 -4
  48. data/lib/fog/vcloud/terremark/ecloud.rb +125 -54
  49. data/lib/fog/vcloud/terremark/ecloud/models/catalog.rb +30 -0
  50. data/lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb +31 -0
  51. data/lib/fog/vcloud/terremark/ecloud/models/internet_service.rb +21 -22
  52. data/lib/fog/vcloud/terremark/ecloud/models/internet_services.rb +11 -25
  53. data/lib/fog/vcloud/terremark/ecloud/models/ip.rb +38 -5
  54. data/lib/fog/vcloud/terremark/ecloud/models/ips.rb +11 -15
  55. data/lib/fog/vcloud/terremark/ecloud/models/network.rb +52 -11
  56. data/lib/fog/vcloud/terremark/ecloud/models/networks.rb +14 -13
  57. data/lib/fog/vcloud/terremark/ecloud/models/node.rb +47 -0
  58. data/lib/fog/vcloud/terremark/ecloud/models/nodes.rb +30 -0
  59. data/lib/fog/vcloud/terremark/ecloud/models/public_ip.rb +6 -9
  60. data/lib/fog/vcloud/terremark/ecloud/models/public_ips.rb +19 -3
  61. data/lib/fog/vcloud/terremark/ecloud/models/server.rb +203 -0
  62. data/lib/fog/vcloud/terremark/ecloud/models/servers.rb +43 -0
  63. data/lib/fog/vcloud/terremark/ecloud/models/task.rb +22 -0
  64. data/lib/fog/vcloud/terremark/ecloud/models/tasks.rb +30 -0
  65. data/lib/fog/vcloud/terremark/ecloud/models/vdc.rb +32 -10
  66. data/lib/fog/vcloud/terremark/ecloud/models/vdcs.rb +5 -6
  67. data/lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb +23 -10
  68. data/lib/fog/vcloud/terremark/ecloud/requests/add_node.rb +54 -0
  69. data/lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb +14 -12
  70. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb +53 -0
  71. data/lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb +52 -0
  72. data/lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb +42 -0
  73. data/lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb +115 -0
  74. data/lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb +4 -23
  75. data/lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb +0 -0
  76. data/lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb +19 -0
  77. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb +18 -0
  78. data/lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb +18 -0
  79. data/lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb +18 -0
  80. data/lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb +9 -16
  81. data/lib/fog/vcloud/terremark/ecloud/requests/get_network.rb +8 -14
  82. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb +36 -0
  83. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb +44 -0
  84. data/lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb +11 -12
  85. data/lib/fog/vcloud/terremark/ecloud/requests/get_node.rb +18 -0
  86. data/lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb +18 -0
  87. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb +5 -19
  88. data/lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb +5 -12
  89. data/lib/fog/vcloud/terremark/ecloud/requests/get_task.rb +18 -0
  90. data/lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb +19 -0
  91. data/lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb +18 -0
  92. data/lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb +7 -15
  93. data/lib/fog/vcloud/terremark/ecloud/requests/power_off.rb +18 -0
  94. data/lib/fog/vcloud/terremark/ecloud/requests/power_on.rb +18 -0
  95. data/lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb +18 -0
  96. data/lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb +18 -0
  97. data/lib/fog/vcloud/terremark/vcloud.rb +4 -18
  98. data/lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb +4 -12
  99. data/spec/aws/requests/simpledb/put_attributes_spec.rb +18 -0
  100. data/spec/vcloud/bin_spec.rb +2 -2
  101. data/spec/vcloud/models/vdc_spec.rb +35 -29
  102. data/spec/vcloud/requests/get_network_spec.rb +32 -43
  103. data/spec/vcloud/requests/get_organization_spec.rb +45 -38
  104. data/spec/vcloud/requests/get_vdc_spec.rb +42 -32
  105. data/spec/vcloud/requests/get_versions_spec.rb +17 -17
  106. data/spec/vcloud/requests/login_spec.rb +7 -4
  107. data/spec/vcloud/spec_helper.rb +137 -46
  108. data/spec/vcloud/terremark/ecloud/models/internet_service_spec.rb +53 -58
  109. data/spec/vcloud/terremark/ecloud/models/internet_services_spec.rb +20 -20
  110. data/spec/vcloud/terremark/ecloud/models/ip_spec.rb +22 -21
  111. data/spec/vcloud/terremark/ecloud/models/ips_spec.rb +18 -18
  112. data/spec/vcloud/terremark/ecloud/models/network_spec.rb +55 -51
  113. data/spec/vcloud/terremark/ecloud/models/networks_spec.rb +16 -15
  114. data/spec/vcloud/terremark/ecloud/models/public_ip_spec.rb +26 -27
  115. data/spec/vcloud/terremark/ecloud/models/public_ips_spec.rb +16 -15
  116. data/spec/vcloud/terremark/ecloud/models/vdc_spec.rb +52 -36
  117. data/spec/vcloud/terremark/ecloud/models/vdcs_spec.rb +18 -15
  118. data/spec/vcloud/terremark/ecloud/requests/add_internet_service_spec.rb +46 -43
  119. data/spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb +37 -32
  120. data/spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb +26 -23
  121. data/spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb +57 -49
  122. data/spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb +41 -0
  123. data/spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb +39 -34
  124. data/spec/vcloud/terremark/ecloud/requests/get_network_spec.rb +26 -48
  125. data/spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb +25 -26
  126. data/spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb +35 -27
  127. data/spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb +85 -110
  128. data/spec/vcloud/terremark/ecloud/requests/login_spec.rb +7 -4
  129. data/spec/vcloud/vcloud_spec.rb +9 -8
  130. metadata +62 -26
  131. data/lib/fog/vcloud/parser.rb +0 -42
  132. data/lib/fog/vcloud/parsers/get_organization.rb +0 -37
  133. data/lib/fog/vcloud/parsers/get_vdc.rb +0 -62
  134. data/lib/fog/vcloud/parsers/get_versions.rb +0 -46
  135. data/lib/fog/vcloud/parsers/login.rb +0 -36
  136. data/lib/fog/vcloud/parsers/network.rb +0 -53
  137. data/lib/fog/vcloud/terremark/all.rb +0 -9
  138. data/lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb +0 -59
  139. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ip.rb +0 -30
  140. data/lib/fog/vcloud/terremark/ecloud/parsers/get_public_ips.rb +0 -40
  141. data/lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb +0 -59
  142. data/lib/fog/vcloud/terremark/ecloud/parsers/internet_service.rb +0 -58
  143. data/lib/fog/vcloud/terremark/ecloud/parsers/network.rb +0 -28
  144. data/lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb +0 -31
  145. data/lib/fog/vcloud/terremark/ecloud/requests/login.rb +0 -27
  146. data/lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb +0 -34
  147. data/spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb +0 -74
data/Gemfile CHANGED
@@ -1,13 +1,13 @@
1
1
  source 'http://gemcutter.org'
2
2
 
3
3
  gem 'rake'
4
- gem 'excon', '>= 0.0.26'
4
+ gem 'excon', '>= 0.1.2'
5
5
  gem 'formatador', ">= 0.0.10"
6
- gem 'json', ">= 0"
6
+ gem 'json', ">= 0"
7
7
  gem 'mime-types', ">= 0"
8
- gem 'net-ssh', ">= 0"
9
- gem 'nokogiri', ">= 0"
10
- gem 'rspec', '>= 0'
11
- gem 'ruby-hmac', '>= 0'
12
- gem 'shindo', '>= 0.1.6'
13
- gem 'builder', '>= 0'
8
+ gem 'net-ssh', ">= 0"
9
+ gem 'nokogiri', ">= 0"
10
+ gem 'rspec', '>= 0'
11
+ gem 'ruby-hmac', '>= 0'
12
+ gem 'shindo', '>= 0.1.6'
13
+ gem 'builder', '>= 0'
@@ -31,7 +31,7 @@ dependencies:
31
31
  excon:
32
32
  group:
33
33
  - :default
34
- version: ">= 0.0.26"
34
+ version: ">= 0.1.2"
35
35
  builder:
36
36
  group:
37
37
  - :default
@@ -50,7 +50,7 @@ specs:
50
50
  - builder:
51
51
  version: 2.1.2
52
52
  - excon:
53
- version: 0.0.26
53
+ version: 0.1.2
54
54
  - formatador:
55
55
  version: 0.0.14
56
56
  - gestalt:
@@ -69,7 +69,7 @@ specs:
69
69
  version: 0.4.0
70
70
  - shindo:
71
71
  version: 0.1.6
72
- hash: 83b7c53965ec61f532d9a504fcd8f5f67a285293
72
+ hash: 5799aef7324bea69e03170607cb33bea95a3e975
73
73
  sources:
74
74
  - Rubygems:
75
75
  uri: http://gemcutter.org
data/bin/fog CHANGED
@@ -3,20 +3,12 @@ require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
3
3
  require 'irb'
4
4
  require 'yaml'
5
5
  require File.join('fog', 'credentials')
6
- require File.join('fog', 'bin')
7
-
8
- Fog.credential = ARGV.first ? :"#{ARGV.first}" : :default
6
+ Fog.credential = ARGV.first ? :"#{ARGV.first}" : :default
9
7
  unless Fog.credentials
10
8
  exit
11
9
  end
12
10
 
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
- require File.join('fog', 'bluebox', 'bin')
11
+ require 'fog/bin'
20
12
 
21
13
  if ARGV.length > 1
22
14
  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.2.0'
11
- s.date = '2010-06-18'
10
+ s.version = '0.2.1'
11
+ s.date = '2010-06-27'
12
12
  s.rubyforge_project = 'fog'
13
13
 
14
14
  ## Make sure your summary is short. The description may be as long
@@ -42,13 +42,14 @@ Gem::Specification.new do |s|
42
42
 
43
43
  ## List your runtime dependencies here. Runtime dependencies are those
44
44
  ## that are needed for an end user to actually USE your code.
45
- s.add_dependency('excon', '>=0.0.24')
45
+ s.add_dependency('excon', '>=0.1.2')
46
46
  s.add_dependency('formatador', '>=0.0.10')
47
47
  s.add_dependency('json')
48
48
  s.add_dependency('mime-types')
49
49
  s.add_dependency('net-ssh')
50
50
  s.add_dependency('nokogiri')
51
51
  s.add_dependency('ruby-hmac')
52
+ s.add_dependency('builder')
52
53
 
53
54
  ## List your development dependencies here. Development dependencies are
54
55
  ## those that are only needed during development
@@ -242,6 +243,15 @@ Gem::Specification.new do |s|
242
243
  lib/fog/local/models/file.rb
243
244
  lib/fog/local/models/files.rb
244
245
  lib/fog/model.rb
246
+ lib/fog/new_servers.rb
247
+ lib/fog/new_servers/bin.rb
248
+ lib/fog/new_servers/requests/add_server.rb
249
+ lib/fog/new_servers/requests/cancel_server.rb
250
+ lib/fog/new_servers/requests/get_server.rb
251
+ lib/fog/new_servers/requests/list_images.rb
252
+ lib/fog/new_servers/requests/list_plans.rb
253
+ lib/fog/new_servers/requests/list_servers.rb
254
+ lib/fog/new_servers/requests/reboot_server.rb
245
255
  lib/fog/parser.rb
246
256
  lib/fog/rackspace.rb
247
257
  lib/fog/rackspace/bin.rb
@@ -378,51 +388,66 @@ Gem::Specification.new do |s|
378
388
  lib/fog/vcloud.rb
379
389
  lib/fog/vcloud/bin.rb
380
390
  lib/fog/vcloud/collection.rb
391
+ lib/fog/vcloud/extension.rb
392
+ lib/fog/vcloud/generators.rb
381
393
  lib/fog/vcloud/model.rb
382
394
  lib/fog/vcloud/models/vdc.rb
383
395
  lib/fog/vcloud/models/vdcs.rb
384
- lib/fog/vcloud/parser.rb
385
- lib/fog/vcloud/parsers/get_organization.rb
386
- lib/fog/vcloud/parsers/get_vdc.rb
387
- lib/fog/vcloud/parsers/get_versions.rb
388
- lib/fog/vcloud/parsers/login.rb
389
- lib/fog/vcloud/parsers/network.rb
390
396
  lib/fog/vcloud/requests/get_network.rb
391
397
  lib/fog/vcloud/requests/get_organization.rb
392
398
  lib/fog/vcloud/requests/get_vdc.rb
393
399
  lib/fog/vcloud/requests/get_versions.rb
394
400
  lib/fog/vcloud/requests/login.rb
395
- lib/fog/vcloud/terremark/all.rb
396
401
  lib/fog/vcloud/terremark/ecloud.rb
402
+ lib/fog/vcloud/terremark/ecloud/models/catalog.rb
403
+ lib/fog/vcloud/terremark/ecloud/models/catalog_item.rb
397
404
  lib/fog/vcloud/terremark/ecloud/models/internet_service.rb
398
405
  lib/fog/vcloud/terremark/ecloud/models/internet_services.rb
399
406
  lib/fog/vcloud/terremark/ecloud/models/ip.rb
400
407
  lib/fog/vcloud/terremark/ecloud/models/ips.rb
401
408
  lib/fog/vcloud/terremark/ecloud/models/network.rb
402
409
  lib/fog/vcloud/terremark/ecloud/models/networks.rb
410
+ lib/fog/vcloud/terremark/ecloud/models/node.rb
411
+ lib/fog/vcloud/terremark/ecloud/models/nodes.rb
403
412
  lib/fog/vcloud/terremark/ecloud/models/public_ip.rb
404
413
  lib/fog/vcloud/terremark/ecloud/models/public_ips.rb
414
+ lib/fog/vcloud/terremark/ecloud/models/server.rb
415
+ lib/fog/vcloud/terremark/ecloud/models/servers.rb
416
+ lib/fog/vcloud/terremark/ecloud/models/task.rb
417
+ lib/fog/vcloud/terremark/ecloud/models/tasks.rb
405
418
  lib/fog/vcloud/terremark/ecloud/models/vdc.rb
406
419
  lib/fog/vcloud/terremark/ecloud/models/vdcs.rb
407
- lib/fog/vcloud/terremark/ecloud/parsers/get_internet_services.rb
408
- lib/fog/vcloud/terremark/ecloud/parsers/get_public_ip.rb
409
- lib/fog/vcloud/terremark/ecloud/parsers/get_public_ips.rb
410
- lib/fog/vcloud/terremark/ecloud/parsers/get_vdc.rb
411
- lib/fog/vcloud/terremark/ecloud/parsers/internet_service.rb
412
- lib/fog/vcloud/terremark/ecloud/parsers/network.rb
413
- lib/fog/vcloud/terremark/ecloud/parsers/network_ips.rb
414
420
  lib/fog/vcloud/terremark/ecloud/requests/add_internet_service.rb
421
+ lib/fog/vcloud/terremark/ecloud/requests/add_node.rb
415
422
  lib/fog/vcloud/terremark/ecloud/requests/configure_internet_service.rb
423
+ lib/fog/vcloud/terremark/ecloud/requests/configure_network.rb
424
+ lib/fog/vcloud/terremark/ecloud/requests/configure_network_ip.rb
425
+ lib/fog/vcloud/terremark/ecloud/requests/configure_node.rb
426
+ lib/fog/vcloud/terremark/ecloud/requests/configure_vapp.rb
416
427
  lib/fog/vcloud/terremark/ecloud/requests/delete_internet_service.rb
428
+ lib/fog/vcloud/terremark/ecloud/requests/delete_node.rb
429
+ lib/fog/vcloud/terremark/ecloud/requests/delete_vapp.rb
430
+ lib/fog/vcloud/terremark/ecloud/requests/get_catalog.rb
431
+ lib/fog/vcloud/terremark/ecloud/requests/get_catalog_item.rb
432
+ lib/fog/vcloud/terremark/ecloud/requests/get_customization_options.rb
417
433
  lib/fog/vcloud/terremark/ecloud/requests/get_internet_services.rb
418
434
  lib/fog/vcloud/terremark/ecloud/requests/get_network.rb
435
+ lib/fog/vcloud/terremark/ecloud/requests/get_network_extensions.rb
436
+ lib/fog/vcloud/terremark/ecloud/requests/get_network_ip.rb
419
437
  lib/fog/vcloud/terremark/ecloud/requests/get_network_ips.rb
438
+ lib/fog/vcloud/terremark/ecloud/requests/get_node.rb
439
+ lib/fog/vcloud/terremark/ecloud/requests/get_nodes.rb
420
440
  lib/fog/vcloud/terremark/ecloud/requests/get_public_ip.rb
421
441
  lib/fog/vcloud/terremark/ecloud/requests/get_public_ips.rb
442
+ lib/fog/vcloud/terremark/ecloud/requests/get_task.rb
443
+ lib/fog/vcloud/terremark/ecloud/requests/get_task_list.rb
444
+ lib/fog/vcloud/terremark/ecloud/requests/get_vapp.rb
422
445
  lib/fog/vcloud/terremark/ecloud/requests/get_vdc.rb
423
- lib/fog/vcloud/terremark/ecloud/requests/login.rb
446
+ lib/fog/vcloud/terremark/ecloud/requests/power_off.rb
447
+ lib/fog/vcloud/terremark/ecloud/requests/power_on.rb
448
+ lib/fog/vcloud/terremark/ecloud/requests/power_reset.rb
449
+ lib/fog/vcloud/terremark/ecloud/requests/power_shutdown.rb
424
450
  lib/fog/vcloud/terremark/vcloud.rb
425
- lib/fog/vcloud/terremark/vcloud/parsers/get_vdc.rb
426
451
  lib/fog/vcloud/terremark/vcloud/requests/get_vdc.rb
427
452
  spec/aws/models/ec2/address_spec.rb
428
453
  spec/aws/models/ec2/addresses_spec.rb
@@ -511,13 +536,13 @@ Gem::Specification.new do |s|
511
536
  spec/vcloud/terremark/ecloud/requests/configure_internet_service_spec.rb
512
537
  spec/vcloud/terremark/ecloud/requests/delete_internet_service_spec.rb
513
538
  spec/vcloud/terremark/ecloud/requests/get_internet_services_spec.rb
539
+ spec/vcloud/terremark/ecloud/requests/get_network_ip_spec.rb
514
540
  spec/vcloud/terremark/ecloud/requests/get_network_ips_spec.rb
515
541
  spec/vcloud/terremark/ecloud/requests/get_network_spec.rb
516
542
  spec/vcloud/terremark/ecloud/requests/get_public_ip_spec.rb
517
543
  spec/vcloud/terremark/ecloud/requests/get_public_ips_spec.rb
518
544
  spec/vcloud/terremark/ecloud/requests/get_vdc_spec.rb
519
545
  spec/vcloud/terremark/ecloud/requests/login_spec.rb
520
- spec/vcloud/terremark/vcloud/requests/get_vdc_spec.rb
521
546
  spec/vcloud/vcloud_spec.rb
522
547
  tests/aws/helper.rb
523
548
  tests/aws/requests/ec2/address_tests.rb
data/lib/fog.rb CHANGED
@@ -30,6 +30,7 @@ require 'fog/ssh'
30
30
  require 'fog/aws'
31
31
  require 'fog/bluebox'
32
32
  require 'fog/local'
33
+ require 'fog/new_servers'
33
34
  require 'fog/rackspace'
34
35
  require 'fog/slicehost'
35
36
  require 'fog/terremark'
@@ -38,7 +39,7 @@ require 'fog/vcloud'
38
39
  module Fog
39
40
 
40
41
  unless const_defined?(:VERSION)
41
- VERSION = '0.2.0'
42
+ VERSION = '0.2.1'
42
43
  end
43
44
 
44
45
  module Mock
@@ -55,13 +55,43 @@ module Fog
55
55
  when :time
56
56
  class_eval <<-EOS, __FILE__, __LINE__
57
57
  def #{name}=(new_#{name})
58
- @#{name} = Time.parse(new_#{name})
58
+ if !new_#{name}.is_a?(Time)
59
+ @#{name} = Time.parse(new_#{name})
60
+ else
61
+ @#{name} = new_#{name}
62
+ end
59
63
  end
60
64
  EOS
61
- else
65
+ when :array
62
66
  class_eval <<-EOS, __FILE__, __LINE__
63
- attr_writer :#{name}
67
+ def #{name}=(new_#{name})
68
+ @#{name} = if new_#{name}.is_a?(Array)
69
+ new_#{name}
70
+ else
71
+ @#{name} = [ new_#{name} ]
72
+ end
73
+ end
64
74
  EOS
75
+ else
76
+ if squash = options[:squash]
77
+ class_eval <<-EOS, __FILE__, __LINE__
78
+ def #{name}=(new_data)
79
+ if new_data.is_a?(Hash)
80
+ if new_data[:#{squash}]
81
+ @#{name} = new_data[:#{squash}]
82
+ else
83
+ @#{name} = [ new_data ]
84
+ end
85
+ else
86
+ @#{name} = new_data
87
+ end
88
+ end
89
+ EOS
90
+ else
91
+ class_eval <<-EOS, __FILE__, __LINE__
92
+ attr_writer :#{name}
93
+ EOS
94
+ end
65
95
  end
66
96
  @attributes ||= []
67
97
  @attributes |= [name]
@@ -72,7 +102,15 @@ module Fog
72
102
 
73
103
  def identity(name, other_names = [])
74
104
  @identity = name
75
- self.attribute(name, other_names)
105
+ self.attribute(name, {:aliases => other_names})
106
+ end
107
+
108
+ def ignore_attributes(*args)
109
+ @ignored_attributes = args
110
+ end
111
+
112
+ def ignored_attributes
113
+ @ignored_attributes ||= []
76
114
  end
77
115
 
78
116
  end
@@ -101,10 +139,12 @@ module Fog
101
139
 
102
140
  def merge_attributes(new_attributes = {})
103
141
  for key, value in new_attributes
104
- if aliased_key = self.class.aliases[key]
105
- send("#{aliased_key}=", value)
106
- else
107
- send("#{key}=", value)
142
+ unless self.class.ignored_attributes.include?(key)
143
+ if aliased_key = self.class.aliases[key]
144
+ send("#{aliased_key}=", value)
145
+ else
146
+ send("#{key}=", value)
147
+ end
108
148
  end
109
149
  end
110
150
  self
@@ -160,13 +160,16 @@ module Fog
160
160
  end
161
161
  @port = options[:port] || 443
162
162
  @scheme = options[:scheme] || 'https'
163
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
164
+ end
165
+
166
+ def reload
167
+ @connection.reset
163
168
  end
164
169
 
165
170
  private
166
171
 
167
172
  def request(params)
168
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
169
-
170
173
  idempotent = params.delete(:idempotent)
171
174
  parser = params.delete(:parser)
172
175
 
@@ -63,13 +63,16 @@ module Fog
63
63
  end
64
64
  @port = options[:port] || 443
65
65
  @scheme = options[:scheme] || 'https'
66
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
67
+ end
68
+
69
+ def reload
70
+ @connection.reset
66
71
  end
67
72
 
68
73
  private
69
74
 
70
75
  def request(params)
71
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
72
-
73
76
  idempotent = params.delete(:idempotent)
74
77
  parser = params.delete(:parser)
75
78
 
@@ -31,7 +31,7 @@ module Fog
31
31
  attribute :state, 'instanceState'
32
32
  attribute :user_data
33
33
 
34
- def initialize(attributes)
34
+ def initialize(attributes={})
35
35
  @groups ||= ["default"]
36
36
  @flavor_id ||= 'm1.small'
37
37
  super
@@ -15,30 +15,61 @@ module Fog
15
15
  # and values may use any UTF-8 characters valid in xml. Control characters
16
16
  # and sequences not allowed in xml are not valid. Each name and value can
17
17
  # be up to 1024 bytes long.
18
+ # * options<~Hash> - Accepts the following keys.
19
+ # :replace => [Array of keys to replace]
20
+ # :expect => {name/value pairs for performing conditional put}
18
21
  #
19
22
  # ==== Returns
20
23
  # * response<~Excon::Response>:
21
24
  # * body<~Hash>:
22
25
  # * 'BoxUsage'
23
26
  # * 'RequestId'
24
- def put_attributes(domain_name, item_name, attributes, replace_attributes = [])
25
- batch_put_attributes(
26
- domain_name,
27
- { item_name => attributes },
28
- { item_name => replace_attributes }
29
- )
27
+ def put_attributes(domain_name, item_name, attributes, options = {})
28
+ options[:expect] = {} unless options[:expect]
29
+ options[:replace] = [] unless options[:replace]
30
+ request({
31
+ 'Action' => 'PutAttributes',
32
+ 'DomainName' => domain_name,
33
+ :parser => Fog::Parsers::AWS::SimpleDB::Basic.new(@nil_string),
34
+ 'ItemName' => item_name
35
+ }.merge!(encode_attributes(attributes, options[:replace], options[:expect])))
30
36
  end
31
37
 
32
38
  end
33
39
 
34
40
  class Mock
35
41
 
36
- def put_attributes(domain_name, item_name, attributes, replace_attributes = [])
37
- batch_put_attributes(
38
- domain_name,
39
- { item_name => attributes },
40
- { item_name => replace_attributes }
41
- )
42
+ def put_attributes(domain_name, item_name, attributes, options = {})
43
+ options[:expect] = {} unless options[:expect]
44
+ options[:replace] = [] unless options[:replace]
45
+ response = Excon::Response.new
46
+ if @data[:domains][domain_name]
47
+ options[:expect].each do |ck, cv|
48
+ if @data[:domains][domain_name][item_name][ck] != [cv]
49
+ response.status = 409
50
+ raise(Excon::Errors.status_error({:expects => 200}, response))
51
+ end
52
+ end
53
+ attributes.each do |key, value|
54
+ @data[:domains][domain_name][item_name] ||= {}
55
+ @data[:domains][domain_name][item_name][key.to_s] = [] unless @data[:domains][domain_name][item_name][key.to_s]
56
+ if options[:replace].include?(key.to_s)
57
+ @data[:domains][domain_name][item_name][key.to_s] = [value.to_s]
58
+ else
59
+ @data[:domains][domain_name][item_name][key.to_s] += [value.to_s]
60
+ end
61
+ end
62
+ response.status = 200
63
+ response.body = {
64
+ 'BoxUsage' => Fog::AWS::Mock.box_usage,
65
+ 'RequestId' => Fog::AWS::Mock.request_id
66
+ }
67
+ else
68
+ response.status = 400
69
+ raise(Excon::Errors.status_error({:expects => 200}, response))
70
+
71
+ end
72
+ response
42
73
  end
43
74
 
44
75
  end
@@ -135,11 +135,11 @@ module Fog
135
135
  end
136
136
  @port = options[:port] || 443
137
137
  @scheme = options[:scheme] || 'https'
138
- reload
138
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent] || true)
139
139
  end
140
140
 
141
141
  def reload
142
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
142
+ @connection.reset
143
143
  end
144
144
 
145
145
  private
@@ -68,13 +68,22 @@ module Fog
68
68
  @nil_string = options[:nil_string]|| 'nil'
69
69
  @port = options[:port] || 443
70
70
  @scheme = options[:scheme] || 'https'
71
+ @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
71
72
  end
72
73
 
73
74
  private
74
75
 
75
- def encode_attributes(attributes, replace_attributes = [])
76
+ def encode_attributes(attributes, replace_attributes = [], expected_attributes = {})
76
77
  encoded_attributes = {}
77
78
  if attributes
79
+
80
+ expected_attributes.keys.each_with_index do |exkey, index|
81
+ for value in Array(expected_attributes[exkey])
82
+ encoded_attributes["Expected.#{index}.Name"] = exkey.to_s
83
+ encoded_attributes["Expected.#{index}.Value"] = sdb_encode(value)
84
+ end
85
+ end
86
+
78
87
  index = 0
79
88
  for key in attributes.keys
80
89
  for value in Array(attributes[key])
@@ -117,8 +126,11 @@ module Fog
117
126
  encoded_attributes
118
127
  end
119
128
 
129
+ def reload
130
+ @connection.reset
131
+ end
132
+
120
133
  def request(params)
121
- @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
122
134
  idempotent = params.delete(:idempotent)
123
135
  parser = params.delete(:parser)
124
136
 
@@ -128,7 +140,7 @@ module Fog
128
140
  :aws_access_key_id => @aws_access_key_id,
129
141
  :hmac => @hmac,
130
142
  :host => @host,
131
- :version => '2007-11-07'
143
+ :version => '2009-04-15'
132
144
  }
133
145
  )
134
146