52 Commits

Author SHA1 Message Date
Vadim Hmyrov
60fb57b94a Simplify heading capitalization in shell's HelpFormatter.
Removed redundant expression for capitalizing the heading
in HelpFormatter.

Change-Id: I063960f6bb18486ce034ec2ae03b26cf8d63716f
2016-12-20 16:12:12 +02:00
ChangBo Guo(gcb)
6c71d8771d Use function import_versioned_module from oslo.utils
oslo.utils 3.17 provides similar function, just use it.

Closes-Bug: #1627313

Change-Id: I1710faafd69cb098d603135ca8a158129edb6fec
2016-11-02 13:36:17 +08:00
Kyrylo Romanenko
11eae85a31 Fix import of ironicclient and reformat docstring
Fix import of ironicclient to ironicclient/shell.py.
Reformat docstring in ironicclient/v1/shell.py.

Change-Id: Iad717d139ef423bb9f93050c6ba0c20fe1912a82
2016-10-10 13:15:36 +00:00
Tang Chen
bd6d94a687 Fix i18n problems in shell.py
Help msg and output info should support i18n.

Change-Id: Ic0e0385773f0315103968bfb841c0c564530931d
2016-08-09 14:04:02 +08:00
Tang Chen
b2c4c7ec95 Make shell main() specify return value in exit code
sys.exit() calls in main() will make the interactive
python interpreter exit. We can call the main() as
below to avoid to exit the interactive interpreter,
and specify the return value of main() in the exit
code at the same time.

sys.exit(main())

Change-Id: I6ead9853fe27e99df3e9121478e906a06839f48c
2016-07-30 22:12:55 +08:00
Anton Arefiev
8a83d36021 Remove httplib2
It's used only for setup debug level info, but since HTTPClient
switched to requests lib, it became useless.

requests lib does no logging of its own. It's logging actually
done by urllib3 and can be setup as usual logging level.

Change-Id: I7df95e41d5f3a2406b43643bfa828b751faab116
2016-03-14 18:37:25 +02:00
Jenkins
992ed7c758 Merge "Remove leftover use of args.os_endpoint" 2016-03-04 01:33:35 +00:00
Vladyslav Drok
acd482516e Remove leftover use of args.os_endpoint
It is now written to args.ironic_url.

Change-Id: I353917ac7a526308661e3d113bd5a05b1695c5f4
2016-03-04 02:14:00 +02:00
Jenkins
cf70f20943 Merge "Use keystoneauth instead of keystoneclient" 2016-03-03 23:52:46 +00:00
Vladyslav Drok
7226ad44aa Use keystoneauth instead of keystoneclient
This change also enables client to be authenticated via 'token'
keystone auth method, allowing to pass os_auth_token instead of
os_username and os_password.

Closes-bug: #1541411
Closes-bug: #1548907
Change-Id: I9739c95069ebf8d60f8362be154844e74334beb2
2016-03-03 18:07:32 +02:00
Aline Bousquet
fda1854865 Add a JSON option to the client
Add a json option to list and show commands to return the JSON
response body from the Ironic API without formatting it.

Change-Id: Ic21c8ce1cc211816e309b4a00b6e89a0a8bf6a9d
Closes-Bug: #1436440
2016-03-02 11:29:40 +00:00
Jenkins
1073a5469b Merge "Use keystoneclient.exception directly" 2015-11-18 02:45:28 +00:00
Lin Tan
4d966622ef Sync with oslo-incubator
According to the latest agreement in Oslo team, apiclient and
clituils will be removed from Oslo incubator. We should keep
the local copy by ourselfs:
1. rename openstack/common/apiclient to common/apiclient
2. Because Ironic only use base.py and exception.py, so delete others.
3. rename openstack/common/cliutils.py to common/clituils.py
4. Delete openstack/common/_i18n becuase we have common/i18n.py
5. Delete openstack folder because it is empty
6. Add related unit tests and add oslotest to test-requirements.

Change-Id: I9eecd0457e86e82e65db1d0bc9a4c5c0ed4bbf74
2015-11-17 09:22:53 -08:00
Lin Tan
c4b8dfa5be Use keystoneclient.exception directly
keystoneclient.openstack.common.apiclient.exception was import in
ironicclient/shell.py, but it's keystoneclient.exception indeed.
And only ClientException was used.

Meanwhile, apiclient is removed from oslo-incubator, so there is a
potention change in keystoneclient.

So use keystoneclient.exception directly.

Change-Id: I87bab4396996e9b4f7be33643ae49599cb2f2f76
2015-11-12 15:52:23 +08:00
Jamie Lennox
3f4671a0b7 Cleanup session creation
When using the session object we want to pass through unknown kwargs to
the adapter so that keystoneclient can add new parameters as required.

This requires fixing the old options so that we can restrict what is
passed and showing a warning when there are values that are being
ignored.

Change-Id: Ia795dfc8e16c60a08df1636816daefe2ebbd0b03
2015-06-18 10:05:14 +08:00
Ben Nemec
e6ae41c537 Register global Keystone args first
As described in the referenced bug, registering the Keystone args
last causes their default values to be ignored.  Registering them
first seems to prevent the problem.

Change-Id: I8eb7882a0153fedbd6591dde2157df13fa2e5ba3
Closes-Bug: 1463581
2015-06-16 18:15:35 +00:00
Ruby Loo
8fd2ac3ba1 Consistent and more valid strings for Booleans
The set of valid input strings for Boolean values was inconsistent among
the subcommands of the Ironic CLI. egs:
 -for node-set-console-mode: 'true', 'false'
 -for node-set-maintenance: 'on', 'off', 'true', 'false', 'True', 'False'

This change allows the same set of valid values for all the subcommands:
'0', '1', 'f', 'false', 'n', 'no', 'off', 'on', 't', 'true', 'y', 'yes'.

For invalid strings, we output the subcommand usage along with the
argument, invalid string, and valid string choices.

At the API level, if NodeManager.set_maintenance() is passed an invalid
state (maintenance mode) value, an InvalidAttribute exception is raised.

Change-Id: I541695388489cdc640265df8ee6a9999e1442870
Closes-Bug: #1415943
2015-05-07 01:29:57 +00:00
Jenkins
5a3957eb9f Merge "Remove unneeded 'utf-8' coding lines" 2015-04-22 14:58:21 +00:00
John L. Villalovos
2df670cf30 Remove unneeded 'utf-8' coding lines
This is basically a revert of commit:
  af741ec2236619880fa902d68aef4a6ae6cef534

It was decided that only files that need to have the line:
  # -*- coding: utf-8 -*-
Should have the line[1] as a general principle

This patch removes the 'utf-8' coding line from files that consist
entirely of ASCII characters.

[1]
http://eavesdrop.openstack.org/meetings/ironic/2015/ironic.2015-04-20-17.00.html

Partial-bug: #1325193
Change-Id: I88c1c37f7b580aa805eae9d4a1e66d33302a325f
2015-04-21 16:44:47 +00:00
Jenkins
e176083af3 Merge "Encode exception on cli for UnicodeDecodeError" 2015-04-21 15:40:16 +00:00
jiangfei
8f476f47b1 Encode exception on cli for UnicodeDecodeError
cli did not handle output exception which is encoded,this patch
implements the shell encoding for exception output.

Change-Id: I7350c9be1bc0a7eafaaf2f992b7ef07bf84d44f8
Closes-Bug: 1437147
2015-04-21 00:10:08 +00:00
Dmitry Tantsur
28bdd0baeb Implement and enable retries on Conflict
Getting Conflict errors is pretty annoying, especially when writing
automation scripts. Nova and ironic-discoverd already have their
own logic for retrying on such errors.

This patch adds 'max_retries' and 'retry_interval' arguments to
get_client for tuning or disabling retries.

Change-Id: Id9720c87ce3846faec61eb40ccf00970ca798ad2
2015-04-17 16:25:44 +02:00
Ghe Rivero
9991b26db1 Use oslo.i18n lib
Stop using gettextutils from oslo.incubator and replace with
the graduated library oslo.i18n

Change-Id: I479be348f6e0894ecff5cd93d37ee66648f3ea01
2015-03-19 18:27:24 +01:00
Jenkins
ff67f214cf Merge "Fix two error strings in the CLI" 2015-03-13 14:08:04 +00:00
John L. Villalovos
144e82b163 Fix the final PEP8 errors
Fix PEP8 E126,E127,E128 errors, which were the only ones remaining.

Fix PEP8 errors:
E126: continuation line over-indented for hanging indent
E127: continuation line over-indented for visual indent
E128: continuation line under-indented for visual indent

Remove the ignore= entries for flake8 in tox.ini

Change-Id: I919551121d85d2aab528f4fa5ecdb3cfd940557a
2015-03-10 14:38:30 -07:00
Devananda van der Veen
a6b9774798 Fix two error strings in the CLI
Two error strings in ironicclient/shell.py were not translated.

This patch adds _() and also improves the clarity of one of
the messages.

Change-Id: I85a4db59aa486d7f7e1c901ab8b41668edd59acc
2015-03-07 13:51:27 -08:00
Chris Krelle
fd6f36474b Fix typo on patch 155624
This is a follow up patch to correct a spelling issue with 155624.

Change-Id: I56df414acb9fcccbd872f902e536a18c5474c1e0
2015-03-06 11:40:39 -08:00
Lin Tan
53095aaa8f Enable ironicclient with --ironic-api-version 1.x
python-ironic-client doesn't recognize API micro-version parameter.
Reuse --ironic-api-version to recognize this.

1. The client accepts '1.x' or 'latest' as valid API version and send
corresponding headers to Ironic.
2. If the user does not specify a version, client will not sent any
extra headers to Ironic. It will use the minimum version.

Closes-Bug: #1417430
Change-Id: I1db6e2f4e57d6d47d86f068018f143d0044b7211
2015-03-06 11:40:33 +08:00
John L. Villalovos
12eedb9ae6 Fix PEP8 E121,E122,E123,E124,E125,E129 errors
E121: continuation line under-indented for hanging indent
E122: continuation line missing indentation or outdented
E123: closing bracket does not match indentation of opening bracket's line
E124: closing bracket does not match visual indentation
E125: continuation line with same indent as next logical line
E129: visually indented line with same indent as next logical line

Remove E121,E122,E123,E124,E125, & E129 from the ignore list for flake8

Change-Id: I1b98335dd24086ab0271d25d662ad667ff8c5835
2015-02-26 08:40:25 -08:00
jiangfei
9201d3896c cli support --os-endpoint
ironicclient not support --os-enpoint:
ironic --os-auth-token d7de11bba5984badb3e25533afec6ae6
--os-endpoint http://127.0.0.1:6385 node-list

You must provide a username via either --os-username or via
env[OS_USERNAME]

Change-Id: I374203559c1636143bb3326d41bd230b7b4f79ec
Closes-Bug: #1417406
2015-02-04 11:29:32 +08:00
Ruby Loo
ba5e7ed62d Add 'API' to description of ironic command
An 'ironic help' displays information about the ironic command.
After the usage part, it shows 'Command-line interface to the
OpenStack Bare Metal Provisioning'.

This adds 'API.' to end that sentence.

Change-Id: If41c326ab31a96894eccef0a37921945a1e21ecd
2014-11-20 00:20:30 +00:00
Arun S A G
108938c769 Fix python-ironicclient crash
- ca_file, cert_file and key_file arguements were renamed part of
  e3d35647 but the commit e3d35647 never renamed the other place this
  variables were used.
- This commit properly renames those variables back to sane values and
  fixes the crash

Change-Id: I7b40b2e6a314abc734d28b76626f09f3d31c0d8b
Closes-Bug: 1386454
2014-10-28 00:04:06 +00:00
John Trowbridge
9d6137380b Adds tty password entry for ironicclient
Added functionality from keystoneclient to fallback to the tty for password
entry if no password is given via the environment or the --os-password option.

Change-Id: I92da7112221c77efc220374617d503dc2184363e
Closes-Bug: 1382146
2014-10-22 17:13:38 +00:00
David Hu
e3d356476b Add keystone v3 CLI support
This change allows user domains and tenant/project domains to
be specified through CLI.  This is necessary because keystone
v2 API is deprecatedas of Icehouse.

Change-Id: I50187a12b73777118ee77590202746b272ecc030
2014-10-06 10:47:06 +00:00
Ruby Loo
91ff271e4c Add defaults to the CLI help strings
This modifies the help strings for timeout, os-service-type, and
os-endpoint-type arguments, to include the default values used.

Change-Id: I6bc9c243654b74550c60caf7fdb40e18addb3cd4
2014-09-16 14:40:27 +00:00
Jenkins
a6923debc8 Merge "handles keyboard interrupt" 2014-09-11 16:46:50 +00:00
Rakesh H S
ad8c27f8e0 handles keyboard interrupt
When an user intentionally provides an keyboard interrupt, ironicclient
throws the entire traceback on to the terminal instead of handling it.
ironicclient will now handle the keyboard interrrupt and provides an crisp
message on to the terminal.

Change-Id: I8e657dc0cf64fa3396fb8fd32c5ffb57016ce864
Closes-Bug: #1367283
2014-09-11 17:51:13 +05:30
Ruby Loo
70b27a083c Add 'bash-completion' to 'ironic help' response
If you do 'ironic' or 'ironic help', it will show a list of subcommands.
This adds 'bash-completion' to that list.

The 'ironic bash-completion' subcommand lists all of the commands.
It won't include 'bash-completion' in this list, to be consistent with
nova's and keystone's bash-completion subcommand.

Change-Id: I7f2b76ad2885d9fe34dc91a97ee77984a21a27f4
Closes-Bug: #1304488
2014-09-09 15:11:18 +00:00
Jenkins
25befcb5f9 Merge "Add bash completion support for ironic cli" 2014-07-15 18:58:11 +00:00
Ramakrishnan G
1155530941 Add bash completion support for ironic cli
This commit adds the 'bash-completion' option to
ironic cli which prints all sub-commands and
options, and bash_completion scripts for bash
auto completion.

Change-Id: Ide5b29e262b4217046f124d86902cd0abfdab1b6
Closes-Bug: 1332408
2014-07-09 22:50:12 +05:30
Andrey Kurilin
fb63911eb1 Remove aliases arg and env from utils
This patch removes aliases in `ironicclient.common.utils` and starts
to use directly `arg` and `env` functions from common code.

Change-Id: Ied396b767e623fbcbf0c7a32326be7b64132b3e1
2014-07-09 11:30:06 +03:00
Martin Geisler
af741ec223 Add UTF-8 coding lines to all Python files
While not strictly necessary for files containing only ASCII
characters, adding a line with "coding: utf-8" can guard against
future SyntaxError's in case someone inserts a Unicode literal.

This commit adds such lines to all .py files. The syntax used by this
commit works with Python (of course). It also works with Emacs, which
will recognize the special "-*-" marker and use the "coding" variable
to correctly decode the file, even in an environment where UTF-8 is
not the default file encoding.

Existing coding lines were normalized to match the new lines added.

Partial-bug: #1325193
Change-Id: I58bf93fea711fd25890356a397e594bd820c99e3
2014-05-31 13:22:44 +02:00
Lucas Alvares Gomes
1aec4586e2 Add missing i18n support
There are some exception messages in common/utils.py and shell.py that
does not support i18n, this patch update the code to support it.

Change-Id: I836b892075333d48e4d1591986fec1362c84fc61
Partial-bug: #1240402
2013-11-28 10:23:54 +00:00
Ghe Rivero
1b1dd31067 Reorder imports
As per hacking and PEP8, grouping third party libraries in
their own group.

http://www.python.org/dev/peps/pep-0008/#imports

Change-Id: I7a574d311b5171def0c6930162a46ce4c215097d
2013-11-11 18:12:58 +01:00
Jenkins
3446a9734d Merge "Transform print statement to print function" 2013-11-11 09:20:09 +00:00
Ghe Rivero
a6fd095e95 Transform print statement to print function
Needed to comply with new hacking>=0.8.0,<0.9 requirement.

Partial implement: blueprint py33-support

Change-Id: I478a47c814462a4f7edb0f389a00666bc901af77
2013-11-06 10:30:39 +01:00
Lucas Alvares Gomes
ce93dd5ce1 Add node-set-power-state to cli
Add the node-set-power-state command to allow changing the power state
of a node using the cli.

Change-Id: I176bfe54db84e1c5677f7955b9cf247f0d09be4e
2013-11-01 17:42:50 +00:00
Lucas Alvares Gomes
958652fcb4 Add short command line option
Add short command line option alternative for resources creation. This
patch also sacrifices the short option used for debug (-d) in place of
improve the user experience for the real user, developers who needs to
enable debug can still use the long form alternative (--debug).

Change-Id: I1588dc453e1c432fd372e07b87978a77faddcd1c
2013-10-03 11:45:48 +01:00
Lucas Alvares Gomes
913ffc3161 Improve help strings
Improve help strings, remove the upper and lower case mix, inform the
user that some fields are required, remove the period at the end of the
strings making them more uniform.

Change-Id: If5531e0f3161b74f29a80d61792746d561660f49
2013-10-03 11:03:54 +01:00
Lucas Alvares Gomes
489daf6710 Improve error feedback
When an error occur instead of just return the HTTP response code the
client will now try to extract the error message that contains the reason
of the problem and show it to the user in a user-friendly way (no codes
at all), the intention of this patch is to improve the usability of the
ironic client. Things like HTTP response codes can still be viewed when
used with the debug mode enabled ( -d ).

Change-Id: Ieca021cc0e0eabe91c13335c3062ef9622da3004
2013-10-02 16:41:53 +01:00