open-iscsi / rtslib-fb

Python library for configuring the Linux kernel-based multiprotocol SCSI target (LIO)
Apache License 2.0
73 stars 90 forks source link

save_to_file: fix fd open mode #163

Closed pkalever closed 4 years ago

pkalever commented 4 years ago

since we used O_WRONLY with os.open(), lets stick to same mode with os.fdopen() too

Signed-off-by: Prasanna Kumar Kalever \prasanna.kalever@redhat.com\

pkalever commented 4 years ago

Seen below trace on centos:

/> saveconfig 
Traceback (most recent call last):
  File "/usr/bin/targetcli", line 5, in <module>
    pkg_resources.run_script('targetcli-fb==2.1.52', 'targetcli')
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 540, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1462, in run_script
    exec_(script_code, namespace, namespace)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 41, in exec_
    exec("""exec code in globs, locs""")
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/targetcli_fb-2.1.52-py2.7.egg/EGG-INFO/scripts/targetcli", line 329, in <module>

  File "/usr/lib/python2.7/site-packages/targetcli_fb-2.1.52-py2.7.egg/EGG-INFO/scripts/targetcli", line 317, in main

  File "/usr/lib/python2.7/site-packages/configshell_fb-1.1.28-py2.7.egg/configshell_fb/shell.py", line 900, in run_interactive
    self._cli_loop()
  File "/usr/lib/python2.7/site-packages/configshell_fb-1.1.28-py2.7.egg/configshell_fb/shell.py", line 729, in _cli_loop
    self.run_cmdline(cmdline)
  File "/usr/lib/python2.7/site-packages/configshell_fb-1.1.28-py2.7.egg/configshell_fb/shell.py", line 843, in run_cmdline
    self._execute_command(path, command, pparams, kparams)
  File "/usr/lib/python2.7/site-packages/configshell_fb-1.1.28-py2.7.egg/configshell_fb/shell.py", line 818, in _execute_command
    result = target.execute_command(command, pparams, kparams)
  File "/usr/lib/python2.7/site-packages/configshell_fb-1.1.28-py2.7.egg/configshell_fb/node.py", line 1406, in execute_command
    return method(*pparams, **kparams)
  File "build/bdist.linux-x86_64/egg/targetcli/ui_root.py", line 194, in ui_command_saveconfig
  File "build/bdist.linux-x86_64/egg/rtslib_fb/root.py", line 482, in save_to_file
OSError: [Errno 22] Invalid argument
[root@server1 rtslib-fb]#