You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2011/03/25 23:01:18 UTC

svn commit: r1085576 - in /incubator/deltacloud/trunk/server: config/drivers.yaml lib/deltacloud/drivers/eucalyptus/ lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb

Author: lutter
Date: Fri Mar 25 22:01:17 2011
New Revision: 1085576

URL: http://svn.apache.org/viewvc?rev=1085576&view=rev
Log:
Eucalyptus driver support

Added:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/eucalyptus/
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
Modified:
    incubator/deltacloud/trunk/server/config/drivers.yaml

Modified: incubator/deltacloud/trunk/server/config/drivers.yaml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/config/drivers.yaml?rev=1085576&r1=1085575&r2=1085576&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/config/drivers.yaml (original)
+++ incubator/deltacloud/trunk/server/config/drivers.yaml Fri Mar 25 22:01:17 2011
@@ -21,6 +21,10 @@
   :name: Rackspace
 :azure: 
   :name: Azure
+:eucalyptus:
+  :name: Eucalyptus
+  :username: Access Key ID
+  :password: Secret Access Key
 :ec2: 
   :entrypoints: 
     s3: 

Added: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb?rev=1085576&view=auto
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb (added)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb Fri Mar 25 22:01:17 2011
@@ -0,0 +1,159 @@
+# Copyright (C) 2009, 2010  Red Hat, Inc.
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+
+require 'deltacloud/drivers/ec2/ec2_driver.rb'
+
+module Deltacloud
+  module Drivers
+    module Eucalyptus
+      class EucalyptusDriver < EC2::EC2Driver
+
+        def supported_collections
+          DEFAULT_COLLECTIONS + [ :keys, :buckets ]
+        end
+
+        feature :instances, :user_data
+        feature :instances, :authentication_key
+        feature :instances, :security_group
+        feature :instances, :instance_count
+        feature :images, :owner_id
+
+        define_hardware_profile('m1.small') do
+          cpu                1
+          memory             128
+          storage            2
+          architecture       'x86_64'
+        end
+
+        define_hardware_profile('c1.medium') do
+          cpu                1
+          memory             256
+          storage            5
+          architecture       'x86_64'
+        end
+
+        define_hardware_profile('m1.large') do
+          cpu                2
+          memory             512
+          storage            10
+          architecture       'x86_64'
+        end
+
+        define_hardware_profile('m1.xlarge') do
+          cpu                2
+          memory             1024
+          storage            20
+          architecture       'x86_64'
+        end
+
+        define_hardware_profile('c1.xlarge') do
+          cpu                4
+          memory             2048
+          storage            20
+          architecture       'x86_64'
+        end
+
+        def self.instance_state_machine
+          EC2::EC2Driver.instance_state_machine
+        end
+
+        def instance_state_machine
+          self.class.instance_state_machine
+        end
+
+        def default_image_owner
+          "self"
+        end
+
+        def default_image_type
+          nil
+        end
+
+        def tagging?
+          false
+        end
+
+        def tag_instance(credentials, instance, name)
+          # dummy
+        end
+
+        def untag_instance(credentials, instance_id)
+          # dummy
+        end
+
+        # because load balancer is not on the supported_collections,
+        # the following methods shouldn't be called.
+        def load_balancer(credentials, opts={})
+          raise Deltacloud::BackendError.new(500, "Loadbalancer",
+                  "Loadbalancer not supported in Eucalyptus", "")
+        end
+
+        def load_balancers(credentials, opts=nil)
+          raise Deltacloud::BackendError.new(500, "Loadbalancer",
+                  "Loadbalancer not supported in Eucalyptus", "")
+        end
+
+        def create_load_balancer(credentials, opts={})
+          raise Deltacloud::BackendError.new(500, "Loadbalancer",
+                  "Loadbalancer not supported in Eucalyptus", "")
+        end
+
+        def destroy_load_balancer(credentials, id)
+          raise Deltacloud::BackendError.new(500, "Loadbalancer",
+                  "Loadbalancer not supported in Eucalyptus", "")
+        end
+
+        def lb_register_instance(credentials, opts={})
+          raise Deltacloud::BackendError.new(500, "Loadbalancer",
+                  "Loadbalancer not supported in Eucalyptus", "")
+        end
+
+        def lb_unregister_instance(credentials, opts={})
+          raise Deltacloud::BackendError.new(500, "Loadbalancer",
+                  "Loadbalancer not supported in Eucalyptus", "")
+        end
+
+        def new_client(credentials, type = :ec2)
+          klass = case type
+                  when :ec2 then Aws::Ec2
+                  when :s3 then Aws::S3
+                  when :elb then raise Deltacloud::BackendError.new(500,
+                                         "Loadbalancer",
+                          "Loadbalancer not supported in Eucalyptus", "")
+                  end
+          klass.new(credentials.user, credentials.password, eucalyptus_endpoint)
+        end
+
+        def eucalyptus_endpoint
+          endpoint = (Thread.current[:provider] || ENV['API_PROVIDER'])
+          #parse endpoint string into server, port, service, and protocol
+          if endpoint
+            {:server => URI.parse(endpoint).host,
+              :port => URI.parse(endpoint).port,
+              :service => URI.parse(endpoint).path,
+              :protocol => URI.parse(endpoint).scheme,
+              :connection_mode => :per_thread}
+          else
+            #EC2_URL/S3_URL env variable will be used by AWS
+            {:connection_mode => :per_thread}
+          end
+        end
+      end
+    end
+  end
+end