incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mohammed Morsi <mmo...@redhat.com>
Subject Re: [PATCH] added ability to scp one or more files to a running instance
Date Tue, 03 Aug 2010 20:10:49 GMT
  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


Mime
View raw message