Re: Module getfile

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

 



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


[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