class Fog::Compute::Softlayer::Real

Makes real connections to Softlayer.

Attributes

softlayer_default_datacenter[RW]
softlayer_default_domain[RW]

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/softlayer/compute.rb, line 128
def initialize(options={})
  @softlayer_api_key = options[:softlayer_api_key]
  @softlayer_username = options[:softlayer_username]
  @softlayer_default_domain = options[:softlayer_default_domain]
  @softlayer_default_datacenter = options[:softlayer_default_datacenter]
end

Public Instance Methods

create_bare_metal_server(opts) click to toggle source
# File lib/fog/softlayer/requests/compute/create_bare_metal_server.rb, line 78
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_bare_metal_tags(id, tags = []) click to toggle source
# File lib/fog/softlayer/requests/compute/create_bare_metal_tags.rb, line 43
def create_bare_metal_tags(id, tags = [])
  raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
  self.request(:hardware_server, "#{id}/set_tags", :body => tags.join(','), :http_method => :post)
end
create_key_pair(opts) click to toggle source
# File lib/fog/softlayer/requests/compute/create_key_pair.rb, line 34
def create_key_pair(opts)
  request(:security_ssh_key, :create_object, :body => opts, :http_method => :post)
end
create_vm(opts) click to toggle source
# 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]] # don't ask...
  self.create_vms(opts)
end
create_vm_tags(id, tags = []) click to toggle source
# File lib/fog/softlayer/requests/compute/create_vm_tags.rb, line 43
def create_vm_tags(id, tags = [])
  raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
  self.request(:virtual_guest, "#{id}/set_tags", :body => tags.join(','), :http_method => :post)
end
create_vms(opts) click to toggle source
# File lib/fog/softlayer/requests/compute/create_vms.rb, line 89
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
delete_bare_metal_server(id) click to toggle source
# 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_bare_metal_tags(id, tags = []) click to toggle source
# File lib/fog/softlayer/requests/compute/delete_bare_metal_tags.rb, line 36
def delete_bare_metal_tags(id, tags = [])
  raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
  subset = self.get_bare_metal_tags(id).body['tagReferences'].map do |i|
    i['tag']['name'] unless tags.include?(i['tag']['name'])
  end.compact
  self.create_bare_metal_tags(id, subset)
end
delete_key_pair(id) click to toggle source
# File lib/fog/softlayer/requests/compute/delete_key_pair.rb, line 30
def delete_key_pair(id)
  request(:security_ssh_key, id, :http_method => :delete)
end
delete_vm(id) click to toggle source
# 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
delete_vm_tags(id, tags = []) click to toggle source
# File lib/fog/softlayer/requests/compute/delete_vm_tags.rb, line 36
def delete_vm_tags(id, tags = [])
  raise ArgumentError, "Tags argument for #{self.class.name}##{__method__} must be Array." unless tags.is_a?(Array)
  subset = self.get_vm_tags(id).body['tagReferences'].map do |i|
    i['tag']['name'] unless tags.include?(i['tag']['name'])
  end.compact
  self.create_vm_tags(id, subset)
end
describe_tags() click to toggle source
# File lib/fog/softlayer/requests/compute/describe_tags.rb, line 24
def describe_tags
  self.request(:account, :get_tags, :query => 'objectMask=mask[referenceCount]')
end
generate_bare_metal_order_template(order_template) click to toggle source
# File lib/fog/softlayer/requests/compute/generate_bare_metal_order_template.rb, line 35
def generate_bare_metal_order_template(order_template)
  request(:hardware_server, :generate_order_template, body: order_template, :http_method => :POST)
end
generate_virtual_guest_order_template(order_template) click to toggle source
# File lib/fog/softlayer/requests/compute/generate_virtual_guest_order_template.rb, line 35
def generate_virtual_guest_order_template(order_template)
  request(:virtual_guest, :generate_order_template, body: order_template, :http_method => :POST)
end
get_available_preset_codes() click to toggle source
# File lib/fog/softlayer/requests/compute/get_available_preset_codes.rb, line 34
def get_available_preset_codes
  self.request(:hardware_server, :get_create_object_options, :http_method => :GET)
end
get_bare_metal_active_tickets(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_active_tickets.rb, line 32
def get_bare_metal_active_tickets(id)
  request(:hardware_server, "#{id.to_s}/getActiveTickets", :http_method => :GET)
end
get_bare_metal_create_options() click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_create_options.rb, line 22
def get_bare_metal_create_options
  request(:hardware_server, "getCreateObjectOptions", :http_method => :GET)
end
get_bare_metal_server(identifier) click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_server.rb, line 28
def get_bare_metal_server(identifier)
  request(:hardware_server, identifier, :expected => [200, 404], :query => 'objectMask=mask[datacenter,tagReferences,memory,provisionDate,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag,userData,frontendNetworkComponents,backendNetworkComponents]')
end
get_bare_metal_server_by_ip(ip_address) click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_server_by_ip.rb, line 26
def get_bare_metal_server_by_ip(ip_address)
  request(:hardware_server, :findByIpAddress, :body => "#{ip_address}", :http_method => :POST, :query => 'objectMask=mask[datacenter,tagReferences,memory,provisionDate,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag,userData,frontendNetworkComponents,backendNetworkComponents]')
end
get_bare_metal_servers() click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_servers.rb, line 22
def get_bare_metal_servers
  request(:account, :get_hardware, :query => 'objectMask=mask[datacenter,tagReferences,memory,processorCoreAmount,hardDrives,datacenter,hourlyBillingFlag,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag,userData,frontendNetworkComponents,backendNetworkComponents]')
end
get_bare_metal_tags(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_tags.rb, line 41
def get_bare_metal_tags(id)
  self.request(:hardware_server, id, :query => 'objectMask=id;tagReferences')
end
get_bare_metal_upgrade_item_prices(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_upgrade_item_prices.rb, line 32
def get_bare_metal_upgrade_item_prices(id)
  request(:hardware_server, "#{id}/getUpgradeItemPrices")
end
get_bare_metal_users(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_bare_metal_users.rb, line 32
def get_bare_metal_users(id)
  request(:hardware_server, "#{id}/getUsers")
end
get_key_pair(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_key_pair.rb, line 30
def get_key_pair(id)
  request(:security_ssh_key, id)
end
get_key_pairs() click to toggle source
# File lib/fog/softlayer/requests/compute/get_key_pairs.rb, line 23
def get_key_pairs
  request(:account, :get_ssh_keys)
end
get_references_by_tag_name(tag_list) click to toggle source
# File lib/fog/softlayer/requests/compute/get_references_by_tag_name.rb, line 36
def get_references_by_tag_name(tag_list)
  self.request(:tag, "get_tag_by_tag_name/#{tag_list}", :query => 'objectMask=references')
end
get_tag(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_tag.rb, line 21
def get_tag(id)
  self.request(:tag, "#{id}/get_object", :query => "objectMask=references;references.tagType")
end
get_virtual_guest_active_tickets(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_virtual_guest_active_tickets.rb, line 32
def get_virtual_guest_active_tickets(id)
  request(:virtual_guest, "#{id.to_s}/getActiveTickets", :http_method => :GET)
end
get_virtual_guest_by_ip(ip_address) click to toggle source
# File lib/fog/softlayer/requests/compute/get_virtual_guest_by_ip.rb, line 26
def get_virtual_guest_by_ip(ip_address)
  request(:virtual_guest, :findByIpAddress, :body => "#{ip_address}", :http_method => :POST, :query => 'objectMask=mask[datacenter,tagReferences,blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag,userData,frontendNetworkComponents,backendNetworkComponents]')
end
get_virtual_guest_create_options() click to toggle source
# File lib/fog/softlayer/requests/compute/get_virtual_guest_create_options.rb, line 22
def get_virtual_guest_create_options
  request(:virtual_guest, "getCreateObjectOptions", :http_method => :GET)
end
get_virtual_guest_upgrade_item_prices(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_virtual_guest_upgrade_item_prices.rb, line 32
def get_virtual_guest_upgrade_item_prices(id)
  request(:virtual_guest, "#{id}/getUpgradeItemPrices", :body => true, :http_method => :POST)
end
get_virtual_guest_users(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_virtual_guest_users.rb, line 32
def get_virtual_guest_users(id)
  request(:virtual_guest, "#{id}/getUsers")
end
get_vm(identifier) click to toggle source
# File lib/fog/softlayer/requests/compute/get_vm.rb, line 28
def get_vm(identifier)
  request(:virtual_guest, identifier, :expected => [200, 404], :query => 'objectMask=mask[datacenter,tagReferences,blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.softwareLicense.softwareDescription.referenceCode,sshKeys.id,privateNetworkOnlyFlag,userData,frontendNetworkComponents,backendNetworkComponents,hourlyBillingFlag]')
end
get_vm_tags(id) click to toggle source
# File lib/fog/softlayer/requests/compute/get_vm_tags.rb, line 41
def get_vm_tags(id)
  self.request(:virtual_guest, id, :query => 'objectMask=mask[tagReferences]')
end
get_vms() click to toggle source
# File lib/fog/softlayer/requests/compute/get_vms.rb, line 22
def get_vms
  request(:account, :get_virtual_guests, :query => 'objectMask=mask[datacenter,tagReferences,blockDevices,blockDeviceTemplateGroup.globalIdentifier,operatingSystem.softwareLicense.softwareDescription.referenceCode,primaryNetworkComponent.networkVlan,sshKeys.id,privateNetworkOnlyFlag,userData,frontendNetworkComponents,backendNetworkComponents,hourlyBillingFlag]')
end
list_servers() click to toggle source
# File lib/fog/softlayer/compute.rb, line 140
def list_servers
  (self.get_vms.body.map {|s| s['bare_metal'] = false; s } << self.get_bare_metal_servers.body.map {|s| s['bare_metal'] = true; s}).flatten
end
power_off_bare_metal_server(id) click to toggle source
# File lib/fog/softlayer/requests/compute/power_off_bare_metal_server.rb, line 35
def power_off_bare_metal_server(id)
  request(:hardware_server, "#{id.to_s}/powerOff", :http_method => :GET)
end
power_off_vm(id, use_hard_poweroff) click to toggle source
# File lib/fog/softlayer/requests/compute/power_off_vm.rb, line 35
def power_off_vm(id, use_hard_poweroff)
  if use_hard_poweroff
    request(:virtual_guest, "#{id.to_s}/powerOff", :http_method => :GET)
  else
    request(:virtual_guest, "#{id.to_s}/powerOffSoft", :http_method => :GET)
  end
end
power_on_bare_metal_server(id) click to toggle source
# File lib/fog/softlayer/requests/compute/power_on_bare_metal_server.rb, line 35
def power_on_bare_metal_server(id)
  request(:hardware_server, "#{id.to_s}/powerOn", :http_method => :GET)
end
power_on_vm(id) click to toggle source
# File lib/fog/softlayer/requests/compute/power_on_vm.rb, line 35
def power_on_vm(id)
  request(:virtual_guest, "#{id.to_s}/powerOn", :http_method => :GET)
end
reboot_bare_metal_server(id, use_hard_reboot) click to toggle source
# File lib/fog/softlayer/requests/compute/reboot_bare_metal_server.rb, line 35
def reboot_bare_metal_server(id, use_hard_reboot)
  if use_hard_reboot
    request(:hardware_server, "#{id.to_s}/rebootHard", :http_method => :GET)
  else
    request(:hardware_server, "#{id.to_s}/rebootSoft", :http_method => :GET)
  end
end
reboot_vm(id, use_hard_reboot) click to toggle source
# File lib/fog/softlayer/requests/compute/reboot_vm.rb, line 35
def reboot_vm(id, use_hard_reboot)
  if use_hard_reboot
    request(:virtual_guest, "#{id.to_s}/rebootHard", :http_method => :GET)
  else
    request(:virtual_guest, "#{id.to_s}/rebootSoft", :http_method => :GET)
  end
end
request(service, path, options = {}) click to toggle source
# File lib/fog/softlayer/compute.rb, line 135
def request(service, path, options = {})
  options = {:username => @softlayer_username, :api_key => @softlayer_api_key}.merge(options)
  Fog::Softlayer::Slapi.slapi_request(service, path, options)
end
update_key_pair(id, opts) click to toggle source
# File lib/fog/softlayer/requests/compute/update_key_pair.rb, line 35
def update_key_pair(id, opts)
  request(:security_ssh_key, id, :body => opts, :http_method => :put)
end