deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <mfoj...@redhat.com>
Subject Re: [PATCH core 14/32] Core: Updated drivers to remove base_driver require and added autoloading of driver
Date Wed, 18 Apr 2012 10:12:05 GMT
On 04/18/12, Koper, Dies wrote:
> Hi Michal,
> 
> > -          running.to( :stopping )       .on( :destroy )
> > +          running.to( :shutting_down )  .on( :destroy )
> 
> In commit 09bfd939db278978d87539534ceda3465737acc3 David changed this
> state to be consistently :stopping.
> Does this mean we're reverting that and change the state consistently to
> :shutting_down?

Good catch Dies, thanks for this. When I forked DC I must miss this update.
I'll remove this state as David did before pushing. (/note added ;-)

  -- Michal


> 
> Cheers,
> Dies Koper
> 
> 
> 
> > -----Original Message-----
> > From: mfojtik@redhat.com [mailto:mfojtik@redhat.com]
> > Sent: Tuesday, 17 April 2012 11:40 PM
> > To: dev@deltacloud.apache.org
> > Subject: [PATCH core 14/32] Core: Updated drivers to remove
> base_driver
> > require and added autoloading of driver
> > 
> > From: Michal Fojtik <mfojtik@redhat.com>
> > 
> > 
> > Signed-off-by: Michal fojtik <mfojtik@redhat.com>
> > ---
> >  server/lib/deltacloud/drivers.rb                   |   48 +------
> >  .../lib/deltacloud/drivers/azure/azure_driver.rb   |    4 -
> >  .../lib/deltacloud/drivers/condor/condor_driver.rb |    9 +-
> >  server/lib/deltacloud/drivers/ec2/ec2_driver.rb    |   18 +--
> >  .../drivers/eucalyptus/eucalyptus_driver.rb        |    4 -
> >  server/lib/deltacloud/drivers/features.rb          |  111
> ++++++++++++++++
> >  .../lib/deltacloud/drivers/gogrid/gogrid_driver.rb |    6 -
> >  .../lib/deltacloud/drivers/google/google_driver.rb |    3 -
> >  server/lib/deltacloud/drivers/mock/mock_client.rb  |   11 --
> >  server/lib/deltacloud/drivers/mock/mock_driver.rb  |   21 +--
> >  .../drivers/mock/mock_driver_cimi_methods.rb       |  139
> --------------------
> >  .../drivers/opennebula/opennebula_driver.rb        |    8 +-
> >  .../drivers/openstack/openstack_driver.rb          |   12 +-
> >  .../drivers/rackspace/rackspace_driver.rb          |    9 +-
> >  .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |   17 +--
> >  .../drivers/rimuhosting/rimuhosting_client.rb      |   17 ++-
> >  .../drivers/rimuhosting/rimuhosting_driver.rb      |   11 +-
> >  .../drivers/terremark/terremark_driver.rb          |    7 +-
> >  .../deltacloud/drivers/vsphere/vsphere_driver.rb   |   15 +--
> >  19 files changed, 160 insertions(+), 310 deletions(-)
> >  create mode 100644 server/lib/deltacloud/drivers/features.rb
> > 
> > diff --git a/server/lib/deltacloud/drivers.rb
> > b/server/lib/deltacloud/drivers.rb
> > index dfc998d..14e7ee0 100644
> > --- a/server/lib/deltacloud/drivers.rb
> > +++ b/server/lib/deltacloud/drivers.rb
> > @@ -13,25 +13,15 @@
> >  # License for the specific language governing permissions and
> limitations
> >  # under the License.
> > 
> > -module Deltacloud
> > +require_relative 'drivers/exceptions'
> > +require_relative 'drivers/base_driver'
> > +require_relative 'drivers/features'
> > +require 'yaml'
> > 
> > +module Deltacloud
> >    module Drivers
> > 
> > -    require 'yaml'
> > -
> > -    DEFAULT_COLLECTIONS = [
> > -      :hardware_profiles,
> > -      :images,
> > -      :instances,
> > -      :instance_states,
> > -      :realms,
> > -      :storage_volumes,
> > -      :storage_snapshots
> > -    ]
> > -
> > -    DRIVER=ENV['API_DRIVER'] ? ENV['API_DRIVER'].to_sym : :mock
> > -
> > -    def driver_config
> > +    def self.driver_config
> >        if Thread::current[:drivers].nil?
> >          Thread::current[:drivers] = {}
> >          top_srcdir = File.join(File.dirname(__FILE__), '..', '..')
> > @@ -42,31 +32,5 @@ module Deltacloud
> >        Thread::current[:drivers]
> >      end
> > 
> > -    def driver_symbol
> > -      (Thread.current[:driver] || DRIVER).to_sym
> > -    end
> > -
> > -    def driver_name
> > -      driver_config[:"#{driver_symbol}"][:name]
> > -    end
> > -
> > -    def driver_class
> > -      basename = driver_config[:"#{driver_symbol}"][:class] ||
> > "#{driver_name}Driver"
> > -      Deltacloud::Drivers.const_get(driver_name).const_get(basename)
> > -    end
> > -
> > -    def driver_source_name
> > -      File.join("deltacloud", "drivers", "#{driver_symbol}",
> > "#{driver_symbol}_driver.rb")
> > -    end
> > -
> > -    def driver_mock_source_name
> > -      return File.join('deltacloud', 'drivers', "#{driver_symbol}",
> > -		       "#{driver_symbol}_driver.rb") if driver_name.eql?
> > 'Mock'
> > -    end
> > -
> > -    def driver
> > -      require driver_source_name
> > -      @driver ||= driver_class.new
> > -    end
> >    end
> >  end
> > diff --git a/server/lib/deltacloud/drivers/azure/azure_driver.rb
> > b/server/lib/deltacloud/drivers/azure/azure_driver.rb
> > index 24feeb7..db2b6c6 100644
> > --- a/server/lib/deltacloud/drivers/azure/azure_driver.rb
> > +++ b/server/lib/deltacloud/drivers/azure/azure_driver.rb
> > @@ -15,7 +15,6 @@
> >  # under the License.
> > 
> >  #Windows Azure (WAZ) gem at http://github.com/johnnyhalife/waz-
> > storage
> > -require 'deltacloud/base_driver'
> >  require 'waz-blobs'
> > 
> >  module Deltacloud
> > @@ -24,9 +23,6 @@ module Deltacloud
> > 
> >  class AzureDriver < Deltacloud::BaseDriver
> > 
> > -  def supported_collections; [:buckets]
> > -  end
> > -
> >  #--
> >  # Buckets
> >  #--
> > diff --git a/server/lib/deltacloud/drivers/condor/condor_driver.rb
> > b/server/lib/deltacloud/drivers/condor/condor_driver.rb
> > index f5cb741..c139b62 100644
> > --- a/server/lib/deltacloud/drivers/condor/condor_driver.rb
> > +++ b/server/lib/deltacloud/drivers/condor/condor_driver.rb
> > @@ -14,9 +14,6 @@
> >  # under the License.
> >  #
> > 
> > -require 'deltacloud/base_driver'
> > -
> > -
> >  class Instance
> >    def self.convert_condor_state(state_id)
> >      case state_id
> > @@ -44,10 +41,6 @@ module Deltacloud
> >          feature :instances, :user_data
> >          feature :instances, :authentication_password
> > 
> > -        def supported_collections
> > -          DEFAULT_COLLECTIONS - [ :storage_volumes,
> :storage_snapshots ]
> > -        end
> > -
> >          CONDOR_MAPPER_DIR = ENV['CONDOR_MAPPER_DIR'] || '/var/tmp'
> > 
> >          def hardware_profiles(credentials, opts={})
> > @@ -175,7 +168,7 @@ module Deltacloud
> >            pending.to( :running )        .automatically
> >            pending.to( :finish )         .on(:destroy)
> >            running.to( :running )        .on( :reboot )
> > -          running.to( :stopping )       .on( :destroy )
> > +          running.to( :shutting_down )  .on( :destroy )
> >            pending.to( :finish )         .automatically
> >          end
> > 
> > diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> > b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> > index 60e86e8..01b76b4 100644
> > --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> > +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
> > @@ -14,7 +14,6 @@
> >  # under the License.
> >  #
> > 
> > -require 'deltacloud/base_driver'
> >  require 'aws'
> > 
> >  class Instance
> > @@ -29,13 +28,8 @@ end
> > 
> >  module Deltacloud
> >    module Drivers
> > -    module EC2
> > -      class EC2Driver < Deltacloud::BaseDriver
> > -
> > -        def supported_collections
> > -
> > -          DEFAULT_COLLECTIONS +
> > [ :keys, :buckets, :load_balancers, :addresses, :firewalls ]
> > -        end
> > +    module Ec2
> > +      class Ec2Driver < Deltacloud::BaseDriver
> > 
> >          feature :instances, :user_data
> >          feature :instances, :authentication_key
> > @@ -127,8 +121,7 @@ module Deltacloud
> >            stopped.to( :running )        .on( :start )
> >            running.to( :running )        .on( :reboot )
> >            running.to( :stopping )       .on( :stop )
> > -          stopping.to(:stopped)         .automatically
> > -          stopping.to(:finish)          .automatically
> > +          shutting_down.to( :stopped )  .automatically
> >            stopped.to( :finish )         .automatically
> >          end
> > 
> > @@ -413,9 +406,7 @@ module Deltacloud
> >            safely do
> >              s3_bucket = s3_client.bucket(opts['bucket'])
> >              if(opts[:id])
> > -              s3_key = s3_bucket.key(opts[:id], true)
> > -              raise "Blob #{opts[:id]} in Bucket #{opts['bucket']}
> NotFound"
> > unless s3_key.exists?
> > -              blobs << convert_object(s3_key)
> > +              blobs << convert_object(s3_bucket.key(opts[:id], true))
> >              else
> >                s3_bucket.keys({}, true).each do |s3_object|
> >                  blobs << convert_object(s3_object)
> > @@ -471,7 +462,6 @@ module Deltacloud
> >            blob_meta = {}
> >            safely do
> >              the_blob =
> s3_client.bucket(opts['bucket']).key(opts[:id], true)
> > -            raise "Blob #{opts[:id]} in Bucket #{opts['bucket']}
> NotFound" unless
> > the_blob.exists?
> >              blob_meta = the_blob.meta_headers
> >            end
> >          end
> > diff --git
> a/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
> > b/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
> > index 2270178..54c1eed 100644
> > --- a/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
> > +++ b/server/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb
> > @@ -21,10 +21,6 @@ module Deltacloud
> >      module Eucalyptus
> >        class EucalyptusDriver < EC2::EC2Driver
> > 
> > -        def supported_collections
> > -          DEFAULT_COLLECTIONS + [ :keys, :buckets, :addresses,
> :firewalls ]
> > -        end
> > -
> >          feature :instances, :user_data
> >          feature :instances, :authentication_key
> >          feature :instances, :firewalls
> > diff --git a/server/lib/deltacloud/drivers/features.rb
> > b/server/lib/deltacloud/drivers/features.rb
> > new file mode 100644
> > index 0000000..01d8656
> > --- /dev/null
> > +++ b/server/lib/deltacloud/drivers/features.rb
> > @@ -0,0 +1,111 @@
> > +# 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.
> > +
> > +module Deltacloud
> > +  module InstanceFeatures
> > +
> > +    def self.included(k)
> > +      current_features = features
> > +      k.instance_eval do
> > +        features(&current_features)
> > +      end
> > +    end
> > +
> > +    def self.features(&block)
> > +      block_given? ? @features = block : @features || Proc.new{}
> > +    end
> > +
> > +    features do
> > +
> > +      feature :user_name, :for => :instances do
> > +        description "Allow to set user-defined name for the instance"
> > +        operation :create do
> > +          param :name, :string, :optional
> > +        end
> > +      end
> > +
> > +      feature :user_data, :for => :instances do
> > +        description "Allow to pass user-defined data into the
> instance"
> > +        operation :create do
> > +          param :user_data, :string, :optional
> > +        end
> > +      end
> > +
> > +      feature :user_iso, :for => :instances do
> > +        description  "Base64 encoded gzipped ISO file will be
> accessible as CD-
> > ROM drive in instance"
> > +        operation :create do
> > +          param :user_iso, :string, :optional
> > +        end
> > +      end
> > +
> > +      feature :firewalls, :for => :instances do
> > +        description "Put instance in one or more firewalls (security
> groups) on
> > launch"
> > +        operation :create do
> > +          param :firewalls, :array, :optional, nil, "Array of
> firewall ID strings"
> > +          "Array of firewall (security group) id"
> > +        end
> > +      end
> > +
> > +      feature :authentication_key, :for => :instances do
> > +        operation :create do
> > +          param :keyname, :string,  :optional, [], "Key
> authentification
> > method"
> > +        end
> > +        operation :show do
> > +        end
> > +      end
> > +
> > +      feature :authentication_password, :for => :instances do
> > +        operation :create do
> > +          param :password, :string, :optional
> > +        end
> > +      end
> > +
> > +      feature :hardware_profiles, :for => :instances do
> > +        description "Size instances according to changes to a
> hardware
> > profile"
> > +        # The parameters are filled in from the hardware profiles
> > +      end
> > +
> > +      feature :register_to_load_balancer, :for => :instances do
> > +        description "Register instance to load balancer"
> > +        operation :create do
> > +          param :load_balancer_id, :string, :optional
> > +        end
> > +      end
> > +
> > +      feature :instance_count, :for => :instances do
> > +        description "Number of instances to be launch with at once"
> > +        operation :create do
> > +          param :instance_count,  :string,  :optional
> > +        end
> > +      end
> > +
> > +      feature :attach_snapshot, :for => :instances do
> > +        description "Attach an snapshot to instance on create"
> > +        operation :create do
> > +          param :snapshot_id,  :string,  :optional
> > +          param :device_name,  :string,  :optional
> > +        end
> > +      end
> > +
> > +      feature :sandboxing, :for => :instances do
> > +        description "Allow lanuching sandbox images"
> > +        operation :create do
> > +          param :sandbox, :string,  :optional
> > +        end
> > +      end
> > +    end
> > +
> > +  end
> > +end
> > diff --git a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
> > b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
> > index 285f58f..2a83c24 100644
> > --- a/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
> > +++ b/server/lib/deltacloud/drivers/gogrid/gogrid_driver.rb
> > @@ -14,7 +14,6 @@
> >  # License for the specific language governing permissions and
> limitations
> >  # under the License.
> > 
> > -require 'deltacloud/base_driver'
> >  require 'deltacloud/drivers/gogrid/gogrid_client'
> > 
> >  class Instance
> > @@ -61,11 +60,6 @@ class GogridDriver < Deltacloud::BaseDriver
> >      @hardware_profiles
> >    end
> > 
> > -  def supported_collections
> > -    DEFAULT_COLLECTIONS.reject! { |c|
> > [ :storage_volumes, :storage_snapshots ].include?(c) }
> > -    DEFAULT_COLLECTIONS + [ :keys, :load_balancers ]
> > -  end
> > -
> >    def images(credentials, opts=nil)
> >      imgs = []
> >      if opts and opts[:id]
> > diff --git a/server/lib/deltacloud/drivers/google/google_driver.rb
> > b/server/lib/deltacloud/drivers/google/google_driver.rb
> > index 2ffb5f8..8bc6f25 100644
> > --- a/server/lib/deltacloud/drivers/google/google_driver.rb
> > +++ b/server/lib/deltacloud/drivers/google/google_driver.rb
> > @@ -21,9 +21,6 @@ module Deltacloud
> > 
> >  class GoogleDriver < Deltacloud::BaseDriver
> > 
> > -  def supported_collections; [:buckets]
> > -  end
> > -
> >    feature :buckets, :bucket_location
> > 
> >  #--
> > diff --git a/server/lib/deltacloud/drivers/mock/mock_client.rb
> > b/server/lib/deltacloud/drivers/mock/mock_client.rb
> > index 94c56af..248cc49 100644
> > --- a/server/lib/deltacloud/drivers/mock/mock_client.rb
> > +++ b/server/lib/deltacloud/drivers/mock/mock_client.rb
> > @@ -91,17 +91,6 @@ module Deltacloud::Drivers::Mock
> >        FileUtils.rm(fname) if File::exists?(fname)
> >      end
> > 
> > -    def store_cimi(collection, obj)
> > -      raise "Why no obj.name?" unless obj.name
> > -      File::open(cimi_file(collection, obj.name), "w") { |f|
> > f.write(obj.to_json) }
> > -    end
> > -
> > -    def destroy_cimi(collection, id)
> > -      fname = cimi_file(collection, id)
> > -      raise "No such object: #{id} in #{collection} collection"
> unless
> > File::exists?(fname)
> > -      FileUtils.rm(fname)
> > -    end
> > -
> >      def load_all_cimi(model_name)
> >          model_files = Dir[File::join(cimi_dir(model_name), "*.json")]
> >          model_files.map{|f| File.read(f)}
> > diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb
> > b/server/lib/deltacloud/drivers/mock/mock_driver.rb
> > index b58872c..15f06fb 100644
> > --- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
> > +++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
> > @@ -14,28 +14,16 @@
> >  # License for the specific language governing permissions and
> limitations
> >  # under the License.
> > 
> > -
> >  require 'yaml'
> >  require 'base64'
> >  require 'etc'
> > -require 'deltacloud/base_driver'
> > -require 'deltacloud/drivers/mock/mock_client'
> > -require 'deltacloud/drivers/mock/mock_driver_cimi_methods'
> > +require_relative 'mock_client'
> > +require_relative 'mock_driver_cimi_methods'
> > 
> >  module Deltacloud::Drivers::Mock
> > 
> >    class MockDriver < Deltacloud::BaseDriver
> > 
> > -    # If the provider is set to storage, pretend to be a storage-only
> > -    # driver
> > -    def supported_collections
> > -      if api_provider == 'storage'
> > -        [:buckets]
> > -      else
> > -        DEFAULT_COLLECTIONS + [:buckets, :keys]
> > -      end
> > -    end
> > -
> >      ( REALMS = [
> >        Realm.new({
> >          :id=>'us',
> > @@ -299,11 +287,6 @@ module Deltacloud::Drivers::Mock
> >        snapshots
> >      end
> > 
> > -    def destroy_storage_snapshot(credentials, opts={})
> > -      check_credentials(credentials)
> > -      @client.destroy(:storage_snapshots, opts[:id])
> > -    end
> > -
> >      def keys(credentials, opts={})
> >        check_credentials(credentials)
> >        result = @client.build_all(Key)
> > diff --git
> > a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > index 2dec66b..bebc45c 100644
> > --- a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > +++ b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > @@ -32,49 +32,6 @@ module Deltacloud::Drivers::Mock
> >        end
> >      end
> > 
> > -    def create_network(credentials, opts={})
> > -      check_credentials(credentials)
> > -      id = "#{opts[:env].send("networks_url")}/#{opts[:name]}"
> > -      net_hsh = { "id"=> id,
> > -                  "name" => opts[:name],
> > -                  "description" => opts[:description],
> > -                  "created" => Time.now,
> > -                  "state" => "STARTED",
> > -                  "access" => opts[:network_config].access,
> > -                  "bandwithLimit" =>
> opts[:network_config].bandwidth_limit,
> > -                  "trafficPriority" =>
> opts[:network_config].traffic_priority,
> > -                  "maxTrafficDelay" =>
> opts[:network_config].max_traffic_delay,
> > -                  "maxTrafficLoss"
> =>opts[:network_config].max_traffic_loss,
> > -                  "maxTrafficJitter"
> =>opts[:network_config].max_traffic_jitter,
> > -                  "routingGroup"=> { "href" =>
> opts[:routing_group].id },
> > -                  "operations" => [{"rel"=>"edit", "href"=> id},
> > -                                   {"rel"=>"delete", "href"=> id}]
> }
> > -      network =
> CIMI::Model::Network.from_json(JSON.generate(net_hsh))
> > -
> > -      @client.store_cimi(:network, network)
> > -      network
> > -    end
> > -
> > -    def delete_network(credentials, id)
> > -      check_credentials(credentials)
> > -      @client.destroy_cimi(:network, id)
> > -    end
> > -
> > -    def start_network(credentials, id)
> > -      check_credentials(credentials)
> > -      update_object_state(id, "Network", "STARTED")
> > -    end
> > -
> > -    def stop_network(credentials, id)
> > -      check_credentials(credentials)
> > -      update_object_state(id, "Network", "STOPPED")
> > -    end
> > -
> > -    def suspend_network(credentials, id)
> > -      check_credentials(credentials)
> > -      update_object_state(id, "Network", "SUSPENDED")
> > -    end
> > -
> >      def network_configurations(credentials, opts={})
> >        check_credentials(credentials)
> >        if opts[:id].nil?
> > @@ -130,43 +87,6 @@ module Deltacloud::Drivers::Mock
> >        end
> >      end
> > 
> > -    def create_vsp(credentials, opts={})
> > -      check_credentials(credentials)
> > -      id = "#{opts[:env].send("vsps_url")}/#{opts[:name]}"
> > -      vsp_hash = { "id"    => id,
> > -                    "name"  => opts[:name],
> > -                    "description" => opts[:description],
> > -                    "state" => "STARTED",
> > -                    "created" => Time.now,
> > -
> > "bandwidthReservation"=>opts[:vsp_config].bandwidth_reservation,
> > -
> "trafficPriority"=>opts[:vsp_config].traffic_priority,
> > -
> "maxTrafficDelay"=>opts[:vsp_config].max_traffic_delay,
> > -
> "maxTrafficLoss"=>opts[:vsp_config].max_traffic_loss,
> > -
> "maxTrafficJitter"=>opts[:vsp_config].max_traffic_jitter,
> > -                    "network" => {"href" => opts[:network].id},
> > -                    "operations" => [{"rel"=>"edit", "href"=> id},
> > -                                     {"rel"=>"delete", "href"=> id}]
> > -                   }
> > -      vsp = CIMI::Model::VSP.from_json(JSON.generate(vsp_hash))
> > -      @client.store_cimi(:vsp, vsp)
> > -      vsp
> > -    end
> > -
> > -    def start_vsp(credentials, id)
> > -      check_credentials(credentials)
> > -      update_object_state(id, "VSP", "STARTED")
> > -    end
> > -
> > -    def stop_vsp(credentials, id)
> > -      check_credentials(credentials)
> > -      update_object_state(id, "VSP", "STOPPED")
> > -    end
> > -
> > -    def delete_vsp(credentials, id)
> > -      check_credentials(credentials)
> > -      @client.destroy_cimi(:vsp, id)
> > -    end
> > -
> >      def vsp_configurations(credentials, opts={})
> >        check_credentials(credentials)
> >        if opts[:id].nil?
> > @@ -189,56 +109,6 @@ module Deltacloud::Drivers::Mock
> >        end
> >      end
> > 
> > -    def addresses(credentials, opts={})
> > -      check_credentials(credentials)
> > -      if opts[:id].nil?
> > -        addresses = @client.load_all_cimi(:address).map{|addr|
> > CIMI::Model::Address.from_json(addr)}
> > -        addresses.map{|addr|convert_cimi_mock_urls(:address, addr,
> > opts[:env])}.flatten
> > -      else
> > -        address =
> > CIMI::Model::Address.from_json(@client.load_cimi(:address, opts[:id]))
> > -        convert_cimi_mock_urls(:address, address, opts[:env])
> > -      end
> > -    end
> > -
> > -    def create_address(credentials, opts={})
> > -      check_credentials(credentials)
> > -      id = "#{opts[:env].send("addresses_url")}/#{opts[:name]}"
> > -      addr_hash = { "id"    => id,
> > -                    "name"  => opts[:name],
> > -                    "description" => opts[:description],
> > -                    "created" => Time.now,
> > -                    "hostName" => opts[:address_template].hostname,
> > -                    "allocation" =>
> opts[:address_template].allocation,
> > -                    "defaultGateway" =>
> opts[:address_template].default_gateway,
> > -                    "dns" => opts[:address_template].dns,
> > -                    "macAddress" =>
> opts[:address_template].mac_address,
> > -                    "protocol" => opts[:address_template].protocol,
> > -                    "mask" => opts[:address_template].mask,
> > -                    "network" => {"href" =>
> opts[:address_template].network.href},
> > -                    "operations" => [{"rel"=>"edit", "href"=> id},
> > -                                     {"rel"=>"delete", "href"=> id}]
> > -                   }
> > -      address =
> CIMI::Model::Address.from_json(JSON.generate(addr_hash))
> > -      @client.store_cimi(:address, address)
> > -      address
> > -    end
> > -
> > -    def delete_address(credentials, id)
> > -      check_credentials(credentials)
> > -      @client.destroy_cimi(:address, id)
> > -    end
> > -
> > -    def address_templates(credentials, opts={})
> > -      check_credentials(credentials)
> > -      if opts[:id].nil?
> > -        address_templates =
> > @client.load_all_cimi(:address_template).map{|addr_templ|
> > CIMI::Model::AddressTemplate.from_json(addr_templ)}
> > -
> > address_templates.map{|addr_templ|convert_cimi_mock_urls(:address_t
> > emplate, addr_templ, opts[:env])}.flatten
> > -      else
> > -        address_template =
> > CIMI::Model::AddressTemplate.from_json(@client.load_cimi(:address_tem
> > plate, opts[:id]))
> > -        convert_cimi_mock_urls(:address_template, address_template,
> > opts[:env])
> > -      end
> > -    end
> > -
> >      private
> > 
> >      def convert_cimi_mock_urls(model_name, cimi_object, context)
> > @@ -270,15 +140,6 @@ module Deltacloud::Drivers::Mock
> >        end
> >      end
> > 
> > -    def update_object_state(id, object, new_state)
> > -      klass = CIMI::Model.const_get("#{object}")
> > -      symbol = object.to_s.downcase.singularize.intern
> > -      obj = klass.from_json(@client.load_cimi(symbol, id))
> > -      obj.state = new_state
> > -      @client.store_cimi(symbol, obj)
> > -      obj
> > -    end
> > -
> >    end
> > 
> >  end
> > diff --git
> a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
> > b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
> > index 371e170..03c337f 100644
> > --- a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
> > +++ b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb
> > @@ -28,10 +28,6 @@ module Deltacloud
> > 
> >  class OpennebulaDriver < Deltacloud::BaseDriver
> > 
> > -  def supported_collections
> > -    DEFAULT_COLLECTIONS - [:storage_volumes, :storage_snapshots]
> > -  end
> > -
> > 
> > ##########################################################
> > ############
> >    # Hardware profiles
> > 
> > ##########################################################
> > ###########
> > @@ -152,8 +148,8 @@ class OpennebulaDriver < Deltacloud::BaseDriver
> >      running.to(:running)        .on( :reboot )
> >      running.to(:stopping)       .on( :stop )
> >      stopping.to(:stopped)       .automatically
> > -    running.to(:stopping)       .on( :destroy )
> > -    stopping.to(:finish)        .automatically
> > +    running.to(:shutting_down)  .on( :destroy )
> > +    shutting_down.to(:finish)   .automatically
> >    end
> > 
> >    def instances(credentials, opts=nil)
> > diff --git
> a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
> > b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
> > index c9ec95b..5d54d5b 100644
> > --- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
> > +++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
> > @@ -14,9 +14,9 @@
> >  # under the License.
> >  #
> > 
> > -require 'deltacloud/base_driver'
> >  require 'openstack/compute'
> >  require 'tempfile'
> > +
> >  module Deltacloud
> >    module Drivers
> >      module Openstack
> > @@ -27,16 +27,12 @@ module Deltacloud
> >          feature :instances, :user_files
> >          feature :images, :user_name
> > 
> > -        def supported_collections
> > -          DEFAULT_COLLECTIONS - [ :storage_snapshots,
> :storage_volumes  ]
> > #+ [ :buckets ]
> > -        end
> > -
> >          define_instance_states do
> >            start.to( :pending )          .on( :create )
> >            pending.to( :running )        .automatically
> >            running.to( :running )        .on( :reboot )
> > -          running.to( :stopping )       .on( :stop )
> > -          stopping.to( :stopped )       .automatically
> > +          running.to( :shutting_down )  .on( :stop )
> > +          shutting_down.to( :stopped )  .automatically
> >            stopped.to( :finish )         .automatically
> >          end
> > 
> > @@ -140,7 +136,7 @@ module Deltacloud
> >            params[:name] = (opts[:name] && opts[:name].length>0)?
> > opts[:name] : Time.now.to_s
> >            params[:imageRef] = image_id
> >            params[:flavorRef] =  (opts[:hwp_id] &&
> opts[:hwp_id].length>0) ?
> > -                          opts[:hwp_id] :
> hardware_profiles(credentials).first.name
> > +                          opts[:hwp_id] :
> hardware_profiles(credentials).first
> >            if opts[:password] && opts[:password].length > 0
> >              params[:adminPass]=opts[:password]
> >            end
> > diff --git
> a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> > b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> > index 1b019d4..f59f832 100644
> > --- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> > +++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
> > @@ -14,7 +14,6 @@
> >  # License for the specific language governing permissions and
> limitations
> >  # under the License.
> > 
> > -require 'deltacloud/base_driver'
> >  require 'cloudfiles'
> >  require 'cloudservers'
> >  require 'base64'
> > @@ -30,10 +29,6 @@ class RackspaceDriver < Deltacloud::BaseDriver
> >    feature :instances, :user_files
> >    feature :images, :user_name
> > 
> > -  def supported_collections
> > -    DEFAULT_COLLECTIONS + [ :buckets ] -
> > [ :storage_snapshots, :storage_volumes ]
> > -  end
> > -
> >    def hardware_profiles(credentials, opts = {})
> >      rs = new_client( credentials )
> >      results = []
> > @@ -194,8 +189,8 @@ class RackspaceDriver < Deltacloud::BaseDriver
> >      start.to( :pending )          .on( :create )
> >      pending.to( :running )        .automatically
> >      running.to( :running )        .on( :reboot )
> > -    running.to( :stopping )       .on( :stop )
> > -    stopping.to( :stopped )       .automatically
> > +    running.to( :shutting_down )  .on( :stop )
> > +    shutting_down.to( :stopped )  .automatically
> >      stopped.to( :finish )         .automatically
> >    end
> > 
> > diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
> > b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
> > index 1c96df7..f138f03 100644
> > --- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
> > +++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
> > @@ -14,27 +14,24 @@
> >  # License for the specific language governing permissions and
> limitations
> >  # under the License.
> > 
> > -require 'deltacloud/base_driver'
> >  require 'rbovirt'
> > 
> >  module Deltacloud
> >    module Drivers
> > -    module RHEVM
> > +    module Rhevm
> > 
> > -class RHEVMDriver < Deltacloud::BaseDriver
> > +class RhevmDriver < Deltacloud::BaseDriver
> > 
> > -  def supported_collections
> > -    DEFAULT_COLLECTIONS - [:storage_snapshots]
> > -  end
> > -
> > -  feature :instances, :user_name do
> > -    constraint :max_length, 50
> > +  Sinatra::Rabbit::InstancesCollection.features do
> > +    feature :user_name, :for => :instances do
> > +      constrain :max_length, 50
> > +    end
> >    end
> > 
> >    feature :instances, :user_data
> >    feature :images, :user_name
> > 
> > -  USER_NAME_MAX =
> > feature(:instances, :user_name).constraints[:max_length]
> > +  USER_NAME_MAX =
> >
> Sinatra::Rabbit::InstancesCollection.feature(:user_name).constraints[:ma
> x_l
> > ength]
> > 
> >    # FIXME: These values are just for ilustration
> >    # Also I choosed 'SERVER' and 'DESKTOP' names
> > diff --git
> a/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb
> > b/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb
> > index 58f8e1b..f44336a 100644
> > --- a/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb
> > +++ b/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb
> > @@ -41,17 +41,16 @@ class RimuHostingClient
> >        headers["Authorization"] = @auth
> >      end
> >      safely do
> > -      r = @service.send_request(method, @uri.path + resource, data,
> > headers)
> > -          puts r.body
> > -      res = JSON.parse(r.body)
> > -      res = res[res.keys[0]]
> > +    r = @service.send_request(method, @uri.path + resource, data,
> > headers)
> > +         puts r.body
> > +    res = JSON.parse(r.body)
> > +    res = res[res.keys[0]]
> > 
> > -      if(res['response_type'] == "ERROR" and (
> (res['error_info']['error_class']
> > == "PermissionException") or
> > +    if(res['response_type'] == "ERROR" and (
> (res['error_info']['error_class']
> > == "PermissionException") or
> >
> (res['error_info']['error_class'] ==
> > "LoginRequired") ))
> > -        raise "AuthFailure"
> > -      end
> > -      res
> > +      raise "AuthFailure"
> >      end
> > +    res
> >    end
> > 
> >    def list_images
> > @@ -82,6 +81,6 @@ class RimuHostingClient
> >    end
> >  end
> > 
> > +    end
> >    end
> >  end
> > -end
> > diff --git
> a/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
> > b/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
> > index 67c415c..8633d53 100644
> > --- a/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
> > +++ b/server/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
> > @@ -16,7 +16,6 @@
> >  # License for the specific language governing permissions and
> limitations
> >  # under the License.
> > 
> > -require "deltacloud/base_driver"
> >  require "deltacloud/drivers/rimuhosting/rimuhosting_client"
> > 
> >  module Deltacloud
> > @@ -131,9 +130,9 @@ class RimuHostingDriver < Deltacloud::BaseDriver
> >              :owner_id => "root",
> >              :instance_profile => InstanceProfile.new("none"),
> >              :actions => instance_actions_for("RUNNING"),
> > -            :public_addresses =>
> > [ InstanceAddress.new(inst["allocated_ips"]["primary_ip"] ) ],
> > -            :launch_time =>
> inst["billing_info"]["order_date"]["iso_format"]
> > -    })
> > +            :public_addresses =>
> > [ InstanceAddress.new(inst["allocated_ips"]["primary_ip"] )],
> > +            :launch_time =>
> inst["billing_info"]["order_date"]["iso_format"]}
> > +                )
> >    end
> > 
> >    define_instance_states do
> > @@ -142,9 +141,9 @@ class RimuHostingDriver < Deltacloud::BaseDriver
> >      pending.to( :running )        .automatically
> > 
> >      running.to( :running )        .on(:reboot)
> > -    running.to( :stopping )       .on(:stop)
> > +    running.to( :shutting_down )  .on(:stop)
> > 
> > -    stopping.to( :stopped )       .automatically
> > +    shutting_down.to( :stopped )  .automatically
> > 
> >      stopped.to( :finish )         .automatically
> >    end
> > diff --git
> a/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
> > b/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
> > index 2dba02a..2e087cb 100644
> > --- a/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
> > +++ b/server/lib/deltacloud/drivers/terremark/terremark_driver.rb
> > @@ -19,8 +19,7 @@
> >  # https://community.vcloudexpress.terremark.com/en-
> > us/product_docs/w/wiki/d-complete-vcloud-express-api-document.aspx
> >  #
> >  # 02 May 2010
> > -#
> > -require 'deltacloud/base_driver'
> > +
> >  require 'fog'
> >  require 'excon'
> >  require 'nokogiri'
> > @@ -118,8 +117,8 @@ VAPP_STATE_MAP = { "0" =>  "PENDING", "1" =>
> > "PENDING", "2" =>  "STOPPED", "4"
> >      pending.to(:stopped)          .automatically
> >      stopped.to(:running)          .on( :start )
> >      running.to(:running)          .on( :reboot )
> > -    running.to(:stopping)         .on( :stop )
> > -    stopping.to(:stopped)         .automatically
> > +    running.to(:shutting_down)    .on( :stop )
> > +    shutting_down.to(:stopped)    .automatically
> >      stopped.to(:finish)           .on( :destroy )
> >     end
> > 
> > diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
> > b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
> > index e16be2f..7ac908a 100644
> > --- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
> > +++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
> > @@ -14,18 +14,17 @@
> >  # under the License.
> >  #
> > 
> > -require 'deltacloud/base_driver'
> >  require 'rbvmomi'
> >  require 'deltacloud/drivers/vsphere/vsphere_client'
> > 
> > -module Deltacloud::Drivers::VSphere
> > +module Deltacloud::Drivers::Vsphere
> > 
> >    MAPPER_STORAGE_ROOT = File::join("/var/tmp", "deltacloud-vsphere-
> > #{ENV["USER"]}")
> > 
> > -  class VSphereDriver < Deltacloud::BaseDriver
> > +  class VsphereDriver < Deltacloud::BaseDriver
> > 
> >      include Deltacloud::Drivers::VSphere::Helper
> > -    include Deltacloud::Drivers::VSphere::FileManager
> > +    include VSphere::FileManager
> > 
> >      # You can use 'user_iso' feature to set 'user_iso' parameter when
> > creating
> >      # a new instance where this parameter can hold gzipped CDROM iso
> > which will
> > @@ -34,10 +33,6 @@ module Deltacloud::Drivers::VSphere
> >      feature :instances, :user_data
> >      feature :instances, :user_name
> > 
> > -    def supported_collections
> > -      DEFAULT_COLLECTIONS - [:storage_volumes, :storage_snapshots]
> > -    end
> > -
> >      # There is just one hardware profile where memory is measured
> using
> > maximum
> >      # memory available on ESX for virtual machines and CPU using
> maximum
> > free
> >      # CPU cores in ESX.
> > @@ -68,8 +63,8 @@ module Deltacloud::Drivers::VSphere
> >        pending.to(:stopped)        .automatically
> >        stopped.to(:running)        .on( :start )
> >        running.to(:running)        .on( :reboot )
> > -      running.to(:stopping)       .on( :stop )
> > -      stopping.to(:stopped)       .automatically
> > +      running.to(:shutting_down)  .on( :stop )
> > +      shutting_down.to(:stopped)  .automatically
> >        stopped.to(:finish)         .on( :destroy )
> >      end
> > 
> > --
> > 1.7.10
> > 
> 
> 

-- 
Michal Fojtik
Sr. Software Engineer, Deltacloud API (http://deltacloud.org)

Mime
View raw message