30 Commits

Author SHA1 Message Date
TerryHowe
2d10b621fa Remove references to v2_0 from examples
The network resources used to be in a v2_0 directory, but
they got moved to v2.

Change-Id: I9d95b3df61a53e0f60536315dbb0185959910fc4
2015-04-29 09:39:31 -06:00
TerryHowe
d607fd3904 Add module name to repr string
Add the module name to the repr string so we can better identify
the resource that created the string.  This is also convenient
for recreating the object from a string such as:

    python examples/get.py openstack/compute/v2/server.py --data "openstack.compute.v2.server.Server(attrs={u'id': u'85d8ecf3-3757-43fd-b7a2-eb6636f7af1c', u'name': u'jenkins'}, loaded=True)"

Change-Id: I7a8bdabd8150e0bd06ec46deecf81eaa126907ab
2015-04-16 06:22:38 -06:00
tengqm
85a28f8690 Add trust-id to command line arguments
This patch enables TRUST_ID based authentication for users to try
the examples. Without this, users won't be aware of this important
parameter/feature.

Change-Id: Ide409c91d8c0530aebaef3b2682997533b639f6c
2015-03-31 06:40:16 -04:00
TerryHowe
fa1ad8dd55 Convert example --data to use eval instead of json
The --data option to the examples expects json.  I don't know why I ever did that, it is inconvenient.  I want to be able to cut and past Python repred data structures into --data and have them available to the example code.  No more converting ' to ".

Closes-Bug: 1425678

Change-Id: I96ba80dd4018ec6834f02ac4a4902f3bab875870
2015-03-06 17:27:21 +00:00
TerryHowe
8379ad612e Convert user_name to username
This will greatly reduce the number of ksc to sdk differences.
Why fight it, everyone is used to username anyway.

Change-Id: Ie6e897c1baa3184af77510b98790196e8f069f5a
2015-02-23 21:43:32 +00:00
Brian Curtin
8dcff5a621 Add logging functionality to openstack.utils
This change moves the ability to enable logging out of the
examples.common module and into the openstack.utils since it is
generally useful.

This is intended to give users a short-term solution to receive
debugging messages. If they want to always have our messages logged in
their application they should create their own logging handler(s) with
their own format, and that will cause our messages to be sent to their
handlers as they wish.
https://bugs.launchpad.net/python-openstacksdk/+bug/1418307 is open to
track the documentation aspect of this.

Change-Id: Ic8768d529d0389b9b04bd4ea31453a82f30faf33
2015-02-16 17:29:13 -06:00
Brian Curtin
0a235978f8 Allow examples.get call without data
It wasn't possible to call examples.get without a --data parameter. This
change checks if the opts.data is empty, and if so, just deals with it.

Change-Id: I262e8f8b061d163e478c3b9fe611a44180119909
2015-01-31 22:46:21 -06:00
Terry Howe
763c741860 Get rid of some useless code
For some reason this argument parsing code in examples had
a useless if statement.

Change-Id: I9ef9fdb48f922b1fd95fafe0286de8f901b142a7
2015-01-23 12:06:39 -07:00
Jenkins
84c5ddddef Merge "Create a discoverable plugin" 2014-11-13 22:49:36 +00:00
Terry Howe
72210d2ee6 Create a discoverable plugin
Move the version detection code into a plugin because it
does not belong in connection.  Create a new discoverable plugin
that looks at the auth_url and makes a best guess if it should
use v2 or v3 auth.

The plugin also now accepts access_info so a cached version
of the authorization can be reproduced without hitting
keystone.

Change-Id: Ia5d32457c90716627a75be2c99267c4ed7903197
2014-11-13 08:11:58 -07:00
Terry Howe
68393cab42 Add an example for the connection class
Also, change around the other examples to use the connection
example so there isn't duplication of code for session and
authentication.

Change-Id: I90dbcfac3eae0c792bd9c4eae071de7d81e1b27d
2014-11-01 10:11:06 -06:00
Terry Howe
5d2b0e8160 Add user preference and example CLI to build it
Add a user preference class to collect user service preferences.

Sorry for all the test changes.  I wanted to make the v2 and v3
tests have the same service catalog in a different format so that
the normalize catalog would be the same for both.

Closes-Bug: #1353030

Change-Id: Ice4e606255533425be7559916f083b4171566502
2014-10-14 17:41:39 -06:00
Terry Howe
46f329afdb Introduce the connection class
The connection class can be made with a transport and/or authenticator
that was already constructed or it can be made with nothing.  The
create method will create a transport, authenticator and session if
they are needed.  The normal use case would look something like:

    conn = connection.Connection(**auth_args)

Change-Id: I27573bce799d9992748967b5ea1b575139a75853
2014-10-12 05:48:30 -06:00
Terry Howe
836b9e852d Use stevedore to load authorization plugins
Add basic infrastructure to load authorization plugins with
stevedore.

Change-Id: I4828be6537bbe865b43ec43de41f6060ea8f2c98
2014-10-06 10:06:09 -06:00
Terry Howe
2fee0f038f Move cacert/insecure awkwardness examples/common
The requests.Session object that transport derives from has
this overloaded meaning for verify that is causing awkwardness
around our code.  I've moved the ugly to the examples/common.py
argument parsing.

Change-Id: I3e8f5311eeba6108d3ea086a01b71663401a52fa
2014-09-12 20:47:58 +00:00
Terry Howe
e744e6006a Change example so CLI names match object arguments
I would like to extract the arguments automatically from the
example command line arguments.  If the names matched, it would
be much easier.

Change-Id: I0877fe8a0b6f5a61505fdecddd2f72ee8c505d29
2014-09-07 14:54:43 +00:00
Terry Howe
5bc607e40f Remove unused os-url option
Change-Id: Ibceca24470cb1f24fdf2b4bfd6750e9e780cc0c1
2014-09-07 08:52:40 -06:00
Terry Howe
cdd8dc7a60 Add domains for v3 authentication
I was having trouble authenticating with devstack identity v3 without domain.
These options make it possible.

Change-Id: I2a968a89136e72898dc086b8f5330608c31ec66f
2014-08-29 13:58:34 -06:00
Terry Howe
f60e721560 Change OS_REGION to OS_REGION_NAME
Dolph made a comment a while back saying region_name should be
region which I did.  Talked with Dean about this and he dug
his heels in saying it should be region_name.  All the CLIs
are using region_name.

Change-Id: I212eb4ec96a59650226ae5f5b0172c40c25dec90
2014-08-18 05:22:31 -06:00
Terry Howe
f03b8ed033 Have examples handle snake case to camel case
Change-Id: I91f1d2ab84f83ff38f7f4ebc60a3a1e22a82d9e7
2014-08-01 07:34:38 -06:00
Terry Howe
d41e3952d2 Allow --data option to pass UUID instead of json
Allow the user to pass UUID only instead of full json.  This will
be handy for get and delete.  For example:

    python -m examples.get openstack/network/v2/network.py \
           --data ab13c9e7-3f30-4eee-9f96-41deb0223183

Change-Id: I12f15728b908d21110e9dead857d24d903bf17a9
2014-07-02 09:00:23 -06:00
Terry Howe
4544ec3b6a Add some comments to the examples
Add some useful usage comments to the examples.

Change-Id: Id12ba3883492d69f971b78c75048fc7f5914998d
2014-07-01 17:32:59 -06:00
Jenkins
e8c410e325 Merge "Example create command" 2014-07-01 22:28:22 +00:00
Jenkins
acfeff4035 Merge "Add common method to find a resource" 2014-07-01 19:39:44 +00:00
Terry Howe
d17c360f90 Example create command
Example create command and new --data option for examples.  For
example:

    python -m examples.create openstack/network/v2_0/network.py \
           --data '{"name": "foo"}'

Change-Id: Ie048f0e7d31b25e8c3df79a59d3cd73f4ce2b1b2
2014-06-25 11:43:36 -06:00
Terry Howe
8843fe03da Add common method to find a resource
The find_resource_cls method can be used by several commands to
locate a resource.  It may be called with a file name or import
path.

Change-Id: Ia83c9e6c1a9745088c3558bfbef32d4a4ca234b2
2014-06-25 11:21:29 -06:00
Terry Howe
c6bb1fa352 Important changes for service filtering
Some important changes for service filtering to support resources:
* Support the notion of ANY service_type in the service filter for
  user preferences.
* Create a join method in ServiceFilter to join a resource
  filter with a user preference.
* Support service filter preference in session.

For example if a user wanted to use region='East' they would create
a service filter preference in their session with that region and
use that session with any resource.

Change-Id: I13fc2838b66ec85bdd0191c78b27b3cd685a8322
2014-06-23 16:56:39 -06:00
Terry Howe
f035d1fe12 Example code reorg and auth examples
A slight reorganization on the example code to avoid conflicts
and make it clearer how to use the example code:
* Move transport code out of common.py to transport.py
* Try to keep example code in silos of functionality to avoid
  conflicts (transport.py, authenticate.py, ...)

For the authentication examples:
* Added basic identity v2 and v3 authentication command

To run:
python -m examples.authenticate
python -m examples.transport https://region-a.geo-1.identity.hpcloudsvc.com:35357/

Change-Id: I3f342409a7df645bfed82963488b665e1fb191e7
2014-06-12 15:56:19 +00:00
Terry Howe
075b2eef58 Add command structure to example code
Add some simple command structure to the example code.

Change-Id: Ic226fe0910b9f29b995402bab23dffa2bf5d5f08
2014-05-29 05:14:09 -06:00
Dean Troyer
7b33afc2e9 Add some sample scripts
This is a very basic starting point for working code example usage of
the SDK.

The common module includes an argument parser that recognizes the common
authentication arguments so setting up auth against a running OpenStack
cloud is the same as the library CLIs.

The inital example for Transport is a couple of simple GETs that also
shows the connection pooling.

Change-Id: I07de2888471a39cbc43daedded36ad683d02a472
2014-04-30 09:43:08 -06:00