51 Commits

Author SHA1 Message Date
ting.wang
e47c83d47a Py3 replace dict.iteritems with six.iteritems
All dict.iteritems in osc are replaced with six.iteritems
except this one.
So fix it to add py3 compatibility.

Change-Id: I1aa51399a36e650d262d839ce2b4ec04d3f91db2
2016-02-24 10:14:56 +08:00
Brandon Palm
11a8f911af Use instanceof instead of type
Adjusted conditional statements to use instanceof when
comparing variables. Instanceof supports inheritance type
checking better than type.

Change-Id: I4ee0004934dc2322d43ef07e797a6811e39a812c
Closes-Bug: 1548530
2016-02-22 16:23:23 -06:00
ting.wang
e2158b7ef4 Clean redundant argument to dict.get
`dict.get()` returns `None` by default, if a key wasn't found.
Removing `None` as second argument to avoid redundancy.

Change-Id: Ia82f7469cd019509bbeccbfe54b15eeedc7bb6ea
2016-02-21 13:21:31 +08:00
Jenkins
867bcb0db8 Merge "Support unscoped token request" 2016-02-21 04:31:51 +00:00
ting.wang
5a978b9ec1 Replace string format arguments with function parameters
There are files containing string format arguments inside logging messages.
Using logging function parameters should be preferred.

Change-Id: I15b405bf4d4715263fe1e1262982467b3d4bc1f4
Closes-Bug: #1321274
2016-02-20 14:16:25 +08:00
guang-yee
41e1bd0be6 Support unscoped token request
Make scope check optional for the "token issue" command as unscoped token is
a valid Keystone V2/V3 API.

Change-Id: Ie1cded4dbfdafd3a78c0ebdf89e3f66762509930
Closes-Bug: #1543214
2016-02-19 16:07:13 -08:00
venkatamahesh
65007432dc Fix a spell typos
Change-Id: I422fc8086af83efa4c04fd1951b4738404c1a1b7
2016-02-03 15:47:25 +05:30
Steve Martinelli
74a6a81ae9 when fetching object store properties use lower()
sometimes properties within object store concepts are stored with
mixed case depending on the client used to store said properties.

when retrieving properties to 'show' the user, always call lower()
on the property in question when comparing it to the reserved
values of the swift API.

Change-Id: I97ffc715788ca3cd021413124b6945a399465c99
Closes-Bug: 1525805
2015-12-14 12:23:44 -05:00
Terry Howe
7a42174c4b Remove old code after sdk integration
We won't need this anymore.

Change-Id: Ib10be1dedb8db81f0cba6e45b8a9b0aade2ab473
2015-12-09 11:45:59 -07:00
Dean Troyer
bf090c69c2 Switch to ksa Session
* Change session imports to keystoneauth1
* Change keystoneclient.exception imports to keystoneauth1
* Change exceptions raised from internal API from keystoneclient to openstack.common

Change-Id: I046d89f561d6fe04baae53726f9749d2e7fe2056
2015-12-02 01:55:14 +00:00
Steve Martinelli
cfd2bf5882 validate non-ascii values for swift properties
skip properties that are non-ascii values, but proceed
with properties that work. log these failed values back
to the user.

Change-Id: Iaca8909f4465a01c8aebfd290b1a322823702359
Closes-Bug: 1503898
2015-11-12 11:07:57 -06:00
Steve Martinelli
1f8b814628 Fix up object-store show commands
1) Change metadata to appear under a common 'properties' key, and
use the utility to format them, this applied to object, account
and container.

2) Clean up container and object output, which were setting the
x-container-meta-owner property, but this is metadata only for
the container, so it's pointless to have, removed it.

3) Container show was showing read/write ACLs and sync stuff, but
these are not being returned by my swift by default, so I moved
these to be checks, so we don't clutter the output.

Change-Id: Ife7521fe9c2724035b06963c118bd6016ba2f5b5
2015-10-10 11:48:07 -04:00
lin-hua-cheng
985b2cdd2c Fix non-ascii issue with object commands
Escape the container and object name whenever it is used
as URL.

Change-Id: I2343c1e67843ab53773b3fca6e258dc329cd9573
Closes-Bug: #1503508
2015-10-06 23:26:08 -07:00
Steve Martinelli
e48c7afee4 add set/unset support for objects in object store
add docs and command support to set and unset metadata of objects
that are stored in an object store (swift).

Closes-Bug: #1501945

Change-Id: If838a4b3343b6ddb97cd4bd1cb63f0ba1c1a00a1
2015-10-06 00:52:24 -04:00
Steve Martinelli
abaf711e24 add support for set/unset of container properties
include docs and commands to set and unset container properties

Partial-Bug: #1501945

Change-Id: I8d7e8cf356a2321a37ed940c4e10cae411b94dfd
2015-10-06 00:18:59 -04:00
Steve Martinelli
faece91756 cleanup account ids from container commands
use a common function to determine account ID instead of different
ways - depending on the response and command

Change-Id: I95adc5dc7d5a82a2cffc570d1ded24d1fc754a11
2015-10-02 01:20:40 +00:00
Steve Martinelli
4733fd0d3c Add support for showing account details
add the command `openstack account show` that lists details
about the object store account that the user authenticated
against.

Partial-Bug: #1501943

Change-Id: I1246dafee812b63a41d43be4e3598224364a2c11
2015-10-02 01:20:06 +00:00
Steve Martinelli
a4483a0513 Add support for updating swift account properties
this patch adds support for creating/updating and removing
properties (nee: metadata) for object store accounts.

Partial-Bug: #1501943

Change-Id: I3ed70a5d8bd8920fedb79adc60cdc602261d5eef
2015-10-01 18:18:36 -07:00
Joshua Harlow
d751a21d2c Fix 'auhentication' spelling error/mistake
Change-Id: Iba58c188d2ae44170539534eea1415cf8eb65ac4
2015-09-01 15:51:58 -07:00
Dave Chen
9f69b43f5a Improve the hint message
Currently, we can get scoped token (domain scoped, project scoped)
as well as unscoped token.

When we use OSC to get a domain scoped token without explicitly set
domain information, the hint message show us we need to set a scoped
domain or project, but it miss that the parameters to be set in order
to get project or domain scoped token is not the same.

Thus, the hint message could be improved to make it more clear to
end user.

Change-Id: I94768c619b30be18737fec189ae6d81e81ba090d
2015-06-14 13:31:02 +00:00
Jamie Lennox
3ae247fdce Set tenant options on parsed namespace
Because of the way OSC registers all plugins together we end up
with os-tenant-X parameters being saved to the project-X attribute after
parsing. If you are using the v2 plugins directly then they and os-client-config
expect the tenant_X values and will assuming no scoping information if
they are not present.

Validating options for scope will also fail in this situation, not just
because the resultant auth dictionary is missing the tenant-X
attributes, but because OSC validates that either project or domain
scope information is present.

Fix this by just always setting the v2 parameters if the v3 parameters
are present. This will have no effect on the generic or v3 case but fix
the v2 case.

Expand validation to include the tenant options so it knows that v2
plugins are scoped.

Change-Id: I8cab3e423663f801cbf2d83106c671bddc58d7e6
Closes-Bug: #1460369
2015-05-31 15:03:42 +10:00
Dean Troyer
5649695c65 Add --os-cloud support
This adds a new option --os-cloud that allows the configuration values
for multiple clouds to be stored in a local file and selected with
a single option.

Internal option names have had 'os_' removed to be comptible with
the options returned from OpenStackConfig().get_one_cloud().

The config file is ~/.config/openstack/clouds.yaml:

Sample
------
clouds:
  devstack:
    auth:
      auth_url: http://192.168.122.10:35357/
      project_name: demo
      username: demo
      password: 0penstack
    region_name: RegionOne
  devstack:
     auth:
       auth_url: http://192.168.122.10:35357/
       project_name: demo
       username: demo
       password: 0penstack
     region_name: RegionOne

Co-Authored-By: Monty Taylor <mordred@inaugust.com>
Change-Id: I4939acf8067e44ffe06a2e26fc28f1adf8985b7d
Depends-On: I45e2550af58aee616ca168d20a557077beeab007
2015-04-18 23:04:51 -05:00
Dean Troyer
f43c1f7655 Defer client imports
So we really weren't deferring the loading of client libs dadgummit,
do that for real where possible.  This shaves a couple of tenths off
the static import times.

Also defer as much import-time procesing as possible.  This is a little
ugly in api.auth but this also eliminates import of the auth plugins
until they are needed.

Change-Id: Ia11d4b9cf98231d37449103fc29101dc17afb009
2015-04-15 22:40:52 -05:00
Jamie Lennox
a9d1e3d219 Base TokenEndpoint plugin on keystoneclient's
Keystoneclient has always provided a TokenEndpoint plugin. Unfortunately
it uses a different option name for url, so subclass the original and
replace the options.

Change-Id: I7e16b31ceb9f75f1c1f6bfb224d8f8f353d06150
2015-03-11 19:16:18 +11:00
Jenkins
2f4cfb6cd5 Merge "Move OSC auth plugins so they can be found" 2015-03-10 05:37:41 +00:00
Dean Troyer
749920bc65 Move OSC auth plugins so they can be found
The plugin detection at the top of openstackclient.api.auth did not
detect the plugins at the bottom of that file because, surprise,
they had not been declared yet so the entry points were ignored.

Move both plugin subclasses into openstackclient.api.auth_plugin.

Fix a problem with the password callback that was otherwise made
worse with this change.

Closes-Bug: 1428912
Change-Id: Idc3b72534071e0013c8922884a8bc14137509a0f
2015-03-10 03:16:12 +00:00
Monty Taylor
59727ba2f9 Don't hack the image url
It's actually breaking usage against HP Public Cloud.

Change-Id: Ic172786c6d1272798b768078a0bcf246f8d64ca8
2015-03-05 20:58:23 -06:00
Jenkins
b972937c82 Merge "Fix auth-required for help command" 2015-03-02 16:19:20 +00:00
Dean Troyer
505fa14cd6 Fix auth-required for help command
When we got picky with the auth arguments we broke using help without
any auth config supplied.  This rearranges things a bit to do the argument
checking when the deferred auth request to Identity occurs so commands
that do not need auth have a chance to live short but useful lives.

Closes-Bug: #1399588
Change-Id: I8ceac491cf65e25eddb62ab2713f471fe686756d
2015-02-27 17:27:17 -06:00
Terry Howe
1186cb4c9f change oslo namespace to avoid warning
Change-Id: Ieff86f841623e1ce34b79c66bc5e8b1b239fa3e9
2015-02-25 17:38:34 +00:00
Jenkins
09357009c1 Merge "Begin low-level API for Network v2" 2015-02-07 00:16:28 +00:00
Dean Troyer
61a40343fd Add filter to image list
* Hides previously broken --page-size option
* Adds --property to image list for filtering on properties
* Adds Visibility, Protected, Owner, Properties/Tags to --long output
* Adds api.utils.simple_filter() for selecting matches out of a list
  of objects
* Adds tests for all of the above
* Updates image docs

There are additional filtering options to be added in later reviews.

Change-Id: I32feff0ad61aae749b33621c817658d7dc90c3aa
Closes-bug: 1401902
2015-01-27 19:17:35 -06:00
Dean Troyer
748e0ab6ce Begin low-level API for Network v2
api.network.APIv2 starts with network_list() support to flush out
the skeleton of the Network API.

list_dhcp_agent() supports the --dhcp option of 'network list'

Change-Id: I9a2b90cde84eced1f2ea6a014b769e2bae668211
2015-01-22 10:06:15 -06:00
Dean Troyer
1ecf1bee2d Begin low-level API for Image v1 and v2
image list for v1 and v2:
* Add --public|--private to command parsers
* Implement local public/private filtering for v1 image_list()
* Pass public/private filter to server for v2 image_list()

Change-Id: Ie7c24ea2d1bf2b3b1b7fa342eb45fee45894634d
2015-01-20 17:01:23 -06:00
Jenkins
c9c28dc31d Merge "Add version url config workaround" 2015-01-19 18:08:53 +00:00
Steve Martinelli
fff4a1cd23 Add helpful messages when authN'ing with password
Setting up auth options can be complicated, and we currently don't
do any checking before we build all our auth parameters to send off
to keystoneclient. We should do some basic checking to guide new
users.

Change-Id: I9c88f1c9637b3870c151952ecc797aaf65be271a
Closes-Bug: #1400531
2015-01-16 02:41:24 -05:00
Dean Troyer
d3b87d7795 Add version url config workaround
This subclasses KSC's generic Password plugin to allow version discovery with
default Keystone configurations that leave admin_endpoint and public_endpoint
at the default values (http://localhost:xxxx).  This patch copies the scheme
and netloc from the original auth_url into the URL returned from version
discovery if the returned netloc begins with 'localhost'.

Due to the specific nature of this review, the Keystone team is not
inclned to include it in keystoneclient so it is addressed here.

Closes-bug: #1410364
Change-Id: I877fe74d86aab3a63122a07b77d1302a007f5b30
2015-01-15 13:51:31 -06:00
Jamie Lennox
25a7c1f27f Don't import form keystoneclient.openstack.common
The keystoneclient.openstack.common directory is where we sync files
from oslo incubator. It is not a public directory and should not be
being consumed by openstackclient.

Change-Id: I011bb95c2c824e2dbc4b822ca922ae77b8d9b955
2014-12-17 18:17:56 +10:00
Jenkins
1989198eac Merge "Enhance the theming for modules page" 2014-12-01 23:06:53 +00:00
Steve Martinelli
6dc128636e Enhance the theming for modules page
Also fixes a few small docstring syntax errors

Change-Id: I85eb968e32c1191cf5d60d02deff2ab7f3291074
2014-11-18 22:07:57 -05:00
Marek Denis
c1b376dc33 Add environment variable in the os-auth-type help
Help for option --os-auth-type doesn't specify what environment variable
configures it. This patch fixes that.

Change-Id: Id2e29e477d5ca56339bd777fb73b5af13788615b
2014-11-17 09:50:12 +00:00
Jenkins
747a62494c Merge "Change --os-auth-plugin to --os-auth-type" 2014-10-24 16:11:42 +00:00
Jenkins
6a4b673e88 Merge "Update use of open() in object API" 2014-10-24 06:38:22 +00:00
Dean Troyer
f079b5b9c4 Change --os-auth-plugin to --os-auth-type
User's don't know what a plugin is.

* Internally, os_auth_type and/or auth_type represents what the
  user supplied.
* auth_plugin_name is the name of the selected plugin
* auth_plugin is the actual plugin object

Plugin selection process:
* if --os-auth-type is supplied:
  * if it matches against an available plugin, done
  * (if it can map to an availble plugin type, done; TODO in a followup)
* if --os-auth-type is not supplied:
  * if --os-url and --os-token are supplied, select 'token_endpoint'
  * if --os-username supplied, select identity_api_version + 'password'
  * if --os-token supplied, select identity_api_version + 'token'

Change-Id: Ice4535214e311ebf924087cf77f6d84d76f5f3ee
2014-10-23 15:37:44 -05:00
Dean Troyer
e063246b97 Clean up shell authentication
* Remove the auth option checks as the auth plugins will validate
  their own options
* Move the initialization of client_manager to the end of
  initialize_app() so it is always called.  Note that no attempts
  to actually authenticate occur until the first use of one of the
  client attributes in client_manager.  This leaves
  initialize_clientmanager() (formerly uathenticate_user()) empty
  so remove it.
* Remove interact() as the client_manager has already been created
  And there is nothing left.
* prepare_to_run_command() is reduced to trigger an authentication
  attempt for the best_effort auth commands, currently the only
  one is 'complete'.
* Add prompt_for_password() to ask the user to enter a password
  when necessary.  Passed to ClientManager in a new kward pw_func.

Bug: 1355838
Change-Id: I9fdec9144c4c84f65aed1cf91ce41fe1895089b2
2014-10-21 23:16:16 -05:00
Dean Troyer
bcf4b3caec Update use of open() in object API
* Switch to use io.open() for py3 compatibility and simpler testing.
* Open files in 'rb' mode to avoid translation on Windows

Previously tests simply relied on files that were present in the
repository to run tests using open().  Change the filenames to ensure
that no longer happens.

requests_mock doesn't have a way to match against the request body for
PUT/POST; an attempt to add a new Matcher to do that worked but it
needs to subclass the currently private adapter._Matcher class or
duplicate most of its functionality.

Change-Id: I8c30b41db20af8ecafe67e760e872fc08adec905
2014-10-13 10:34:11 -05:00
Dean Troyer
c3c6edbe8a Add plugin to support token-endpoint auth
The ksc auth plugins do not have support for the original
token-endpoint (aka token flow) auth where the user supplies
a token (possibly the Keystone admin_token) and an API endpoint.
This is used for bootstrapping Keystone but also has other uses
when a scoped user token is provided.

The api.auth:TokenEndpoint class is required to provide the
same interface methods so all of the special-case code branches
to support token-endpoint can be removed.

Some additional cleanups related to ClientManager and creating
the Compute client also were done to streamline using sessions.

Change-Id: I1a6059afa845a591eff92567ca346c09010a93af
2014-10-12 16:48:43 -05:00
Matthieu Huin
0c77a9fe8b Support for keystone auth plugins
This patch allows the user to choose which authentication plugin
to use with the CLI. The arguments needed by the auth plugins are
automatically added to the argument parser. Some examples with
the currently available authentication plugins::

  OS_USERNAME=admin OS_PROJECT_NAME=admin OS_AUTH_URL=http://keystone:5000/v2.0 \
  OS_PASSWORD=admin openstack user list

  OS_USERNAME=admin OS_PROJECT_DOMAIN_NAME=default OS_USER_DOMAIN_NAME=default \
  OS_PROJECT_NAME=admin OS_AUTH_URL=http://keystone:5000/v3 OS_PASSWORD=admin \
  OS_IDENTITY_API_VERSION=3 OS_AUTH_PLUGIN=v3password openstack project list

  OS_TOKEN=1234 OS_URL=http://service_url:35357/v2.0 \
  OS_IDENTITY_API_VERSION=2.0 openstack user list

The --os-auth-plugin option can be omitted; if so the CLI will attempt to
guess which plugin to use from the other options.

Change-Id: I330c20ddb8d96b3a4287c68b57c36c4a0f869669
Co-Authored-By: Florent Flament <florent.flament-ext@cloudwatt.com>
2014-10-09 12:34:47 +02:00
Steve Martinelli
388bbbac2c Fix issues with object related commands
1) Can't create instance of swiftclient. Since we now create
an API instance, creating a swiftclient instance won't work.
Trying to do any object related command fails.

2) Listing objects in a container fails, we depend on the
data returned in a specific way, during the API transition
this must have slipped through.

Needs regression/funcitonal tests to mame sure this doesn't
happen again.

Change-Id: I69079a0dc9f32b84e6f9307729d3dbbba549ac5e
2014-10-06 20:04:19 -04:00
Dean Troyer
31018bf7c2 Move object-store commands to low-level API
api.object_store.APIv1 now contains the formerly top-level functions
implementing the object-store REST client. This replaces the old-style
ObjectClientv1 that is no longer necessary.

Change-Id: I7d8fea326b214481e7d6b24119bd41777c6aa968
2014-10-01 13:50:13 -04:00