Re: Module getfile

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK it's done.

Overlord module:
http://func.pastebin.com/kA4Xq2ne

Minion module:
http://func.pastebin.com/dZ7SDMMZ

How to use (example):
#!/usr/bin/python
import func.overlord.client as fc
client_handle = fc.Client("*")

remotesource='/etc/hosts'
localfolder='/tmp/out'

print client_handle.local.getfile.get(remotesource,localfolder)

I made tests
- on RHEL4
- on RHEL5
- with some minions which don't have the file
- with some minions unreachable

It seams fine.

It's slow for big files, but fine for little configuration or inventory files.
The slowness has the same cause as for copyfile: xml-rpc is not fitted
for copying files.

Could you consider testing it and adding it in the upstream git ?

Louis


2010/10/27 seth vidal <skvidal@xxxxxxxxxxxxxxxxx>:
> On Mon, 2010-10-04 at 11:57 +0200, Louis Coilliot wrote:
>> Hello,
>>
>> it is not so straightforward if there are more than one minion.
>>
>> For copyfile, the overlord part uses:
>> if data:
>> Â Â Â Â Â Â Â Â self.parent.run("copyfile", "append", [remotepath,
>> xmlrpclib.Binary(data)])
>>
>> This applies to all target minions because it is the same file for all.
>>
>> I can't do the opposite for getfile, because the action differs from
>> one minion to the other (the files can have different lengths)
>>
>> I need to do something like this because I cut the files in chunks to get them:
>> for chunknum in range(chunkslen):
>> Â Â Â Â Â Â checksum,chunk = Âself.parent.run("getfile", "getchunk",
>> [chunknum, source]).items()[0][1]
>>
>> It is fine when I restrict the target to one minion.
>>
>> Do you know how I could do the run on one single minion (replacing
>> parent.run), so I just have to loop over the minions ?
>>
>> I don't.
>
>
>
> okay - so I finally got a chance to look at this code and I think I see
> the problem.
>
> So - like all func modules when you run from the overlord you normally
> get back a dict with keys == minion and value == data.
>
> Here's what it seems like you want to do:
>
> modify overlord module getfile.get to include a target_prefix and a
> miniondir kwarg. That way if the user only specifies a single minion
> then they can put the file they are retrieving into a specific dir.
>
> If they are doing a bunch of minions then they can have it make a
> miniondir.
>
> also the target prefix is so you could do something like
>
> getfile.get(source=/etc/passwd, target=/etc/passwd,
> target_prefix=/var/minion-backup/, miniondir=True)
>
> and have it make:
>
> Â/var/minion-backup/hostname1/etc/passwd
> Â/var/minion-backup/hostname2/etc/passwd
> etc etc
>
> Now - with the self.parent.run(getfile.getchunks) it seems to me what
> you want to do is be writing ALL of the files at each time. So keep
> updating whatever you get from getchunks() until you don't get anymore.
>
> Instead of working on it like a loop where you loop over the minions -
> just keep calling getchunks() until you have nothing left to get.
>
> Alternatively, instead of using chunkslen to figure out how many times
> to loop - let it be handled by the result of getchunks() being ''.
>
>
> Do you see what I mean?
>
> I think it's definitely doable.
>
> -sv
>
>
> _______________________________________________
> Func-list mailing list
> Func-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/func-list
>

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list



[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux