4 Copyright 2007, Red Hat, Inc
7 This software may be freely redistributed under the terms of the GNU
8 general public license.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software
12 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 from func
.overlord
import command
23 from func
.overlord
import client
27 class CopyFile(client
.command
.Command
):
29 usage
= "copy a file to a client"
33 self
.parser
.add_option("-f", "--file", dest
="filename",
35 self
.parser
.add_option("", "--remotepath", dest
="remotepath",
37 self
.parser
.add_option("", "--force", dest
="force",
39 self
.parser
.add_option("-v", "--verbose", dest
="verbose",
41 self
.parser
.add_option("-p", "--port", dest
="port")
43 def handleOptions(self
, options
):
44 self
.port
= DEFAULT_PORT
46 self
.port
= self
.options
.port
50 self
.server_spec
= self
.parentCommand
.server_spec
52 client_obj
= client
.Client(self
.server_spec
,
55 verbose
=self
.options
.verbose
,
60 fb
= open(self
.options
.filename
, "r").read()
62 print "Unable to open file: %s: %s" % (self
.options
.filename
, e
)
65 st
= os
.stat(self
.options
.filename
)
66 mode
= stat
.S_IMODE(st
.st_mode
)
71 data
= xmlrpclib
.Binary(fb
)
72 results
= client_obj
.run("copyfile", "copyfile", [self
.options
.remotepath
, data
,