summaryrefslogtreecommitdiff
path: root/targetcli
Commit message (Collapse)AuthorAgeFilesLines
* Fix changing savedir directory modeLee Duncan2023-04-241-4/+6
| | | | | | | | | | Commit 9f5764dac39b ("saveconfig: set right perms on /etc/target/ dir") fixed CVE-2020-13867 by ensuring that the mode of the target meta-data directory (/etc/target) was always mode 0600. But users can specify a different directory, such as "/tmp", and we don't want targetcli changing the mode of such directories to 0600. So only change the mode of the directory, when saving a config file, if the directory is /etc/target.
* version 2.1.54v2.1.54Maurizio Lombardi2021-03-041-1/+1
| | | | Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
* fileio backstore: fix sparse file creationMaurizio Lombardi2020-11-231-8/+8
| | | | | | | | | | | | | | | | fallocate() can't be used to create sparse files because it actually preallocates all the disk space that will be used by the file backstore, sparse files do not have preallocated disk space by definition. We must therefore use ftruncate(). We can, on the other hand, use fallocate() to create non-sparse files and fall back to the slower "while() fwrite()" if we are running on Python version < 3.3 where fallocate() is not available Fixes 3bd4d8ef7c9b154c53e8b8dd863a570bce7f5c2c Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
* version 2.1.53v2.1.53Maurizio Lombardi2020-06-241-1/+1
| | | | Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
* saveconfig: set right perms on /etc/target/ dirPrasanna Kumar Kalever2020-06-011-15/+25
| | | | Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* saveconfig: set right perms on backup dirPrasanna Kumar Kalever2020-06-011-3/+10
| | | | Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* saveconfig: set 0o600 perms on backupfilesPrasanna Kumar Kalever2020-06-011-0/+5
| | | | Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* version 2.1.52v2.1.52Maurizio Lombardi2020-05-111-1/+1
|
* daemonized-mode: add interactive shell supportPrasanna Kumar Kalever2020-04-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* version 2.1.51v2.1.51Maurizio Lombardi2019-11-061-1/+1
|
* Merge pull request #141 from cvubrugier/remove-epydocMaurizio Lombardi2019-11-044-97/+97
|\ | | | | Remove Epydoc markup from command messages
| * Remove Epydoc markup from command messagesChristophe Vu-Brugier2019-08-014-97/+97
| | | | | | | | Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
* | version 2.1.50v2.1.50Maurizio Lombardi2019-08-261-1/+1
| |
* | Merge pull request #144 from pkalever/reload-single-so-tgMaurizio Lombardi2019-08-261-2/+6
|\ \ | | | | | | [targetcli] restoreconfig: add ability to restore/reload single target or storage_object
| * | restoreconfig: add ability to restore/reload single target or storage_objectPrasanna Kumar Kalever2019-08-131-2/+6
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: ------- Right now, if any target or storage_object is failed to load as part of target service bringup or manual restoreconfig, may be because of an issue from the backend, then there is no way to reload that single storage_object or target, we need to reload/restart all the targets/storage_objects present in the node just to load one single target/storage_object, this interrupts on going I/O (via this path) for all the volumes hosted within the node. Solution: -------- Add a capability to reload single target or storage_object without touching other targets or storage_objects hosted in the node. usage: $ targetcli targetcli shell version 2.1.fb49 Copyright 2011-2013 by Datera, Inc and others For help on commands, type 'help'. /> help [...] AVAILABLE COMMANDS The following commands are available in the current path: [...] - restoreconfig [savefile] [clear_existing] [target] [storage_object] [...] Ex 1. reload single storage_object $ targetcli restoreconfig /etc/target/saveconfig.json clear_existing \ storage_object=blockx Ex 2. reload single target $ targetcli restoreconfig /etc/target/saveconfig.json clear_existing \ target=iqn.2016-12.org.gluster-block:xxx Ex 3. reload a given target and storage_object $ targetcli restoreconfig /etc/target/saveconfig.json clear_existing \ target=iqn.2016-12.org.gluster-block:xxx storage_object=blockx Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* | iscsi discovery_auth enable is a number not a stringLee Duncan2019-08-151-3/+8
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The discovery_auth attribute group in the /iscsi node has several attributes, and all area treated like strings, even though "enable" is a number in sysfs, accepting either zero or one. It would break backwards compatability to convert this attribute to be a boolean, so at least treat it like a proper number instead of a string. This avoids stack dumps like the following when trying to set this attribute to 'true' or 'false': > /iscsi> set discovery_auth enable=false > Traceback (most recent call last): > File "/usr/bin/targetcli", line 122, in <module> > main() > File "/usr/bin/targetcli", line 112, in main > shell.run_interactive() > File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 905, in run_interactive > self._cli_loop() > File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 734, in _cli_loop > self.run_cmdline(cmdline) > File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 848, in run_cmdline > self._execute_command(path, command, pparams, kparams) > File "/usr/lib/python3.6/site-packages/configshell_fb/shell.py", line 823, in _execute_command > result = target.execute_command(command, pparams, kparams) > File "/usr/lib/python3.6/site-packages/configshell_fb/node.py", line 1406, in execute_command > return method(*pparams, **kparams) > File "/usr/lib/python3.6/site-packages/configshell_fb/node.py", line 522, in ui_command_set > group_setter(param, value) > File "/usr/lib/python3.6/site-packages/targetcli/ui_target.py", line 134, in ui_setgroup_discovery_auth > self.rtsnode.discovery_enable_auth = value > File "/usr/lib/python3.6/site-packages/rtslib_fb/fabric.py", line 243, in _set_discovery_enable_auth > if int(enable): > ValueError: invalid literal for int() with base 10: 'false' Now the output will be: > Not setting enable! Syntax error, 'false' is not a NUMBER.
* Merge pull request #132 from pkalever/daemonizeMaurizio Lombardi2019-06-171-0/+3
|\ | | | | targetclid: add daemonize component for targetcli
| * targetcli: way to enable targetclid as default choicePrasanna Kumar Kalever2019-06-111-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | $ 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>
* | Do not remove the first digit when auto-completing the TPG tagChristophe Vu-Brugier2019-05-211-1/+1
|/ | | | | | | | | | Instead of removing the first three characters of the "tpg" prefix to get matches for the TPG tag number, the code removes four characters, thus erasing the first digit of the TPG tag number. This patches fixes issue #134. Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
* Remove the extra semicolon in _save_backupstang.wenji2019-02-261-1/+1
| | | | Signed-off-by: tang.wenji <tang.wenji@zte.com.cn>
* Merge pull request #127 from ddiss/emulate_prMaurizio Lombardi2019-01-291-0/+1
|\ | | | | Add emulate_pr backstore attribute
| * Add emulate_pr backstore attributeDavid Disseldorp2019-01-151-0/+1
| | | | | | | | | | | | | | | | Added to the kernel via b49d6f7885306ee636d5c1af52170f3069ccf5f7, the emulate_pr attribute can be used to disable support for SCSI-2 (RESERVE/RELEASE) and Persistent Reservations. Signed-off-by: David Disseldorp <ddiss@suse.de>
* | targetcli-fb: Fix raise exception error in _save_backupsLeo Zhang2019-01-091-1/+1
| | | | | | | | Signed-off-by: Leo Zhang <nguzcf@gmail.com>
* | saveconfig: compress the backup config filesPrasanna Kumar Kalever2018-11-281-5/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have noticed saveconfig.json with 100 storage objects and 100 targets (each holding a single tpg and a portal) consumes disk space around ~500K. Which is very expensive, and backing-up such 100 saveconfig.json files will take ~50M of disk space under /etc/target/backup/ And at scale like 1000 storage objects and targets, this will become worst. Hence this patch attempts to compress(gzip) and store saveconfig.json while backing-up. Saved space example: [root@localhost ~]# targetcli ls | grep -e "user:glfs" -e "iscsi" | o- user:glfs ......................... [Storage Objects: 100] o- iscsi ............................... [Targets: 100] [root@localhost ~]# du -sh /etc/target/saveconfig.json 448K /etc/target/saveconfig.json [root@localhost ~]# du -sh /etc/target/backup/saveconfig-20181128-18\:20\:43-json.gz 12K /etc/target/backup/saveconfig-20181128-18:20:43-json.gz Reducing disk usage per backup file from 448K to 12K is very efficient right. Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* | version 2.1.fb49v2.1.fb49Maurizio Lombardi2018-09-051-1/+1
| | | | | | | | Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
* | Merge pull request #115 from bgly/masterMaurizio Lombardi2018-09-031-0/+13
|\ \ | | | | | | targetcli-fb: Add support for media change
| * | targetcli-fb: Add support for media changeBryant G. Ly2018-08-311-0/+13
| | | | | | | | | | | | | | | Signed-off-by: Bryant G. Ly <bryantly@linux.vnet.ibm.com> Signed-off-by: Mike Christie mchristi@redhat.com
* | | fix the parameter of define_config_group_paramtangwenji2018-07-011-1/+1
| | | | | | | | | | | | Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
* | | saveconfig: handle backups with block-level deletePrasanna Kumar Kalever2018-06-121-0/+4
| | | | | | | | | | | | Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* | | saveconfig: way for block-level save with delete commandPrasanna Kumar Kalever2018-06-011-2/+3
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | currently, we can use block-level save feature for create command and reconfig of different attributes, but there is no way to use block-level feature for delete command. This patch introduces 'save' flag (False on default), which can trigger saveconfig internally as part of delete command. $ targetcli /backstores/user:glfs delete test save=True Deleted storage object test. Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* | Merge pull request #109 from pkalever/control_strAndy Grover2018-04-301-2/+4
|\ \ | | | | | | create: add a way to set control string
| * | create: add a way to set control stringPrasanna Kumar Kalever2018-04-171-2/+4
| |/ | | | | | | | | | | | | | | | | | | | | | | this patch enable users to supply control option, a string containing comma separated control=value kind tuples, that are passed to the kernel control file. Example: $ targetcli /backstores/user:glfs create blockX1 1073741824 \ test@192.168.124.227/block-store/e59309bb-d591-4121-a891-e98ff3416446 \ control="max_data_area_mb=32,hw_max_sectors=256" Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* | fix amount of backup files in backup dirtangwenji2018-04-121-1/+1
|/ | | | Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
* config: add saveconfig command to StorageObject levelPrasanna Kumar Kalever2018-03-272-47/+85
| | | | | | | | | | | | | | | | $ targetcli /backstores/user:glfs/block1 help [...] AVAILABLE COMMANDS [...] - saveconfig [savefile] - set [group] [parameter=value...] - status - version $ targetcli /backstores/user:glfs/block1 saveconfig Storage Object 'user:block1' config saved to /etc/target/saveconfig.json Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* Fix default max_backup_files in ui_command_saveconfigtangwenji2018-03-151-1/+1
| | | | Signed-off-by: tangwenji <tang.wenji@zte.com.cn>
* Merge pull request #103 from pzakha/lun-limitAndy Grover2018-02-201-1/+1
|\ | | | | MappedLuns and Luns max number is not the same anymore
| * MappedLuns and Luns max number is not the same anymorePavel Zakharov2018-02-201-1/+1
| |
* | Use signed char instead of charTaylor Jakobson2018-02-021-1/+1
| | | | | | | | Python3 does not have the "character" type, use signed char instead.
* | version 2.1.fb48v2.1.fb48Andy Grover2018-01-261-1/+1
|/ | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* backup: global option to tune max no. of backup conf filesPrasanna Kumar Kalever2017-12-202-3/+8
| | | | | | | | | | | 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>
* config: rename key 'kept_backups' as 'max_backup_files'Prasanna Kumar Kalever2017-12-191-5/+5
| | | | | | | | | | | $ cat /etc/target/targetcli.conf max_backup_files = 25 $ targetcli / saveconfig Last 25 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* config: backup when current config is different from recent backup copyPrasanna Kumar Kalever2017-12-181-24/+29
| | | | | | | | With this change, when '/etc/target/saveconfig.json' is same as '/etc/target/backup/saveconfig-${latest-stamp}.json we skip backing up saveconfig.json Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* config: defend on '/etc/target/backup' directoryPrasanna Kumar Kalever2017-12-151-21/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently we do not create '/etc/target/backup/' while we expect the directory to be presented by package (rpm). If for some reason '/etc/target/backup' is not available, say may be a unintentional deletion or use of targetcli which is compiled from source, we see below errors on up on saveconfig command, Case 1: No '/etc/target/backup/' dir $ targetcli / saveconfig Could not create backup file /etc/target/backup/saveconfig-20171215-15:26:48.json: No such file or directory. Configuration saved to /etc/target/saveconfig.json Case 2: No '/etc/target/' dir $ targetcli / saveconfig Could not create backup file /etc/target/backup/saveconfig-20171215-15:27:42.json: No such file or directory. [Errno 2] No such file or directory: '/etc/target/saveconfig.json.temp' This patch tries to create '/etc/target/backup' directory tree in case if it is absent. Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
* Auto-detect readonly state for iblock devicesDavid Disseldorp2017-12-121-1/+29
| | | | | | | | | | | | | Configuring a read-only block device as read-write currently results in a backstore->enable configfs I/O error, as documented in: http://www.spinics.net/lists/target-devel/msg16310.html This change sees targetcli check the read-only status of the underlying block device via ioctl(BLKROGET). If a readonly= parameter isn't provided, then the backstore will use the ioctl(BLKROGET) value as the default. Signed-off-by: David Disseldorp <ddiss@suse.de>
* Read number of backup files to keep from fileTaylor Jakobson2017-11-011-1/+10
| | | | | | | Use /etc/target/targetcli.conf file to store universal configurations that are the same for all users. Configuration file has format of: key = value
* Merge pull request #91 from cvubrugier/dbus-gobjectAndy Grover2017-09-291-10/+20
|\ | | | | Replace dbus-python with GObject Introspection
| * Replace dbus-python with GObject IntrospectionChristophe Vu-Brugier2017-09-011-10/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The dbus-python homepage advises against using it: https://pypi.python.org/pypi/dbus-python/1.2.4 dbus-python might not be the best D-Bus binding for you to use. dbus-python does not follow the principle of “In the face of ambiguity, refuse the temptation to guess”, and can’t be changed to not do so without seriously breaking compatibility. In addition, it uses libdbus (which has known problems with multi-threaded use) and attempts to be main-loop-agnostic (which means you have to select a suitable main loop for your application). Alternative ways to get your Python code onto D-Bus include: - GDBus, part of the GIO module of GLib, via GObject-Introspection and PyGI (uses the GLib main loop and object model) - QtDBus, part of Qt, via PyQt (uses the Qt main loop and object model) This patch replaces dbus-python with the GObject Introspection Gio module and fixes issue #90. Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
* | skip refreshing user backed storage object when it is nullKenjiro Nakayama2017-09-161-1/+1
|/
* version 2.1.fb47v2.1.fb47Andy Grover2017-08-151-1/+1
| | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* targetcli: handle tcmu dev creation errorsMike Christie2017-06-201-2/+6
| | | | | | | | | | | | With these kernel patches: https://www.spinics.net/lists/target-devel/msg15657.html tcmu will be able to return errors during device addition. This patch to targetcli catches errors from rtslib (rtslib will catch the error and cleanup the configfs/kernel device and do a raise) and return a error and message to the user.