Fog

 Fog

Getting started with the Fog cloud services library. Presented at the SDRuby monthly meeting on November 3, 2011

07bfe45ca4c9ebe69c64208c7482932c?s=128

James Miller

October 26, 2011
Tweet

Transcript

  1. Fog Ruby Cloud Services Library

  2. github.com/fog/fog fog.io @fog

  3. APIs Hurt

  4. 1. Search for existing, often shoddy library

  5. 2. DIY Wrapper

  6. 3. New vendor comes along that does your laundry too!

  7. 4. Sad face :(

  8. Amazon EC2 Amazon S3 Zerigo DNS RS Files RS Servers

    Amazon Cloudfront Amazon Route 53 Dynect DNS DNSimple Amazon RDS Linode Google Storage
  9. Cross Service Compatibility

  10. gem install fog

  11. require 'fog'

  12. Cloud Storage

  13. s3 = Fog::Storage.new( provider: "AWS", aws_access_key_id: "KEY", aws_secret_access_key: "SECRET" )

    gg = Fog::Storage.new( provider: "Google", google_storage_access_key_id: "KEY", google_storage_secret_access_key: "SECRET" ) rs = Fog::Storage.new( provider: "Rackspace", rackspace_api_key: "KEY", rackspace_auth_url: "URL", rackspace_username: "USERNAME" ) s3.put_object(bucket_name, object_name, data, options = {}) gg.put_object(bucket_name, object_name, data, options = {}) rs.put_object(container, object_name, data, options = {})
  14. s3.put_object(bucket_name, object_name, data, options = {}) gg.put_object(bucket_name, object_name, data, options

    = {}) rs.put_object(container, object_name, data, options = {}) Consistency Provider Flexibility
  15. Cloud Servers

  16. ec2 = Fog::Compute.new( provider: "AWS", aws_access_key_id: "KEY", aws_secret_access_key: "SECRET" )

    rsc = Fog::Compute.new( provider: "Rackspace", rackspace_api_key: "KEY", rackspace_username: "SECRET" ) ec2.servers.create( flavor_id: "c1.medium", image_id: "ami-6936fb00", # Ubuntu 10.04 LTS key_name: "mykeyname", groups: ["default"], ) rsc.servers.create( flavor_id: 5, # 4GB Memory image_id: 49, # Ubuntu 10.04 LTS name: 'my_server_name' )
  17. DNS

  18. z = Fog::DNS::Zerigo.new( zerigo_email: "email", zerigo_token: "secret", scheme: "https", port:

    443 ) zone_id = z.create_zone("bensie.com", 14400, "pri_sec") .body["id"] z.create_host(zone_id, "CNAME", "ghs.google.com", hostname: "mail", ttl: 14400 )
  19. AWS Management Console RS Cloud Control Panel • Multi-step wizards

    • Missing features • Slow • One account at a time
  20. AWS Management Console

  21. rds = Fog::AWS::RDS.new( aws_access_key_id: "KEY", aws_secret_access_key: "SECRET" ) rds.create_db_instance("my-db-instance" "AllocatedStorage"

    => 50, "AutoMinorVersionUpgrade" => false, "BackupRetentionPeriod" => 3, "DBInstanceClass" => "db.m1.large", "DBParameterGroupName" => "utf8", "Engine" => "mysql", "EngineVersion" => "5.5.12", "MasterUsername" => "username", "MasterUserPassword" => "password", "MultiAZ" => true )
  22. rds = Fog::AWS::RDS.new( aws_access_key_id: "KEY", aws_secret_access_key: "SECRET" ) rds.create_db_parameter_group( "utf8",

    "mysql5.5", "utf8" ) rds.modify_db_parameter_group("utf8", [ { "ParameterName" => "character_set_server", "ParameterValue" => "utf8", "ApplyMethod" => "immediate" }, { "ParameterName" => "collation_server", "ParameterValue" => "utf8_general_ci", "ApplyMethod" => "immediate" } ] )
  23. elb = Fog::AWS::ELB.new( aws_access_key_id: "KEY", aws_secret_access_key: "SECRET" ) load_balancers =

    elb.describe_load_balancers .body["DescribeLoadBalancersResult"] ["LoadBalancerDescriptions"] load_balancers.each do |lb| elb.register_instances_with_load_balancer( ["i-3dcba453", "i-37cba459"], lb["LoadBalancerName"] ) end
  24. Documentation

  25. Inline

  26. READ code that you use

  27. Code Organization

  28. lib/fog/provider/service/requests lib/fog/provider/service/models lib/fog/provider/service/parsers

  29. Contributing

  30. Forgetting to delete servers after testing =

  31. James Miller github.com/bensie @bensie