fog 1.2.0 → 1.3.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/Rakefile +1 -0
- data/changelog.txt +91 -0
- data/fog.gemspec +3 -3
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/compute.rb +5 -4
- data/lib/fog/aws/models/compute/security_group.rb +7 -1
- data/lib/fog/aws/models/compute/subnet.rb +0 -1
- data/lib/fog/aws/parsers/compute/create_security_group.rb +24 -0
- data/lib/fog/aws/requests/cloud_watch/get_metric_statistics.rb +1 -1
- data/lib/fog/aws/requests/compute/authorize_security_group_ingress.rb +19 -11
- data/lib/fog/aws/requests/compute/create_security_group.rb +5 -3
- data/lib/fog/aws/requests/compute/describe_security_groups.rb +1 -1
- data/lib/fog/aws/requests/storage/get_object_http_url.rb +2 -2
- data/lib/fog/aws/requests/storage/get_object_https_url.rb +2 -2
- data/lib/fog/aws/simpledb.rb +6 -1
- data/lib/fog/bin.rb +1 -0
- data/lib/fog/bin/ibm.rb +34 -0
- data/lib/fog/compute.rb +3 -0
- data/lib/fog/core/errors.rb +2 -0
- data/lib/fog/ibm.rb +176 -0
- data/lib/fog/ibm/compute.rb +233 -0
- data/lib/fog/ibm/models/compute/address.rb +62 -0
- data/lib/fog/ibm/models/compute/addresses.rb +28 -0
- data/lib/fog/ibm/models/compute/image.rb +61 -0
- data/lib/fog/ibm/models/compute/images.rb +27 -0
- data/lib/fog/ibm/models/compute/instance-type.rb +14 -0
- data/lib/fog/ibm/models/compute/instance-types.rb +15 -0
- data/lib/fog/ibm/models/compute/key.rb +35 -0
- data/lib/fog/ibm/models/compute/keys.rb +35 -0
- data/lib/fog/ibm/models/compute/location.rb +15 -0
- data/lib/fog/ibm/models/compute/locations.rb +27 -0
- data/lib/fog/ibm/models/compute/server.rb +193 -0
- data/lib/fog/ibm/models/compute/servers.rb +27 -0
- data/lib/fog/ibm/models/storage/offering.rb +18 -0
- data/lib/fog/ibm/models/storage/offerings.rb +19 -0
- data/lib/fog/ibm/models/storage/volume.rb +95 -0
- data/lib/fog/ibm/models/storage/volumes.rb +27 -0
- data/lib/fog/ibm/requests/compute/clone_image.rb +48 -0
- data/lib/fog/ibm/requests/compute/create_address.rb +50 -0
- data/lib/fog/ibm/requests/compute/create_image.rb +56 -0
- data/lib/fog/ibm/requests/compute/create_instance.rb +80 -0
- data/lib/fog/ibm/requests/compute/create_key.rb +61 -0
- data/lib/fog/ibm/requests/compute/delete_address.rb +46 -0
- data/lib/fog/ibm/requests/compute/delete_image.rb +43 -0
- data/lib/fog/ibm/requests/compute/delete_instance.rb +52 -0
- data/lib/fog/ibm/requests/compute/delete_key.rb +41 -0
- data/lib/fog/ibm/requests/compute/get_image.rb +67 -0
- data/lib/fog/ibm/requests/compute/get_image_agreement.rb +66 -0
- data/lib/fog/ibm/requests/compute/get_image_manifest.rb +39 -0
- data/lib/fog/ibm/requests/compute/get_instance.rb +76 -0
- data/lib/fog/ibm/requests/compute/get_instance_logs.rb +25 -0
- data/lib/fog/ibm/requests/compute/get_key.rb +49 -0
- data/lib/fog/ibm/requests/compute/get_location.rb +55 -0
- data/lib/fog/ibm/requests/compute/get_request.rb +78 -0
- data/lib/fog/ibm/requests/compute/list_address_offerings.rb +58 -0
- data/lib/fog/ibm/requests/compute/list_addresses.rb +53 -0
- data/lib/fog/ibm/requests/compute/list_images.rb +58 -0
- data/lib/fog/ibm/requests/compute/list_instances.rb +57 -0
- data/lib/fog/ibm/requests/compute/list_keys.rb +57 -0
- data/lib/fog/ibm/requests/compute/list_locations.rb +37 -0
- data/lib/fog/ibm/requests/compute/list_vlans.rb +52 -0
- data/lib/fog/ibm/requests/compute/modify_instance.rb +71 -0
- data/lib/fog/ibm/requests/compute/modify_key.rb +52 -0
- data/lib/fog/ibm/requests/storage/create_volume.rb +66 -0
- data/lib/fog/ibm/requests/storage/delete_volume.rb +42 -0
- data/lib/fog/ibm/requests/storage/get_volume.rb +72 -0
- data/lib/fog/ibm/requests/storage/list_offerings.rb +76 -0
- data/lib/fog/ibm/requests/storage/list_volumes.rb +47 -0
- data/lib/fog/ibm/storage.rb +82 -0
- data/lib/fog/ovirt/compute.rb +1 -0
- data/lib/fog/ovirt/models/compute/server.rb +5 -0
- data/lib/fog/ovirt/requests/compute/vm_ticket.rb +21 -0
- data/lib/fog/providers.rb +1 -0
- data/lib/fog/storage.rb +3 -0
- data/tests/aws/requests/compute/security_group_tests.rb +37 -39
- data/tests/compute/helper.rb +4 -0
- data/tests/compute/models/flavors_tests.rb +1 -1
- data/tests/helper.rb +1 -1
- data/tests/helpers/mock_helper.rb +2 -0
- data/tests/ibm/models/compute/image_tests.rb +10 -0
- data/tests/ibm/models/compute/key_tests.rb +23 -0
- data/tests/ibm/models/compute/keys_tests.rb +35 -0
- data/tests/ibm/models/compute/locations_tests.rb +18 -0
- data/tests/ibm/models/compute/server_tests.rb +88 -0
- data/tests/ibm/models/compute/servers_tests.rb +37 -0
- data/tests/ibm/models/storage/volume_tests.rb +60 -0
- data/tests/ibm/requests/compute/address_tests.rb +44 -0
- data/tests/ibm/requests/compute/image_tests.rb +110 -0
- data/tests/ibm/requests/compute/instance_tests.rb +102 -0
- data/tests/ibm/requests/compute/key_tests.rb +50 -0
- data/tests/ibm/requests/compute/location_tests.rb +28 -0
- data/tests/ibm/requests/storage/volume_tests.rb +100 -0
- metadata +122 -43
@@ -0,0 +1,46 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Deletes the Address that the authenticated user manages with the specified :address_id
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * address_id<~String> - Id of address
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# *'success'<~Bool>: true or false for success
|
15
|
+
def delete_address(address_id)
|
16
|
+
request(
|
17
|
+
:method => 'DELETE',
|
18
|
+
:expects => 200,
|
19
|
+
:path => "/addresses/#{address_id}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def delete_address(address_id)
|
28
|
+
response = Excon::Response.new
|
29
|
+
if address_exists? address_id
|
30
|
+
self.data[:addresses].delete address_id
|
31
|
+
response.status = 200
|
32
|
+
response.body = { "success" => true }
|
33
|
+
else
|
34
|
+
response.status = 404
|
35
|
+
end
|
36
|
+
response
|
37
|
+
end
|
38
|
+
|
39
|
+
def address_exists?(address_id)
|
40
|
+
self.data[:addresses].key? address_id
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Deletes the image that the authenticated user manages with the specified :image_id
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * image_id<~String> - Id of image
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# *'success'<~Bool>: true or false for success
|
15
|
+
def delete_image(image_id)
|
16
|
+
request(
|
17
|
+
:method => 'DELETE',
|
18
|
+
:expects => 200,
|
19
|
+
:path => "/offerings/image/#{image_id}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
class Mock
|
25
|
+
|
26
|
+
def delete_image(image_id)
|
27
|
+
response = Excon::Response.new
|
28
|
+
# TODO: We should probably check that an image is deleteable.
|
29
|
+
# i.e. that the user has appropriate permissions
|
30
|
+
if image_exists? image_id
|
31
|
+
self.data[:images].delete image_id
|
32
|
+
response.status = 200
|
33
|
+
response.body = {"success"=>true}
|
34
|
+
else
|
35
|
+
response.status = 404
|
36
|
+
end
|
37
|
+
response
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Deletes the Instance that the authenticated user manages with the specified :instance_id
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * instance_id<~String> - Id of instance
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# *'success'<~Bool>: true or false for success
|
15
|
+
def delete_instance(instance_id)
|
16
|
+
request(
|
17
|
+
:method => 'DELETE',
|
18
|
+
:expects => 200,
|
19
|
+
:path => "/instances/#{instance_id}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
def delete_instance(instance_id)
|
28
|
+
response = Excon::Response.new
|
29
|
+
if deleteable? instance_id
|
30
|
+
# remove from memoreeeez.
|
31
|
+
self.data[:instances].delete instance_id
|
32
|
+
response.body = { 'success' => true }
|
33
|
+
response.status = 200
|
34
|
+
else
|
35
|
+
# TODO: we should really return a 412 if the instance is in an invalid state, and a 404 if it doesn't exist.
|
36
|
+
response.status = 404
|
37
|
+
end
|
38
|
+
response
|
39
|
+
end
|
40
|
+
|
41
|
+
# we can't delete the instance if it doesn't exist, or is in an invalid state.
|
42
|
+
def deleteable?(instance_id)
|
43
|
+
return false unless instance_exists? instance_id
|
44
|
+
instance = self.data[:instances][instance_id]
|
45
|
+
return false if [0, 1, 7, 14, 15].include?(instance["status"].to_i)
|
46
|
+
true
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Deletes the key specified with key_name
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * key_name<~String> - name of key to be deleted
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# *'success'<~Bool>: true or false for success
|
15
|
+
def delete_key(key_name)
|
16
|
+
request(
|
17
|
+
:method => 'DELETE',
|
18
|
+
:expects => 200,
|
19
|
+
:path => "/keys/#{key_name}"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
class Mock
|
25
|
+
|
26
|
+
def delete_key(key_name)
|
27
|
+
response = Excon::Response.new
|
28
|
+
if key_exists? key_name
|
29
|
+
self.data[:keys].delete(key_name)
|
30
|
+
response.status = 200
|
31
|
+
response.body = {"success"=>true}
|
32
|
+
else
|
33
|
+
response.status = 404
|
34
|
+
end
|
35
|
+
response
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Returns details of image specified by id
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# 'image_id'<~String>: id of desired image
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * 'name'<~String>: image name
|
15
|
+
# * 'location'<~String>: instance location id
|
16
|
+
# * 'createdTime'<~Integer>: time created in epoch time
|
17
|
+
# * 'supportedInstanceTypes'<~Array>: list of prices per image
|
18
|
+
# * 'pricePerQuantity'<~Integer>:
|
19
|
+
# * 'effectiveDate'<~Fixnum>:
|
20
|
+
# * 'rate'<~Float>: price per unit
|
21
|
+
# * 'countryCode'<~String>:
|
22
|
+
# * 'unitOfMeasure'<~String>: unit of measurement
|
23
|
+
# * 'currencyCode'<~String>: currency billed in
|
24
|
+
# * 'productCodes'<~Array>:
|
25
|
+
# * 'id'<~String>:
|
26
|
+
# * 'documentation'<~String>: link to documentation for image
|
27
|
+
# * 'manifest'<~String>: link to xml manifest file
|
28
|
+
# * 'description'<~String>: text description of image
|
29
|
+
# * 'visibility'<~String>: status of visibilty of image. known values so far are "PUBLIC" and "PRIVATE"
|
30
|
+
# * 'platform'<~String>: operating system
|
31
|
+
# * 'architecture'<~String>: architecture supported by image
|
32
|
+
# * 'documentation'<~String>: link to documentation for image
|
33
|
+
# * 'owner'<~String>: owner of image
|
34
|
+
# * 'state'<~Integer>: state of availability of image
|
35
|
+
def get_image(image_id)
|
36
|
+
request(
|
37
|
+
:method => 'GET',
|
38
|
+
:expects => 200,
|
39
|
+
:path => "/offerings/image/#{image_id}"
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
class Mock
|
46
|
+
|
47
|
+
def get_image(image_id)
|
48
|
+
response = Excon::Response.new
|
49
|
+
if image_exists? image_id
|
50
|
+
response.status = 200
|
51
|
+
response.body = self.data[:images][image_id]
|
52
|
+
else
|
53
|
+
response.status = 404
|
54
|
+
end
|
55
|
+
response
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def image_exists?(image_id)
|
61
|
+
self.data[:images].key? image_id
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Returns license agreement of image specified by id
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# 'image_id'<~String>: id of desired image
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * 'text'<~String>: text of license
|
15
|
+
# * 'id'<~String>: id of image
|
16
|
+
# * 'attachments'<~Array>: Additional agreements attached to image
|
17
|
+
# * 'label'<~String>: description of attachment
|
18
|
+
# * 'url'<~String>: url to retrieve attachment
|
19
|
+
# * 'type'<~Integer>: type of attachment
|
20
|
+
def get_image_agreement(image_id)
|
21
|
+
request(
|
22
|
+
:method => 'GET',
|
23
|
+
:expects => 200,
|
24
|
+
:path => "/offerings/image/#{image_id}/agreement"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class Mock
|
31
|
+
|
32
|
+
# TODO: Fix this so they work.
|
33
|
+
def get_image_agreement(image_id)
|
34
|
+
response = Excon::Response.new
|
35
|
+
response.status = 200
|
36
|
+
response.body = {"text"=>
|
37
|
+
"test, operating system is SUSE Linux Enterprise Server/11 SP1 - English\n\nYour access to and use of the Service, including all selected options, are governed by the terms of the Agreement signed between your Enterprise and IBM. Each Service is also governed by one or more Attachments (including, for example, Image Terms Attachments). Applicable Attachments are part of the Agreement between you and IBM and include Attachments for Services you acquire after the Agreement was signed. The Agreement also references applicable IBM and third party end user license agreements that govern the use of IBM software and operating system software provided as part of an Image.\n\nYou are responsible for complying with the terms of the Agreement (including applicable Attachments) and applicable license agreements. You may review the terms for the Service by 1) obtaining information regarding the Agreement from your Account Administrator and 2) accessing the Asset Catalog to review specific Image Terms and end user license agreements for IBM and third party software provided as part of an Image. ",
|
38
|
+
"id"=>"20020159",
|
39
|
+
"attachments"=>
|
40
|
+
[{"label"=>"Service Description for Developement & Test Service",
|
41
|
+
"url"=>
|
42
|
+
"https://www-147.ibm.com/cloud/enterprise/static/internal_user_agreement.pdf",
|
43
|
+
"type"=>0},
|
44
|
+
{"label"=>"Smart Business on the IBM Public Cloud Agreement",
|
45
|
+
"url"=>
|
46
|
+
"https://www-147.ibm.com/cloud/enterprise/static/internal_user_agreement.pdf",
|
47
|
+
"type"=>1},
|
48
|
+
{"label"=>
|
49
|
+
"End User License for SUSE 10.2 Linux Enterprise Server software",
|
50
|
+
"url"=>
|
51
|
+
"https://www.novell.com/licensing/eula/sles_10/sles_10_english.pdf",
|
52
|
+
"type"=>2},
|
53
|
+
{"label"=>
|
54
|
+
"End User License for SUSE 11.0 Linux Enterprise Server software",
|
55
|
+
"url"=>"https://www.novell.com/licensing/eula/sles_11/sles_11_en.pdf",
|
56
|
+
"type"=>2},
|
57
|
+
{"label"=>"End User License for RedHat Linux RHEL software",
|
58
|
+
"url"=>"https://www.redhat.com/licenses/",
|
59
|
+
"type"=>2}]}
|
60
|
+
response
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Returns manifest of image specified by id
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# 'image_id'<~String>: id of desired image
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * 'manifest'<~String>: manifest of image in xml
|
15
|
+
def get_image_manifest(image_id)
|
16
|
+
request(
|
17
|
+
:method => 'GET',
|
18
|
+
:expects => 200,
|
19
|
+
:path => "/offerings/image/#{image_id}/manifest"
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
class Mock
|
26
|
+
|
27
|
+
# TODO: Create a data store for this.
|
28
|
+
def get_image_manifest(image_id)
|
29
|
+
response = Excon::Response.new
|
30
|
+
response.status = 200
|
31
|
+
response.body = {"manifest"=>
|
32
|
+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><parameters xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"platform:/resource/com.ibm.ccl.devcloud.client/schema/parameters.xsd\">\n\t<firewall>\n\t\t<rule>\n\t\t\t<source>0.0.0.0/0</source>\n\t\t\t<minport>1</minport>\n\t\t\t<maxport>65535</maxport>\n\t\t</rule>\n\t</firewall>\n</parameters>"}
|
33
|
+
response
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Returns the Instance that the authenticated user manages with the specified :instance_id
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# * instance_id<~String> - Id of instance
|
10
|
+
#
|
11
|
+
# ==== Returns
|
12
|
+
# * response<~Excon::Response>:
|
13
|
+
# * body<~Hash>:
|
14
|
+
# * 'name'<~String>: instance name
|
15
|
+
# * 'location'<~String>: instance location id
|
16
|
+
# * 'keyName'<~String>: instance assigned keypair
|
17
|
+
# * 'primaryIP'<~Hash>: assigned ip address, type, and hostname
|
18
|
+
# * 'productCodes'<~Array>: associated product codes
|
19
|
+
# * 'requestId'<~String>:
|
20
|
+
# * 'imageId'<~String>:
|
21
|
+
# * 'launchTime'<~Integer>: UNIX time integer representing when the instance was launched
|
22
|
+
# * 'id'<~String>: instance id
|
23
|
+
# * 'volumes'<~Array>:
|
24
|
+
# * 'isMiniEphemeral'<~Boolean>: minimal local storage
|
25
|
+
# * 'instanceType'<~String>: instance type
|
26
|
+
# * 'diskSize'<~String>: instance disk size
|
27
|
+
# * 'requestName'<~String>: instance request name
|
28
|
+
# * 'secondaryIP'<~Array>: additional IP Addresses associated with this instance
|
29
|
+
# * 'status'<~Integer>: instance status flag
|
30
|
+
# * 'software'<~Array>: Software associated with this instance
|
31
|
+
# * 'application'<~Hash>: Application name, type, and version (primarily OS information)
|
32
|
+
# * 'expirationTime'<~Integer>: UNIX timestamp representing when the instance expires
|
33
|
+
# * 'owner'<~String>: instance owner
|
34
|
+
def get_instance(instance_id)
|
35
|
+
request(
|
36
|
+
:method => 'GET',
|
37
|
+
:expects => 200,
|
38
|
+
:path => "/instances/#{instance_id}"
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
class Mock
|
45
|
+
|
46
|
+
def get_instance(instance_id)
|
47
|
+
response = Excon::Response.new
|
48
|
+
if instance_exists? instance_id
|
49
|
+
activate_instance(instance_id) # Set it to Active if it's not running
|
50
|
+
response.status = 200
|
51
|
+
response.body = self.data[:instances][instance_id]
|
52
|
+
else
|
53
|
+
raise Fog::Compute::IBM::NotFound
|
54
|
+
end
|
55
|
+
response
|
56
|
+
end
|
57
|
+
|
58
|
+
# Checks if an instance exists
|
59
|
+
def instance_exists?(instance_id)
|
60
|
+
self.data[:instances].key? instance_id
|
61
|
+
end
|
62
|
+
|
63
|
+
# Sets instance status to Active if it's not already set.
|
64
|
+
def activate_instance(instance_id)
|
65
|
+
self.data[:instances][instance_id]["status"] = 5 unless instance_active? instance_id
|
66
|
+
end
|
67
|
+
|
68
|
+
# Checks if an instance is Active
|
69
|
+
def instance_active?(instance_id)
|
70
|
+
self.data[:instances][instance_id]["status"] == 5
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class IBM
|
4
|
+
class Real
|
5
|
+
|
6
|
+
# Get an instance's logs
|
7
|
+
#
|
8
|
+
# ==== Returns
|
9
|
+
# * response<~Excon::Response>:
|
10
|
+
# * body<~Hash>:
|
11
|
+
# * logs<~Array>:
|
12
|
+
# TODO: docs
|
13
|
+
def get_instance_logs(instance_id, start_index=nil)
|
14
|
+
request(
|
15
|
+
:method => 'GET',
|
16
|
+
:expects => 200,
|
17
|
+
:path => "/instances/#{instance_id}/logs" +
|
18
|
+
(start_index ? "?startIndex=#{start_index}" : '')
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|