refs #1101 add ogMcastSendFile()
parent
f232fb8bdf
commit
bddbf6fa57
|
@ -11,6 +11,7 @@ import FileSystemLib
|
||||||
import StringLib
|
import StringLib
|
||||||
import NetLib
|
import NetLib
|
||||||
import DiskLib
|
import DiskLib
|
||||||
|
import FileLib
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
#@file ProtocolLib.py
|
#@file ProtocolLib.py
|
||||||
|
@ -366,6 +367,54 @@ def ogMcastSyntax (op, sess, file=None, device=None, tool=None, level=None):
|
||||||
#*/ ##
|
#*/ ##
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#ogMcastSendFile [str_REPOSITORY] [int_ndisk int_npart] /Relative_path_file sesionMcast" \
|
||||||
|
#ogMcastSendFile (disk=1, par=1, file='/aula1/winxp.img', sess='sesionMcast')
|
||||||
|
#ogMcastSendFile (from='REPO', file='/aula1/ubuntu.iso', sess='sesionMcast')
|
||||||
|
#ogMcastSendFile (from='CACHE', file='/aula1/winxp.img', sess='sesionMcast')
|
||||||
|
#ogMcastSendFile ( file='/opt/opengnsys/images/aula1/hd500.vmx', sess='sesionMcast')
|
||||||
|
def ogMcastSendFile (disk=None, par=None, take_from=None, file=None, sess=None):
|
||||||
|
if file is None:
|
||||||
|
raise TypeError ('missing required argument: "file"')
|
||||||
|
if sess is None:
|
||||||
|
raise TypeError ('missing required argument: "sess"')
|
||||||
|
|
||||||
|
if take_from is not None:
|
||||||
|
if disk is None and par is None:
|
||||||
|
## we were given take_from=
|
||||||
|
source = FileLib.ogGetPath (src=take_from, file=file)
|
||||||
|
dev_err = ' '.join ([take_from, file])
|
||||||
|
print (f'ogGetPath (src=({take_from}), file=({file})) = source ({source})')
|
||||||
|
else:
|
||||||
|
raise TypeError ('argument "take_from" can be specified along neither "disk" nor "par"')
|
||||||
|
|
||||||
|
else:
|
||||||
|
if disk is not None and par is not None:
|
||||||
|
## we were given disk= par=
|
||||||
|
source = FileLib.ogGetPath (src=f'{disk} {par}', file=file)
|
||||||
|
dev_err = ' '.join ([disk, par, file])
|
||||||
|
print (f'ogGetPath (src=({disk} {par}), file=({file})) = source ({source})')
|
||||||
|
elif disk is None and par is None:
|
||||||
|
## we were given nothing
|
||||||
|
source = FileLib.ogGetPath (file=file)
|
||||||
|
dev_err = file
|
||||||
|
print (f'ogGetPath (file=({file})) = source ({source})')
|
||||||
|
else:
|
||||||
|
raise TypeError ('if one of "disk" and "par" are specified, then both must be')
|
||||||
|
|
||||||
|
path2 = FileLib.ogGetPath (file=source)
|
||||||
|
print (f'path2 ({path2})')
|
||||||
|
if not path2:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, f'device or file {dev_err} not found')
|
||||||
|
return
|
||||||
|
|
||||||
|
cmd = ogMcastSyntax ('SENDFILE', sess, file=source)
|
||||||
|
if not cmd: return None
|
||||||
|
print (f'cmd ({cmd})')
|
||||||
|
try:
|
||||||
|
subprocess.run (cmd, shell=True, check=True)
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_MCASTSENDFILE, ' ')
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue