fog-softlayer 0.4.2.pre → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CONTRIBUTORS.md +2 -0
- data/examples/compute.md +37 -1
- data/lib/fog/softlayer/compute.rb +8 -1
- data/lib/fog/softlayer/dns.rb +0 -1
- data/lib/fog/softlayer/ext/hash.rb +6 -0
- data/lib/fog/softlayer/ext/string.rb +20 -0
- data/lib/fog/softlayer/models/compute/flavor.rb +0 -2
- data/lib/fog/softlayer/models/compute/flavors.rb +0 -1
- data/lib/fog/softlayer/models/compute/image.rb +0 -2
- data/lib/fog/softlayer/models/compute/images.rb +0 -1
- data/lib/fog/softlayer/models/compute/key_pair.rb +0 -2
- data/lib/fog/softlayer/models/compute/key_pairs.rb +0 -1
- data/lib/fog/softlayer/models/compute/network_component.rb +0 -2
- data/lib/fog/softlayer/models/compute/network_components.rb +0 -1
- data/lib/fog/softlayer/models/compute/server.rb +10 -0
- data/lib/fog/softlayer/models/compute/servers.rb +25 -1
- data/lib/fog/softlayer/models/compute/tag.rb +0 -2
- data/lib/fog/softlayer/models/compute/tags.rb +0 -1
- data/lib/fog/softlayer/models/dns/domain.rb +1 -1
- data/lib/fog/softlayer/models/dns/domains.rb +1 -1
- data/lib/fog/softlayer/models/dns/record.rb +0 -1
- data/lib/fog/softlayer/models/dns/records.rb +1 -1
- data/lib/fog/softlayer/models/network/datacenter.rb +0 -2
- data/lib/fog/softlayer/models/network/datacenters.rb +0 -1
- data/lib/fog/softlayer/models/network/ip.rb +0 -2
- data/lib/fog/softlayer/models/network/ips.rb +0 -1
- data/lib/fog/softlayer/models/network/network.rb +0 -2
- data/lib/fog/softlayer/models/network/networks.rb +0 -1
- data/lib/fog/softlayer/models/network/subnet.rb +0 -2
- data/lib/fog/softlayer/models/network/subnets.rb +0 -1
- data/lib/fog/softlayer/models/network/tag.rb +0 -1
- data/lib/fog/softlayer/models/network/tags.rb +1 -1
- data/lib/fog/softlayer/models/product/item.rb +0 -1
- data/lib/fog/softlayer/models/product/items.rb +0 -1
- data/lib/fog/softlayer/models/product/package.rb +0 -1
- data/lib/fog/softlayer/models/product/packages.rb +0 -1
- data/lib/fog/softlayer/models/storage/directories.rb +0 -1
- data/lib/fog/softlayer/models/storage/directory.rb +0 -1
- data/lib/fog/softlayer/models/storage/file.rb +0 -2
- data/lib/fog/softlayer/models/storage/files.rb +0 -1
- data/lib/fog/softlayer/network.rb +0 -2
- data/lib/fog/softlayer/product.rb +0 -1
- data/lib/fog/softlayer/requests/compute/create_bare_metal_server.rb +1 -0
- data/lib/fog/softlayer/requests/compute/create_vms.rb +1 -0
- data/lib/fog/softlayer/requests/compute/get_bare_metal_active_tickets.rb +79 -0
- data/lib/fog/softlayer/requests/compute/get_bare_metal_create_options.rb +1116 -0
- data/lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb +32 -0
- data/lib/fog/softlayer/requests/compute/get_bare_metal_users.rb +148 -0
- data/lib/fog/softlayer/requests/compute/get_virtual_guest_active_tickets.rb +79 -0
- data/lib/fog/softlayer/requests/compute/get_virtual_guest_by_ip.rb +32 -0
- data/lib/fog/softlayer/requests/compute/get_virtual_guest_create_options.rb +4060 -0
- data/lib/fog/softlayer/requests/compute/get_virtual_guest_users.rb +148 -0
- data/lib/fog/softlayer/slapi.rb +96 -0
- data/lib/fog/softlayer/storage.rb +1 -3
- data/lib/fog/softlayer/version.rb +1 -1
- data/lib/fog/softlayer.rb +69 -6
- data/tests/softlayer/requests/compute/bmc_tests.rb +38 -0
- data/tests/softlayer/requests/compute/vm_tests.rb +37 -0
- metadata +41 -32
- data/lib/fog/softlayer/core.rb +0 -176
@@ -0,0 +1,148 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matheus Francisco Barra Mina (<mfbmina@gmail.com>)
|
3
|
+
# © Copyright IBM Corporation 2015.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
module Fog
|
8
|
+
module Compute
|
9
|
+
class Softlayer
|
10
|
+
class Mock
|
11
|
+
# Gets all Virtual Guest users
|
12
|
+
# @param [Integer] id
|
13
|
+
# @return [Excon::Response]
|
14
|
+
def get_virtual_guest_users(id)
|
15
|
+
response = Excon::Response.new
|
16
|
+
found = self.get_vms.body.map{|server| server['id']}.include?(id)
|
17
|
+
unless found
|
18
|
+
response.status = 404
|
19
|
+
response.body = {
|
20
|
+
"error" => "Unable to find object with id of '#{id}'.",
|
21
|
+
"code" => "SoftLayer_Exception_ObjectNotFound"
|
22
|
+
}
|
23
|
+
else
|
24
|
+
response.status = 200
|
25
|
+
response.body = get_users
|
26
|
+
end
|
27
|
+
response
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Real
|
32
|
+
def get_virtual_guest_users(id)
|
33
|
+
request(:virtual_guest, "#{id}/getUsers")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
module Fog
|
41
|
+
module Compute
|
42
|
+
class Softlayer
|
43
|
+
class Mock
|
44
|
+
def get_users
|
45
|
+
[
|
46
|
+
{
|
47
|
+
"accountId"=>000000,
|
48
|
+
"address1"=>"Your address",
|
49
|
+
"authenticationToken"=>
|
50
|
+
{
|
51
|
+
"hash"=>"06e849qqq25e5266753043484893344232",
|
52
|
+
"user"=>nil,
|
53
|
+
"userId"=>000000
|
54
|
+
},
|
55
|
+
"city"=>"Your City",
|
56
|
+
"companyName"=>"Your Company",
|
57
|
+
"country"=>"Your country",
|
58
|
+
"createDate"=>"2014-03-05T13:23:04-06:00",
|
59
|
+
"daylightSavingsTimeFlag"=>true,
|
60
|
+
"denyAllResourceAccessOnCreateFlag"=>false,
|
61
|
+
"displayName"=>"Your name",
|
62
|
+
"email"=>"youremail@example.com",
|
63
|
+
"firstName"=>"Your name",
|
64
|
+
"forumPasswordHash"=>"121kdsksdkvm323j4j3",
|
65
|
+
"id"=>000000,
|
66
|
+
"lastName"=>"Your last name",
|
67
|
+
"localeId"=>1,
|
68
|
+
"modifyDate"=>"2014-03-05T13:23:04-06:00",
|
69
|
+
"officePhone"=>"+55 00 111-111",
|
70
|
+
"parentId"=>nil,
|
71
|
+
"passwordExpireDate"=>nil,
|
72
|
+
"permissionSystemVersion"=>2,
|
73
|
+
"postalCode"=>"000000-000",
|
74
|
+
"pptpVpnAllowedFlag"=>false,
|
75
|
+
"savedId"=>"000000",
|
76
|
+
"secondaryLoginManagementFlag"=>nil,
|
77
|
+
"secondaryLoginRequiredFlag"=>nil,
|
78
|
+
"secondaryPasswordModifyDate"=>"2014-03-05T13:40:12-06:00",
|
79
|
+
"secondaryPasswordTimeoutDays"=>nil,
|
80
|
+
"sslVpnAllowedFlag"=>false,
|
81
|
+
"state"=>"OT",
|
82
|
+
"statusDate"=>"2014-03-05T13:23:04-06:00",
|
83
|
+
"timezoneId"=>114,
|
84
|
+
"userStatusId"=>1001,
|
85
|
+
"username"=>"Your username",
|
86
|
+
"vpnManualConfig"=>false,
|
87
|
+
"account"=>
|
88
|
+
{
|
89
|
+
"accountManagedResourcesFlag"=>false,
|
90
|
+
"accountStatusId"=>1001,
|
91
|
+
"address1"=>"Your address 1",
|
92
|
+
"address2"=>"Your address 2",
|
93
|
+
"allowedPptpVpnQuantity"=>1,
|
94
|
+
"brandId"=>2,
|
95
|
+
"city"=>"Your city",
|
96
|
+
"claimedTaxExemptTxFlag"=>false,
|
97
|
+
"companyName"=>"Your company",
|
98
|
+
"country"=>"Your country",
|
99
|
+
"createDate"=>"2014-03-05T13:23:04-06:00",
|
100
|
+
"email"=>"youremail@example.com",
|
101
|
+
"firstName"=>"Your name",
|
102
|
+
"id"=>000000,
|
103
|
+
"isReseller"=>1,
|
104
|
+
"lastName"=>"Your last name",
|
105
|
+
"lateFeeProtectionFlag"=>nil,
|
106
|
+
"modifyDate"=>"2014-04-29T15:22:55-05:00",
|
107
|
+
"officePhone"=>"+00 00 0000-0000",
|
108
|
+
"postalCode"=>"00000-000",
|
109
|
+
"state"=>"OT",
|
110
|
+
"statusDate"=>nil,
|
111
|
+
"masterUser"=>nil
|
112
|
+
},
|
113
|
+
"apiAuthenticationKeys"=>
|
114
|
+
[
|
115
|
+
{
|
116
|
+
"authenticationKey"=>"43k43dsmkf9994m3mdkm3k2mcdsk32",
|
117
|
+
"id"=>000000,
|
118
|
+
"timestampKey"=>302399304309,
|
119
|
+
"userId"=>000000
|
120
|
+
}
|
121
|
+
],
|
122
|
+
"locale"=>
|
123
|
+
{
|
124
|
+
"friendlyName"=>"English",
|
125
|
+
"id"=>1,
|
126
|
+
"languageTag"=>"en-US",
|
127
|
+
"name"=>"English"
|
128
|
+
},
|
129
|
+
"timezone"=>
|
130
|
+
{
|
131
|
+
"id"=>114,
|
132
|
+
"longName"=>"(GMT-06:00) America/Dallas - CST", "name"=>"America/Chicago",
|
133
|
+
"offset"=>"-0600",
|
134
|
+
"shortName"=>"CST"
|
135
|
+
},
|
136
|
+
"userStatus"=>
|
137
|
+
{
|
138
|
+
"id"=>1001,
|
139
|
+
"keyName"=>"ACTIVE",
|
140
|
+
"name"=>"Active"
|
141
|
+
}
|
142
|
+
}
|
143
|
+
]
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<plribeiro3000@gmail.com>)
|
3
|
+
# © Copyright IBM Corporation 2015.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
module Fog
|
9
|
+
module Softlayer
|
10
|
+
module Slapi
|
11
|
+
# Sends the real request to the real SoftLayer service.
|
12
|
+
#
|
13
|
+
# @param [String] service
|
14
|
+
# ...ayer.com/rest/v3/Softlayer_Service_Name...
|
15
|
+
# @param path [String]
|
16
|
+
# ...ayer.com/rest/v3/Softlayer_Service_Name/path.json
|
17
|
+
# @param [Hash] options
|
18
|
+
# @option options [Array<Hash>] :body
|
19
|
+
# HTTP request body parameters
|
20
|
+
# @option options [String] :softlayer_api_url
|
21
|
+
# Override the default (or configured) API endpoint
|
22
|
+
# @option options [String] :softlayer_username
|
23
|
+
# Email or user identifier for user based authentication
|
24
|
+
# @option options [String] :softlayer_api_key
|
25
|
+
# Password for user based authentication
|
26
|
+
# @return [Excon::Response]
|
27
|
+
def self.slapi_request(service, path, options)
|
28
|
+
# default HTTP method to get if not passed
|
29
|
+
http_method = options[:http_method] || :get
|
30
|
+
# set the target base url
|
31
|
+
@request_url = options[:softlayer_api_url] || Fog::Softlayer::SL_API_URL
|
32
|
+
# tack on the username and password
|
33
|
+
credentialize_url(options[:username], options[:api_key])
|
34
|
+
# set the SoftLayer Service name
|
35
|
+
set_sl_service(service)
|
36
|
+
# set the request path (known as the "method" in SL docs)
|
37
|
+
set_sl_path(path)
|
38
|
+
# set the query params if any
|
39
|
+
|
40
|
+
|
41
|
+
# build request params
|
42
|
+
params = { :headers => user_agent_header }
|
43
|
+
params[:headers]['Content-Type'] = 'application/json'
|
44
|
+
params[:expects] = options[:expected] || [200,201]
|
45
|
+
params[:query] = options[:query] unless options[:query].nil?
|
46
|
+
unless options[:body].nil?
|
47
|
+
options[:body] = [options[:body]] unless options[:body].kind_of?(Array)
|
48
|
+
params[:body] = Fog::JSON.encode({:parameters => options[:body]})
|
49
|
+
end
|
50
|
+
|
51
|
+
# initialize connection object
|
52
|
+
@connection = Fog::Core::Connection.new(@request_url, false, params)
|
53
|
+
|
54
|
+
# send it
|
55
|
+
response = @connection.request(:method => http_method)
|
56
|
+
|
57
|
+
# decode it
|
58
|
+
response.body = Fog::JSON.decode(response.body)
|
59
|
+
response
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def self.credentialize_url(username, apikey)
|
65
|
+
@request_url = "https://#{sanitize_username(username)}:#{apikey}@#{@request_url}"
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.sanitize_username(username)
|
69
|
+
username.gsub!(/@/, '%40')
|
70
|
+
username
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
# Prepend "SoftLayer_" to the service name and Snake_Camel_Case the string before appending it to the @request_url.
|
75
|
+
#
|
76
|
+
def self.set_sl_service(service)
|
77
|
+
service = "SoftLayer_" << service.to_s.gsub(/^softlayer_/i, '').split('_').map{|i|i.capitalize}.join('_')
|
78
|
+
service.fix_convention_exceptions
|
79
|
+
@request_url += "/#{service}"
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Try to smallCamelCase the path before appending it to the @request_url
|
84
|
+
#
|
85
|
+
def self.set_sl_path(path)
|
86
|
+
path = path.to_s.softlayer_underscore.softlayer_camelize
|
87
|
+
path.fix_convention_exceptions
|
88
|
+
@request_url += "/#{path}.json"
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.user_agent_header
|
92
|
+
{"User-Agent" => "Fog SoftLayer Adapter #{Fog::Softlayer::VERSION}"}
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -5,8 +5,6 @@
|
|
5
5
|
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
6
|
#
|
7
7
|
|
8
|
-
require 'fog/softlayer/core'
|
9
|
-
|
10
8
|
module Fog
|
11
9
|
module Storage
|
12
10
|
class Softlayer < Fog::Service
|
@@ -108,7 +106,7 @@ module Fog
|
|
108
106
|
params = _build_params(params)
|
109
107
|
response = @connection.request(params)
|
110
108
|
|
111
|
-
if response.status == 401
|
109
|
+
if response.status == 401 && !!@auth_token
|
112
110
|
@auth_token = nil; @auth_expires = nil
|
113
111
|
authenticate
|
114
112
|
response = @connection.request(params)
|
data/lib/fog/softlayer.rb
CHANGED
@@ -5,9 +5,72 @@
|
|
5
5
|
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
6
|
#
|
7
7
|
|
8
|
-
require 'fog/
|
9
|
-
require 'fog/
|
10
|
-
require '
|
11
|
-
require '
|
12
|
-
require '
|
13
|
-
require '
|
8
|
+
require 'fog/core'
|
9
|
+
require 'fog/json'
|
10
|
+
require 'time'
|
11
|
+
require File.expand_path('../softlayer/version', __FILE__)
|
12
|
+
require File.expand_path('../softlayer/ext/string', __FILE__)
|
13
|
+
require File.expand_path('../softlayer/ext/hash', __FILE__) unless {}.respond_to? :deep_merge
|
14
|
+
|
15
|
+
module Fog
|
16
|
+
module Compute
|
17
|
+
autoload :Softlayer, File.expand_path('../softlayer/compute', __FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
module DNS
|
21
|
+
autoload :Softlayer, File.expand_path('../softlayer/dns', __FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
module Network
|
25
|
+
autoload :Softlayer, File.expand_path('../softlayer/network', __FILE__)
|
26
|
+
end
|
27
|
+
|
28
|
+
module Storage
|
29
|
+
autoload :Softlayer, File.expand_path('../softlayer/storage', __FILE__)
|
30
|
+
end
|
31
|
+
|
32
|
+
module Softlayer
|
33
|
+
extend Fog::Provider
|
34
|
+
|
35
|
+
autoload :Product, File.expand_path('../softlayer/product', __FILE__)
|
36
|
+
autoload :Slapi, File.expand_path('../softlayer/slapi', __FILE__)
|
37
|
+
|
38
|
+
SL_API_URL = 'api.softlayer.com/rest/v3' unless defined? SL_API_URL
|
39
|
+
SL_STORAGE_AUTH_URL = 'objectstorage.softlayer.net/auth/v1.0' unless defined? SL_STORAGE_AUTH_URL
|
40
|
+
|
41
|
+
service(:compute, 'Compute')
|
42
|
+
service(:dns, 'DNS')
|
43
|
+
service(:network, 'Network')
|
44
|
+
service(:product, 'Product')
|
45
|
+
service(:storage, 'Storage')
|
46
|
+
|
47
|
+
def self.mock_account_id
|
48
|
+
Fog.mocking? and @sl_account_id ||= Fog::Mock.random_numbers(7)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.mock_vm_id
|
52
|
+
Fog::Mock.random_numbers(7)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.mock_global_identifier
|
56
|
+
Fog::UUID.uuid
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.valid_request?(required, passed)
|
60
|
+
required.all? {|k| k = k.to_sym; passed.key?(k) and !passed[k].nil?}
|
61
|
+
end
|
62
|
+
|
63
|
+
# CGI.escape, but without special treatment on spaces
|
64
|
+
def self.escape(str,extra_exclude_chars = '')
|
65
|
+
str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
|
66
|
+
'%' + $1.unpack('H2' * $1.bytesize).join('%').upcase
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.stringify_keys(obj)
|
71
|
+
return obj.inject({}){|memo,(k,v)| memo[k.to_s] = stringify_keys(v); memo} if obj.is_a? Hash
|
72
|
+
return obj.inject([]){|memo,v | memo << stringify_keys(v); memo} if obj.is_a? Array
|
73
|
+
obj
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -23,16 +23,36 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
|
|
23
23
|
tests("#create_bare_metal_server('#{@bmc}')") do
|
24
24
|
response = @sl_connection.create_bare_metal_server(@bmc)
|
25
25
|
@server_id = response.body['id']
|
26
|
+
@server_ip = response.body['primaryIpAddress']
|
26
27
|
data_matches_schema(Softlayer::Compute::Formats::BareMetal::SERVER, {:allow_extra_keys => true}) { response.body }
|
27
28
|
data_matches_schema(201) { response.status }
|
28
29
|
end
|
29
30
|
|
31
|
+
tests"#get_bare_metal_server_by_ip('#{@server_ip}'))" do
|
32
|
+
response = @sl_connection.get_bare_metal_server_by_ip(@server_ip)
|
33
|
+
data_matches_schema(200) { response.status }
|
34
|
+
data_matches_schema(Softlayer::Compute::Formats::BareMetal::SERVER) { response.body }
|
35
|
+
end
|
36
|
+
|
37
|
+
|
30
38
|
tests("#get_bare_metal_servers()") do
|
31
39
|
@sl_connection.get_bare_metal_servers.body.each do |bms|
|
32
40
|
data_matches_schema(Softlayer::Compute::Formats::BareMetal::SERVER) { bms }
|
33
41
|
end
|
34
42
|
end
|
35
43
|
|
44
|
+
tests("#get_bare_metal_active_tickets('#{@server_id})'") do
|
45
|
+
response = @sl_connection.get_bare_metal_active_tickets(@server_id)
|
46
|
+
data_matches_schema(Array) {response.body}
|
47
|
+
data_matches_schema(200) {response.status}
|
48
|
+
end
|
49
|
+
|
50
|
+
tests("#get_bare_metal_users('#{@server_id})'") do
|
51
|
+
response = @sl_connection.get_bare_metal_users(@server_id)
|
52
|
+
data_matches_schema(Array) {response.body}
|
53
|
+
data_matches_schema(200) {response.status}
|
54
|
+
end
|
55
|
+
|
36
56
|
tests("#power_on_bare_metal_server('#{@server_id})'") do
|
37
57
|
response = @sl_connection.power_on_bare_metal_server(@server_id)
|
38
58
|
data_matches_schema(true) {response.body}
|
@@ -62,6 +82,12 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
|
|
62
82
|
data_matches_schema(true) {response.body}
|
63
83
|
data_matches_schema(200) {response.status}
|
64
84
|
end
|
85
|
+
|
86
|
+
tests("#get_bare_metal_create_options()") do
|
87
|
+
response = @sl_connection.get_bare_metal_create_options
|
88
|
+
data_matches_schema(Hash) {response.body}
|
89
|
+
data_matches_schema(200) {response.status}
|
90
|
+
end
|
65
91
|
end
|
66
92
|
|
67
93
|
tests('failure') do
|
@@ -77,6 +103,18 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
|
|
77
103
|
@sl_connection.create_bare_metal_server([@bmc])
|
78
104
|
end
|
79
105
|
|
106
|
+
tests("#get_bare_metal_server_by_ip('1.1.1.1')") do
|
107
|
+
response = @sl_connection.get_bare_metal_server_by_ip('1.1.1.1')
|
108
|
+
data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
|
109
|
+
data_matches_schema(404){ response.status }
|
110
|
+
end
|
111
|
+
|
112
|
+
tests("#get_bare_metal_users('#{bmc}')") do
|
113
|
+
response = @sl_connection.get_bare_metal_users(bmc)
|
114
|
+
data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
|
115
|
+
data_matches_schema(404){ response.status }
|
116
|
+
end
|
117
|
+
|
80
118
|
tests("#power_on_bare_metal_server('#{bmc}')") do
|
81
119
|
response = @sl_connection.power_on_bare_metal_server(bmc)
|
82
120
|
data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
|
@@ -40,16 +40,35 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
|
|
40
40
|
tests("#create_vm('#{@vm}')") do
|
41
41
|
response = @sl_connection.create_vm(@vm)
|
42
42
|
@vm_id = response.body.first['id']
|
43
|
+
@vm_ip = response.body.first['primaryIpAddress']
|
43
44
|
#data_matches_schema([Softlayer::Compute::Formats::VirtualGuest::SERVER], {:allow_extra_keys => true}) { response.body }
|
44
45
|
data_matches_schema(200) { response.status }
|
45
46
|
end
|
46
47
|
|
48
|
+
tests"#get_virtual_guest_by_ip('#{@vm_ip}'))" do
|
49
|
+
response = @sl_connection.get_virtual_guest_by_ip(@vm_ip)
|
50
|
+
data_matches_schema(200) { response.status }
|
51
|
+
data_matches_schema(Softlayer::Compute::Formats::VirtualGuest::SERVER) { response.body }
|
52
|
+
end
|
53
|
+
|
47
54
|
tests"#get_vms()" do
|
48
55
|
response = @sl_connection.get_vms
|
49
56
|
data_matches_schema(200) { response.status }
|
50
57
|
#data_matches_schema(Softlayer::Compute::Formats::VirtualGuest::SERVER) { vm }
|
51
58
|
end
|
52
59
|
|
60
|
+
tests("#get_virtual_guest_active_tickets(#{@vm_id})") do
|
61
|
+
response = @sl_connection.get_virtual_guest_active_tickets(@vm_id)
|
62
|
+
data_matches_schema(Array) {response.body}
|
63
|
+
data_matches_schema(200) {response.status}
|
64
|
+
end
|
65
|
+
|
66
|
+
tests("#get_virtual_guest_users(#{@vm_id})") do
|
67
|
+
response = @sl_connection.get_virtual_guest_users(@vm_id)
|
68
|
+
data_matches_schema(Array) {response.body}
|
69
|
+
data_matches_schema(200) {response.status}
|
70
|
+
end
|
71
|
+
|
53
72
|
tests("#power_on_vm(#{@vm_id})") do
|
54
73
|
response = @sl_connection.power_on_vm(@vm_id)
|
55
74
|
data_matches_schema(true) {response.body}
|
@@ -85,6 +104,12 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
|
|
85
104
|
data_matches_schema(true) {response.body}
|
86
105
|
data_matches_schema(200) {response.status}
|
87
106
|
end
|
107
|
+
|
108
|
+
tests("#get_virtual_guest_create_options()") do
|
109
|
+
response = @sl_connection.get_virtual_guest_create_options
|
110
|
+
data_matches_schema(Hash) {response.body}
|
111
|
+
data_matches_schema(200) {response.status}
|
112
|
+
end
|
88
113
|
end
|
89
114
|
|
90
115
|
tests('failure') do
|
@@ -110,6 +135,18 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
|
|
110
135
|
@sl_connection.create_vm(@vms)
|
111
136
|
end
|
112
137
|
|
138
|
+
tests("#get_virtual_guest_by_ip('1.1.1.1')") do
|
139
|
+
response = @sl_connection.get_virtual_guest_by_ip('1.1.1.1')
|
140
|
+
data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
|
141
|
+
data_matches_schema(404) {response.status}
|
142
|
+
end
|
143
|
+
|
144
|
+
tests("#get_virtual_guest_users('99999999999999')") do
|
145
|
+
response = @sl_connection.get_virtual_guest_users(99999999999999)
|
146
|
+
data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
|
147
|
+
data_matches_schema(404) {response.status}
|
148
|
+
end
|
149
|
+
|
113
150
|
tests("#power_on_vm('99999999999999')") do
|
114
151
|
response = @sl_connection.power_on_vm(99999999999999)
|
115
152
|
data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
|