summaryrefslogtreecommitdiff
path: root/scripts
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #197 from zoumingzhe/killMaurizio Lombardi2023-04-141-1/+4
|\ | | | | targetcli: avoild Ctrl+C print error stack
| * targetcli: avoild Ctrl+C print error stackMingzhe Zou2023-03-271-1/+4
| | | | | | | | Signed-off-by: Mingzhe Zou <zoumingzhe@qq.com>
* | fix setting preference rollback errormingzhe.zou@easystack.cn2021-10-221-18/+20
|/ | | | | | | | | | | | | | | | 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>
* daemon-interactive: do not allow clearing the promptPrasanna Kumar Kalever2020-04-071-2/+1
| | | | | | | | | 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>
* daemon-interactive: show path on promptPrasanna Kumar Kalever2020-04-061-7/+45
| | | | | | | | | | | | | | | | $ 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>
* daemonized-mode: add interactive shell supportPrasanna Kumar Kalever2020-04-061-20/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Use temp file objects for temporary storage areaPrasanna Kumar Kalever2020-04-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | 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>
* targetcli: depreciate the redundant '--tcp' optionPrasanna Kumar Kalever2019-11-041-12/+4
| | | | | | | | 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>
* cli: show useful hint in header area of shell in daemonized modePrasanna Kumar Kalever2019-10-301-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* cli: provide a way to disable using daemonPrasanna Kumar Kalever2019-10-301-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* cli: show better error msg when daemon is not runningPrasanna Kumar Kalever2019-10-181-0/+3
| | | | | | | | | | | | | | | | | 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>
* Handle Python 3.7 stricter binary vs. string rules.Lee Duncan2019-10-101-2/+3
| | | | | | | | 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.
* Fix a syntax error in some except clausesChristophe Vu-Brugier2019-08-011-2/+2
| | | | | | | "except Exception, e" triggers a syntax error on Python 3.7. The correct syntax is "except Exception as e". This patch fixes issue #142.
* targetcli: serialize multiple requestsPrasanna Kumar Kalever2019-07-311-0/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: way to enable targetclid as default choicePrasanna Kumar Kalever2019-06-111-12/+23
| | | | | | | | | | | | | | $ 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>
* targetclid: add daemonize component for targetcliPrasanna Kumar Kalever2019-06-111-8/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Allow to customize a home directoryAndrei Vagin2018-03-161-2/+2
| | | | | | | | | 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>
* remove wrong exit code from targetcli --versionOlaf Hering2018-01-171-1/+1
| | | | | | | | 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>
* backup: global option to tune max no. of backup conf filesPrasanna Kumar Kalever2017-12-201-0/+1
| | | | | | | | | | | 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>
* Add a global pref for adding default portalAndy Grover2014-12-171-0/+1
| | | | | | | | Expand info messages to mention this pref as well Fixes #46 Signed-off-by: Andy Grover <agrover@redhat.com>
* Change targetcli to use new package import namesAndy Grover2014-12-021-2/+2
| | | | | | | | | 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>
* Move UIRoot creation inside try blockAndy Grover2014-12-021-2/+1
| | | | | | | If not invoked as root, we can't load modules and UIRoot() will raise an exception. Signed-off-by: Andy Grover <agrover@redhat.com>
* Add --version and --help support to targetcliadd-usageAndy Grover2014-09-231-0/+21
| | | | | | | 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>
* Change targetcli for configshell exception changeAndy Grover2014-03-031-3/+14
| | | | | | | | | | | | 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>
* Make except clause compatible with Python 3 in scripts/targetcliChristophe Vu-Brugier2013-10-121-1/+1
| | | | Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* targetcli: Change copyright to Apache License 2.0Nicholas Bellinger2013-07-231-13/+11
| | | | | | | | | | 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>
* Catch module load errorsAndy Grover2013-06-181-1/+4
| | | | | | | | | | 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>
* model alias follow-upAndy Grover2013-02-071-0/+1
| | | | | | | | | | | | | | | 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>
* Don't try to save config if not rootAndy Grover2012-07-251-1/+1
| | | | | | It won't work and will print an ugly message. Signed-off-by: Andy Grover <agrover@redhat.com>
* Changed default auto_cd_after_create to FalseJerome Martin2012-05-311-1/+1
| | | | | | * Do not enter a new object context right after creating it by default. Signed-off-by: Andy Grover <agrover@redhat.com>
* Made startup message less verbose, display versionAndy Grover2012-05-311-9/+7
| | | | | | | | | | | | | | | [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>
* Add auto_save_on_exit preferenceAndy Grover2012-02-131-0/+5
| | | | | | Defaulted to true. Signed-off-by: Andy Grover <agrover@redhat.com>
* Enable execution of cmdline parameters in targetcliAndy Grover2011-12-061-9/+14
| | | | | | | 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>
* Remove backstore_legacy, dedup_so_name(), and legacy_hba_viewAndy Grover2011-12-061-1/+0
| | | | | | Don't need to worry about legacy backstores. Signed-off-by: Andy Grover <agrover@redhat.com>
* Remove ads from cli welcome msg. Mention help is available.Andy Grover2011-11-281-2/+2
| | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* Changed name to targetcli at community request.Jerome Martin2011-09-201-7/+7
|
* Converted to refactored ConfigShell/Node layout.Jerome Martin2011-07-181-6/+9
| | | | | | | * 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.
* Added auto_cd_after_create global.Jerome Martin2011-06-011-0/+1
| | | | | * 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.
* Switched to 1:1 hba:storage view.Jerome Martin2011-05-311-1/+2
| | | | | | | | | * 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.
* Global 'auto_add_mapped_luns' now defaults to true.Jerome Martin2011-05-261-1/+2
|
* Cleanly abort startup if RTSLibError happens.Jerome Martin2011-05-141-2/+7
|
* Disable privileged commands if user is not root.Jerome Martin2011-05-111-2/+10
|
* initial rtsadmin commit1.99Nicholas Bellinger2011-05-041-0/+61
Signed-off-by: Nicholas Bellinger <nab@risingtidesystems.com>