Patch to add a getfile command module

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

 



This command module makes it possible to call "getfile" from the command line. It is a fairly straightforward adaption of the command module for copyfile.

 

Usage:

  func (minions) getfile -l localdir -r remotefile

Both -l and -r are required. If either is omitted then the command prints the help text. The local directory will be created if it does not already exist.

 

--

Marcus

>From 270cd6227e77624cf6d39d09484ea4cbd61e8351 Mon Sep 17 00:00:00 2001
From: Marcus Lauer <marcuslauer@xxxxxxxxxx>
Date: Mon, 20 Aug 2012 18:18:25 -0400
Subject: [PATCH 1/2] Created command-line module for getfile

Create a command module for the "getfile" function. This allows
getfile to be used from the command line.

Usage:
  func (minions) getfile -l localdir -r remotefile
---
 func/overlord/cmd_modules/getfile.py |   54 ++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
 create mode 100644 func/overlord/cmd_modules/getfile.py

diff --git a/func/overlord/cmd_modules/getfile.py b/func/overlord/cmd_modules/getfile.py
new file mode 100644
index 0000000..561e5d8
--- /dev/null
+++ b/func/overlord/cmd_modules/getfile.py
@@ -0,0 +1,54 @@
+"""
+getfile command line
+Based on "copyfile command line" by RedHat, Inc
+Modifications are Copyright Marcus Lauer (ml1100@xxxxxxx) and released under the GNU Public License
+
+Copyright for the GPL code used in this project can be found below.
+---
+copyfile command line
+
+Copyright 2007, Red Hat, Inc
+see AUTHORS
+
+This software may be freely redistributed under the terms of the GNU
+general public license.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+"""
+
+
+import optparse
+import os
+import pprint
+import stat
+import xmlrpclib
+
+from func.overlord import base_command
+from func.overlord import client
+
+
+class CopyFile(base_command.BaseCommand):
+    name = "getfile"
+    usage = "\n  getfile -l localdir -r remotesource\n    remotesource = file to download from the specified minions\n    localdir = directory in which to put the downloaded files"
+    summary = "get a file from minions"
+
+    def addOptions(self):
+        self.parser.add_option("-l", "--localdir", dest="localdir",
+                               action="store")
+        self.parser.add_option("-r", "--remotesource", dest="remotesource",
+                                action="store")
+
+    def handleOptions(self, options):
+        pass
+
+    def do(self, args):
+        if not self.options.localdir or not self.options.remotesource:
+            self.outputUsage()
+            return
+
+        self.server_spec = self.parentCommand.server_spec
+        self.getOverlord()
+
+        return self.overlord_obj.local.getfile.get(self.options.remotesource, self.options.localdir)
-- 
1.7.7


>From 620384563402dc03fb4f942182b937c5be8d31f4 Mon Sep 17 00:00:00 2001
From: Marcus Lauer <marcuslauer@xxxxxxxxxx>
Date: Mon, 20 Aug 2012 18:34:17 -0400
Subject: [PATCH 2/2] Changed name of getfile object in command module from
 CopyFile to GetFile

---
 func/overlord/cmd_modules/getfile.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/func/overlord/cmd_modules/getfile.py b/func/overlord/cmd_modules/getfile.py
index 561e5d8..76bba43 100644
--- a/func/overlord/cmd_modules/getfile.py
+++ b/func/overlord/cmd_modules/getfile.py
@@ -29,7 +29,7 @@ from func.overlord import base_command
 from func.overlord import client
 
 
-class CopyFile(base_command.BaseCommand):
+class GetFile(base_command.BaseCommand):
     name = "getfile"
     usage = "\n  getfile -l localdir -r remotesource\n    remotesource = file to download from the specified minions\n    localdir = directory in which to put the downloaded files"
     summary = "get a file from minions"
-- 
1.7.7

_______________________________________________
func mailing list
func@xxxxxxxxxxxxxxxxxxxxxx
https://lists.fedorahosted.org/mailman/listinfo/func

[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