summaryrefslogtreecommitdiff
path: root/targetcli/ui_root.py
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.
* 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>
* Merge pull request #141 from cvubrugier/remove-epydocMaurizio Lombardi2019-11-041-9/+8
|\ | | | | Remove Epydoc markup from command messages
| * Remove Epydoc markup from command messagesChristophe Vu-Brugier2019-08-011-9/+8
| | | | | | | | Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
* | 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>
* Remove the extra semicolon in _save_backupstang.wenji2019-02-261-1/+1
| | | | Signed-off-by: tang.wenji <tang.wenji@zte.com.cn>
* 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>
* 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-271-47/+63
| | | | | | | | | | | | | | | | $ 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>
* backup: global option to tune max no. of backup conf filesPrasanna Kumar Kalever2017-12-201-3/+5
| | | | | | | | | | | 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>
* 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
* Properly detect errors when writing backup files. (Closes: #80) (#81)Christian Seiler2017-03-231-10/+18
| | | | | | | | | | | | | | | | | | | | | | * Properly detect errors when writing backup files. (Closes: #80) If the backup directory does not exist, properly detect that and show a warning message to the user, so that they don't think that their configuration was backed up, when it fact wasn't. Additionally, try to automatically create the backup directory if it does not exist. Signed-off-by: Christian Seiler <christian@iwakd.de> * Don't automatically create backup directory if it doesn't exist. After discussion on the issue tracker, it was decided to not auto-create the backup-directory if it doesn't exist yet. If the directory doesn't exist, the user will now see the warning. Signed-off-by: Christian Seiler <christian@iwakd.de>
* Clear backstore cache on refreshAmartey Pearson2017-01-231-0/+4
| | | | | | | | | | | | | | | | rtslib creates a backstore cache from configfs as a global variable. The targetcli refresh function needs to clear out said cache, or you end up with errors such as the following from an active shell if you create a new backstore from a different shell. /> refresh Storage object fileio/test not found In order to work this depends on pull request #87 from rtslib_fb, however it is written so that it won't break if an older version of the library is still in use. Signed-off-by: Amartey Pearson <apearson@us.ibm.com>
* Fix the "unused import" warnings reported by PylintChristophe Vu-Brugier2015-06-051-1/+0
| | | | Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
* Support Python 3 with "six" instead of running `2to3`Christophe Vu-Brugier2015-06-031-10/+11
| | | | | | | | | | * Replace dict.iteritems() with six.iteritems(dict) * Use six.moves.range() to get xrange() on Python 2 and range() on Python 3 * Add classifiers to setup.py * Sort imports Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
* Autocomplete for restoreconfig and clearconfigAndy Grover2014-12-171-1/+14
| | | | | | Use complete_path from ui_backstore. Signed-off-by: Andy Grover <agrover@redhat.com>
* Change targetcli to use new package import namesAndy Grover2014-12-021-3/+3
| | | | | | | | | 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>
* Use any() for seeing if fm.wwns generates anythingAndy Grover2014-11-131-1/+1
| | | | | | Slightly more efficient. Signed-off-by: Andy Grover <agrover@redhat.com>
* Fix issue with sessions detail commandAndy Grover2014-11-041-1/+1
| | | | | | | | Do not reference the backstore, access the plugin field off the so directly. This is a regression introduced with the backstore removal changes a while back. Signed-off-by: Andy Grover <agrover@redhat.com>
* Change targetcli for configshell exception changeAndy Grover2014-03-031-7/+5
| | | | | | | | | | | | 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>
* Use new rtslib restore_from_file and save_to_file APIsAndy Grover2013-11-201-15/+6
| | | | | | | | | As a result it's now better for saveconfig to save/cull backups before saving the current state, hopefully not a big deal. Resolves #34 Signed-off-by: Andy Grover <agrover@redhat.com>
* Save RTSRoot to a member variableAndy Grover2013-11-201-7/+7
| | | | | | | Get the RTSRoot object on init, and then use it when needed in other methods. Signed-off-by: Andy Grover <agrover@redhat.com>
* Replace filter() with list comprehensionsChristophe Vu-Brugier2013-10-111-1/+1
| | | | | | Generated with `2to3 -f filter`. Signed-off-by: Christophe Vu-Brugier <cvubrugier@yahoo.fr>
* targetcli: Change copyright to Apache License 2.0Nicholas Bellinger2013-07-231-10/+10
| | | | | | | | | | 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>
* Fix pychecker questionable codeAndy Grover2013-05-091-1/+1
| | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* Use 'with ignored'Andy Grover2013-04-121-3/+2
| | | | | | Woo, saved one line. Signed-off-by: Andy Grover <agrover@redhat.com>
* Save N backups of config fileAndy Grover2013-02-121-9/+23
| | | | | | | | | We save so much, they can get smooshed when something goes wrong but you're just checking it out with targetcli. Save 10. Only save backups when saving to default location. Signed-off-by: Andy Grover <agrover@redhat.com>
* Change summary formats to "<thing>s: X" and handle rtslib changesAndy Grover2013-02-061-1/+1
| | | | | | | | | This lets us not bother with different text to have good grammar if the number of objects is 0, 1, or more. Update for rtslib changes. Signed-off-by: Andy Grover <agrover@redhat.com>
* Use new restore functionality to provide better restoreconfig errorsAndy Grover2013-01-071-1/+3
| | | | | | | rtslib.root.restore() now returns a list of the specific errors that occurred. Print this list. Signed-off-by: Andy Grover <agrover@redhat.com>
* Safer savefile writingAndy Grover2012-08-071-1/+4
| | | | | | | | Would erase savefile if exception occurred during dump fsync() for correctness too. Signed-off-by: Andy Grover <agrover@redhat.com>
* Only show fabrics present in the systemAndy Grover2012-08-011-2/+4
| | | | | | | | | Don't show fabrics that need physical WWNs unless they are present. Showing them is just clutter. Simplify target summary. Signed-off-by: Andy Grover <agrover@redhat.com>
* Update ui_command_sessionsAndy Grover2012-03-191-44/+50
| | | | | | | | | | | | | | | | | | | Handle root.sessions returning dicts instead of classes "details" action renamed to "detail", a little more English noun/verb agreeable added nested function print_session, to separate printing logic from control logic. used poorly-documented (but cool) dict selector syntax for string substitutions in print_session. Now also prints more names in front of values. Mapped lun line prints plugin/so-name instead of udev_path, not all backstores have a udev_path, e.g. ramdisk. Signed-off-by: Andy Grover <agrover@redhat.com>
* + command options for sessions, close #11Johannes Dewender2012-03-151-29/+69
| | | | | | | | | | | | | | Made listing the session details optional, option to show only a specific session, documented the session command, check given options. The bare list doesn't show much specific for the session, only the alias, sid, type and state. Displaying the inititatorname would be possible, but it is too long to fit the entry on one line then. Signed-off-by: Johannes Dewender <github@JonnyJD.net>
* + root command sessions, re #11Johannes Dewender2012-03-151-0/+45
| | | | | | | | | A session command at the root node, implemented with the new Session class in rtslib. This displays a detailed list of the open sessions to the targets. Signed-off-by: Johannes Dewender <github@JonnyJD.net>
* Shorten output by only printing basename of backup fileAndy Grover2012-02-131-1/+1
| | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* Remove differential behavior based on self.loadedv2.0rc1.fb7Andy Grover2012-02-071-11/+2
| | | | | | We no longer differentiate between loaded and non-loaded fabric modules. Signed-off-by: Andy Grover <agrover@redhat.com>
* Don't load fabric modules on init.Andy Grover2012-02-071-18/+1
| | | | | | | We're probably not going to use them all, and they can now demand-load themselves. Signed-off-by: Andy Grover <agrover@redhat.com>
* Savefile may contain passwords, chmod to 600Andy Grover2012-01-251-0/+2
| | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* Print better error messagesAndy Grover2012-01-121-3/+10
| | | | | | | | | RTSRoot().restore() now returns the number of nonfatal errors that occurred when parsing the dict. Catch json parsing exception and print a nicer message. Signed-off-by: Andy Grover <agrover@redhat.com>
* Fixup clearconfig param parsing a littleAndy Grover2011-12-131-2/+4
| | | | | | | | use ui_eval_param to convert param from string to actual bool. And, docstring. Signed-off-by: Andy Grover <agrover@redhat.com>
* Simplify targetcli version commandAndy Grover2011-12-091-13/+1
| | | | | | | | | Proper versioning of dependencies should be enforced by package manager, so we don't need those listed here. Remove warning on version = 'GIT_VERSION' Signed-off-by: Andy Grover <agrover@redhat.com>
* Use expanduser(), check for existence in restoreconfig()Andy Grover2011-12-091-0/+9
| | | | Signed-off-by: Andy Grover <agrover@redhat.com>
* Clean up importsAndy Grover2011-12-091-8/+2
| | | | Signed-off-by: Andy Grover <agrover@redhat.com>