Module: Fog

Defined in:
lib/fog.rb,
lib/fog/aws.rb,
lib/fog/bin.rb,
lib/fog/model.rb,
lib/fog/aws/s3.rb,
lib/fog/parser.rb,
lib/fog/aws/ec2.rb,
lib/fog/rackspace.rb,
lib/fog/slicehost.rb,
lib/fog/terremark.rb,
lib/fog/collection.rb,
lib/fog/connection.rb,
lib/fog/credentials.rb,
lib/fog/aws/simpledb.rb,
lib/fog/rackspace/files.rb,
lib/fog/rackspace/servers.rb,
lib/fog/aws/models/s3/file.rb,
lib/fog/aws/models/s3/files.rb,
lib/fog/aws/models/ec2/image.rb,
lib/fog/aws/models/ec2/flavor.rb,
lib/fog/aws/models/ec2/images.rb,
lib/fog/aws/models/ec2/server.rb,
lib/fog/aws/models/ec2/volume.rb,
lib/fog/aws/parsers/ec2/basic.rb,
lib/fog/aws/models/ec2/address.rb,
lib/fog/aws/models/ec2/flavors.rb,
lib/fog/aws/models/ec2/servers.rb,
lib/fog/aws/models/ec2/volumes.rb,
lib/fog/slicehost/models/image.rb,
lib/fog/terremark/parsers/task.rb,
lib/fog/terremark/parsers/vapp.rb,
lib/fog/aws/models/ec2/key_pair.rb,
lib/fog/aws/models/ec2/snapshot.rb,
lib/fog/aws/models/s3/directory.rb,
lib/fog/slicehost/models/flavor.rb,
lib/fog/slicehost/models/images.rb,
lib/fog/slicehost/models/server.rb,
lib/fog/aws/models/ec2/addresses.rb,
lib/fog/aws/models/ec2/key_pairs.rb,
lib/fog/aws/models/ec2/snapshots.rb,
lib/fog/slicehost/models/flavors.rb,
lib/fog/slicehost/models/servers.rb,
lib/fog/terremark/requests/reset.rb,
lib/fog/aws/models/s3/directories.rb,
lib/fog/aws/parsers/s3/get_bucket.rb,
lib/fog/terremark/parsers/get_vdc.rb,
lib/fog/aws/parsers/s3/copy_object.rb,
lib/fog/aws/parsers/s3/get_service.rb,
lib/fog/aws/parsers/simpledb/basic.rb,
lib/fog/aws/requests/s3/get_bucket.rb,
lib/fog/aws/requests/s3/get_object.rb,
lib/fog/aws/requests/s3/put_bucket.rb,
lib/fog/aws/requests/s3/put_object.rb,
lib/fog/terremark/requests/get_vdc.rb,
lib/fog/aws/parsers/simpledb/select.rb,
lib/fog/aws/requests/s3/copy_object.rb,
lib/fog/aws/requests/s3/get_service.rb,
lib/fog/aws/requests/s3/head_object.rb,
lib/fog/rackspace/models/files/file.rb,
lib/fog/slicehost/parsers/get_image.rb,
lib/fog/slicehost/parsers/get_slice.rb,
lib/fog/terremark/requests/get_task.rb,
lib/fog/terremark/requests/get_vapp.rb,
lib/fog/terremark/requests/power_on.rb,
lib/fog/terremark/requests/shutdown.rb,
lib/fog/aws/requests/simpledb/select.rb,
lib/fog/rackspace/models/files/files.rb,
lib/fog/slicehost/parsers/get_flavor.rb,
lib/fog/slicehost/parsers/get_images.rb,
lib/fog/slicehost/parsers/get_slices.rb,
lib/fog/slicehost/requests/get_image.rb,
lib/fog/slicehost/requests/get_slice.rb,
lib/fog/terremark/requests/power_off.rb,
lib/fog/aws/models/ec2/security_group.rb,
lib/fog/aws/parsers/ec2/attach_volume.rb,
lib/fog/aws/parsers/ec2/create_volume.rb,
lib/fog/aws/parsers/ec2/detach_volume.rb,
lib/fog/aws/parsers/ec2/run_instances.rb,
lib/fog/aws/requests/s3/delete_bucket.rb,
lib/fog/aws/requests/s3/delete_object.rb,
lib/fog/slicehost/parsers/get_backups.rb,
lib/fog/slicehost/parsers/get_flavors.rb,
lib/fog/slicehost/requests/get_flavor.rb,
lib/fog/slicehost/requests/get_images.rb,
lib/fog/slicehost/requests/get_slices.rb,
lib/fog/terremark/parsers/get_catalog.rb,
lib/fog/aws/models/ec2/security_groups.rb,
lib/fog/aws/requests/ec2/attach_volume.rb,
lib/fog/aws/requests/ec2/create_volume.rb,
lib/fog/aws/requests/ec2/delete_volume.rb,
lib/fog/aws/requests/ec2/detach_volume.rb,
lib/fog/aws/requests/ec2/run_instances.rb,
lib/fog/rackspace/models/servers/image.rb,
lib/fog/slicehost/parsers/create_slice.rb,
lib/fog/slicehost/requests/get_backups.rb,
lib/fog/slicehost/requests/get_flavors.rb,
lib/fog/terremark/parsers/node_service.rb,
lib/fog/terremark/requests/delete_vapp.rb,
lib/fog/terremark/requests/deploy_vapp.rb,
lib/fog/terremark/requests/get_catalog.rb,
lib/fog/aws/parsers/ec2/create_key_pair.rb,
lib/fog/aws/parsers/ec2/create_snapshot.rb,
lib/fog/aws/parsers/ec2/describe_images.rb,
lib/fog/rackspace/models/servers/flavor.rb,
lib/fog/rackspace/models/servers/images.rb,
lib/fog/rackspace/models/servers/server.rb,
lib/fog/slicehost/requests/create_slice.rb,
lib/fog/slicehost/requests/delete_slice.rb,
lib/fog/slicehost/requests/reboot_slice.rb,
lib/fog/aws/parsers/ec2/allocate_address.rb,
lib/fog/aws/parsers/ec2/describe_regions.rb,
lib/fog/aws/parsers/ec2/describe_volumes.rb,
lib/fog/aws/requests/ec2/create_key_pair.rb,
lib/fog/aws/requests/ec2/create_snapshot.rb,
lib/fog/aws/requests/ec2/delete_key_pair.rb,
lib/fog/aws/requests/ec2/delete_snapshot.rb,
lib/fog/aws/requests/ec2/describe_images.rb,
lib/fog/aws/requests/ec2/release_address.rb,
lib/fog/rackspace/models/files/directory.rb,
lib/fog/rackspace/models/servers/flavors.rb,
lib/fog/rackspace/models/servers/servers.rb,
lib/fog/terremark/parsers/get_public_Ips.rb,
lib/fog/terremark/parsers/get_tasks_list.rb,
lib/fog/aws/parsers/simpledb/list_domains.rb,
lib/fog/aws/requests/ec2/allocate_address.rb,
lib/fog/aws/requests/ec2/describe_regions.rb,
lib/fog/aws/requests/ec2/describe_volumes.rb,
lib/fog/aws/requests/ec2/reboot_instances.rb,
lib/fog/terremark/requests/get_public_ips.rb,
lib/fog/terremark/requests/get_tasks_list.rb,
lib/fog/aws/parsers/ec2/describe_addresses.rb,
lib/fog/aws/parsers/ec2/describe_instances.rb,
lib/fog/aws/parsers/ec2/describe_key_pairs.rb,
lib/fog/aws/parsers/ec2/describe_snapshots.rb,
lib/fog/aws/parsers/ec2/get_console_output.rb,
lib/fog/aws/parsers/s3/get_bucket_location.rb,
lib/fog/aws/parsers/s3/get_request_payment.rb,
lib/fog/aws/requests/ec2/associate_address.rb,
lib/fog/aws/requests/simpledb/list_domains.rb,
lib/fog/rackspace/models/files/directories.rb,
lib/fog/terremark/parsers/get_catalog_item.rb,
lib/fog/terremark/parsers/get_organization.rb,
lib/fog/terremark/parsers/internet_service.rb,
lib/fog/aws/parsers/ec2/terminate_instances.rb,
lib/fog/aws/parsers/simpledb/get_attributes.rb,
lib/fog/aws/requests/ec2/describe_addresses.rb,
lib/fog/aws/requests/ec2/describe_instances.rb,
lib/fog/aws/requests/ec2/describe_key_pairs.rb,
lib/fog/aws/requests/ec2/describe_snapshots.rb,
lib/fog/aws/requests/ec2/get_console_output.rb,
lib/fog/aws/requests/s3/get_bucket_location.rb,
lib/fog/aws/requests/s3/get_request_payment.rb,
lib/fog/aws/requests/s3/put_request_payment.rb,
lib/fog/aws/requests/simpledb/create_domain.rb,
lib/fog/aws/requests/simpledb/delete_domain.rb,
lib/fog/rackspace/requests/files/get_object.rb,
lib/fog/rackspace/requests/files/put_object.rb,
lib/fog/terremark/parsers/get_organizations.rb,
lib/fog/terremark/parsers/get_vapp_template.rb,
lib/fog/terremark/requests/add_node_service.rb,
lib/fog/terremark/requests/get_catalog_item.rb,
lib/fog/terremark/requests/get_organization.rb,
lib/fog/aws/parsers/simpledb/domain_metadata.rb,
lib/fog/aws/requests/ec2/terminate_instances.rb,
lib/fog/aws/requests/simpledb/get_attributes.rb,
lib/fog/aws/requests/simpledb/put_attributes.rb,
lib/fog/rackspace/requests/files/head_object.rb,
lib/fog/terremark/requests/get_organizations.rb,
lib/fog/terremark/requests/get_vapp_template.rb,
lib/fog/aws/requests/ec2/disassociate_address.rb,
lib/fog/aws/requests/simpledb/domain_metadata.rb,
lib/fog/aws/requests/ec2/create_security_group.rb,
lib/fog/aws/requests/ec2/delete_security_group.rb,
lib/fog/rackspace/requests/files/delete_object.rb,
lib/fog/rackspace/requests/files/get_container.rb,
lib/fog/rackspace/requests/files/put_container.rb,
lib/fog/rackspace/requests/servers/list_images.rb,
lib/fog/terremark/requests/delete_node_service.rb,
lib/fog/aws/requests/simpledb/delete_attributes.rb,
lib/fog/rackspace/requests/files/get_containers.rb,
lib/fog/rackspace/requests/files/head_container.rb,
lib/fog/rackspace/requests/servers/create_image.rb,
lib/fog/rackspace/requests/servers/delete_image.rb,
lib/fog/rackspace/requests/servers/list_flavors.rb,
lib/fog/rackspace/requests/servers/list_servers.rb,
lib/fog/terremark/requests/add_internet_service.rb,
lib/fog/aws/parsers/ec2/describe_security_groups.rb,
lib/fog/rackspace/requests/files/head_containers.rb,
lib/fog/rackspace/requests/servers/create_server.rb,
lib/fog/rackspace/requests/servers/delete_server.rb,
lib/fog/rackspace/requests/servers/reboot_server.rb,
lib/fog/rackspace/requests/servers/update_server.rb,
lib/fog/aws/requests/ec2/describe_security_groups.rb,
lib/fog/rackspace/requests/files/delete_container.rb,
lib/fog/rackspace/requests/servers/list_addresses.rb,
lib/fog/aws/requests/simpledb/batch_put_attributes.rb,
lib/fog/terremark/requests/create_internet_service.rb,
lib/fog/terremark/requests/delete_internet_service.rb,
lib/fog/aws/parsers/ec2/describe_availability_zones.rb,
lib/fog/aws/parsers/ec2/describe_reserved_instances.rb,
lib/fog/terremark/parsers/instantiate_vapp_template.rb,
lib/fog/aws/requests/ec2/describe_availability_zones.rb,
lib/fog/aws/requests/ec2/describe_reserved_instances.rb,
lib/fog/rackspace/requests/servers/get_image_details.rb,
lib/fog/terremark/requests/instantiate_vapp_template.rb,
lib/fog/rackspace/requests/servers/get_flavor_details.rb,
lib/fog/rackspace/requests/servers/get_server_details.rb,
lib/fog/rackspace/requests/servers/list_images_detail.rb,
lib/fog/aws/requests/ec2/revoke_security_group_ingress.rb,
lib/fog/rackspace/requests/servers/list_flavors_detail.rb,
lib/fog/rackspace/requests/servers/list_servers_detail.rb,
lib/fog/rackspace/requests/servers/list_public_addresses.rb,
lib/fog/aws/requests/ec2/authorize_security_group_ingress.rb,
lib/fog/rackspace/requests/servers/list_private_addresses.rb

Defined Under Namespace

Modules: AWS, Mock, Parsers, Rackspace, Slicehost, Terremark Classes: Collection, Connection, MockNotImplemented, Model

Class Method Summary collapse

Class Method Details

.credentialObject


9
10
11
# File 'lib/fog/credentials.rb', line 9

def credential
  @credential || :default
end

.credential=(new_credential) ⇒ Object


4
5
6
7
# File 'lib/fog/credentials.rb', line 4

def credential=(new_credential)
  @credential = new_credential
  @credentials = nil
end

.credentialsObject


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fog/credentials.rb', line 13

def credentials
  @credentials ||= begin
    path = File.expand_path('~/.fog')
    credentials = if File.exists?(path)
      File.open(path) do |file|
        YAML.load(file.read)
      end
    else
      nil
    end
    unless credentials && credentials[credential]
      print("\n  To run as '#{credential}', add the following to ~/.fog\n")
      yml = <<-YML

:#{credential}:
  :aws_access_key_id:     INTENTIONALLY_LEFT_BLANK
  :aws_secret_access_key: INTENTIONALLY_LEFT_BLANK
  :rackspace_api_key:     INTENTIONALLY_LEFT_BLANK
  :rackspace_username:    INTENTIONALLY_LEFT_BLANK
  :slicehost_password:    INTENTIONALLY_LEFT_BLANK
  :terremark_username:    INTENTIONALLY_LEFT_BLANK
  :terremark_password:    INTENTIONALLY_LEFT_BLANK

YML
      print(yml)
      raise(ArgumentError.new("Missing Credentials"))
    end
    credentials[credential]
  end
end

.flavorsObject


16
17
18
19
20
21
22
23
24
# File 'lib/fog/bin.rb', line 16

def flavors
  flavors = {}
  services.each do |service|
    if service.respond_to?(:flavors)
      flavors[service] = service.flavors
    end
  end
  flavors
end

.imagesObject


26
27
28
29
30
31
32
33
34
# File 'lib/fog/bin.rb', line 26

def images
  images = {}
  services.each do |service|
    if service.respond_to?(:images)
      images[service] = service.images
    end
  end
  images
end

.mock!Object


37
38
39
# File 'lib/fog.rb', line 37

def self.mock!
  @mocking = true
end

.mocking?Boolean

Returns:

  • (Boolean)

41
42
43
# File 'lib/fog.rb', line 41

def self.mocking?
  !!@mocking
end

.serversObject


36
37
38
39
40
41
42
43
44
# File 'lib/fog/bin.rb', line 36

def servers
  servers = {}
  services.each do |service|
    if service.respond_to?(:servers)
      servers[service] = service.servers
    end
  end
  servers
end

.servicesObject


6
7
8
9
10
11
12
13
14
# File 'lib/fog/bin.rb', line 6

def services
  services = []
  [::AWS, ::Rackspace, ::Slicehost, ::Terremark].each do |service|
    if service.initialized?
      services << service
    end
  end
  services
end