fog-maestrodev 1.14.0.20130806165225 → 1.15.0.20130829165835

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. data/changelog.txt +296 -0
  2. data/fog.gemspec +2 -2
  3. data/lib/fog/atmos/storage.rb +0 -3
  4. data/lib/fog/aws/cdn.rb +1 -2
  5. data/lib/fog/aws/compute.rb +52 -2
  6. data/lib/fog/aws/dns.rb +0 -1
  7. data/lib/fog/aws/models/auto_scaling/groups.rb +6 -3
  8. data/lib/fog/aws/models/compute/address.rb +1 -0
  9. data/lib/fog/aws/models/compute/flavors.rb +19 -0
  10. data/lib/fog/aws/models/compute/route_table.rb +69 -0
  11. data/lib/fog/aws/models/compute/route_tables.rb +92 -0
  12. data/lib/fog/aws/models/rds/instance_option.rb +21 -0
  13. data/lib/fog/aws/models/rds/instance_options.rb +30 -0
  14. data/lib/fog/aws/parsers/compute/associate_route_table.rb +20 -0
  15. data/lib/fog/aws/parsers/compute/create_route_table.rb +75 -0
  16. data/lib/fog/aws/parsers/compute/describe_account_attributes.rb +42 -0
  17. data/lib/fog/aws/parsers/compute/describe_route_tables.rb +85 -0
  18. data/lib/fog/aws/parsers/rds/describe_orderable_db_instance_options.rb +47 -0
  19. data/lib/fog/aws/rds.rb +5 -0
  20. data/lib/fog/aws/requests/auto_scaling/describe_auto_scaling_groups.rb +9 -1
  21. data/lib/fog/aws/requests/auto_scaling/describe_policies.rb +15 -1
  22. data/lib/fog/aws/requests/compute/associate_dhcp_options.rb +2 -2
  23. data/lib/fog/aws/requests/compute/associate_route_table.rb +75 -0
  24. data/lib/fog/aws/requests/compute/attach_internet_gateway.rb +2 -2
  25. data/lib/fog/aws/requests/compute/create_route.rb +89 -0
  26. data/lib/fog/aws/requests/compute/create_route_table.rb +70 -0
  27. data/lib/fog/aws/requests/compute/create_vpc.rb +16 -1
  28. data/lib/fog/aws/requests/compute/delete_dhcp_options.rb +2 -2
  29. data/lib/fog/aws/requests/compute/delete_internet_gateway.rb +2 -2
  30. data/lib/fog/aws/requests/compute/delete_network_interface.rb +2 -2
  31. data/lib/fog/aws/requests/compute/delete_route.rb +60 -0
  32. data/lib/fog/aws/requests/compute/delete_route_table.rb +51 -0
  33. data/lib/fog/aws/requests/compute/delete_subnet.rb +2 -2
  34. data/lib/fog/aws/requests/compute/delete_vpc.rb +2 -2
  35. data/lib/fog/aws/requests/compute/describe_account_attributes.rb +49 -0
  36. data/lib/fog/aws/requests/compute/describe_route_tables.rb +87 -0
  37. data/lib/fog/aws/requests/compute/detach_internet_gateway.rb +2 -2
  38. data/lib/fog/aws/requests/compute/detach_network_interface.rb +2 -2
  39. data/lib/fog/aws/requests/compute/disassociate_route_table.rb +57 -0
  40. data/lib/fog/aws/requests/compute/reset_network_interface_attribute.rb +2 -1
  41. data/lib/fog/aws/requests/elb/create_load_balancer.rb +23 -9
  42. data/lib/fog/aws/requests/iam/upload_server_certificate.rb +1 -1
  43. data/lib/fog/aws/requests/rds/describe_orderable_db_instance_options.rb +76 -0
  44. data/lib/fog/aws/storage.rb +0 -2
  45. data/lib/fog/brightbox/models/compute/collaboration.rb +10 -2
  46. data/lib/fog/brightbox/models/compute/collaborations.rb +26 -2
  47. data/lib/fog/brightbox/models/compute/user_collaboration.rb +16 -1
  48. data/lib/fog/brightbox/models/compute/user_collaborations.rb +10 -2
  49. data/lib/fog/cloudstack/models/compute/server.rb +4 -0
  50. data/lib/fog/core/collection.rb +18 -0
  51. data/lib/fog/core/credentials.rb +6 -1
  52. data/lib/fog/google/compute.rb +17 -0
  53. data/lib/fog/google/examples/get_list_images.rb +27 -0
  54. data/lib/fog/google/examples/get_list_snapshots.rb +20 -0
  55. data/lib/fog/google/examples/image_create.rb +18 -0
  56. data/lib/fog/google/examples/launch_micro_instance.rb +10 -5
  57. data/lib/fog/google/examples/network.rb +21 -0
  58. data/lib/fog/google/models/compute/disk.rb +16 -5
  59. data/lib/fog/google/models/compute/image.rb +36 -18
  60. data/lib/fog/google/models/compute/images.rb +36 -10
  61. data/lib/fog/google/models/compute/server.rb +41 -11
  62. data/lib/fog/google/models/compute/servers.rb +1 -1
  63. data/lib/fog/google/models/compute/snapshot.rb +36 -0
  64. data/lib/fog/google/models/compute/snapshots.rb +28 -0
  65. data/lib/fog/google/requests/compute/delete_disk.rb +5 -1
  66. data/lib/fog/google/requests/compute/get_disk.rb +2 -1
  67. data/lib/fog/google/requests/compute/get_snapshot.rb +34 -0
  68. data/lib/fog/google/requests/compute/insert_disk.rb +23 -7
  69. data/lib/fog/google/requests/compute/insert_image.rb +16 -9
  70. data/lib/fog/google/requests/compute/insert_server.rb +22 -10
  71. data/lib/fog/google/requests/compute/list_disks.rb +1 -1
  72. data/lib/fog/google/requests/compute/list_snapshots.rb +30 -0
  73. data/lib/fog/google/storage.rb +1 -3
  74. data/lib/fog/hp/storage.rb +0 -2
  75. data/lib/fog/internet_archive/storage.rb +0 -2
  76. data/lib/fog/local/storage.rb +0 -2
  77. data/lib/fog/ninefold/storage.rb +0 -1
  78. data/lib/fog/openstack/models/storage/file.rb +2 -0
  79. data/lib/fog/openstack/requests/compute/add_flavor_access.rb +1 -1
  80. data/lib/fog/openstack/requests/compute/create_volume.rb +8 -7
  81. data/lib/fog/openstack/requests/compute/list_tenants_with_flavor_access.rb +1 -1
  82. data/lib/fog/openstack/requests/compute/remove_flavor_access.rb +1 -1
  83. data/lib/fog/openstack/requests/image/create_image.rb +23 -23
  84. data/lib/fog/openstack/requests/image/update_image.rb +31 -33
  85. data/lib/fog/openstack/requests/storage/get_object_https_url.rb +3 -3
  86. data/lib/fog/openstack/requests/storage/post_set_meta_temp_url_key.rb +1 -1
  87. data/lib/fog/openstack/storage.rb +10 -11
  88. data/lib/fog/openstack.rb +10 -1
  89. data/lib/fog/rackspace/cdn.rb +13 -0
  90. data/lib/fog/rackspace/compute.rb +8 -4
  91. data/lib/fog/rackspace/compute_v2.rb +2 -0
  92. data/lib/fog/rackspace/databases.rb +4 -4
  93. data/lib/fog/rackspace/dns.rb +6 -6
  94. data/lib/fog/rackspace/examples/compute_v2/bootstrap_server.rb +98 -0
  95. data/lib/fog/rackspace/load_balancers.rb +5 -4
  96. data/lib/fog/rackspace/models/compute_v2/flavors.rb +1 -2
  97. data/lib/fog/rackspace/models/compute_v2/images.rb +35 -3
  98. data/lib/fog/rackspace/models/compute_v2/metadatum.rb +2 -2
  99. data/lib/fog/rackspace/models/identity/service_catalog.rb +34 -16
  100. data/lib/fog/rackspace/models/load_balancers/load_balancer.rb +8 -3
  101. data/lib/fog/rackspace/models/monitoring/alarm.rb +16 -8
  102. data/lib/fog/rackspace/models/monitoring/base.rb +2 -8
  103. data/lib/fog/rackspace/monitoring.rb +14 -6
  104. data/lib/fog/rackspace/requests/compute_v2/list_flavors_detail.rb +39 -0
  105. data/lib/fog/rackspace/requests/compute_v2/list_images.rb +15 -5
  106. data/lib/fog/rackspace/requests/compute_v2/list_images_detail.rb +53 -0
  107. data/lib/fog/rackspace/requests/identity/create_token.rb +1 -1
  108. data/lib/fog/rackspace/requests/load_balancers/create_load_balancer.rb +12 -0
  109. data/lib/fog/rackspace/requests/load_balancers/get_stats.rb +31 -0
  110. data/lib/fog/rackspace/requests/monitoring/get_entity.rb +33 -0
  111. data/lib/fog/rackspace/service.rb +7 -0
  112. data/lib/fog/rackspace/storage.rb +6 -3
  113. data/lib/fog/rackspace.rb +8 -5
  114. data/lib/fog/riakcs/provisioning.rb +0 -1
  115. data/lib/fog/riakcs/usage.rb +2 -3
  116. data/lib/fog/storage.rb +2 -0
  117. data/lib/fog/vcloud/examples/README.md +54 -0
  118. data/lib/fog/vcloud/examples/creating_a_connection.md +20 -0
  119. data/lib/fog/vcloud/examples/creating_a_vapp.md +17 -0
  120. data/lib/fog/vcloud/examples/get_network_information.md +10 -0
  121. data/lib/fog/vcloud/examples/get_vapp_information.md +10 -0
  122. data/lib/fog/vcloud/examples/more_on_vapps.md +23 -0
  123. data/lib/fog/version.rb +1 -1
  124. data/lib/tasks/changelog_task.rb +1 -0
  125. data/tests/aws/models/elb/model_tests.rb +5 -0
  126. data/tests/aws/models/rds/instance_option_tests.rb +14 -0
  127. data/tests/aws/requests/compute/client_tests.rb +25 -0
  128. data/tests/aws/requests/compute/route_tests.rb +277 -0
  129. data/tests/aws/requests/rds/helper.rb +22 -0
  130. data/tests/aws/requests/rds/instance_option_tests.rb +21 -0
  131. data/tests/core/credential_tests.rb +21 -0
  132. data/tests/core/service_tests.rb +26 -0
  133. data/tests/openstack/authenticate_tests.rb +22 -0
  134. data/tests/openstack/models/storage/file_tests.rb +20 -1
  135. data/tests/openstack/requests/compute/flavor_tests.rb +27 -12
  136. data/tests/openstack/requests/compute/volume_tests.rb +10 -12
  137. data/tests/openstack/requests/image/image_tests.rb +30 -15
  138. data/tests/rackspace/block_storage_tests.rb +9 -4
  139. data/tests/rackspace/cdn_tests.rb +14 -0
  140. data/tests/rackspace/compute_tests.rb +10 -4
  141. data/tests/rackspace/compute_v2_tests.rb +9 -4
  142. data/tests/rackspace/databases_tests.rb +9 -4
  143. data/tests/rackspace/dns_tests.rb +9 -4
  144. data/tests/rackspace/helper.rb +21 -2
  145. data/tests/rackspace/identity_tests.rb +9 -4
  146. data/tests/rackspace/load_balancer_tests.rb +8 -4
  147. data/tests/rackspace/models/compute_v2/server_tests.rb +18 -21
  148. data/tests/rackspace/models/identity/service_catalog_tests.rb +54 -29
  149. data/tests/rackspace/models/load_balancers/load_balancer_tests.rb +5 -0
  150. data/tests/rackspace/models/monitoring/alarm_examples_tests.rb +1 -1
  151. data/tests/rackspace/models/monitoring/alarm_tests.rb +2 -2
  152. data/tests/rackspace/monitoring_tests.rb +9 -4
  153. data/tests/rackspace/requests/compute_v2/flavor_tests.rb +6 -0
  154. data/tests/rackspace/requests/compute_v2/image_tests.rb +4 -0
  155. data/tests/rackspace/requests/compute_v2/server_tests.rb +2 -2
  156. data/tests/rackspace/requests/load_balancers/get_stats_tests.rb +13 -0
  157. data/tests/rackspace/requests/load_balancers/helper.rb +9 -0
  158. data/tests/rackspace/requests/monitoring/alarm_tests.rb +4 -5
  159. data/tests/rackspace/requests/monitoring/entity_tests.rb +9 -1
  160. data/tests/rackspace/requests/storage/large_object_tests.rb +12 -4
  161. data/tests/rackspace/storage_tests.rb +23 -4
  162. data/tests/rackspace/url_encoding_tests.rb +3 -1
  163. metadata +117 -133
  164. checksums.yaml +0 -15
  165. data/lib/fog/aws/parsers/compute/associate_dhcp_options.rb +0 -24
  166. data/lib/fog/aws/parsers/compute/attach_internet_gateway.rb +0 -24
  167. data/lib/fog/aws/parsers/compute/delete_dhcp_options.rb +0 -24
  168. data/lib/fog/aws/parsers/compute/delete_internet_gateway.rb +0 -24
  169. data/lib/fog/aws/parsers/compute/delete_network_interface.rb +0 -24
  170. data/lib/fog/aws/parsers/compute/delete_subnet.rb +0 -24
  171. data/lib/fog/aws/parsers/compute/delete_vpc.rb +0 -24
  172. data/lib/fog/aws/parsers/compute/detach_internet_gateway.rb +0 -24
  173. data/lib/fog/aws/parsers/compute/detach_network_interface.rb +0 -24
@@ -10,6 +10,8 @@ module Fog
10
10
  identity :name
11
11
  attribute :image_name, :aliases => 'image'
12
12
  attribute :network_interfaces, :aliases => 'networkInterfaces'
13
+ attribute :network, :aliases => 'network'
14
+ attribute :external_ip, :aliases => 'externalIP'
13
15
  attribute :state, :aliases => 'status'
14
16
  attribute :zone_name, :aliases => 'zone'
15
17
  attribute :machine_type, :aliases => 'machineType'
@@ -28,11 +30,13 @@ module Fog
28
30
 
29
31
  def public_ip_address
30
32
  ip = nil
31
- if self.network_interfaces
33
+ if self.network_interfaces.respond_to? :each
32
34
  self.network_interfaces.each do |netif|
33
- netif["accessConfigs"].each do |access_config|
34
- if access_config["name"] == "External NAT"
35
- ip = access_config['natIP']
35
+ if netif["accessConfigs"].respond_to? :each
36
+ netif["accessConfigs"].each do |access_config|
37
+ if access_config["name"] == "External NAT"
38
+ ip = access_config['natIP']
39
+ end
36
40
  end
37
41
  end
38
42
  end
@@ -41,6 +45,14 @@ module Fog
41
45
  ip
42
46
  end
43
47
 
48
+ def private_ip_address
49
+ ip = nil
50
+ if self.network_interfaces.respond_to? :first
51
+ ip = self.network_interfaces.first['networkIP']
52
+ end
53
+ ip
54
+ end
55
+
44
56
  def ready?
45
57
  self.state == RUNNING
46
58
  end
@@ -55,6 +67,23 @@ module Fog
55
67
  end
56
68
  end
57
69
 
70
+ def add_ssh_key username, key
71
+ if self.metadata.nil?
72
+ self.metadata = Hash.new("")
73
+ end
74
+
75
+ # You can have multiple SSH keys, seperated by newlines.
76
+ # https://developers.google.com/compute/docs/console?hl=en#sshkeys
77
+ if !self.metadata["sshKeys"].empty?
78
+ self.metadata["sshKeys"] += "\n"
79
+ end
80
+
81
+ self.metadata["sshKeys"] += "#{username}:#{key.strip}"
82
+
83
+ return self.metadata
84
+ end
85
+
86
+
58
87
  def reload
59
88
  data = service.get_server(self.name, self.zone).body
60
89
  self.merge_attributes(data)
@@ -65,25 +94,26 @@ module Fog
65
94
  requires :machine_type
66
95
  requires :zone_name
67
96
 
68
- if self.metadata.nil?
69
- self.metadata = {}
97
+ if not service.zones.include? self.zone_name
98
+ raise ArgumentError.new "#{self.zone_name.inspect} is either down or you don't have permission to use it."
70
99
  end
71
100
 
72
- self.metadata.merge!({
73
- "sshKeys" => "#{username}:#{public_key.strip}"
74
- }) if public_key
101
+ self.add_ssh_key(self.username, self.public_key) if self.public_key
75
102
 
76
103
  options = {
77
104
  'image' => image_name,
78
105
  'machineType' => machine_type,
79
106
  'networkInterfaces' => network_interfaces,
107
+ 'network' => network,
108
+ 'externalIp' => external_ip,
80
109
  'disks' => disks,
81
110
  'kernel' => kernel,
82
111
  'metadata' => metadata
83
- }
84
- options.delete_if {|key, value| value.nil?}
112
+ }.delete_if {|key, value| value.nil?}
113
+
85
114
  service.insert_server(name, zone_name, options)
86
115
  data = service.backoff_if_unfound {service.get_server(self.name, self.zone_name).body}
116
+
87
117
  service.servers.merge_attributes(data)
88
118
  end
89
119
 
@@ -49,7 +49,7 @@ module Fog
49
49
  :name => "fog-#{Time.now.to_i}",
50
50
  :image_name => "debian-7-wheezy-v20130617",
51
51
  :machine_type => "n1-standard-1",
52
- :zone_name => "us-central1-a",
52
+ :zone_name => "us-central1-b",
53
53
  :private_key_path => File.expand_path("~/.ssh/id_rsa"),
54
54
  :public_key_path => File.expand_path("~/.ssh/id_rsa.pub"),
55
55
  :username => ENV['USER'],
@@ -0,0 +1,36 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Compute
5
+ class Google
6
+
7
+ class Snapshot < Fog::Model
8
+
9
+ identity :name
10
+
11
+ attribute :kind
12
+ attribute :self_link , :aliases => 'selfLink'
13
+ attribute :creation_timestamp, :aliases => 'creationTimestamp'
14
+ attribute :disk_size_gb , :aliases => 'diskSizeGb'
15
+ attribute :source_disk , :aliases => 'sourceDisk'
16
+ attribute :source_disk_id , :aliases => 'sourceDiskId'
17
+ attribute :description
18
+
19
+ def reload
20
+ requires :name
21
+
22
+ data = service.get_snapshot(name, self.service.project).body
23
+
24
+ self.merge_attributes(data)
25
+ self
26
+ end
27
+
28
+ def resource_url
29
+ "#{self.service.project}/global/snapshots/#{name}"
30
+ end
31
+
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,28 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/google/models/compute/snapshot'
3
+
4
+ module Fog
5
+ module Compute
6
+ class Google
7
+
8
+ class Snapshots < Fog::Collection
9
+
10
+ model Fog::Compute::Google::Snapshot
11
+
12
+ def all
13
+ data = service.list_snapshots(self.service.project)
14
+ snapshots = data.body['items'] || []
15
+ load(snapshots)
16
+ end
17
+
18
+ def get(snap_id)
19
+ response = service.get_snapshot(snap_id, self.service.project)
20
+ return nil if response.nil?
21
+ new(response.body)
22
+ end
23
+
24
+ end
25
+
26
+ end
27
+ end
28
+ end
@@ -12,7 +12,11 @@ module Fog
12
12
 
13
13
  class Real
14
14
 
15
- def delete_disk(disk_name, zone_name=@default_zone)
15
+ def delete_disk(disk_name, zone_name)
16
+ if zone_name.start_with? 'http'
17
+ zone_name = zone_name.split('/')[-1]
18
+ end
19
+
16
20
  api_method = @compute.disks.delete
17
21
  parameters = {
18
22
  'project' => @project,
@@ -12,10 +12,11 @@ module Fog
12
12
 
13
13
  class Real
14
14
 
15
- def get_disk(disk_name, zone_name=@default_zone)
15
+ def get_disk(disk_name, zone_name)
16
16
  if zone_name.start_with? 'http'
17
17
  zone_name = zone_name.split('/')[-1]
18
18
  end
19
+
19
20
  api_method = @compute.disks.get
20
21
  parameters = {
21
22
  'project' => @project,
@@ -0,0 +1,34 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+
5
+ class Mock
6
+
7
+ def get_snapshot(snap_name)
8
+ Fog::Mock.not_implemented
9
+ end
10
+
11
+ end
12
+
13
+ class Real
14
+
15
+ def get_snapshot(snap_name, project=@project)
16
+ if snap_name.nil?
17
+ raise ArgumentError.new "snap_name must not be nil."
18
+ end
19
+
20
+ api_method = @compute.snapshots.get
21
+ parameters = {
22
+ 'snapshot' => snap_name,
23
+ 'project' => project,
24
+ }
25
+
26
+ result = self.build_result(api_method, parameters)
27
+ response = self.build_response(result)
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -12,22 +12,38 @@ module Fog
12
12
 
13
13
  class Real
14
14
 
15
- def insert_disk(disk_name, disk_size, zone_name=@default_zone, image_name=nil)
15
+ def insert_disk(disk_name, zone_name, image_name=nil, opts={})
16
16
  api_method = @compute.disks.insert
17
17
  parameters = {
18
18
  'project' => @project,
19
19
  'zone' => zone_name
20
20
  }
21
+
21
22
  if image_name
22
- # We don't know the owner of the image.
23
- image = images.create({:name => image_name})
23
+ image = images.get(image_name)
24
+ raise ArgumentError.new('Invalid image specified') unless image
24
25
  @image_url = @api_url + image.resource_url
25
26
  parameters['sourceImage'] = @image_url
26
27
  end
27
- body_object = {
28
- 'name' => disk_name,
29
- 'sizeGb' => disk_size,
30
- }
28
+
29
+ body_object = { 'name' => disk_name }
30
+
31
+ # These must be present if image_name is not specified
32
+ if image_name.nil?
33
+ unless opts.has_key?('sourceSnapshot') and opts.has_key?('sizeGb')
34
+ raise ArgumentError.new('Must specify image OR snapshot and '\
35
+ 'disk size when creating a disk.')
36
+ end
37
+
38
+ body_object['sizeGb'] = opts.delete('sizeGb')
39
+
40
+ snap = snapshots.get(opts.delete('sourceSnapshot'))
41
+ raise ArgumentError.new('Invalid source snapshot') unless snap
42
+ body_object['sourceSnapshot'] = @api_url + snap.resource_url
43
+ end
44
+
45
+ # Merge in any remaining options (only 'description' should remain)
46
+ body_object.merge(opts)
31
47
 
32
48
  result = self.build_result(api_method, parameters,
33
49
  body_object)
@@ -12,22 +12,29 @@ module Fog
12
12
 
13
13
  class Real
14
14
 
15
- def insert_image(image_name, source)
15
+ def insert_image(image_name, options={})
16
16
  api_method = @compute.images.insert
17
+
17
18
  parameters = {
18
19
  'project' => @project,
19
20
  }
21
+
22
+ kernel_url = @api_url + 'google/global/kernels/' + \
23
+ options.delete('preferredKernel').to_s
24
+
20
25
  body_object = {
21
- "name" => image_name,
22
- "sourceType" => "RAW",
23
- "source" => source,
24
- "preferredKernel" => '',
26
+ 'sourceType' => 'RAW',
27
+ 'name' => image_name,
28
+ 'rawDisk' => options.delete('rawDisk'),
29
+ 'preferredKernel' => kernel_url,
25
30
  }
26
31
 
27
- result = self.build_result(
28
- api_method,
29
- parameters,
30
- body_object=body_object)
32
+ # Merge in the remaining params (only 'description' should remain)
33
+ body_object.merge(options)
34
+
35
+ result = self.build_result(api_method,
36
+ parameters,
37
+ body_object=body_object)
31
38
  response = self.build_response(result)
32
39
  end
33
40
 
@@ -30,22 +30,34 @@ module Fog
30
30
 
31
31
  if options.has_key? 'image'
32
32
  image_name = options.delete 'image'
33
- # We don't know the owner of the image.
34
- image = images.create({:name => image_name})
33
+ image = images.get(image_name)
35
34
  @image_url = @api_url + image.resource_url
36
35
  body_object['image'] = @image_url
37
36
  end
38
37
  body_object['machineType'] = @api_url + @project + "/zones/#{zone_name}/machineTypes/#{options.delete 'machineType'}"
38
+ network = nil
39
+ if options.has_key? 'network'
40
+ network = options.delete 'network'
41
+ elsif @default_network
42
+ network = @default_network
43
+ end
44
+
45
+ # ExternalIP is default value for server creation
46
+ if options.has_key? 'externalIp'
47
+ external_ip = options.delete 'externalIp'
48
+ else
49
+ external_ip = true
50
+ end
51
+
39
52
  networkInterfaces = []
40
- if @default_network
41
- networkInterfaces << {
42
- 'network' => @api_url + @project + "/global/networks/#{@default_network}",
43
- 'accessConfigs' => [
44
- {'type' => 'ONE_TO_ONE_NAT',
45
- 'name' => 'External NAT'}
46
- ]
47
- }
53
+ if ! network.nil?
54
+ networkInterface = { 'network' => @api_url + @project + "/global/networks/#{network}" }
55
+ if external_ip
56
+ networkInterface['accessConfigs'] = [{'type' => 'ONE_TO_ONE_NAT', 'name' => 'External NAT'}]
57
+ end
58
+ networkInterfaces << networkInterface
48
59
  end
60
+
49
61
  # TODO: add other networks
50
62
  body_object['networkInterfaces'] = networkInterfaces
51
63
 
@@ -12,7 +12,7 @@ module Fog
12
12
 
13
13
  class Real
14
14
 
15
- def list_disks(zone_name=@default_zone)
15
+ def list_disks(zone_name)
16
16
  api_method = @compute.disks.list
17
17
  parameters = {
18
18
  'project' => @project,
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+
5
+ class Mock
6
+
7
+ def list_snapshots
8
+ Fog::Mock.not_implemented
9
+ end
10
+
11
+ end
12
+
13
+ class Real
14
+
15
+ def list_snapshots(project=nil)
16
+ api_method = @compute.snapshots.list
17
+ project=@project if project.nil?
18
+ parameters = {
19
+ 'project' => project
20
+ }
21
+
22
+ result = self.build_result(api_method, parameters)
23
+ response = self.build_response(result)
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -144,7 +144,6 @@ module Fog
144
144
  end
145
145
 
146
146
  def initialize(options={})
147
- require 'mime/types'
148
147
  @google_storage_access_key_id = options[:google_storage_access_key_id]
149
148
  end
150
149
 
@@ -162,7 +161,7 @@ module Fog
162
161
 
163
162
  end
164
163
 
165
-
164
+
166
165
  class Real
167
166
  include Utils
168
167
 
@@ -185,7 +184,6 @@ module Fog
185
184
  # * Storage object with connection to google.
186
185
  def initialize(options={})
187
186
  require 'fog/core/parser'
188
- require 'mime/types'
189
187
 
190
188
  @google_storage_access_key_id = options[:google_storage_access_key_id]
191
189
  @google_storage_secret_access_key = options[:google_storage_secret_access_key]
@@ -220,7 +220,6 @@ module Fog
220
220
  end
221
221
 
222
222
  def initialize(options={})
223
- require 'mime/types'
224
223
  # deprecate hp_account_id
225
224
  if options[:hp_account_id]
226
225
  Fog::Logger.deprecation(":hp_account_id is deprecated, please use :hp_access_key instead.")
@@ -250,7 +249,6 @@ module Fog
250
249
  attr_reader :hp_cdn_ssl
251
250
 
252
251
  def initialize(options={})
253
- require 'mime/types'
254
252
  # deprecate hp_account_id
255
253
  if options[:hp_account_id]
256
254
  Fog::Logger.deprecation(":hp_account_id is deprecated, please use :hp_access_key instead.")
@@ -196,7 +196,6 @@ module Fog
196
196
  end
197
197
 
198
198
  def initialize(options={})
199
- require 'mime/types'
200
199
  setup_credentials(options)
201
200
  options[:region] ||= 'us-east-1'
202
201
  @host = options[:host] || Fog::InternetArchive::API_DOMAIN_NAME
@@ -248,7 +247,6 @@ module Fog
248
247
  # * S3 object with connection to aws.
249
248
  def initialize(options={})
250
249
  require 'fog/core/parser'
251
- require 'mime/types'
252
250
 
253
251
  setup_credentials(options)
254
252
  @connection_options = options[:connection_options] || {}
@@ -33,7 +33,6 @@ module Fog
33
33
  def initialize(options={})
34
34
  Fog::Mock.not_implemented
35
35
 
36
- require 'mime/types'
37
36
  @local_root = ::File.expand_path(options[:local_root])
38
37
 
39
38
  @endpoint = options[:endpoint] || build_endpoint_from_options(options)
@@ -68,7 +67,6 @@ module Fog
68
67
  attr_reader :endpoint
69
68
 
70
69
  def initialize(options={})
71
- require 'mime/types'
72
70
  @local_root = ::File.expand_path(options[:local_root])
73
71
 
74
72
  @endpoint = options[:endpoint] || build_endpoint_from_options(options)
@@ -26,7 +26,6 @@ module Fog
26
26
  include Utils
27
27
 
28
28
  def initialize(options={})
29
- require 'mime/types'
30
29
  @ninefold_storage_token = options[:ninefold_storage_token]
31
30
  @ninefold_storage_secret = options[:ninefold_storage_secret]
32
31
  end
@@ -10,6 +10,7 @@ module Fog
10
10
 
11
11
  attribute :content_length, :aliases => ['bytes', 'Content-Length'], :type => :integer
12
12
  attribute :content_type, :aliases => ['content_type', 'Content-Type']
13
+ attribute :content_disposition, :aliases => ['content_disposition', 'Content-Disposition']
13
14
  attribute :etag, :aliases => ['hash', 'Etag']
14
15
  attribute :last_modified, :aliases => ['last_modified', 'Last-Modified'], :type => :time
15
16
  attribute :access_control_allow_origin, :aliases => ['Access-Control-Allow-Origin']
@@ -72,6 +73,7 @@ module Fog
72
73
  def save(options = {})
73
74
  requires :body, :directory, :key
74
75
  options['Content-Type'] = content_type if content_type
76
+ options['Content-Disposition'] = content_disposition if content_disposition
75
77
  options['Access-Control-Allow-Origin'] = access_control_allow_origin if access_control_allow_origin
76
78
  options['Origin'] = origin if origin
77
79
  options.merge!(metadata_to_headers)
@@ -21,7 +21,7 @@ module Fog
21
21
  response = Excon::Response.new
22
22
  response.status = 200
23
23
  response.body = {
24
- "flavor_access" => [{ "tenant_id" => tenant_id, "flavor_id" => flavor_ref }]
24
+ "flavor_access" => [{ "tenant_id" => tenant_id.to_s, "flavor_id" => flavor_ref.to_s }]
25
25
  }
26
26
  response
27
27
  end
@@ -33,15 +33,16 @@ module Fog
33
33
  response.status = 202
34
34
  data = {
35
35
  'id' => Fog::Mock.random_numbers(2),
36
- 'name' => name,
37
- 'description' => description,
36
+ 'displayName' => name,
37
+ 'displayDescription' => description,
38
38
  'size' => size,
39
39
  'status' => 'creating',
40
- 'snapshot_id' => '4',
41
- 'volume_type' => nil,
42
- 'availability_zone' => 'nova',
43
- 'created_at' => Time.now,
44
- 'attachments' => []
40
+ 'snapshotId' => nil,
41
+ 'volumeType' => 'None',
42
+ 'availabilityZone' => 'nova',
43
+ 'createdAt' => Time.now.strftime('%FT%T.%6N'),
44
+ 'attachments' => [],
45
+ 'metadata' => {}
45
46
  }
46
47
  self.data[:volumes][data['id']] = data
47
48
  response.body = { 'volume' => data }
@@ -16,7 +16,7 @@ module Fog
16
16
  response = Excon::Response.new
17
17
  response.status = 200
18
18
  response.body = {
19
- "flavor_access" => [{ "tenant_id" => @tenant_id, "flavor_id" => flavor_ref }]
19
+ "flavor_access" => [{ "tenant_id" => @tenant_id.to_s, "flavor_id" => flavor_ref.to_s }]
20
20
  }
21
21
  response
22
22
  end
@@ -6,7 +6,7 @@ module Fog
6
6
  request(
7
7
  :body => MultiJson.encode({
8
8
  "removeTenantAccess" => {
9
- "tenant" => tenant_id
9
+ "tenant" => tenant_id.to_s
10
10
  }
11
11
  }),
12
12
  :expects => [200, 203],
@@ -5,18 +5,18 @@ module Fog
5
5
 
6
6
  def create_image(attributes)
7
7
  data = {
8
- 'Content-Type'=>'application/octet-stream',
9
- 'x-image-meta-name' => attributes[:name],
10
- 'x-image-meta-disk-format' => attributes[:disk_format],
8
+ 'Content-Type' =>'application/octet-stream',
9
+ 'x-image-meta-name' => attributes[:name],
10
+ 'x-image-meta-disk-format' => attributes[:disk_format],
11
11
  'x-image-meta-container-format' => attributes[:container_format],
12
- 'x-image-meta-size' => attributes[:size],
13
- 'x-image-meta-is-public' => attributes[:is_public],
14
- 'x-image-meta-min-ram' => attributes[:min_ram],
15
- 'x-image-meta-min-disk' => attributes[:min_disk],
16
- 'x-image-meta-checksum' => attributes[:checksum],
17
- 'x-image-meta-owner' => attributes[:owner],
18
- 'x-glance-api-copy-from' => attributes[:copy_from]
19
- }.reject { |k,v| v.nil? }
12
+ 'x-image-meta-size' => attributes[:size],
13
+ 'x-image-meta-is-public' => attributes[:is_public],
14
+ 'x-image-meta-min-ram' => attributes[:min_ram],
15
+ 'x-image-meta-min-disk' => attributes[:min_disk],
16
+ 'x-image-meta-checksum' => attributes[:checksum],
17
+ 'x-image-meta-owner' => attributes[:owner],
18
+ 'x-glance-api-copy-from' => attributes[:copy_from]
19
+ }.reject {|k,v| v.nil? }
20
20
 
21
21
  body = String.new
22
22
  if attributes[:location]
@@ -52,23 +52,23 @@ module Fog
52
52
 
53
53
  image_id = Fog::Mock.random_hex(32)
54
54
  image = self.data[:images][image_id] = {
55
- 'name' => attributes['name'] || attributes[:name],
56
- 'size' => Fog::Mock.random_numbers(8).to_i,
57
- 'min_disk' => 0,
58
- 'disk_format' => attributes['disk_format'] || attributes[:disk_format] || 'raw',
59
- 'created_at' => Time.now.to_s,
60
- 'container_format' => attributes['container_format'] || attributes[:container_format] || 'bare',
55
+ 'name' => attributes[:name],
56
+ 'size' => attributes[:size] || Fog::Mock.random_numbers(8).to_i,
57
+ 'min_disk' => attributes[:min_disk] || 0,
58
+ 'disk_format' => attributes[:disk_format] || 'raw',
59
+ 'created_at' => Time.now.strftime('%FT%T.%6N'),
60
+ 'container_format' => attributes[:container_format] || 'bare',
61
61
  'deleted_at' => nil,
62
- 'updated_at' => Time.now.to_s,
63
- 'checksum' => Fog::Mock.random_hex(32),
62
+ 'updated_at' => Time.now.strftime('%FT%T.%6N'),
63
+ 'checksum' => attributes[:checksum] || Fog::Mock.random_hex(32),
64
64
  'id' => image_id,
65
65
  'deleted' => false,
66
66
  'protected' => false,
67
- 'is_public' => false,
67
+ 'is_public' => attributes[:is_public].to_s == 'true',
68
68
  'status' => 'queued',
69
- 'min_ram' => 0,
70
- 'owner' => attributes['owner'] || attributes[:owner],
71
- 'properties' => attributes['properties'] || attributes[:properties] || {}
69
+ 'min_ram' => attributes[:min_ram] || 0,
70
+ 'owner' => attributes[:owner],
71
+ 'properties' => attributes[:properties] || {}
72
72
  }
73
73
  response.body = { 'image'=> image }
74
74
  response