On Nov 14, 2012, at 10:16 AM, [email protected] wrote:

ACK.

Small inline comment below.

  -- Michal


> From: marios <[email protected]>
> 
> https://issues.apache.org/jira/browse/DTACLOUD-367
> https://issues.apache.org/jira/browse/DTACLOUD-368
> 
> Signed-off-by: marios <[email protected]>
> ---
> server/lib/cimi/collections/machines.rb                     | 6 +++---
> server/lib/cimi/models/machine.rb                           | 2 +-
> server/lib/deltacloud/drivers/openstack/openstack_driver.rb | 8 ++++----
> 3 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/server/lib/cimi/collections/machines.rb 
> b/server/lib/cimi/collections/machines.rb
> index 6fdfbc2..1ae71e6 100644
> --- a/server/lib/cimi/collections/machines.rb
> +++ b/server/lib/cimi/collections/machines.rb
> @@ -85,15 +85,15 @@ module CIMI::Collections
>         end
>       end
> 
> -      action :restart, :with_capability => :restart_instance do
> +      action :restart, :with_capability => :reboot_instance do
>         description "Start specific machine."
>         param :id,          :string,    :required
>         control do
>           machine = Machine.find(params[:id], self)
>           if request.content_type.end_with?("json")
> -            action = Action.from_json(request.body.read)
> +            action = Action.from_json(request.body.read.gsub("restart", 
> "reboot"))
>           else
> -            action = Action.from_xml(request.body.read)
> +            action = Action.from_xml(request.body.read.gsub("restart", 
> "reboot"))
>           end
>           machine.perform(action, self) do |operation|
>             no_content_with_status(202) if operation.success?
> diff --git a/server/lib/cimi/models/machine.rb 
> b/server/lib/cimi/models/machine.rb
> index 648c395..1958806 100644
> --- a/server/lib/cimi/models/machine.rb
> +++ b/server/lib/cimi/models/machine.rb
> @@ -79,7 +79,7 @@ class CIMI::Model::Machine < CIMI::Model::Base
> 
>   def perform(action, context, &block)
>     begin
> -      if context.driver.send(:"#{action.name}_instance", 
> context.credentials, self.name)
> +      if context.driver.send(:"#{action.name}_instance", 
> context.credentials, self.id.split("/").last)

I have seen this many times before. Perhaps we can create some String helper 
for this:

class String

  def extract_id_from_url
    split('/').last
  end

end


>         block.callback :success
>       else
>         raise "Operation failed to execute on given Machine"
> diff --git a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb 
> b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
> index 0f3c97a..6425d1b 100644
> --- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
> +++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
> @@ -173,10 +173,10 @@ module Deltacloud
>           end
>           if opts[:keyname] && opts[:keyname].length > 0
>             params[:key_name]=opts[:keyname]
> -       end
> -       if opts[:user_data] && opts[:user_data].length > 0
> -         params[:user_data]=Base64.encode64(opts[:user_data])
> -       end
> +          end
> +          if opts[:user_data] && opts[:user_data].length > 0
> +            params[:user_data]=Base64.encode64(opts[:user_data])
> +          end
>           safely do
>             server = os.create_server(params)
>             result = convert_from_server(server, os.connection.authuser)
> -- 
> 1.7.11.7
> 

Michal Fojtik
http://deltacloud.org
[email protected]



Reply via email to