Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #335 #338: Modify so general opts work in interactive mode #336

Merged
merged 3 commits into from
Sep 16, 2019

Conversation

KSchopmeyer
Copy link
Contributor

@KSchopmeyer KSchopmeyer commented Sep 12, 2019

Overview:

  1. Save saves the current connection with modifications from the general options
    pywbemcli> --user fred connection save t1

    Sets user to fred and saves the connection as t1.

  1. Connection save changed to allow overwrite of the connection if already in the connections file by removing the test for existing name in the file. Since the new general options are not retained after the connection save command, there is no impact on the current connection. # issue "connection save" should overwrite existing connection definitions #338

  2. Uses general options before all commands except connect [select]. Sets the general options values into the current connection but restores any previous connection definition for subsequent commands in the interactive session. Connection select, makes the defined option the current option for the defined interactive session but DOES not apply the modifications from the general options because they would have been applied to the current connection, not the connection we are selecting. NOTE: we do not notify the user of this issue.

  3. Connection select with general options gets the connection from the repo, makes the changes from the general options and also makes this the current option for this interactive session. There will be NO way to select the current connect and change it, only persistent connections.

  $  pywbemcli  -n myserver
  pywbemcli> --user blah --pasword blah connection save myserver

 Changes the user and password for the myserver connection.

  1. When the general options are applied to a connection, the connection is reset so that the first command to the server reinitiates the connecton.

Issues:

Some options cannot be unset. Thus, you can set value into --user but you cannot set it back to None because it is the existence of the general option that causes it to be set. This applies to --user, --password, --keyfile, etc.

**COMMENT" Since click does not support the concept of options with optional arguments, see click issue: pallets/click#549, we propose that setting the value of these options to "" is a valid way to let pywbemcli set the values to None. I propose that this be a separate PR just to keep the changes to this PR limited.

Modified -no-verify per the commit message so it can be set, unset, etc. The new option is `--verify/--no-verify' and there is no short form

@andy-maier
Copy link
Contributor

Since PR #306 is now merged, please rebase this on master.

@KSchopmeyer KSchopmeyer force-pushed the ks/#335/use-general-opts branch 2 times, most recently from b144bdb to cdae6e0 Compare September 14, 2019 20:44
@KSchopmeyer KSchopmeyer force-pushed the ks/#335/use-general-opts branch 4 times, most recently from 87f2c58 to bbe4798 Compare September 14, 2019 22:31
docs/appendix.rst Outdated Show resolved Hide resolved
docs/appendix.rst Outdated Show resolved Hide resolved
docs/appendix.rst Outdated Show resolved Hide resolved
docs/appendix.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@andy-maier andy-maier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments

@KSchopmeyer KSchopmeyer force-pushed the ks/#335/use-general-opts branch 2 times, most recently from 5706e01 to c0c202a Compare September 15, 2019 19:37
@KSchopmeyer KSchopmeyer changed the title WIP Ks/#335/use general opts Fixes issues # 335 and # 338, Modify so general opts work in interactive mode. Sep 15, 2019
docs/appendix.rst Outdated Show resolved Hide resolved
docs/appendix.rst Outdated Show resolved Hide resolved
docs/appendix.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@andy-maier andy-maier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments

…ions.

Modified the structure to allow use of the general options within an
interactive session.

1. Removed some of the properties (timestats, use_pull, pull_max_cnt,
log, verbose) from PywbemServer class. These are maintained only in the
context and therefore, when set, they apply to all commands, not any
particular pywbem server. They were always accessed from the context
rather than the server so should never have been in the server.

2. Added property setters to PywbemServer class so can individually
set properties.

3. Modified no_verify option. Modified no-verify option to allow 3 values
 (None, True, False). This allows the code to determine if the
option was defined.

4. Reorganized pywbemcli.py slightly to do function cli input argument
processing on all calls, startup and command calls. This produces
resolve_... versions of each of the input arguments so that the code
can determine if the argument was actually input or the default was set.

5. Changed the name of the no_verify option to verify because the order
of processing in the click option that handles '--a/--no_a' is such that
we would have either had to define it as '--no-a/--a' or invert the
argument in processing. Besides this actually seems more logical instead
of the double negative (i.e. is no-verify True or false). Note that the
alternative would have been to make it a choice argument (choice
("true", "false"). We had to do something so that we could determine if
the argument was input or not and the is-flag does not do that.

6. Remove the block on overwrite of connection definitions with
'connection save'.
change to code to simplify, and .  Does not include change for
proposed move of use_pull and pull_max_cnt back to the connection
defintion or the change for interactive mode on connection show.
help and also expands the _show command to more explicitly define why
ic cannot show anything (no connections file, no current connection,
etc.) The messages now show where the connections file should be if
it is empty/missing.

Added more tests for the errors with empty repo on connection show,
delete, select.
@andy-maier andy-maier changed the title Fixes issues # 335 and # 338, Modify so general opts work in interactive mode. Fixes #335 #338: Modify so general opts work in interactive mode Sep 16, 2019
@andy-maier
Copy link
Contributor

Approved

@andy-maier andy-maier merged commit 0b64ab0 into master Sep 16, 2019
@andy-maier andy-maier deleted the ks/#335/use-general-opts branch September 16, 2019 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants