From: Sang-Min Park <[email protected]>

---
 server/config/drivers.yaml                         |    4 +
 .../drivers/eucalyptus/eucalyptus_driver.rb        |  147 ++++++++++++++++++++
 2 files changed, 151 insertions(+), 0 deletions(-)
 create mode 100644 
server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb

diff --git a/server/config/drivers.yaml b/server/config/drivers.yaml
index d028ca0..8248e05 100644
--- a/server/config/drivers.yaml
+++ b/server/config/drivers.yaml
@@ -21,6 +21,10 @@
   :name: Rackspace
 :azure: 
   :name: Azure
+:eucalyptus:
+  :name: Eucalyptus
+  :username: Access Key ID
+  :password: Secret Access Key
 :ec2: 
   :entrypoints: 
     s3: 
diff --git a/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb 
b/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
new file mode 100644
index 0000000..a13dc01
--- /dev/null
+++ b/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
@@ -0,0 +1,147 @@
+# 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
+            {:connection_mode => :per_thread} #EC2_URL/S3_URL env variable 
will be used by AWS
+          end
+        end
+      end
+    end
+  end
+end
+
-- 
1.7.1

Reply via email to