request :digitalocean_resize
# File lib/fog/digitalocean/compute.rb, line 44 def self.data @data ||= Hash.new do |hash, key| hash[key] = { :servers => [], :ssh_keys => [] } end end
# File lib/fog/digitalocean/requests/compute/create_server.rb, line 38 def create_server( name, size_id, image_id, region_id, options = {} ) response = Excon::Response.new response.status = 200 # New York 2 (region id 4) is currently the only region that supports # private networking. The Digital Ocean IP will return a null # private_ip_address for any other region has_private_ip = !!options[:private_networking] && (region_id == 4) mock_data = { "id" => Fog::Mock.random_numbers(1).to_i, "event_id" => Fog::Mock.random_numbers(2).to_i, "name" => name, "size_id" => size_id, "image_id" => image_id, "region_id" => region_id, "ip_address" => "127.0.0.1", "private_ip_address" => has_private_ip ? "10.0.0.1" : nil, "status" => 'active', "created_at" => Time.now.strftime("%FT%TZ") } response.body = { "status" => "OK", "droplet" => mock_data } self.data[:servers] << mock_data response end
# File lib/fog/digitalocean/requests/compute/create_ssh_key.rb, line 16 def create_ssh_key( name, pub_key ) response = Excon::Response.new response.status = 200 mock_data = { "id" => Fog::Mock.random_numbers(1).to_i, "name" => name, "ssh_pub_key" => pub_key } response.body = { "status" => "OK", "ssh_key" => mock_data } self.data[:ssh_keys] << mock_data response end
# File lib/fog/digitalocean/compute.rb, line 61 def data self.class.data[@digitalocean_api_key] end
# File lib/fog/digitalocean/requests/compute/destroy_server.rb, line 20 def destroy_server( id ) response = Excon::Response.new response.status = 200 response.body = { "event_id" => Fog::Mock.random_numbers(1).to_i, "status" => "OK" } server = self.data[:servers].reject! { |s| s['id'] == id } response end
# File lib/fog/digitalocean/requests/compute/destroy_ssh_key.rb, line 20 def destroy_ssh_key(id) response = Excon::Response.new response.status = 200 if self.data[:ssh_keys].reject! { |k| k['id'] == id } response.body = { "status" => "OK" } else response.body = { "status" => "ERROR" } end response end
# File lib/fog/digitalocean/requests/compute/get_server_details.rb, line 15 def get_server_details(server_id) response = Excon::Response.new response.status = 200 server = self.data[:servers].find { |s| s['id'] == server_id } response.body = { "status" => "OK", "droplet" => self.data[:servers].find { |s| s['id'] == server_id } } response end
# File lib/fog/digitalocean/requests/compute/get_ssh_key.rb, line 21 def get_ssh_key(id) response = Excon::Response.new response.status = 200 response.body = { "status" => "OK", # key listing does not return ssh_pub_key # https://developers.digitalocean.com/ssh-keys "ssh_key" => self.data[:ssh_keys].find { |k| k['id'] == id } } response end
# File lib/fog/digitalocean/requests/compute/list_flavors.rb, line 15 def list_flavors response = Excon::Response.new response.status = 200 response.body = { "status" => "OK", "sizes" => [ {"id" => 33,"name" => "512MB"}, {"id" => 34,"name" => "1GB"}, {"id" => 35,"name" => "2GB"}, {"id" => 36,"name" => "4GB"}, {"id" => 37,"name" => "8GB"}, {"id" => 38,"name" => "16GB"} ] } response end
# File lib/fog/digitalocean/requests/compute/list_images.rb, line 15 def list_images response = Excon::Response.new response.status = 200 response.body = { "status" => "OK", "images" => [ # Sample image { "id" => 1601, "name" => "CentOS 5.8 x64", "distribution" => "CentOS" }, { "id" => 1602, "name" => "CentOS 5.8 x32", "distribution" => "CentOS" }, { "id" => 2676, "name" => "Ubuntu 12.04 x64", "distribution" => "Ubuntu" }, ] } response end
# File lib/fog/digitalocean/requests/compute/list_regions.rb, line 15 def list_regions response = Excon::Response.new response.status = 200 response.body = { "status" => "OK", "regions" => [ { "id" => 1, "name" => "New York 1" }, { "id" => 2, "name" => "Amsterdam 1" }, { "id" => 3, "name" => "San Francisco 1" }, { "id" => 4, "name" => "New York 2" }, { "id" => 5, "name" => "Amsterdam 2" }, { "id" => 6, "name" => "Singapore 1" } ] } response end
# File lib/fog/digitalocean/requests/compute/list_servers.rb, line 15 def list_servers response = Excon::Response.new response.status = 200 response.body = { "status" => "OK", "droplets" => self.data[:servers] } response end
# File lib/fog/digitalocean/requests/compute/list_ssh_keys.rb, line 15 def list_ssh_keys response = Excon::Response.new response.status = 200 response.body = { "status" => "OK", "ssh_keys" => self.data[:ssh_keys] } response end
# File lib/fog/digitalocean/requests/compute/power_cycle_server.rb, line 15 def power_cycle_server( id ) response = Excon::Response.new response.status = 200 server = self.data[:servers].find { |s| s['id'] == id } server['status'] = 'off' if server response.body = { "event_id" => Fog::Mock.random_numbers(1).to_i, "status" => "OK" } response end
# File lib/fog/digitalocean/requests/compute/power_off_server.rb, line 15 def power_off_server( id ) response = Excon::Response.new response.status = 200 server = self.data[:servers].find { |s| s['id'] } server['status'] = 'off' if server response.body = { "event_id" => Fog::Mock.random_numbers(1).to_i, "status" => "OK" } response end
# File lib/fog/digitalocean/requests/compute/power_on_server.rb, line 15 def power_on_server( id ) response = Excon::Response.new response.status = 200 server = self.data[:servers].find { |s| s['id'] } server['status'] = 'active' if server response.body = { "event_id" => Fog::Mock.random_numbers(1).to_i, "status" => "OK" } response end
# File lib/fog/digitalocean/requests/compute/reboot_server.rb, line 15 def reboot_server( id ) response = Excon::Response.new response.status = 200 server = self.data[:servers].find { |s| s['id'] == id } server['status'] = 'off' if server response.body = { "event_id" => Fog::Mock.random_numbers(1).to_i, "status" => "OK" } response end
# File lib/fog/digitalocean/compute.rb, line 65 def reset_data self.class.data.delete(@digitalocean_api_key) end
# File lib/fog/digitalocean/requests/compute/shutdown_server.rb, line 15 def shutdown_server( id ) response = Excon::Response.new response.status = 200 server = self.data[:servers].find { |s| s['id'] == id } # Simulate reboot server['status'] = 'off' if server response.body = { "event_id" => Fog::Mock.random_numbers(1).to_i, "status" => "OK" } response end
Generated with the Darkfish Rdoc Generator 2.