| Commit message (Collapse) | Author | Age | Files | Lines |
| |\
| |
| | |
targetcli: avoild Ctrl+C print error stack
|
| | |
| |
| |
| | |
Signed-off-by: Mingzhe Zou <zoumingzhe@qq.com>
|
| |/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Setting preference maybe rollback when execute multiple targetcli requests concurrently.
ConfigShell always initialization new Console object.
However, the lockfile need to be opened before requesting flock.
At this time, an exception may occur and need to be output to the console.
Currently, ConfigShell always initializes a new Console object.
So, ConfigShell is initialized first to be able to print information.
The prefs.bin file will be loaded when ConfigShell is initialized.
In this case, the old value may be read, if a new preference is being set and not saved.
In order to solve this problem we must first initialize a Console object.
This patch needs https://github.com/open-iscsi/configshell-fb/pull/62 to be merged first.
Signed-off-by: Zou Mingzhe <mingzhe.zou@easystack.cn>
|
| |
|
|
|
|
|
|
|
| |
Typing somthing and then hitting backspace multiple-times would clear
the prompt previously.
This patch do not let backspace clear the prompt msg.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
$ targetcli
targetcli shell version 2.1.51
Entering targetcli interactive mode for daemonized approach.
Type 'exit' to quit.
/> pwd
/
/> cd /iscsi
/iscsi> ls
o- iscsi .......................................... [Targets: 0]
/iscsi> exit
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
set interactive mode as default to make it appear similar to cli approach,
$ targetcli
targetcli shell version 2.1.51
Entering targetcli interactive mode for daemonized approach.
Type 'exit' to quit.
/> pwd
/
/> cd /iscsi
/> pwd
/iscsi
/> exit
Here we introduce a new global option daemon_use_batch_mode for switching between
batch and interactive modes.
$ targetcli set global daemon_use_batch_mode=true
Parameter daemon_use_batch_mode is now 'true'.
$ targetcli
targetcli shell version 2.1.51
Entering targetcli batch mode for daemonized approach.
Enter multiple commands separated by newline and type 'exit' to run them
all in one go.
/> pwd
/> cd /iscsi
/> pwd
/
/iscsi
Fixes: #160
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
happen to see yet another issue after we switch to stringIO/bytesIO:
$ targetcli ls
'unicode' does not have the buffer interface
After which I felt like dealing with StringIO/BytesIO is like a
wild goose chase and we are after all attempting to deal with python
incompatible apis.
Technically speaking, the rtslib and configshell libraries are expecting a
string IO stream, but then for python2 with ByteIO() we are passing a
bytestream, and stringIO() is behaving a bit different in python2 than
expected as explained in my previous patch.
Lets simply switch to temporary file in the most secure manner possible,
opening files in string mode will assure the compatibility across the platforms.
At the end we wish to have a consistent behaviour across all python versions.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
| |
It looks like '--tcp' option is no more needed after our recent
global auto_use_daemon flag addition, which helps set/unset the
daemonized approach.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
-------
When auto_use_daemon=true, entering multi-line command-mode/shell-mode appears
like the cli is stuck for new users, as we do not display any info now :-)
$ targetcli
---- nothing here, is it stuck ? -------
$ targetcli
cd /backstores/
get global auto_use_daemon
pwd
ls
exit
auto_use_daemon=true
/backstores
o- backstores ................................................ [...]
o- block .................................... [Storage Objects: 0]
o- fileio ................................... [Storage Objects: 0]
o- pscsi .................................... [Storage Objects: 0]
o- ramdisk .................................. [Storage Objects: 0]
o- user:glfs ................................ [Storage Objects: 0]
Solution:
-------
Add some userful info and a '/> ' in each line,
$ targetcli
targetcli shell version 2.1.50
Entering targetcli batch mode for daemonized approach.
Enter multiple commands separated by newline and type 'exit' to run them all in one go.
/> cd /backstores/
/> get global auto_use_daemon
/> pwd
/> ls
/> exit
auto_use_daemon=true
/backstores
o- backstores ................................................ [...]
o- block .................................... [Storage Objects: 0]
o- fileio ................................... [Storage Objects: 0]
o- pscsi .................................... [Storage Objects: 0]
o- ramdisk .................................. [Storage Objects: 0]
o- user:glfs ................................ [Storage Objects: 0]
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
-------
Currently when auto_use_daemon is set to true and in case for some
reasons user do not want to start the daemon or the dameon is not starting
succefully for some unknown reason, then there is no way to bypass the
calls to dameon and use cli directly
$ targetcli pwd
[Errno 111] Connection refused
Solution:
--------
Provide an option with cli to turn auto_use_daemon to false.
$ targetcli pwd
[Errno 111] Connection refused
Currently auto_use_daemon is true, hence please make sure targetclid daemon is running ...
(or)
Incase if you wish to turn auto_use_daemon to false then run '#targetcli --disable-daemon'
$ targetcli --help
Usage: ./scripts/targetcli [--version|--help|CMD|--tcp|--disable-daemon]
[...]
--disable-daemon Turn-off the global auto use daemon flag
See man page for more information.
$ targetcli --disable-daemon
Parameter auto_use_daemon is now 'false'.
$ targetcli pwd
/
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When auto_use_daemon is set to true and daemon is not running/stopped
Before:
------
$ targetcli ls
[Errno 111] Connection refused
Now:
---
$ targetcli ls
[Errno 111] Connection refused
Currently auto_use_daemon is true, hence please make sure targetclid daemon is running ...
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
| |
We can no longer have python automatically convert
binary to/from string data, so be explicit about it.
Also, the TargetCLI __del__ method was testing for a
non-existant attribute, so close our socket if open.
|
| |
|
|
|
|
|
| |
"except Exception, e" triggers a syntax error on Python 3.7. The
correct syntax is "except Exception as e".
This patch fixes issue #142.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
-------
targetcli/rtslib cannot handle parallel requests at the moment.
Read more about this at http://bit.ly/targetcli-parallel-requests-issue
$ for i in {1..10}; do \
targetcli /backstores/fileio create ${i} /tmp/file${i} 10M& done
Created fileio 1 with size 10485760
This _Backstore already exists in configFS
This _Backstore already exists in configFS
This _Backstore already exists in configFS
This _Backstore already exists in configFS
This _Backstore already exists in configFS
Created fileio 6 with size 10485760
Created fileio 2 with size 10485760
This _Backstore already exists in configFS
Created fileio 8 with size 10485760
Created fileio 9 with size 10485760
bails-out most of the time with above errors and sometimes even crashes.
Solution:
--------
Serialize/defend the parallel requests by simply taking a wait lock at
targetcli level, so that only one request can be processed by targetcli at
any given point in time.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
$ targetcli set global
GLOBAL CONFIG GROUP
[...]
auto_use_daemon=bool
If true, commands will be sent to targetclid.
[...]
$ targetcli set global auto_use_daemon=True
Parameter auto_use_daemon is now 'true'.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Problem:
-------
Overall creation time of a block using targetcli is raising linearly as the
block count increase.
This is because of the recurring issue involving refresh(reload) at
multiple objects/places, as the LIO's configfs is deeply nested.
Earlier discussion of the problem statement with stats and graphs about delays:
http://bit.ly/targetcli-create-delay
Solution:
--------
Introduce a daemon component for targetcli[d] which will retain state of
Configshell object in memory, so that any new requests can directly use it,
instead of loading the storageObjects/targetObjects again.
Details about "how to use it ?":
-------------------------------
$ systemctl start targetclid
$ systemctl status targetclid
● targetclid.service - Targetcli daemon
Loaded: loaded (/usr/lib/systemd/system/targetclid.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2019-04-10 12:19:51 IST; 2h 17min ago
Main PID: 3950 (targetclid)
Tasks: 3 (limit: 4915)
CGroup: /system.slice/targetclid.service
└─3950 /usr/bin/python /usr/bin/targetclid
Apr 10 12:19:51 localhost.localdomain systemd[1]: Started Targetcli daemon.
$ targetcli help
Usage: /usr/bin/targetcli [--version|--help|CMD|--tcp]
--version Print version
--help Print this information
CMD Run targetcli shell command and exit
<nothing> Enter configuration shell
--tcp CMD Pass targetcli command to targetclid
--tcp <nothing> Enter multi-line command mode for targetclid
See man page for more information.
One line command usage:
----------------------
$ targetcli --tcp CMD
Eg:
$ targetcli --tcp pwd
/
Multiple line commands usage:
----------------------------
$ targetcli --tcp
CMD1
CMD2
.
.
CMDN
exit
Eg:
$ targetcli --tcp
^Tab
/ backstores/ iscsi/ loopback/ vhost/ xen-pvscsi/ cd
clearconfig exit get help ls pwd refresh
restoreconfig saveconfig set status
pwd
get global logfile
get global auto_save_on_exit
/ saveconfig
exit
output follows:
/
logfile=/var/log/gluster-block/gluster-block-configshell.log
auto_save_on_exit=false
Configuration saved to /etc/target/saveconfig.json
Stats with and without changes:
------------------------------
Running simple 'pwd' command after creating 1000 blocks on a node:
Without this change:
$ time targetcli pwd
/
real 0m8.963s
user 0m7.775s
sys 0m1.103s
with daemonize changes:
$ time targetcli --tcp "pwd"
/
real 0m0.126s
user 0m0.099s
sys 0m0.024s
Thanks to Maurizio for hangingout with me for all the discussions involved.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
|
| |
In some cases, it looks reasonable to have a separate preference file.
For example, we have a set of scripts to configure iscsi targets, and we
want to have a separate preference file for these scripts.
Signed-off-by: Andrei Vagin <avagin@openvz.org>
|
| |
|
|
|
|
|
|
| |
Calling targetcli --version is a good way to verify if targetcli is
present. Running the shell in mode '-e' will exit scripts even if
targetcli is available. Adjust exit code.
Signed-off-by: Olaf Hering <olaf@aepfle.de>
|
| |
|
|
|
|
|
|
|
|
|
| |
Eg:
/> set global max_backup_files=1000
Parameter max_backup_files is now '1000'.
If 'max_backup_files' is set in /etc/target/targetcli.conf, then max value
between conf file setting and global option settings is considered.
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
|
| |
|
|
|
|
|
|
| |
Expand info messages to mention this pref as well
Fixes #46
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
|
|
| |
Since rtslib-fb and configshell-fb have different APIs from the original
rtslib and configshell, we're trying to move off those package names since
it can cause user confusion. Change our version of targetcli to indicate it
requires the -fb versions.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
| |
If not invoked as root, we can't load modules and UIRoot() will raise an
exception.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
| |
I don't envision targetcli taking a lot of cmdline options, so just
implement by looking at sys.argv[1] instead of using getopt or ArgParse.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
If run_cmdline raises an exception, return 1 as exit code and print
exception text to stderr.
Keep running shell.run_interactive until shell._exit is set, logging
error messages.
Overriding execute_command in UINode no longer needed, remove.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
| |
Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
|
| |
|
|
|
|
|
|
|
|
| |
This patch converts rtslib code copyright from AGPL to the
permissive Apache License 2.0.
It also update copyright owner to Datera, Inc.
Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com>
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
|
|
|
| |
If targetcli is not run for the first time not as root, refresh() will
fail because it can't load modules. This returns a nicer error message
in that case.
See https://bugzilla.redhat.com/show_bug.cgi?id=973852
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Don't raise an exception if we can't set emulate_model_alias, just
print a diagnostic.
Rename ui_set_model_alias to setup_model_alias. 'setup' seems a little
more accurate since we don't always set model alias, it depends on
the preference.
Rename export_backstore_as_model pref to export_backstore_name_as_model.
Add a configshell default for export_backstore_name_as_model, set to True.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
| |
It won't work and will print an ugly message.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
| |
* Do not enter a new object context right after creating it by default.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
[original comments from 5bcef69]
* Now displaying targetcli / rtslib version on startup
* Retained only copyright notice.
[end]
fb changes:
- only display targetcli version, we don't have rtslib version in code
- move later to only display if entering shell
- remove extraneous copyright verbiage
- add "and others" to be explicit about our derived-work status
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
| |
Defaulted to true.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
|
| |
Check the commandline and only enter interactive shell if no additional
parameters were given. If parameters were given, execute them and exit.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
|
|
| |
Don't need to worry about legacy backstores.
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| |
|
|
| |
Signed-off-by: Andy Grover <agrover@redhat.com>
|
| | |
|
| |
|
|
|
|
|
| |
* Now using console, log, prefs through shell.
* Root node binds to shell, not the other way.
* Replaced del_child() calls by remove_child()
* Replaced a children loop scan by ConfigNode get_child() method.
|
| |
|
|
|
| |
* Automatically cd's to newly created object after a 'create' command if true.
* Added autosave (always) of last created node's path under @last bookmark.
|
| |
|
|
|
|
|
|
|
| |
* Added 'legacy_hba_view' global boolean to select legacy view if needed.
* Added root refresh when setting a global parameter.
* All backstore plugins now part of the backstores/ tree
* Only one storage object by backstore.
* We now hide indiviual backstores. As they are mapped 1:1 with
storage objects, both levels are collapsed.
|
| | |
|
| | |
|
| | |
|
|
|
Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com>
|