From 509bf6e469f7a79aa0dcd5c517a9744306edf60b Mon Sep 17 00:00:00 2001 From: "geemus (Wesley Beary)" Date: Sat, 3 Apr 2010 00:33:35 -0700 Subject: [PATCH] defer requires to initialize time, speeding load time for those using fewer services --- lib/fog/aws/ec2.rb | 95 ++++++++++++++++++------------------ lib/fog/aws/s3.rb | 35 ++++++------- lib/fog/aws/simpledb.rb | 21 ++++---- lib/fog/rackspace/files.rb | 31 ++++++------ lib/fog/rackspace/servers.rb | 49 ++++++++++--------- lib/fog/slicehost.rb | 35 ++++++------- lib/fog/terremark.rb | 35 ++++++------- 7 files changed, 154 insertions(+), 147 deletions(-) diff --git a/lib/fog/aws/ec2.rb b/lib/fog/aws/ec2.rb index fb434eeac..ee4347066 100644 --- a/lib/fog/aws/ec2.rb +++ b/lib/fog/aws/ec2.rb @@ -1,55 +1,56 @@ -require 'fog/aws/models/ec2/address' -require 'fog/aws/models/ec2/addresses' -require 'fog/aws/models/ec2/flavor' -require 'fog/aws/models/ec2/flavors' -require 'fog/aws/models/ec2/image' -require 'fog/aws/models/ec2/images' -require 'fog/aws/models/ec2/key_pair' -require 'fog/aws/models/ec2/key_pairs' -require 'fog/aws/models/ec2/security_group' -require 'fog/aws/models/ec2/security_groups' -require 'fog/aws/models/ec2/server' -require 'fog/aws/models/ec2/servers' -require 'fog/aws/models/ec2/snapshot' -require 'fog/aws/models/ec2/snapshots' -require 'fog/aws/models/ec2/volume' -require 'fog/aws/models/ec2/volumes' -require 'fog/aws/requests/ec2/allocate_address' -require 'fog/aws/requests/ec2/associate_address' -require 'fog/aws/requests/ec2/attach_volume' -require 'fog/aws/requests/ec2/authorize_security_group_ingress' -require 'fog/aws/requests/ec2/create_key_pair' -require 'fog/aws/requests/ec2/create_security_group' -require 'fog/aws/requests/ec2/create_snapshot' -require 'fog/aws/requests/ec2/create_volume' -require 'fog/aws/requests/ec2/delete_key_pair' -require 'fog/aws/requests/ec2/delete_security_group' -require 'fog/aws/requests/ec2/delete_snapshot' -require 'fog/aws/requests/ec2/delete_volume' -require 'fog/aws/requests/ec2/describe_addresses' -require 'fog/aws/requests/ec2/describe_availability_zones' -require 'fog/aws/requests/ec2/describe_images' -require 'fog/aws/requests/ec2/describe_instances' -require 'fog/aws/requests/ec2/describe_reserved_instances' -require 'fog/aws/requests/ec2/describe_key_pairs' -require 'fog/aws/requests/ec2/describe_regions' -require 'fog/aws/requests/ec2/describe_security_groups' -require 'fog/aws/requests/ec2/describe_snapshots' -require 'fog/aws/requests/ec2/describe_volumes' -require 'fog/aws/requests/ec2/detach_volume' -require 'fog/aws/requests/ec2/disassociate_address' -require 'fog/aws/requests/ec2/get_console_output' -require 'fog/aws/requests/ec2/reboot_instances' -require 'fog/aws/requests/ec2/release_address' -require 'fog/aws/requests/ec2/revoke_security_group_ingress' -require 'fog/aws/requests/ec2/run_instances' -require 'fog/aws/requests/ec2/terminate_instances' - module Fog module AWS module EC2 def self.new(options={}) + + require 'fog/aws/models/ec2/address' + require 'fog/aws/models/ec2/addresses' + require 'fog/aws/models/ec2/flavor' + require 'fog/aws/models/ec2/flavors' + require 'fog/aws/models/ec2/image' + require 'fog/aws/models/ec2/images' + require 'fog/aws/models/ec2/key_pair' + require 'fog/aws/models/ec2/key_pairs' + require 'fog/aws/models/ec2/security_group' + require 'fog/aws/models/ec2/security_groups' + require 'fog/aws/models/ec2/server' + require 'fog/aws/models/ec2/servers' + require 'fog/aws/models/ec2/snapshot' + require 'fog/aws/models/ec2/snapshots' + require 'fog/aws/models/ec2/volume' + require 'fog/aws/models/ec2/volumes' + require 'fog/aws/requests/ec2/allocate_address' + require 'fog/aws/requests/ec2/associate_address' + require 'fog/aws/requests/ec2/attach_volume' + require 'fog/aws/requests/ec2/authorize_security_group_ingress' + require 'fog/aws/requests/ec2/create_key_pair' + require 'fog/aws/requests/ec2/create_security_group' + require 'fog/aws/requests/ec2/create_snapshot' + require 'fog/aws/requests/ec2/create_volume' + require 'fog/aws/requests/ec2/delete_key_pair' + require 'fog/aws/requests/ec2/delete_security_group' + require 'fog/aws/requests/ec2/delete_snapshot' + require 'fog/aws/requests/ec2/delete_volume' + require 'fog/aws/requests/ec2/describe_addresses' + require 'fog/aws/requests/ec2/describe_availability_zones' + require 'fog/aws/requests/ec2/describe_images' + require 'fog/aws/requests/ec2/describe_instances' + require 'fog/aws/requests/ec2/describe_reserved_instances' + require 'fog/aws/requests/ec2/describe_key_pairs' + require 'fog/aws/requests/ec2/describe_regions' + require 'fog/aws/requests/ec2/describe_security_groups' + require 'fog/aws/requests/ec2/describe_snapshots' + require 'fog/aws/requests/ec2/describe_volumes' + require 'fog/aws/requests/ec2/detach_volume' + require 'fog/aws/requests/ec2/disassociate_address' + require 'fog/aws/requests/ec2/get_console_output' + require 'fog/aws/requests/ec2/reboot_instances' + require 'fog/aws/requests/ec2/release_address' + require 'fog/aws/requests/ec2/revoke_security_group_ingress' + require 'fog/aws/requests/ec2/run_instances' + require 'fog/aws/requests/ec2/terminate_instances' + unless options[:aws_access_key_id] raise ArgumentError.new('aws_access_key_id is required to access ec2') end diff --git a/lib/fog/aws/s3.rb b/lib/fog/aws/s3.rb index e966bcdd4..d30177fb7 100644 --- a/lib/fog/aws/s3.rb +++ b/lib/fog/aws/s3.rb @@ -1,25 +1,26 @@ -require 'fog/aws/models/s3/directories' -require 'fog/aws/models/s3/directory' -require 'fog/aws/models/s3/files' -require 'fog/aws/models/s3/file' -require 'fog/aws/requests/s3/copy_object' -require 'fog/aws/requests/s3/delete_bucket' -require 'fog/aws/requests/s3/delete_object' -require 'fog/aws/requests/s3/get_bucket' -require 'fog/aws/requests/s3/get_bucket_location' -require 'fog/aws/requests/s3/get_object' -require 'fog/aws/requests/s3/get_request_payment' -require 'fog/aws/requests/s3/get_service' -require 'fog/aws/requests/s3/head_object' -require 'fog/aws/requests/s3/put_bucket' -require 'fog/aws/requests/s3/put_object' -require 'fog/aws/requests/s3/put_request_payment' - module Fog module AWS module S3 def self.new(options={}) + + require 'fog/aws/models/s3/directories' + require 'fog/aws/models/s3/directory' + require 'fog/aws/models/s3/files' + require 'fog/aws/models/s3/file' + require 'fog/aws/requests/s3/copy_object' + require 'fog/aws/requests/s3/delete_bucket' + require 'fog/aws/requests/s3/delete_object' + require 'fog/aws/requests/s3/get_bucket' + require 'fog/aws/requests/s3/get_bucket_location' + require 'fog/aws/requests/s3/get_object' + require 'fog/aws/requests/s3/get_request_payment' + require 'fog/aws/requests/s3/get_service' + require 'fog/aws/requests/s3/head_object' + require 'fog/aws/requests/s3/put_bucket' + require 'fog/aws/requests/s3/put_object' + require 'fog/aws/requests/s3/put_request_payment' + if Fog.mocking? Fog::AWS::S3::Mock.new(options) else diff --git a/lib/fog/aws/simpledb.rb b/lib/fog/aws/simpledb.rb index 567c06148..45e43b13e 100644 --- a/lib/fog/aws/simpledb.rb +++ b/lib/fog/aws/simpledb.rb @@ -1,18 +1,19 @@ -require 'fog/aws/requests/simpledb/batch_put_attributes' -require 'fog/aws/requests/simpledb/create_domain' -require 'fog/aws/requests/simpledb/delete_attributes' -require 'fog/aws/requests/simpledb/delete_domain' -require 'fog/aws/requests/simpledb/domain_metadata' -require 'fog/aws/requests/simpledb/get_attributes' -require 'fog/aws/requests/simpledb/list_domains' -require 'fog/aws/requests/simpledb/put_attributes' -require 'fog/aws/requests/simpledb/select' - module Fog module AWS module SimpleDB def self.new(options={}) + + require 'fog/aws/requests/simpledb/batch_put_attributes' + require 'fog/aws/requests/simpledb/create_domain' + require 'fog/aws/requests/simpledb/delete_attributes' + require 'fog/aws/requests/simpledb/delete_domain' + require 'fog/aws/requests/simpledb/domain_metadata' + require 'fog/aws/requests/simpledb/get_attributes' + require 'fog/aws/requests/simpledb/list_domains' + require 'fog/aws/requests/simpledb/put_attributes' + require 'fog/aws/requests/simpledb/select' + if Fog.mocking? Fog::AWS::SimpleDB::Mock.new(options) else diff --git a/lib/fog/rackspace/files.rb b/lib/fog/rackspace/files.rb index 7198a1724..63a573067 100644 --- a/lib/fog/rackspace/files.rb +++ b/lib/fog/rackspace/files.rb @@ -1,23 +1,24 @@ -require 'fog/rackspace/models/files/directory' -require 'fog/rackspace/models/files/directories' -require 'fog/rackspace/models/files/file' -require 'fog/rackspace/models/files/files' -require 'fog/rackspace/requests/files/delete_container' -require 'fog/rackspace/requests/files/delete_object' -require 'fog/rackspace/requests/files/get_container' -require 'fog/rackspace/requests/files/get_containers' -require 'fog/rackspace/requests/files/get_object' -require 'fog/rackspace/requests/files/head_container' -require 'fog/rackspace/requests/files/head_containers' -require 'fog/rackspace/requests/files/head_object' -require 'fog/rackspace/requests/files/put_container' -require 'fog/rackspace/requests/files/put_object' - module Fog module Rackspace module Files def self.new(options={}) + + require 'fog/rackspace/models/files/directory' + require 'fog/rackspace/models/files/directories' + require 'fog/rackspace/models/files/file' + require 'fog/rackspace/models/files/files' + require 'fog/rackspace/requests/files/delete_container' + require 'fog/rackspace/requests/files/delete_object' + require 'fog/rackspace/requests/files/get_container' + require 'fog/rackspace/requests/files/get_containers' + require 'fog/rackspace/requests/files/get_object' + require 'fog/rackspace/requests/files/head_container' + require 'fog/rackspace/requests/files/head_containers' + require 'fog/rackspace/requests/files/head_object' + require 'fog/rackspace/requests/files/put_container' + require 'fog/rackspace/requests/files/put_object' + if Fog.mocking? Fog::Rackspace::Files::Mock.new(options) else diff --git a/lib/fog/rackspace/servers.rb b/lib/fog/rackspace/servers.rb index 31c007f16..5f840327c 100644 --- a/lib/fog/rackspace/servers.rb +++ b/lib/fog/rackspace/servers.rb @@ -1,32 +1,33 @@ -require 'fog/rackspace/models/servers/flavor' -require 'fog/rackspace/models/servers/flavors' -require 'fog/rackspace/models/servers/image' -require 'fog/rackspace/models/servers/images' -require 'fog/rackspace/models/servers/server' -require 'fog/rackspace/models/servers/servers' -require 'fog/rackspace/requests/servers/create_image' -require 'fog/rackspace/requests/servers/create_server' -require 'fog/rackspace/requests/servers/delete_image' -require 'fog/rackspace/requests/servers/delete_server' -require 'fog/rackspace/requests/servers/get_flavor_details' -require 'fog/rackspace/requests/servers/get_server_details' -require 'fog/rackspace/requests/servers/list_addresses' -require 'fog/rackspace/requests/servers/list_private_addresses' -require 'fog/rackspace/requests/servers/list_public_addresses' -require 'fog/rackspace/requests/servers/list_flavors' -require 'fog/rackspace/requests/servers/list_flavors_detail' -require 'fog/rackspace/requests/servers/list_images' -require 'fog/rackspace/requests/servers/list_images_detail' -require 'fog/rackspace/requests/servers/list_servers' -require 'fog/rackspace/requests/servers/list_servers_detail' -require 'fog/rackspace/requests/servers/reboot_server' -require 'fog/rackspace/requests/servers/update_server' - module Fog module Rackspace module Servers def self.new(options={}) + + require 'fog/rackspace/models/servers/flavor' + require 'fog/rackspace/models/servers/flavors' + require 'fog/rackspace/models/servers/image' + require 'fog/rackspace/models/servers/images' + require 'fog/rackspace/models/servers/server' + require 'fog/rackspace/models/servers/servers' + require 'fog/rackspace/requests/servers/create_image' + require 'fog/rackspace/requests/servers/create_server' + require 'fog/rackspace/requests/servers/delete_image' + require 'fog/rackspace/requests/servers/delete_server' + require 'fog/rackspace/requests/servers/get_flavor_details' + require 'fog/rackspace/requests/servers/get_server_details' + require 'fog/rackspace/requests/servers/list_addresses' + require 'fog/rackspace/requests/servers/list_private_addresses' + require 'fog/rackspace/requests/servers/list_public_addresses' + require 'fog/rackspace/requests/servers/list_flavors' + require 'fog/rackspace/requests/servers/list_flavors_detail' + require 'fog/rackspace/requests/servers/list_images' + require 'fog/rackspace/requests/servers/list_images_detail' + require 'fog/rackspace/requests/servers/list_servers' + require 'fog/rackspace/requests/servers/list_servers_detail' + require 'fog/rackspace/requests/servers/reboot_server' + require 'fog/rackspace/requests/servers/update_server' + if Fog.mocking? Fog::Rackspace::Servers::Mock.new(options) else diff --git a/lib/fog/slicehost.rb b/lib/fog/slicehost.rb index 80fd78682..6ac8b3817 100644 --- a/lib/fog/slicehost.rb +++ b/lib/fog/slicehost.rb @@ -1,24 +1,25 @@ -require 'fog/slicehost/models/flavor' -require 'fog/slicehost/models/flavors' -require 'fog/slicehost/models/image' -require 'fog/slicehost/models/images' -require 'fog/slicehost/models/server' -require 'fog/slicehost/models/servers' -require 'fog/slicehost/requests/create_slice' -require 'fog/slicehost/requests/delete_slice' -require 'fog/slicehost/requests/get_backups' -require 'fog/slicehost/requests/get_flavor' -require 'fog/slicehost/requests/get_flavors' -require 'fog/slicehost/requests/get_image' -require 'fog/slicehost/requests/get_images' -require 'fog/slicehost/requests/get_slice' -require 'fog/slicehost/requests/get_slices' -require 'fog/slicehost/requests/reboot_slice' - module Fog module Slicehost def self.new(options={}) + + require 'fog/slicehost/models/flavor' + require 'fog/slicehost/models/flavors' + require 'fog/slicehost/models/image' + require 'fog/slicehost/models/images' + require 'fog/slicehost/models/server' + require 'fog/slicehost/models/servers' + require 'fog/slicehost/requests/create_slice' + require 'fog/slicehost/requests/delete_slice' + require 'fog/slicehost/requests/get_backups' + require 'fog/slicehost/requests/get_flavor' + require 'fog/slicehost/requests/get_flavors' + require 'fog/slicehost/requests/get_image' + require 'fog/slicehost/requests/get_images' + require 'fog/slicehost/requests/get_slice' + require 'fog/slicehost/requests/get_slices' + require 'fog/slicehost/requests/reboot_slice' + unless options[:slicehost_password] raise ArgumentError.new('slicehost_password is required to access slicehost') end diff --git a/lib/fog/terremark.rb b/lib/fog/terremark.rb index dd2c31d52..e22f39e80 100644 --- a/lib/fog/terremark.rb +++ b/lib/fog/terremark.rb @@ -1,24 +1,25 @@ -require 'fog/terremark/requests/delete_vapp' -require 'fog/terremark/requests/deploy_vapp' -require 'fog/terremark/requests/get_catalog' -require 'fog/terremark/requests/get_catalog_item' -require 'fog/terremark/requests/get_organization' -require 'fog/terremark/requests/get_organizations' -require 'fog/terremark/requests/get_task' -require 'fog/terremark/requests/get_tasks_list' -require 'fog/terremark/requests/get_vapp' -require 'fog/terremark/requests/get_vapp_template' -require 'fog/terremark/requests/get_vdc' -require 'fog/terremark/requests/instantiate_vapp_template' -require 'fog/terremark/requests/reset' -require 'fog/terremark/requests/power_off' -require 'fog/terremark/requests/power_on' -require 'fog/terremark/requests/shutdown' - module Fog module Terremark def self.new(options={}) + + require 'fog/terremark/requests/delete_vapp' + require 'fog/terremark/requests/deploy_vapp' + require 'fog/terremark/requests/get_catalog' + require 'fog/terremark/requests/get_catalog_item' + require 'fog/terremark/requests/get_organization' + require 'fog/terremark/requests/get_organizations' + require 'fog/terremark/requests/get_task' + require 'fog/terremark/requests/get_tasks_list' + require 'fog/terremark/requests/get_vapp' + require 'fog/terremark/requests/get_vapp_template' + require 'fog/terremark/requests/get_vdc' + require 'fog/terremark/requests/instantiate_vapp_template' + require 'fog/terremark/requests/reset' + require 'fog/terremark/requests/power_off' + require 'fog/terremark/requests/power_on' + require 'fog/terremark/requests/shutdown' + unless options[:terremark_password] raise ArgumentError.new('terremark_password is required to access terremark') end