Class: Fog::Compute::Softlayer::Real
- Inherits:
-
Object
- Object
- Fog::Compute::Softlayer::Real
show all
- Includes:
- Softlayer::Compute::Shared
- Defined in:
- lib/fog/softlayer/compute.rb,
lib/fog/softlayer/requests/compute/get_vm.rb,
lib/fog/softlayer/requests/compute/get_vms.rb,
lib/fog/softlayer/requests/compute/create_vm.rb,
lib/fog/softlayer/requests/compute/delete_vm.rb,
lib/fog/softlayer/requests/compute/create_vms.rb,
lib/fog/softlayer/requests/compute/get_bare_metal_server.rb,
lib/fog/softlayer/requests/compute/get_bare_metal_servers.rb,
lib/fog/softlayer/requests/compute/create_bare_metal_server.rb,
lib/fog/softlayer/requests/compute/delete_bare_metal_server.rb
Overview
Makes real connections to Softlayer.
Instance Attribute Summary collapse
Instance Method Summary
collapse
#initialize, valid_request?
Instance Attribute Details
#default_domain ⇒ Object
Returns the value of attribute default_domain.
80
81
82
|
# File 'lib/fog/softlayer/compute.rb', line 80
def default_domain
@default_domain
end
|
Instance Method Details
77
78
79
80
|
# File 'lib/fog/softlayer/requests/compute/create_bare_metal_server.rb', line 77
def create_bare_metal_server(opts)
raise ArgumentError, "Fog::Compute::Softlayer#create_bare_metal_server expects argument of type Hash" unless opts.kind_of?(Hash)
request(:hardware_server, :create_object, :body => opts, :http_method => :POST)
end
|
#create_vm(opts) ⇒ Object
44
45
46
47
48
|
# File 'lib/fog/softlayer/requests/compute/create_vm.rb', line 44
def create_vm(opts)
raise ArgumentError, "Fog::Compute::Softlayer#create_vm expects argument of type Hash" unless opts.kind_of?(Hash)
opts = [opts]
self.create_vms(opts)
end
|
#create_vms(opts) ⇒ Object
87
88
89
90
|
# File 'lib/fog/softlayer/requests/compute/create_vms.rb', line 87
def create_vms(opts)
raise ArgumentError, "Fog::Compute::Softlayer#create_vms expects argument of type Array" unless opts.kind_of?(Array)
request(:virtual_guest, :create_objects, :body => opts, :http_method => :POST)
end
|
35
36
37
|
# File 'lib/fog/softlayer/requests/compute/delete_bare_metal_server.rb', line 35
def delete_bare_metal_server(id)
request(:hardware_server, id.to_s, :http_method => :DELETE)
end
|
#delete_vm(id) ⇒ Object
35
36
37
|
# File 'lib/fog/softlayer/requests/compute/delete_vm.rb', line 35
def delete_vm(id)
request(:virtual_guest, id.to_s, :http_method => :DELETE)
end
|
22
23
24
|
# File 'lib/fog/softlayer/requests/compute/get_bare_metal_server.rb', line 22
def get_bare_metal_server(identifier)
request(:hardware_server, identifier, :expected => [200, 404], :query => 'objectMask=mask[memory,provisionDate,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.passwords.password]')
end
|
22
23
24
|
# File 'lib/fog/softlayer/requests/compute/get_bare_metal_servers.rb', line 22
def get_bare_metal_servers
request(:account, :get_hardware)
end
|
#get_vm(identifier) ⇒ Object
22
23
24
|
# File 'lib/fog/softlayer/requests/compute/get_vm.rb', line 22
def get_vm(identifier)
request(:virtual_guest, identifier, :expected => [200, 404], :query => 'objectMask=mask[blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.passwords.password]')
end
|
#get_vms ⇒ Object
22
23
24
|
# File 'lib/fog/softlayer/requests/compute/get_vms.rb', line 22
def get_vms
request(:account, :get_virtual_guests)
end
|
#list_servers ⇒ Object
132
133
134
|
# File 'lib/fog/softlayer/compute.rb', line 132
def list_servers
(self.get_vms.body << self.get_bare_metal_servers.body).flatten
end
|
#request(service, path, options = {}) ⇒ Excon::Response
Sends the real request to the real SoftLayer service.
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/fog/softlayer/compute.rb', line 99
def request(service, path, options={})
http_method = options[:http_method] || :get
@request_url = options[:softlayer_api_url] || Fog::Softlayer::SL_API_URL
credentialize_url(@credentials[:username], @credentials[:api_key])
set_sl_service(service)
set_sl_path(path)
params = { :headers => }
params[:headers]['Content-Type'] = 'application/json'
params[:expects] = options[:expected] || [200,201]
params[:body] = Fog::JSON.encode({:parameters => [ options[:body] ]}) unless options[:body].nil?
params[:query] = options[:query] unless options[:query].nil?
@connection = Fog::Core::Connection.new(@request_url, false, params)
response = @connection.request(:method => http_method)
response.body = Fog::JSON.decode(response.body)
response
end
|