You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by David Lutterkort <lu...@redhat.com> on 2010/08/03 03:02:56 UTC

Re: [PATCH] added ability to scp one or more files to a running instance

On Thu, 2010-07-29 at 19:23 -0400, Mohammed Morsi wrote:
> diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb
> index c2c9ff4..e0cd7a6 100644
> --- a/server/lib/deltacloud/models/instance.rb
> +++ b/server/lib/deltacloud/models/instance.rb
> @@ -17,6 +17,7 @@
>  # under the License.
>  
>  require 'net/ssh'
> +require 'net/scp'
>  
>  class Instance < BaseModel
>  
> @@ -53,4 +54,15 @@ class Instance < BaseModel
>      return output
>    end
>  
> +  def copy_files(files, destination, username='', opts={})
> +    files = [files] unless files.is_a? Array
> +    hostname = self.public_addresses.first
> +    return "No hostname/IP address specified" unless hostname
> +    Net::SCP.start(hostname, username || 'root', opts) do |session|
> +      files.each { |f|
> +        session.upload! f, destination
> +      }
> +    end
> +  end

Doens't that copy all files into the same destination ?

> +  operation :copy_files, :method => :post, :member => true do
> +    description "Securely copy one or more files to an instance"
> +    param :id,           :string, :required
> +    param :files,        :string, :required # FIXME should be array of strings

That explains the above - only one file per copy. Would be nice to allow
a number of files with their contents.

David



Re: [PATCH] added ability to scp one or more files to a running instance

Posted by David Lutterkort <lu...@redhat.com>.
On Tue, 2010-08-03 at 16:10 -0400, Mohammed Morsi wrote:
> On 08/02/2010 09:02 PM, David Lutterkort wrote:
> > On Thu, 2010-07-29 at 19:23 -0400, Mohammed Morsi wrote:
> >>
> >> +  operation :copy_files, :method =>  :post, :member =>  true do
> >> +    description "Securely copy one or more files to an instance"
> >> +    param :id,           :string, :required
> >> +    param :files,        :string, :required # FIXME should be array of strings
> > That explains the above - only one file per copy. Would be nice to allow
> > a number of files with their contents.
> >
> > David
> 
> Since the core wui has jquery support I can easily add more file 
> selection boxes. The only thing is, I'm not sure how to specify the 
> 'files' param to this operation, as being able to accept an array of 
> string file names (no other operation params seem to take :array as the 
> type). Is there an easy way to do this? Or does the rabbit module need 
> to be expanded?

No other operation needs that (yet), so it would need to be an extension
of the rabbit module. But we'll also need that for RAX-style file
injection.

David



Re: [PATCH] added ability to scp one or more files to a running instance

Posted by Mohammed Morsi <mm...@redhat.com>.
  On 08/02/2010 09:02 PM, David Lutterkort wrote:
> On Thu, 2010-07-29 at 19:23 -0400, Mohammed Morsi wrote:
>> diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb
>> index c2c9ff4..e0cd7a6 100644
>> --- a/server/lib/deltacloud/models/instance.rb
>> +++ b/server/lib/deltacloud/models/instance.rb
>> @@ -17,6 +17,7 @@
>>   # under the License.
>>
>>   require 'net/ssh'
>> +require 'net/scp'
>>
>>   class Instance<  BaseModel
>>
>> @@ -53,4 +54,15 @@ class Instance<  BaseModel
>>       return output
>>     end
>>
>> +  def copy_files(files, destination, username='', opts={})
>> +    files = [files] unless files.is_a? Array
>> +    hostname = self.public_addresses.first
>> +    return "No hostname/IP address specified" unless hostname
>> +    Net::SCP.start(hostname, username || 'root', opts) do |session|
>> +      files.each { |f|
>> +        session.upload! f, destination
>> +      }
>> +    end
>> +  end
> Doens't that copy all files into the same destination ?
>

If destination is a directory, all files will be copied there.


>> +  operation :copy_files, :method =>  :post, :member =>  true do
>> +    description "Securely copy one or more files to an instance"
>> +    param :id,           :string, :required
>> +    param :files,        :string, :required # FIXME should be array of strings
> That explains the above - only one file per copy. Would be nice to allow
> a number of files with their contents.
>
> David

Since the core wui has jquery support I can easily add more file 
selection boxes. The only thing is, I'm not sure how to specify the 
'files' param to this operation, as being able to accept an array of 
string file names (no other operation params seem to take :array as the 
type). Is there an easy way to do this? Or does the rabbit module need 
to be expanded?

   -Mo