# File lib/fog/clodo/compute.rb, line 75 def initialize(options={}) @clodo_api_key = options[:clodo_api_key] @clodo_username = options[:clodo_username] @clodo_auth_url = options[:clodo_auth_url] @clodo_servicenet = options[:clodo_servicenet] @clodo_auth_token = options[:clodo_auth_token] @clodo_management_url = options[:clodo_management_url] @clodo_must_reauthenticate = false authenticate Excon.ssl_verify_peer = false if options[:clodo_servicenet] == true @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) end
Bye new IP-address for specified server
server_id<~Integer> - Id of server to bye IP for
response<~Excon::Response>
# File lib/fog/clodo/requests/compute/add_ip_address.rb, line 14 def add_ip_address(server_id) request( :expects => [204], :method => 'PUT', :path => "servers/#{server_id}/ips" ) end
Input: vps_title - VDS title to display in VDS list vps_type - VDS type (VirtualServer,ScaleServer) vps_memory - memory size in megabytes (for ScaleServer - low limit) vps_memory_max - maximum number of ScaleServer memory megabytes to scale up. vps_hdd - Virtual HDD size im gigabytes. vps_admin - support level (1 - usual&free, 2 - extended, 3 - VIP) vps_os - OS ID to install Output: id - VDS ID name - VDS title imageId - OS ID adminPass - root password
# File lib/fog/clodo/requests/compute/create_server.rb, line 19 def create_server(image_id, options = {}) data = { 'server' => { :vps_os => image_id, :vps_hdd => options[:vps_hdd]?options[:vps_hdd]:5, :vps_memory => options[:vps_memory]?options[:vps_memory]:256, :vps_memory_max => options[:vps_memory_max]?options[:vps_memory_max]:1024, :vps_admin => options[:vps_admin]?options[:vps_admin]:1 } } data['server'].merge! options if options request( :body => Fog::JSON.encode(data), :expects => [200, 202], :method => 'POST', :path => 'servers' ) end
Delete IP-address from specified server
server_id<~Integer> - Id of server to delete IP from
ip<~String> - IP-address to delete
response<~Excon::Response>
# File lib/fog/clodo/requests/compute/delete_ip_address.rb, line 15 def delete_ip_address(server_id, ip) data = {'ip' => ip} request( :expects => [204], :method => 'DELETE', :path => "servers/#{server_id}/ips", :body => Fog::JSON.encode(data) ) end
Delete an existing server
id<~Integer> - Id of server to delete
# File lib/fog/clodo/requests/compute/delete_server.rb, line 11 def delete_server(server_id) request( :expects => 204, :method => 'DELETE', :path => "servers/#{server_id}" ) end
# File lib/fog/clodo/requests/compute/get_image_details.rb, line 5 def get_image_details(image_id) request(:expects => [200,203], :method => 'GET', :path => "images/#{image_id}") end
Get details about a server
server_id<~Integer> - Id of server to get details for
response<~Excon::Response>:
body<~Hash>:
'server'<~Hash>:
'addresses'<~Hash>:
'public'<~Array> - public address strings
'private'<~Array> - private address strings
'id'<~Integer> - Id of server
'imageId'<~Integer> - Id of image used to boot server
'name<~String> - Name of server
'status'<~String> - Current server status
# File lib/fog/clodo/requests/compute/get_server_details.rb, line 22 def get_server_details(server_id) request( :expects => [200, 203], :method => 'GET', :path => "servers/#{server_id}" ) end
List all images (IDs and names only)
response<~Excon::Response>:
body<~Hash>:
'id'<~Integer> - Id of the image
'name'<~String> - Name of the image
'status'<~String> - Status of the image
'vps_type'<~String> - VirtualServer or ScaleServer
# File lib/fog/clodo/requests/compute/list_images.rb, line 15 def list_images request( :expects => [200, 203], :method => 'GET', :path => 'images' ) end
List all images
response<~Excon::Response>:
body<~Hash>:
'os_type'<~String> - OS distribution
'os_bits'<~Integer> - OS bits
'os_hvm'<~Integer> - HVM flag
'_attr'<~Hash>:
'id'<~Integer> - Id of the image
'name'<~String> - Name of the image
'status'<~String> - Status of the image
'vps_type'<~String> - VirtualServer or ScaleServer
# File lib/fog/clodo/requests/compute/list_images_detail.rb, line 20 def list_images_detail request( :expects => [200, 203], :method => 'GET', :path => 'images/detail' ) end
List all servers (IDs and names only)
response<~Excon::Response>:
body<~Hash>:
'servers'<~Array>:
'id'<~String> - Id of server
'name'<~String> - Name of server
'addresses'<~Hash>:
'public'<~Array>:
'dosprotect'<~Bool> - DDoS protection enabled
'primary_ip'<~Bool> - Is a primary IP-address
'isp'<~Bool> - ISPManager license enabled
'ip'<~String> - IP-address
'imageId'<~String> - ID of OS image installed
'type'<~String> - Type (ScaleServer or Virtual Server)
'status'<~String> - Server's status
# File lib/fog/clodo/requests/compute/list_servers.rb, line 23 def list_servers request( :expects => [200, 203], :method => 'GET', :path => 'servers' ) end
List all servers details
response<~Excon::Response>:
body<~Hash>:
'servers'<~Array>:
'id'<~Integer> - Id of server
'name<~String> - Name of server
'imageId'<~Integer> - Id of image used to boot server
'status'<~String> - Current server status
'addresses'<~Hash>:
'public'<~Array> - public address strings
# File lib/fog/clodo/requests/compute/list_servers_detail.rb, line 18 def list_servers_detail request( :expects => [200, 203], :method => 'GET', :path => 'servers/detail' ) end
Move IP-address to specified server.
server_id<~Integer> - Id of server to move IP to
ip<~String> - IP-address to move
response<~Excon::Response>
# File lib/fog/clodo/requests/compute/move_ip_address.rb, line 15 def move_ip_address(server_id, ip) request( :expects => [204], :method => 'GET', :path => "servers/#{server_id}/ips/moveip", :body => Fog::JSON.encode({'ip'=>"#{ip}"}) ) end
# File lib/fog/clodo/requests/compute/reboot_server.rb, line 5 def reboot_server(id, type) body = {'reboot' => {}} server_action(id, body) end
# File lib/fog/clodo/requests/compute/rebuild_server.rb, line 5 def rebuild_server(id, image_id, vps_isp = nil) body = {'rebuild' => {'imageId' => image_id}} body['rebuild']['vps_isp'] = vps_isp if vps_isp server_action(id, body) end
# File lib/fog/clodo/compute.rb, line 88 def reload @connection.reset end
# File lib/fog/clodo/compute.rb, line 92 def request(params) begin response = @connection.request(params.merge({ :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, :path => "#{@path}/#{params[:path]}" })) rescue Excon::Errors::Unauthorized => error if error.response.body != 'Bad username or password' # token expiration @clodo_must_reauthenticate = true authenticate retry else # bad credentials raise error end rescue Excon::Errors::HTTPStatusError => error raise case error when Excon::Errors::NotFound Fog::Compute::Clodo::NotFound.slurp(error) else error end end unless response.body.empty? response.body = Fog::JSON.decode(response.body) end response end
# File lib/fog/clodo/requests/compute/server_action.rb, line 5 def server_action(id, action) request( :body => Fog::JSON.encode(action), :expects => [204], :method => 'POST', :path => "servers/#{id}/action") end
Generated with the Darkfish Rdoc Generator 2.