Commit Graph

103 Commits

Author SHA1 Message Date
Andrey Kurilin 0a60aae852 Rename v1_1 to v2
Module novaclient.v1_1 is used as implementation of V1.1, V2 and V3.
Since future development(microversioning) will be done across V2,
implementation should be done in appropriate module(to prevent misleading).

Despite the fact that implementation for all versions are equal, discover
method for contrib path worked only for v1.1. This patch fixes this bug and
modifies shell tests to check all versions.

Change-Id: Ib6798f4dfe177586302141f522dc593560ce6a5b
2015-02-04 17:40:46 +02:00
Matthew Gilliard b5e36ced8f Adds separate class for Hypervisor Stats
Hypervisor stats was being called from the Hypervisors class, which means that
the statistics were being modeled as if they were a single Hypervisor. This
mostly worked, except that the stats didn't have an id field so a call to
__repr__() (implicitly called by print, or in the REPL) would throw an
AttributeError.

This patch creates a new class HypervisorStats which models a collection of
statistics about hypervisors. So you can now call:

  nc.hypervisor_stats.statistics()

The old call of

  nc.hypervisors.statistics()

is left for backward compatibility but just calls into the new method.

Change-Id: Ia31aacb95b1d517dab3ad38763d6448715bab68e
Closes-bug: 1370415
2015-01-09 08:45:17 +00:00
Jamie Lennox 003f1ed048 Pass kwargs through to the adapter
A major point of the adapter is that we should be able to add new
arguments to the adapter that are supported automatically by the clients
that support it. This means we have to pass all additional arguments
through to adapter.

Regardless of whether the arguments are passed to the adapter or to the
traditional client the kwargs are explicitly provided so we won't end up
with missing arguments.

Closes-Bug: #1403329
Change-Id: I7303b184875dc296ca855ad89496173c42070879
2014-12-19 11:15:32 +10:00
David Hu 8597a0c234 Support using the Keystone V3 API from the Nova CLI
This changeset enables support for Keystone V3 authentication
on the Nova CLI. This provides consistency between using
novaclient as the Nova CLI and using it as a library
as the Keystone V3 support already exists for the libary usecase.

The bulk of the change surrounds the use of the keystoneclient
session object for authentication, retriving the service catalog,
and HTTP connection/session management.

Co-Authored-By: Morgan Fainberg <morgan.fainberg@gmail.com>
Change-Id: Iece9f41320a8770176c7eeb5acd86be4d80cc58f
2014-11-11 21:04:20 -08:00
Matt Fischer b6afd59e61 Add support for security-group-default-rules
Add API & CLI support for security-group-default-rules. Security group
default rules allows users to create, delete, list, and get rules that
will be pre-populated into the Security Group "default" that is
populated in all projects on creation. This feature was intoduced in
Grizzly.

This commit also includes a small typo fix in the security_group_rules fake.

Change-Id: I6722b659934bde34bd206103f92dbd2cc42b1537
Closes-Bug: #1326941
2014-07-31 19:58:05 -06:00
Jenkins d97fe1c01b Merge "Add "version-list" for listing REST API versions" 2014-07-25 12:55:25 +00:00
Ken'ichi Ohmichi 67585ab36e Add "version-list" for listing REST API versions
Nova provides REST API versions.
This patch adds a subcommand "version-list" for outputting the versions.

Change-Id: I1b40ad57912aa740c0b1d9221018aba9b13a5436
2014-07-15 06:50:50 +00:00
Jamie Lennox cc7364067f Allow us to use keystoneclient's session
The session object is a cross-client means of standardizing the
transport layer.

Novaclient's HTTPClient object has diverged significantly from other
clients. It is easier to simply replace it if a session is provided. If
a session is provided then users of the library need to be aware that
functions such as authenticate() will no longer have any effect/are in
error because this is no longer managed by nova.

Change-Id: I8f146b878908239d9b6c1c7d6cdc01c7e124f4e5
2014-07-01 16:53:47 +01:00
Chris Yeoh 6aa419b82e Adds clarification note for project_id vs tenant_id
The client __init__ method takes both a project_id and tenant_id which is
rather confusing as in the Nova API these terms are used interchangeably. The
comment clarifies the difference between a project_id and tenant_id
when using novaclient.

For backwards compatibility reasons we can't really change the names (though for V3
perhaps we should in the future).

Change-Id: I569fe9318335c8d686153b0936205cb190e01ef1
2014-06-30 09:26:13 +09:30
Mark McLoughlin 9f1ee1249a Mention keystoneclient.Session use in docs
Jamie added some excellent "Using Sessions" docs to keystoneclient in
I5e44c1029ce160cb2798cfb8a535aa9f3311799a. These will be published to

  http://docs.openstack.org/developer/python-keystoneclient/using-sessions.html

once the version after 0.9.0 is released.

Let's add a brief example on how to use this API and reference the
keystoneclient docs.

Change-Id: Icbcef45f13c1f962c90aa3db9dde4360520166ff
2014-07-01 16:53:47 +01:00
Rick Harris 4c8cefb98a Overhaul bash-completion to support non-UUID based IDs
There are a few things currently wrong with bash-completion as it stands now:

    1) IDs are currently required to be UUIDs. This is an arbitrary limitation
       and doesn't make sense for certain kinds of objects, like `Flavors`
       where a valid ID could be `performance-16gb`.

    2) The code is spread out between Oslo's `Resource` and Novaclient's
       `Manager` class. This makes it difficult to improve the code because it
       requires changes to two separate projects. We should centralize the
       code in Novaclient until the API is stable, then import the code into
       Oslo in its entirety, not partially like it is now.

    3) The completion code is handled by the `Manager` of which there is one
       per Resource-type. In the interest of centralizing this functionality,
       we should create a `CompletionCache` class and hang it off of `Client`
       of which there is one-per-session.

    4) The completion-code currently runs by default even in headless mode
       (e.g. novaclient without the shell). It'd be much more efficient to
       only write to the completion cache if we're accessing the `Client` from
       the novaclient shell. We can make this an option to support third-party
       CLI clients that want to use the completion-cache as well.

NOTE:
    * The corresponding Oslo patch is here:

        https://review.openstack.org/#/c/101376/

    * This patch was tested in multithreaded mode to prevent any regression
      from:

        https://bugs.launchpad.net/python-novaclient/+bug/1213958.

Change-Id: Idada83de103358974b739f81d4f392574f9e1237
Closes-Bug: 1332270
2014-06-20 16:37:28 -05:00
Sergio Cazzolato d05da4e985 Revert "Remove quota-class subcommand"
This reverts commit 7c11b06bd4.

The quota_class subcommand was used to set default quota values
so it shouldn't have been removed.

Related mailing list thread on the topic:
http://lists.openstack.org/pipermail/openstack-dev/2014-May/035383.html

Change-Id: I8f392f8e54bef52c1c950f75377e6bb93a41996d
Partial-Bug: #1299517
2014-05-29 16:50:31 -03:00
Boris Pavlovic 98934d7bf1 Fix session handling in novaclient
Prior to this patch, novaclient was handling sessions in an inconsistent
manner.

Every time we created a client instance, it would use a global
connection pool, which made it difficult to use in a process that is
meant to be forked.

Obviously sessions like the ones provided by the requests library that
will automatically cause connections to be kept alive should not be
implicit. This patch moves the novaclient back to the age of a single
session-less request call by default, but also adds two more
resource-reuse friendly options that a user needs to be explicit about.

The first one is that both v1_1 and v3 clients can now be used as
context managers,. where the session will be kept open (and thus the
connection kept-alive) for the duration of the with block. This is far
more ideal for a web worker use-case as the session can be made
request-long.

The second one is the per-instance session. This is very similar to what
we had up until now, except it is not a global object so forking is
possible as long as each child instantiates it's own client. The session
once created will be kept open for the duration of the client object
lifetime.

Please note: client instances are not thread safe. As can be seen from
above forking example - if you wish to use threading/multiprocessing,
you *must not* share client instances.

DocImpact

Related-bug: #1247056
Closes-Bug: #1297796
Co-authored-by: Nikola Dipanov <ndipanov@redhat.com>
Change-Id: Id59e48f61bb3f3c6223302355c849e1e99673410
2014-04-07 19:38:51 +02:00
Jenkins a002abc060 Merge "Remove quota-class subcommand" 2014-04-01 23:09:17 +00:00
Jenkins 8ecc6b3eff Merge "Allow user ID for authentication" 2014-03-21 19:51:23 +00:00
Gary Kotton c40891b282 Nova CLI for server groups
CLI support for blueprint instance-group-api-extension

REST API support:- https://review.openstack.org/#/c/62557/

DocImpact
 - supports create, list, get and delete
 - only V2 is supported

Change-Id: Iaa5a2922b9a0eed9f682b7584c2acf582379b422
2014-03-13 04:14:11 -07:00
Phil Day dd8bde71ff Allow user ID for authentication
In Keystone V3 user names are no longer necessarily unique
accross domains.

A user can still authenticate a user in the non default
domain via the V2 API providng they use IDs instead of names.

Tenant_ID is already supported, this change adds support
for user ID

Change-Id: I36ba75f3e67c8cdb959e31923d5e557414ab6f9b
2014-03-07 19:24:22 +00:00
Masayuki Igawa 7c11b06bd4 Remove quota-class subcommand
quota-classes API was already removed.
  Change-Id: I1110022d6f628d03aaf363da707f2d2ef1600437
This patch removed quota-class subcommand from nova client.

Change-Id: I18bf7c255fabdb52c8ce8159f68c3e5c70e54993
2014-03-03 14:30:56 +09:00
Jenkins e2b1de000a Merge "Don't call CS if a token + URL are provided" 2014-01-21 10:07:56 +00:00
Alexis Lee bd9ebc5d27 Don't call CS if a token + URL are provided
Adds --os-auth-token (matching Glance client at least) to accept a
pre-obtained authentication token.

CS will be called iff:
      One or both of token and URL are not provided;
  AND the cache is empty/disabled or we don't have a tenant-id.

Removed some code altering the auth request to a GET if a token is
supplied - did not work for me and I think the path was dead previously.
Fixed test to account for this change.

Completes blueprint token-endpoint-instantiation

Change-Id: I67410b80e506bb80c152223cd113b7139a62a536
2014-01-15 17:11:35 +00:00
Masayuki Igawa 8e9c038f15 Remove the coverage extension code
The coverage extension has been removed from Nova V2 API by the
        I07d798129ee277a6f7691c25f88c07a5204c0943
This commit remove the code.

Change-Id: I430a8b17be11bb961dc5b89b2d098f373e0a27fa
2014-01-14 09:14:11 +09:00
Sahid Orentino Ferdjaoui 0ddcf11732 Removes vim configuration headers
- Removes vim headers: It's not needed to set tabstop tons of times,
   this can be done by setting vimrc.
 - I did not update files in common/* and install_venv_common.py because
   these files are sync with oslo.

Note:
  http://lists.openstack.org/pipermail/openstack-dev/2013-October/017353.html

Closes-Bug: #1265474
Change-Id: Ia09dc2c908187a756bf55eaba74655484304517d
2014-01-08 08:13:46 +00:00
Sushil Kumar 3ecaeb416e Enables H306 pep8 rules
Updates tox.ini to reduce ignored rules.

Updates code for H306 violation.

Change-Id: I9beea02510a1122afb55ad3df3b37f770fe05134
2013-12-12 17:43:08 +00:00
Julie Pichon f702c25d43 Fix backwards-incompatible API change (method signature)
project_id was changed to projectid in a previous changeset.

Fixes bug 1203001

Change-Id: If9c21ae4f3cfbeb89569f6e4bd415c2041dc6294
2013-07-12 08:30:33 +01:00
Jenkins 32f38fe19e Merge "Allow tenant ID for authentication" 2013-07-18 21:51:19 +00:00
Phil Day 02f906bcd6 Allow tenant ID for authentication
Tenant names are not necessarily unique for a User, so the client
should also allow authentication by tenant_id

If both ID and Name are specificed then use the ID

Fixes bug 1195454

Change-Id: Ib62aabc3702db88f02259cd721f9efb31404bcb7
2013-07-03 16:05:13 +01:00
Dirk Mueller 0134008f9b Fixup trivial License Header mismatch.
The currently proposed Hacking check H103
compares the license boilerplate header in
source files with a known good version.
Fix up the syntactical-only mismatches with
that check.

Change-Id: Ie8861b9ded858aabb4cebbe9db656e8cccc9efed
2013-06-27 21:42:11 +02:00
Alvaro Lopez Garcia abd75f24b1 Improve authentication plugins management.
The current auth plugin system lacks some functionality to be used with
other methods that might require additional configuration options or
that do not require a user to pass some options that are now compulsory
(for example, X.509 authentication needs to get a certificate file, and
does not need either a username or a password). This commit extends
the current system to handle these extra features, while remaining
compatible with older plugins.

DocImpact: We should documment how to implement additional
authentication plugins, such as BasicAuth, X509, etc.
Implements: blueprint authentication-plugins

Change-Id: I7b0ef4981efba8160dea94bf852dba7e2e4068f5
2013-04-01 14:19:01 +00:00
Davanum Srinivas c5b579926f Fix Copyright Headers from LLC to Foundation
follow the lead from nova and oslo projects

Change-Id: I270c5f1e4eefa4b72e292bfb4a4c60de0c3f6e4a
2013-03-13 20:12:23 -04:00
Zhi Yan Liu 4516efa8db Show the summary or details of all availability zones of a region
Adding "availability-zone-list" sub-command allow user list all
availability zones and its status in a region.
* summary list for normal user: list availability zones summary whitin a
flat view.
* details list for administrator user: list availability zones details
within a tree view, include zones, hosts and components.

Implement one workitem for bp:show-availability-zone

Change-Id: Id87fe470c7e0f6fbfb9465551f63717724b5fc18
2013-02-05 20:31:50 +08:00
Dean Troyer aa1df04bad Use requests module for HTTP/HTTPS
* Implement correct certificate verification
* Add --os-cacert
* Rework tests for requests

Pinned requests module to < 1.0 as 1.0.2 is now current in pipi
as of 17Dec2012.

Blueprint: tls-verify

Change-Id: I9a25a94c8dfcaf483c4c8328439809d65cf10b38
2012-12-20 13:04:46 -06:00
Jenkins c81931226d Merge "Add support for the coverage extension." 2012-12-20 17:38:49 +00:00
Matthew Treinish c59de35be2 Add support for the coverage extension.
This adds support for the coverage extension and also adds 3
CLI commands to interact with coverage:

nova coverage-start

nova coverage-stop

nova coverage-report

'nova coverage-report' has a required '--filename' argument
which gives the filename for the generated report files.

Change-Id: I9cb002b0e32cfe5572878d2c8436270663c0ae96
2012-12-19 10:08:34 -05:00
Jenkins df8db07495 Merge "Add nova client support for nova-manage agent command" 2012-12-13 16:10:21 +00:00
ivan-zhu 08d0c05013 Add nova client support for nova-manage agent command
This add four CLI (agent-list/agent-create/agent-delete/agent-modify)
in nova-client

so we can use:
'nova agent-list' like 'nova-manage agent list' with one optional
parameter. Show a list of all agent-builds. Filter by hypervisor.
The difference between the two commands is that 'nova agent-list'
will display the id of the agent build, 'nova-manage agent list'
will not.

'nova agent-create' like 'nova-manage agent create'. It will create
a agent build.

'nova agent-delete id' will delete the agent-build with specific id.

'nova agent-modfiy' will update the version, url, md5hash of the agent
build with specific id.

This patch depends on https://review.openstack.org/#/c/15831/
Implements one workitem of blueprint apis-for-nova-manage

Change-Id: Ic7589077d130efa5abc77252bd79addcaea483c8
2012-12-12 22:43:17 +08:00
Dan Prince e483455a12 Adds --os-cache to replace old --no-cache.
Deprecates the old --no-cache option in favor of --os-cache.

The old CLI args (--no_cache and --no-cache) and ENV option
(OS_NO_CACHE) are still supported but no longer show up
in help.

The new option for --os-cache can also be set via the OS_CACHE ENV
variable... which now defaults to False. This should be much more user friendly.

Fixes LP Bug #1087776.

Change-Id: I3cea089c7e11ce75f22c2d7f3242b02b80441323
2012-12-11 12:58:37 -05:00
Chris Yeoh 4e3aa56fe7 Adds nova client support for nova-manage floating command
Adds the following commands:
- nova floating-ip-bulk-list
- nova floating-ip-bulk-create
- nova floating-ip-bulk-delete

Change-Id: Ia183a7a478d23fee3552d43a866ba96abb7472b2
Implements: blueprint apis-for-nova-manage
2012-11-30 10:30:31 +10:30
Jenkins c4f0f50a2a Merge "Adds nova client support for nova-manage fixed command" 2012-11-29 18:51:08 +00:00
Chris Yeoh 3839d284da Adds nova client support for nova-manage fixed command
Adds the following commands:
- "fixed-ip-get <ip_addr>" - displays information about the fixed ip ip_addr
- "fixed-ip-reserve <ip_addr>" - reserves the fixed ip ip_addr
- "fixed-ip-unreserve <ip_addr>" - unreserves the fixed ip ip_addr

Change-Id: I6a5c8b9f7ab359adeb57b86240279649cd421801
Implements: blueprint apis-for-nova-manage
2012-11-22 22:43:59 +10:30
Alessio Ababilov ff69e4d383 Implement fping calls in nova client
Implements blueprint novaclient-fping

Provide fping API calls in nova client as well as unit tests. API is
accessed by `fping` field of nova client.
Methods:
* list(all_tenants=False|True, include=[VM ids], exclude=[VM ids]) -
  perform fping for all VMs in current project (or all projects if
  all_tenants==True)
* get(server object or id) - perform fping for single instance

Change-Id: Ic3eda142781d1a14f2cfc83626672a579fc93a7d
2012-11-22 10:16:09 +02:00
Jenkins f790ccc6bc Merge "make tenant id optional for quota-defaults and quota-show" 2012-11-21 17:10:15 +00:00
Christian Berendt c819c2fb50 make tenant id optional for quota-defaults and quota-show
When using quota-defaults or quota-show without specifing a tenant
the currently used tenant should be used.

Change-Id: I1ef71b68673dd4a95cbf8b5a8dc901fb6eb06865
2012-11-09 10:52:23 +01:00
ivan-zhu d037172b70 Add nova client support for nova-manage service command
Implements the one workitem of blueprint apis-for-nova-manage

This add three CLI (service-list/sevice-enable/service-diabel) in
nova-client.

So we can use:
"nova service-list" like "nova-manage service list" with two optional
parameters. Show a list of all running services. Filter by host and
service name.

"nova service-enable hostname servicename" like "nova-manage service
enable hostname servicename". It will enable the service specified by
hostname and serviename.

"nova service-disable hostname servicename" like "nova-manage service
diable hostname servicename". It will disable the service specified by
hostname and serviename.

This patch depends on https://review.openstack.org/#/c/15206/

Change-Id: I01d4cee4ef95c1783f6181f8b840244e748387e5
2012-11-08 18:13:12 +08:00
Jenkins 3a8942562d Merge "Implement project specific flavors API, client bindings" 2012-08-27 20:23:39 +00:00
unicell f160a20fd9 Implement project specific flavors API, client bindings
blueprint project-specific-flavors

This change implements client bindings for the project specific flavor API in following change
https://review.openstack.org/#/c/11270/

Change-Id: Id8d559985f9369f53926e63ee5f5ce23a051e25b
2012-08-27 22:38:36 +08:00
Alessio Ababilov 845c97b7e9 Implement network calls in nova client
Implements blueprint novaclient-networks

Provide network API calls in nova client as well
as unit tests. API is accessed by `networks` field
of nova client.
Methods:
* list() - return network list
* get(network object or id) - return requested network
* delete(network object or id) - delete requested network
* create(network properties) - create a new network with requested
  properties
* disassociate(network object or id) - disassociate the network
  from its project
* add(network object or id[optional]) - associate the current
  project with a network

Change-Id: Ie6ab11cd2ad6e1625ead4b08c6beab5b845291a1
2012-08-23 10:01:51 +03:00
Chmouel Boudjnah 86c713b17a Allow different auth providers via plugin system.
- Remove the NOVA_RAX_AUTH hack and provide (temporary) compatibility
  with the new system.
- Example plugin for RAX and HP provided here :
    RAX - https://github.com/emonty/rackspace-auth-openstack
    HP - https://github.com/emonty/hpcloud-auth-openstack
- Plugin are allowed to specify their own auth_url directly.
- Thanks to mtaylor for helping on this.

Change-Id: Ie96835be617c6a20d9c3fc3bd1536083aecfdc0b
2012-08-06 09:10:00 +02:00
Major Hayden 6483ad10a7 Bring back the output from client.http_log()
Change-Id: If7c583751abe9ae60f299515a5f7778db72fa70c
2012-07-02 15:42:02 -05:00
Kevin L. Mitchell a11788515e Add hypervisor information extension.
Adds support for a new nova extension for getting information about
hypervisors (as opposed to compute hosts), including a list of
hypervisors matching a regular expression (database regular
expression, i.e., %'s) and a list of hypervisors with the list of
instances living on those hypervisors.

Change-Id: I7353991ffbf484da175a0912ee46e80f623e230f
2012-06-29 12:21:19 -05:00
Sandy Walsh f78553211c More friendly keyring support when token caching is off.
The token caching would always try to save the token even
if --no_cache was specified. The downside of this is
environments where there is no keyring agent it would prompt
for a password. Now, if --no_cache is specified it won't try
to save the token.

Also ability to reset timings (--timings) which is handy for
client-driven profiling efforts. Yes, this should be a separate
branch, but it's so tiny it's hardly worth the effort.

I'd also like to take this time to express my admiration for
Brian Waldon. A stalwart young fellow and a fine coder.

Change-Id: I97c2c5f6864fe156a3e204927b2831b74fb1c893
2012-06-28 17:15:57 -03:00