fog 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. data/Rakefile +1 -0
  2. data/changelog.txt +91 -0
  3. data/fog.gemspec +3 -3
  4. data/lib/fog.rb +1 -1
  5. data/lib/fog/aws/compute.rb +5 -4
  6. data/lib/fog/aws/models/compute/security_group.rb +7 -1
  7. data/lib/fog/aws/models/compute/subnet.rb +0 -1
  8. data/lib/fog/aws/parsers/compute/create_security_group.rb +24 -0
  9. data/lib/fog/aws/requests/cloud_watch/get_metric_statistics.rb +1 -1
  10. data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +19 -11
  11. data/lib/fog/aws/requests/compute/create_security_group.rb +5 -3
  12. data/lib/fog/aws/requests/compute/describe_security_groups.rb +1 -1
  13. data/lib/fog/aws/requests/storage/get_object_http_url.rb +2 -2
  14. data/lib/fog/aws/requests/storage/get_object_https_url.rb +2 -2
  15. data/lib/fog/aws/simpledb.rb +6 -1
  16. data/lib/fog/bin.rb +1 -0
  17. data/lib/fog/bin/ibm.rb +34 -0
  18. data/lib/fog/compute.rb +3 -0
  19. data/lib/fog/core/errors.rb +2 -0
  20. data/lib/fog/ibm.rb +176 -0
  21. data/lib/fog/ibm/compute.rb +233 -0
  22. data/lib/fog/ibm/models/compute/address.rb +62 -0
  23. data/lib/fog/ibm/models/compute/addresses.rb +28 -0
  24. data/lib/fog/ibm/models/compute/image.rb +61 -0
  25. data/lib/fog/ibm/models/compute/images.rb +27 -0
  26. data/lib/fog/ibm/models/compute/instance-type.rb +14 -0
  27. data/lib/fog/ibm/models/compute/instance-types.rb +15 -0
  28. data/lib/fog/ibm/models/compute/key.rb +35 -0
  29. data/lib/fog/ibm/models/compute/keys.rb +35 -0
  30. data/lib/fog/ibm/models/compute/location.rb +15 -0
  31. data/lib/fog/ibm/models/compute/locations.rb +27 -0
  32. data/lib/fog/ibm/models/compute/server.rb +193 -0
  33. data/lib/fog/ibm/models/compute/servers.rb +27 -0
  34. data/lib/fog/ibm/models/storage/offering.rb +18 -0
  35. data/lib/fog/ibm/models/storage/offerings.rb +19 -0
  36. data/lib/fog/ibm/models/storage/volume.rb +95 -0
  37. data/lib/fog/ibm/models/storage/volumes.rb +27 -0
  38. data/lib/fog/ibm/requests/compute/clone_image.rb +48 -0
  39. data/lib/fog/ibm/requests/compute/create_address.rb +50 -0
  40. data/lib/fog/ibm/requests/compute/create_image.rb +56 -0
  41. data/lib/fog/ibm/requests/compute/create_instance.rb +80 -0
  42. data/lib/fog/ibm/requests/compute/create_key.rb +61 -0
  43. data/lib/fog/ibm/requests/compute/delete_address.rb +46 -0
  44. data/lib/fog/ibm/requests/compute/delete_image.rb +43 -0
  45. data/lib/fog/ibm/requests/compute/delete_instance.rb +52 -0
  46. data/lib/fog/ibm/requests/compute/delete_key.rb +41 -0
  47. data/lib/fog/ibm/requests/compute/get_image.rb +67 -0
  48. data/lib/fog/ibm/requests/compute/get_image_agreement.rb +66 -0
  49. data/lib/fog/ibm/requests/compute/get_image_manifest.rb +39 -0
  50. data/lib/fog/ibm/requests/compute/get_instance.rb +76 -0
  51. data/lib/fog/ibm/requests/compute/get_instance_logs.rb +25 -0
  52. data/lib/fog/ibm/requests/compute/get_key.rb +49 -0
  53. data/lib/fog/ibm/requests/compute/get_location.rb +55 -0
  54. data/lib/fog/ibm/requests/compute/get_request.rb +78 -0
  55. data/lib/fog/ibm/requests/compute/list_address_offerings.rb +58 -0
  56. data/lib/fog/ibm/requests/compute/list_addresses.rb +53 -0
  57. data/lib/fog/ibm/requests/compute/list_images.rb +58 -0
  58. data/lib/fog/ibm/requests/compute/list_instances.rb +57 -0
  59. data/lib/fog/ibm/requests/compute/list_keys.rb +57 -0
  60. data/lib/fog/ibm/requests/compute/list_locations.rb +37 -0
  61. data/lib/fog/ibm/requests/compute/list_vlans.rb +52 -0
  62. data/lib/fog/ibm/requests/compute/modify_instance.rb +71 -0
  63. data/lib/fog/ibm/requests/compute/modify_key.rb +52 -0
  64. data/lib/fog/ibm/requests/storage/create_volume.rb +66 -0
  65. data/lib/fog/ibm/requests/storage/delete_volume.rb +42 -0
  66. data/lib/fog/ibm/requests/storage/get_volume.rb +72 -0
  67. data/lib/fog/ibm/requests/storage/list_offerings.rb +76 -0
  68. data/lib/fog/ibm/requests/storage/list_volumes.rb +47 -0
  69. data/lib/fog/ibm/storage.rb +82 -0
  70. data/lib/fog/ovirt/compute.rb +1 -0
  71. data/lib/fog/ovirt/models/compute/server.rb +5 -0
  72. data/lib/fog/ovirt/requests/compute/vm_ticket.rb +21 -0
  73. data/lib/fog/providers.rb +1 -0
  74. data/lib/fog/storage.rb +3 -0
  75. data/tests/aws/requests/compute/security_group_tests.rb +37 -39
  76. data/tests/compute/helper.rb +4 -0
  77. data/tests/compute/models/flavors_tests.rb +1 -1
  78. data/tests/helper.rb +1 -1
  79. data/tests/helpers/mock_helper.rb +2 -0
  80. data/tests/ibm/models/compute/image_tests.rb +10 -0
  81. data/tests/ibm/models/compute/key_tests.rb +23 -0
  82. data/tests/ibm/models/compute/keys_tests.rb +35 -0
  83. data/tests/ibm/models/compute/locations_tests.rb +18 -0
  84. data/tests/ibm/models/compute/server_tests.rb +88 -0
  85. data/tests/ibm/models/compute/servers_tests.rb +37 -0
  86. data/tests/ibm/models/storage/volume_tests.rb +60 -0
  87. data/tests/ibm/requests/compute/address_tests.rb +44 -0
  88. data/tests/ibm/requests/compute/image_tests.rb +110 -0
  89. data/tests/ibm/requests/compute/instance_tests.rb +102 -0
  90. data/tests/ibm/requests/compute/key_tests.rb +50 -0
  91. data/tests/ibm/requests/compute/location_tests.rb +28 -0
  92. data/tests/ibm/requests/storage/volume_tests.rb +100 -0
  93. metadata +122 -43
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Compute
3
+ class IBM
4
+ class Real
5
+
6
+ # Returns the list of Images available to be provisioned on the IBM DeveloperCloud.
7
+ #
8
+ # ==== Parameters
9
+ # No parameters
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * 'locations'<~Array>: list of locations
15
+ def list_locations
16
+ request(
17
+ :method => 'GET',
18
+ :expects => 200,
19
+ :path => "/locations"
20
+ )
21
+ end
22
+
23
+ end
24
+
25
+ class Mock
26
+
27
+ def list_locations
28
+ response = Excon::Response.new
29
+ response.status = 200
30
+ response.body = { "locations" => self.data[:locations].values }
31
+ response
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Compute
3
+ class IBM
4
+ class Real
5
+
6
+ # Returns the vlan offerings for user
7
+ #
8
+ # ==== Parameters
9
+ # No parameters
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * 'addresses'<~Array>: list of addresses
15
+ # * 'location'<~String>: location of address
16
+ # * 'mode'<~Integer>:
17
+ # * 'offeringId'<~String>: offering ID
18
+ # * 'id'<~String>: id
19
+ # * 'type'<~Integer>: TODO unsure
20
+ # * 'ip'<~String>: IP address.. with space at the end
21
+ # * 'hostname'<~String>: seems to be same as ip
22
+ # * 'state'<~Integer>: state of address
23
+ def list_vlans
24
+ request(
25
+ :method => 'GET',
26
+ :expects => 200,
27
+ :path => '/offerings/vlan'
28
+ )
29
+ end
30
+
31
+ end
32
+ class Mock
33
+
34
+ def list_vlans
35
+ response = Excon::Response.new
36
+ response.status = 200
37
+ response.body = {"addresses"=>
38
+ [{"location"=>"101",
39
+ "mode"=>0,
40
+ "offeringId"=>"20001223",
41
+ "id"=>"75321",
42
+ "type"=>1,
43
+ "ip"=>"170.224.192.210 ",
44
+ "hostname"=>"170.224.192.210 ",
45
+ "state"=>2}]},
46
+ response
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,71 @@
1
+ module Fog
2
+ module Compute
3
+ class IBM
4
+ class Real
5
+
6
+ # Modify an instance
7
+ #
8
+ # ==== Parameters
9
+ # * instance_id<~String> - id of instance to rename
10
+ # * params<~Hash> - depends on type of request
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'success'<~Bool>:
16
+ # OR
17
+ # * response<~Excon::Response>:
18
+ # * body<~Hash>:
19
+ # ????
20
+ # * 'expirationTime'<~Integer>: new expiration time of instance (epoch)
21
+ #
22
+ # Note: The feature of dynamically attaching or detaching storage is only
23
+ # supported by data centers where the KVM host version is RHEL 6.1. If the
24
+ # feature is not supported by the data center, you will get an exception like
25
+ # "Unsupported exception. Dynamic features are not supported on the KVM
26
+ # Host".
27
+ def modify_instance(instance_id, options={})
28
+ request(
29
+ :method => 'PUT',
30
+ :expects => 200,
31
+ :path => "/instances/#{instance_id}",
32
+ :body => options
33
+ )
34
+ end
35
+ end
36
+
37
+ class Mock
38
+
39
+ def modify_instance(instance_id, params={})
40
+ response = Excon::Response.new
41
+ if instance_exists? instance_id
42
+ if params['state'] == 'restart'
43
+ self.data[:instances][instance_id]["status"] = "8"
44
+ response.status = 200
45
+ response.body = { "success" => true }
46
+ elsif params['type'] == 'attach' || params['type'] == 'detach'
47
+ if Fog::Storage[:ibm].volume_exists?(params['volume_id'])
48
+ # TODO: Update the instance in the data hash, assuming IBM ever gets this feature working properly.
49
+ response.status = 415
50
+ else
51
+ response.status = 404
52
+ end
53
+ elsif params['name']
54
+ self.data[:instances][instance_id]["name"] = params['name']
55
+ response.status = 200
56
+ response.body = { "success" => true }
57
+ elsif params['expirationTime']
58
+ self.data[:instances][instance_id]["expirationTime"] = params['expirationTime']
59
+ response.status = 200
60
+ response.body = { 'expirationTime' => params['expirationTime'] }
61
+ end
62
+ else
63
+ response.status = 404
64
+ end
65
+ response
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,52 @@
1
+ module Fog
2
+ module Compute
3
+ class IBM
4
+ class Real
5
+
6
+ # Modify a key
7
+ #
8
+ # ==== Parameters
9
+ # * key_name<~String> - name of key to be modified
10
+ # * params<~Hash> - depends on type of request
11
+ #
12
+ # ==== Returns
13
+ # * response<~Excon::Response>:
14
+ # * body<~Hash>:
15
+ # * 'success'<~Bool>: success status of update request
16
+ def modify_key(key_name, params={})
17
+ request(
18
+ :method => 'PUT',
19
+ :expects => 200,
20
+ :path => "/keys/#{key_name}",
21
+ :body => params
22
+ )
23
+ end
24
+
25
+ end
26
+ class Mock
27
+
28
+ def modify_key(key_name, params={})
29
+ response = Excon::Response.new
30
+ if key_exists? key_name
31
+ if params['public_key']
32
+ self.data[:keys][key_name]['keyMaterial'] = public_key
33
+ self.data[:keys][key_name]['lastModifiedTime'] = Fog::IBM::Mock.launch_time
34
+ end
35
+ if params['default']
36
+ self.data[:keys].values.each do |key|
37
+ key['default'] = false
38
+ end
39
+ self.data[:keys][key_name]['default'] = true
40
+ end
41
+ response.status = 200
42
+ response.body = {"success"=>true}
43
+ else
44
+ response.status = 404
45
+ end
46
+ response
47
+ end
48
+
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,66 @@
1
+ module Fog
2
+ module Storage
3
+ class IBM
4
+ class Real
5
+
6
+ # Requests a new Storage Volume be created.
7
+ #
8
+ # ==== Parameters
9
+ # * name<~String> - The alias to use to referance storage volume
10
+ # * offeringID<~String> - offering id can be requested from /computecloud/enterprise/api/rest/20100331/offerings/storage
11
+ # * format<~String> - filesystem format for volume
12
+ # * location<~String> - datacenter location for volume
13
+ # * size<~String> - size of volume desired (Small, Medium, Large) (varies by location what size actually is)
14
+ # * storageAreaID<~String> - (not supported yet)
15
+ #
16
+ # === Returns
17
+ # * response<~Excon::Response>:
18
+ # * body<~Hash>:
19
+ # * name<~String> - The alias to use to referance storage volume
20
+ # * format<~String> - filesystem format for storage
21
+ # * location<~String> - datacenter location for storage
22
+ # * createdTime<~Integer> - Epoch time of creation
23
+ # * size<~String> - size of storage desired (Small, Medium, Large) (varies by location what size actually is)
24
+ # * productCodes<~Array> -
25
+ # * offeringID<~String> - offering id can be requested from /computecloud/enterprise/api/rest/20100331/offerings/storage
26
+ # * id<~String> - id of new storage
27
+ # * owner<~String> - owner of new storage
28
+ # * state<~Integer> - state of newly requested storage
29
+ def create_volume(name, offering_id, format, location_id, size)
30
+ request(
31
+ :method => 'POST',
32
+ :expects => 200,
33
+ :path => '/storage',
34
+ :body => {
35
+ 'name' => name,
36
+ 'offeringID' => offering_id,
37
+ 'format' => format,
38
+ 'location' => location_id,
39
+ 'size' => size
40
+ }
41
+ )
42
+ end
43
+ end
44
+
45
+ class Mock
46
+
47
+ def create_volume(name, offering_id, format, location_id, size)
48
+ volume = Fog::IBM::Mock.create_volume(name, offering_id, format, location_id, size)
49
+ self.data[:volumes][volume['id']] = volume
50
+ response = Excon::Response.new
51
+ response.status = 200
52
+ response.body = format_create_volume_response_for(volume['id'])
53
+ response
54
+ end
55
+
56
+ # The create_volume response doesn't contain ioPrice either
57
+ def format_create_volume_response_for(volume_id)
58
+ # If we aren't attached/ready, make us ready
59
+ ready_volume(volume_id) unless volume_attached? volume_id
60
+ self.data[:volumes][volume_id].reject { |k,v| k == 'ioPrice' }
61
+ end
62
+
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,42 @@
1
+ module Fog
2
+ module Storage
3
+ class IBM
4
+ class Real
5
+
6
+ # Deletes the storage that the authenticated user manages with the specified :storage_id
7
+ #
8
+ # ==== Parameters
9
+ # * volume_id<~String> - Id of storage volume
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # *'success'<~Bool>: true or false for success
15
+ def delete_volume(volume_id)
16
+ request(
17
+ :method => 'DELETE',
18
+ :expects => 200,
19
+ :path => "/storage/#{volume_id}"
20
+ )
21
+ end
22
+
23
+ end
24
+
25
+ class Mock
26
+
27
+ def delete_volume(volume_id)
28
+ response = Excon::Response.new
29
+ if volume_exists? volume_id
30
+ self.data[:volumes].delete volume_id
31
+ response.status = 200
32
+ response.body = {"success"=>true}
33
+ else
34
+ response.status = 404
35
+ end
36
+ response
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,72 @@
1
+ module Fog
2
+ module Storage
3
+ class IBM
4
+ class Real
5
+
6
+ # Used to retrieve the specified storage volume for specified volume_id
7
+ #
8
+ # ==== Parameters
9
+ # * volume_id<~String> - Id of storage volume
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ def get_volume(volume_id)
15
+ request(
16
+ :method => 'GET',
17
+ :expects => 200,
18
+ :path => "/storage/#{volume_id}"
19
+ )
20
+ end
21
+
22
+ end
23
+
24
+ class Mock
25
+
26
+ # For whatever reason, get_volume returns different data than an entry in list_volumes
27
+ def get_volume(volume_id)
28
+ response = Excon::Response.new
29
+ if volume_exists? volume_id
30
+ response.status = 200
31
+ response.body = format_get_volume_response_for(volume_id)
32
+ else
33
+ response.status = 404
34
+ end
35
+ response
36
+ end
37
+
38
+ # get_volume response doesn't contain instanceId
39
+ def format_get_volume_response_for(volume_id)
40
+ # If we aren't attached/ready, make us ready
41
+ ready_volume(volume_id) unless volume_attached? volume_id
42
+ self.data[:volumes][volume_id].reject { |k,v| k == 'instanceId' }
43
+ end
44
+
45
+ # The list_volumes response doesn't contain ioPrice
46
+ def format_list_volumes_response
47
+ self.data[:volumes].values.dup.map { |volume| volume.reject { |k,v| k == 'ioPrice'} }
48
+ end
49
+
50
+ def volume_exists?(volume_id)
51
+ self.data[:volumes].key? volume_id
52
+ end
53
+
54
+ # Checks if an volume is Active
55
+ def volume_ready?(volume_id)
56
+ self.data[:volumes][volume_id]['state'] == 4
57
+ end
58
+
59
+ def volume_attached?(volume_id)
60
+ self.data[:volumes][volume_id]['instanceId'] != "0"
61
+ end
62
+
63
+ # Sets volume status to Detached if it's not already set, and or attached
64
+ def ready_volume(volume_id)
65
+ # If not ready, make ready
66
+ self.data[:volumes][volume_id]['state'] = 4
67
+ end
68
+
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,76 @@
1
+ module Fog
2
+ module Storage
3
+ class IBM
4
+ class Real
5
+
6
+ # Returns the offerings of storage for the authenticated user
7
+ #
8
+ # ==== Parameters
9
+ # No parameters
10
+ #
11
+ # ==== Returns
12
+ # * response<~Excon::Response>:
13
+ # * body<~Hash>:
14
+ # * 'volumes'<~Array>: list of images
15
+ # * 'name'<~String>: Name of storage offering
16
+ # * 'price'<~Hash>: hash containing pricing information
17
+ # * 'pricePerQuantity'<~Integer>:
18
+ # * 'effectiveDate'<~Integer>: starting date price is effective
19
+ # * 'rate'<~Float>: rate per unit
20
+ # * 'countryCode'<~String>:
21
+ # * 'currencyCode'<~String>: currency used
22
+ # * 'location'<~String>: datacenter location string
23
+ # * 'id'<~String>: id of offering
24
+ # * 'formats'<~Array>: filesystem format storage offered with
25
+ # * 'label'<~String>: label for filesystem
26
+ # * 'id'<~String>: string used for id of format
27
+ # * 'capacity'<~Integer>: size in GB's
28
+ def list_offerings
29
+ request(
30
+ :method => 'GET',
31
+ :expects => 200,
32
+ :path => '/offerings/storage'
33
+ )
34
+ end
35
+
36
+ end
37
+
38
+ class Mock
39
+
40
+ def list_offerings
41
+ response = Excon::Response.new
42
+ response.status = 200
43
+ response.body = {"volumes"=>
44
+ [{"name"=>"Small",
45
+ "price"=>
46
+ {"pricePerQuantity"=>1,
47
+ "effectiveDate"=>-1,
48
+ "rate"=>0.0384,
49
+ "countryCode"=>"897",
50
+ "unitOfMeasure"=>"UHR",
51
+ "currencyCode"=>"USD"},
52
+ "location"=>"61",
53
+ "id"=>"20001208",
54
+ "formats"=>
55
+ [{"label"=>"ext3", "id"=>"EXT3"}, {"label"=>"raw", "id"=>"RAW"}],
56
+ "capacity"=>256},
57
+ {"name"=>"Small",
58
+ "price"=>
59
+ {"pricePerQuantity"=>1,
60
+ "effectiveDate"=>-1,
61
+ "rate"=>0.0384,
62
+ "countryCode"=>"897",
63
+ "unitOfMeasure"=>"UHR",
64
+ "currencyCode"=>"USD"},
65
+ "location"=>"141",
66
+ "id"=>"20001208",
67
+ "formats"=>
68
+ [{"label"=>"ext3", "id"=>"EXT3"}, {"label"=>"raw", "id"=>"RAW"}],
69
+ "capacity"=>256}]},
70
+ response
71
+ end
72
+
73
+ end
74
+ end
75
+ end
76
+ end