Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=54726a4950756b8f0c3e1…
Commit: 54726a4950756b8f0c3e19c4c7d5feb6fb838e00
Parent: c73b9f062c8ed59dc0bfa859cab4a692295a56cb
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Apr 28 16:43:42 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Apr 28 16:51:04 2017 -0500
fix running commands from a script file
Using any arg with a command name in a script file
would cause the command to fail.
The name of the script file being executed was being passed
to lvm_register_commands() and define_commands(), which
prevented command defs from being defined (simple commands
were still being defined only by name which was enough for those
to still work when run trivially with no args).
---
WHATS_NEW | 1 +
tools/lvmcmdline.c | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 2db7dc4..846e998 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.171 -
==================================
+ Fix running commands from a script file.
Add pvcreate prompt when device size doesn't match setphysicalvolumesize.
lvconvert - preserve region size on raid1 image count changes
Adjust pvresize/pvcreate messages and prompt if underlying dev size differs.
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index c0c81ba..29ec06b 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -3444,6 +3444,10 @@ int lvm2_main(int argc, char **argv)
goto_out;
}
+ /* Can be the name of a script file. */
+ if (run_name && !find_command_name(run_name))
+ run_name = NULL;
+
if (!lvm_register_commands(run_name)) {
ret = ECMD_FAILED;
goto out;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=86b9c23dbe4a5033eea66…
Commit: 86b9c23dbe4a5033eea6667c0274655e7c0c8e68
Parent: 4f9ff14508084789c731e99d8921c052da694319
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Apr 27 14:21:01 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Apr 27 14:21:01 2017 -0500
commands: improve syntax suggestion when no command is found
The logic for suggesting the nearest valid command syntax
was missing the simplest case. If a command has only one
valid syntax, that is the one we should suggest. (We were
suggesting nothing in this case.)
---
tools/lvmcmdline.c | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 37e9ef8..c0c81ba 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1516,6 +1516,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
int match_required, match_ro, match_rp, match_type, match_unused, mismatch_required;
int best_i = 0, best_required = 0, best_type = 0, best_unused = 0;
int close_i = 0, close_ro = 0, close_type = 0;
+ int only_i = 0;
int temp_unused_options[MAX_UNUSED_COUNT];
int temp_unused_count;
int best_unused_options[MAX_UNUSED_COUNT] = { 0 };
@@ -1525,12 +1526,23 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
int i, j;
int opt_enum, opt_i;
int accepted, count;
+ int variants = 0;
name = last_path_component(path);
+ /* factor_common_options() is only for usage, so cname->variants is not set. */
for (i = 0; i < COMMAND_COUNT; i++) {
if (strcmp(name, commands[i].name))
continue;
+ variants++;
+ }
+
+ for (i = 0; i < COMMAND_COUNT; i++) {
+ if (strcmp(name, commands[i].name))
+ continue;
+
+ if (variants == 1)
+ only_i = i;
/* For help and version just return the first entry with matching name. */
if (arg_is_set(cmd, help_ARG) || arg_is_set(cmd, help2_ARG) || arg_is_set(cmd, longhelp_ARG) || arg_is_set(cmd, version_ARG))
@@ -1701,7 +1713,11 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
if (!best_required) {
/* cmd did not have all the required opt/pos args of any command */
log_error("No command with matching syntax recognised. Run '%s --help' for more information.", name);
- if (close_ro) {
+
+ if (only_i) {
+ log_warn("Correct command syntax is:");
+ print_usage(&_cmdline.commands[only_i], 0, 0);
+ } else if (close_ro) {
log_warn("Nearest similar command has syntax:");
print_usage(&_cmdline.commands[close_i], 0, 0);
}
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5cf51fb2f74ad43a2555b…
Commit: 5cf51fb2f74ad43a2555bc391cf069caa1d99775
Parent: 0e3c16af5699c000f1824c42c596fec58d019dfa
Author: Marian Csontos <mcsontos(a)redhat.com>
AuthorDate: Thu Apr 27 18:12:20 2017 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Thu Apr 27 18:16:17 2017 +0200
dbus: log_debug needs qualifier
Adding qualifier makes the only unqualified log_debug occurence
consistent with other uses in the same file.
Other possible ways to fix this:
- using `from .utils import log_debug`
- moving the line below `from . import utils` line
---
daemons/lvmdbusd/manager.py | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/daemons/lvmdbusd/manager.py b/daemons/lvmdbusd/manager.py
index 1ae9c8b..d77c7b4 100644
--- a/daemons/lvmdbusd/manager.py
+++ b/daemons/lvmdbusd/manager.py
@@ -6,7 +6,6 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from utils import log_debug
from .automatedproperties import AutomatedProperties
from . import utils
@@ -145,7 +144,7 @@ class Manager(AutomatedProperties):
p = cfg.om.get_object_path_by_uuid_lvm_id(key, key)
if not p:
p = '/'
- log_debug('LookUpByLvmId: key = %s, result = %s' % (key, p))
+ utils.log_debug('LookUpByLvmId: key = %s, result = %s' % (key, p))
return p
@dbus.service.method(