842 Commits

Author SHA1 Message Date
Andrey Kurilin
363bc3eafc [functional-tests] fix version of novaclient instance
setUp method of base class for functional tests creates an instance of
novaclient.client.Client with const version. This logic is wrong since we
have tests for microversions.

Change-Id: Ibd3ee5c730ae1fb3c19f512728f2a0a3693763e8
2015-12-10 23:35:04 +02:00
Javeme
e919c9b792 remove the default arguments "[]"
remove the default arguments "[]" when the function is defined.

ref: http://docs.python-guide.org/en/latest/writing/gotchas/

Change-Id: I71ee8fbf5dec12d93bbed0e336124ad833014845
2015-12-09 20:59:48 +08:00
Zhihai
11e0782f62 Change the logic for the client to retrive resources
The ID (primary key) of a resource can not be retrived by the client.
There is no sense to provide the functionality to get an resource by
its ID. Especially when an instance is named by an interger, client
will try to get the instance with the ID of that interger value.
This patch will change the order in which the novaclient retrive
resources. First by UUID, then by name, finally by the ID. This will
also reduce api call overhead, since UUID is used mostly.

Change-Id: I0bfa5cb03a04625c3def5608dd4529e52d50f944
Closes-Bug: #1516924
2015-12-09 12:47:05 +00:00
Jenkins
691e8d4f8b Merge "Add accessIPv4 and accessIPv6 when create server" 2015-12-09 04:39:50 +00:00
Andrey Kurilin
8aaf0a9080 Fix help message in case of microversions
novaclient should display help message of the proper versioned method
(based on api_version value).

Closes-Bug: #1523649
Closes-Bug: #1523651

Change-Id: I67f7fc2befde9d312400e9a1569e590bd763156e
2015-12-08 17:09:31 +02:00
Andrey Kurilin
0ec6bedf42 [microversions] Increase max version to 2.12
2.12 - Exposes VIF net-id attribute in os-virtual-interfaces. User will be
able to get Virtual Interfaces net-id in Virtual Interfaces list and can
determine in which network a Virtual Interface is plugged into.

novaclient.base.Resource class is a parent class of VirtualInterface resource.
Since `Resource` is a universal interface for any resources and doesn't
require hard-code attributes which describe partial resource, there are no
required changes to support this microversion in "novaclient as a lib".

"novaclient as CLI" doesn't provide an interface for VirtualInterface yet
(see bug 1522424 for more details). When it will be implemented, we will need
to check that new attribute is displayed correctly.

Based on the fact that 1522424 is not resolved and novaclient.base.Resource
class has enough tests, this patch doesn't require any tests.

Also this patch fixes representation of VirtualInterface resource.

Change-Id: I18cf23847d3b2b01f5a6ffae2ebc4bede54babce
2015-12-07 22:17:22 +02:00
Andrey Kurilin
65658ed6fc [microversions] Add support for 2.10
2.10 - Added user_id parameter to os-keypairs plugin, as well as a new
property in the request body, for the create operation. Administrators will
be able to list, get details and delete keypairs owned by users other than
themselves and to create new keypairs on behalf of their users.

Change-Id: I13ca3f8a4dd9cf11bec79966bb8a2ab48847be22
2015-12-07 22:14:21 +02:00
Andrey Kurilin
96a7e1ddc4 [microversions] update test_versions with implemented versions
Change-Id: Ifc401e00fc6436ac85ade3fa119ef9a47607a5ec
2015-12-07 22:13:23 +02:00
Ghanshyam
573bdaa290 Fix H404/405 violations in novaclient/tests/*
There is a lot of H404/405 violations in novaclient, and it is better
to fix those to have a better doc string for class/methods.

This patch fixes these violations for files under  novaclient/tests/
folder.

As there are lot of violations and cannot be fixed in single patches,
So separating those in multiple patches for easy review.

Partial-Bug: #1521899
Change-Id: I6e712ece14c745013bfba0bee9d77e7875dd2263
2015-12-07 14:17:56 +09:00
Jenkins
06af0bf79b Merge "Fix repr of a host from a hosts.list()" 2015-12-04 19:55:33 +00:00
Jenkins
713b6f12e8 Merge "[microversions] Increase max version to 2.9" 2015-12-04 13:10:07 +00:00
Jenkins
0718f1a252 Merge "[microversions] Add support for 2.8" 2015-12-04 12:59:12 +00:00
Jenkins
d1fed78d09 Merge "Remove novaclient.v1_1 module" 2015-12-03 17:02:08 +00:00
Andrey Kurilin
0a535e3287 [microversions] Increase max version to 2.9
2.9 - Add a new locked attribute to the detailed view of servers. locked
will be true if anyone is currently holding a lock on the server, false
otherwise.

This microversion doesn't require any change in novaclient's code.
Just added functional tests and changed version

Change-Id: I7f33757e6f03f172e5a13ade0aa5e8d3a10dbf01
2015-12-03 10:10:21 +00:00
Andrey Kurilin
9fe53065ef [microversions] Add support for 2.8
2.8 - Add new protocol for VM console (mks)

Also, this patch removes code duplication and fixes docstrings for consoles
methods.

Co-Authored-By: jichenjc <jichenjc@cn.ibm.com>

Change-Id: Ic24183a5118872581b30f82734fa9d6ce0e53544
2015-12-03 12:09:56 +02:00
chen-li
1431f1b823 Enable pass instance name as parameter in nova cli
After the proposed bug fix, the admin can also start/stop/reset-state
instances of other tenants by passing instance name as the parameter.
Initially it could be done only through ids. One additional argument
--all-tenants is added so that the instance name is searched across all
tenants.

Previous command was:
nova start/stop/reset-state <instance_name>

New command is:
nova start/stop/reset-state <instance_name> --all-tenants

Co-Authored-By: Jyotsna <jyotsna.priya1@tcs.com>
(cherry picked from commit Ie5f8c5c15dee6060b979a34ed0aa01262e05e122)

Change-Id: I66f277b16b378a7908d8b951fe39d039df4ef6a4
Closes-Bug: #1297963
2015-12-03 17:07:30 +08:00
Jenkins
520ffae282 Merge "Optimize "open" method with context manager" 2015-12-02 20:42:54 +00:00
Jenkins
ee2db5f173 Merge "Not transform to str on potential unicode fields" 2015-12-02 15:45:18 +00:00
xiexs
6036114aa4 Optimize "open" method with context manager
Use opening context manager to open a file.

Change-Id: I50e4f2df54737e1ea5b4c7fbe8639f1cd981a627
2015-11-29 00:59:25 +08:00
melanie witt
c3dda7636c Fix repr of a host from a hosts.list()
The os-hosts API uses different attribute names depending on
whether the host was returned as part of a list or not.
A host returned from 'show host' has the attribute "host"
whereas a host returned from 'list hosts' has the attribute
"host_name".

This adds a host_name property to the Host class that will set the
"host" attribute if necessary. Although this doesn't exactly mirror
the responses coming back from nova api, it will make it easier for
users to use the objects interchangeably for hosts.list() operations
and hosts.update() operations, for example.

Co-Authored-By: Chung Chih, Hung <lyan.h@inwinstack.com>

Closes-Bug: #1434167

Change-Id: I5c339bdd1ab867d972759ade9a10b86bfda1e70a
2015-11-25 07:58:38 +00:00
jichenjc
297231c108 Add accessIPv4 and accessIPv6 when create server
nova support accessIPv4 and accessIPv6 as input param
but nova client don't support it as input param when
doing create operation.
Because it's already support in v2.1 so no microversion
introduced.

Change-Id: Idd50fe921f8c931ee28902f90ffdde6bfba34359
Closes-Bug: 1522359
2015-11-24 21:59:21 +08:00
Andrey Kurilin
4393d90524 Check response headers for microversions
novaclient provides version negotiation on CLI layer. In case of usage
novaclient as a lib, user can specify api_version with microversion part
and can try communicate with Nova endpoint which doesn't support
microversions. Nova endpoint will not check X-OpenStack-Nova-API-Version
header and will execute request(it can be correct or not). It this case
we should warn user about his mistake and about "incorrect" response.

Change-Id: I7a5ab964b7b2b2a49cc80c22bf67ad5548afb30b
2015-11-23 20:13:13 +02:00
jichenjc
8b8edc72e0 Not transform to str on potential unicode fields
some fields such as instance.display_name can be unicode,
nova client should not translate it to 'str'. otherwise
it will report UnicodeEncodeError.

Change-Id: I4f6011105b3b11dbbcb23f3a7c1bbcf7f20bcc8c
Closes-Bug: 1518141
2015-11-22 04:34:07 +08:00
Jenkins
62b1379cf8 Merge "Fix typo in error message" 2015-11-19 13:25:52 +00:00
Jenkins
dada6cc91d Merge "Added command for device to cinder volume mapping" 2015-11-19 13:25:49 +00:00
Jenkins
55ae89fb70 Merge "Add sort_dir/key to flavor list" 2015-11-19 12:44:57 +00:00
Jenkins
bc54eaa0b1 Merge "Add pagination params for flavor list" 2015-11-19 12:44:23 +00:00
Vincent Untz
7d800a9e65 Fix typo in error message
Change-Id: I9ff3babd0460c41e05f18b34c3b46032edbf1459
2015-11-17 07:19:25 +01:00
Jenkins
fd13e89c46 Merge "Functional tests for os-extended-server-attributes" 2015-11-12 17:00:09 +00:00
Jenkins
903538ee59 Merge "Refactor parsing metadata to a common function" 2015-11-11 11:00:45 +00:00
Sujitha
6a18757509 Added command for device to cinder volume mapping
Added new sub command volume-attachments which displays the list
of volumes attached to a server.

Change-Id: I1f56a6fa18c35f3df2bdd11b9cf83bd5c5d9e182
Closes-Bug: #1116593
2015-11-10 22:43:11 +00:00
Jenkins
e77d770bd9 Merge "Add v2 support for optional project_id in version discovery urls" 2015-11-09 18:08:36 +00:00
Anna Babich
e9268e9864 Functional tests for os-extended-server-attributes
The added tests check basic set of extended server attributes
and additional attributes exposed by microversion 2.3

To avoid leak resources, cleanup part has been refactored

Change-Id: I0c8f096134838b90e17720f2a28e649998a02e3b
2015-11-09 16:47:45 +02:00
Jenkins
fc2f4abf6c Merge "make project_id optional in urls for version discovery" 2015-11-05 03:40:15 +00:00
Augustina Ragwitz
5f5ec354be Add v2 support for optional project_id in version discovery urls
This is part of the work to allow Nova and Novaclient to handle endpoints both
with and without project id's. v2 version information returns a different data
structure than later versions. This patch updates the mock tests to return a
different data structure corresponding to v2 or v2.x depending on the
endpoint_type. A caller using the mock test class can set the attribute
endpoint_type to a version number, and the method get_endpoint, will return the
appropriate data structure. This is more of a workaround given the current state
of mocking Nova api calls in our unit tests.

Part of bp:service-catalog-tng

Change-Id: I61984ee592f7a5d7f1a91c9e2ff3038c0245f797
2015-11-04 18:09:14 -08:00
Matt Riedemann
f7e2129f88 Remove novaclient.v1_1 module
This reverts commit 036d42d7087a3c83a5feec0ad0a4c6af35df72c9

Once novaclient 2.34 is released we can merge this and
release as 3.0.0. The dependency is on the 2.34 release
request.

Change-Id: I1e3a8a8079b954fe60371c2d38ec23a10727c408
Depends-On: I4fc044e518a5cc5ea7b309a2824984a7035945bd
2015-10-29 14:04:45 +00:00
Jenkins
bba1d6ece4 Merge "Revert "Remove novaclient.v1_1 module"" 2015-10-29 05:04:59 +00:00
Matt Riedemann
036d42d708 Revert "Remove novaclient.v1_1 module"
This reverts commit 0cd58123be5e2c2bc2f1233a3e15fb35b2ead1a0

This is a backward incompatible change that is blocking our
ability to release 2.34 for 63c7a57, which was a revert for
another backward incompatible change (2961e82) which slipped
into 2.33.

Once we release 2.34 with the bug fixes, we'll revert this
revert and release that as novaclient 3.0.

Change-Id: If79d37df3e99004897f1bb2d8564d2f1d8aa0978
2015-10-28 21:25:02 +00:00
Matt Riedemann
63c7a576e1 Revert "Do not expose exceptions from requests library"
This reverts commit 2961e82bfa6e375ac3c17933fac532ed316ac976

This broke cinder unit tests that have a timeout test for novaclient
where they mock the requests library raising a Timeout exception. That
test expects to get a requests Timeout passed through but with the
change being reverted it was getting a RequestTimeout exception from
novaclient, which breaks the test and fails the gate runs.

We could change the cinder unit test to handle both the requests.Timeout
and the new novaclient RequestTimeout, but that's just papering over
the cinder failure, we wouldn't know what other clients are failing
in the same way because they have code working around the requests
exceptions getting passed through, so we should treat this like an API
change.

I'd be in favor of making the same change again iff the novaclient
exceptions extended the requests exception types so it would be transparent
to consumers, since novaclient.exceptions.RequestTimeout would be a
requests.Timeout via inheritance. But given the gate breakage and it being
summit week I'm inclined to revert first and think about a better long term
fix later when people are back to discuss.

Change-Id: I368728588e5997eef860a168539eb66c58f2e72a
Closes-Bug: #1510790
2015-10-28 07:27:40 -07:00
Jenkins
2276c92718 Merge "Remove novaclient.v1_1 module" 2015-10-23 16:24:33 +00:00
Jenkins
a5363ae0d6 Merge "Support the server side remote-console API changes" 2015-10-23 12:56:32 +00:00
Jenkins
5d5def785d Merge "Do not expose exceptions from requests library" 2015-10-23 12:56:11 +00:00
Jason Dunsmore
2961e82bfa Do not expose exceptions from requests library
Novaclient expects the requests library to always be able to get a
response back and doesn't handle other cases where it might raise
an exception even before the request is completed (e.g.
ConnectionError).

These exceptions should be captured and properly converted to some
native novaclient exception.

Change-Id: Iec7247b715c38c29910b30e76413cead4e951a37
Co-Authored-By: Kuo-tung Kao <jelly.k@inwinstack.com>
Closes-Bug: #1406586
2015-10-22 14:34:23 -05:00
Sean Dague
4f16fe65c4 make project_id optional in urls for version discovery
Currently there is a baked in assumption throughout the nova ecosystem
that endpoint urls will end in {project_id}.

This means that the version document for a specific major API version
is "endpoint - last_chunk_of_url". This is not a discoverable URL,
it's one that we heuristically generate.

GET /v2.1/{project_id} is a 404.

If we make Nova able to handle endpoint ids without {project_id} we
run into a problem with novaclient, which is that end_point is now
/v2.1. The heuristic gives us a version url of /. Which returns a very
different doc than /v2.1. This causes all novaclient commands to explode.

In order to support this transition we need to make both Nova and
Novaclient handle endpoints with and without {project_id}.

The proposal is thus to try the raw value of the endpoint first. If it
works, great. If it fails with a 404, fall back to the heuristics.

While this change and the nova change are technically independent, we
should land this one as soon as possible, because clients before this
change will not work with Nova deploys that get rid of project_id in
their service catalog in the future.

Part of bp:service-catalog-tng

Co-Authored-By: Augustina Ragwitz <aragwitz+lp@pobox.com>
Change-Id: Id4a2f73cbcfcf36aea750375fd92b1c2d3cd824e
2015-10-22 11:10:56 -07:00
Mark Doffman
cce7cd3277 Support the server side remote-console API changes
In microversion 2.6 the remote-console API was changed.
See http://docs.openstack.org/developer/nova/api_microversion_history.html
for details of those changes.

This adds support for the new remote-console API.

Change-Id: I67098d6ce8c71f3ac0073628fd3b0aa23cd81918
Closes-Bug: #1500688
2015-10-22 10:14:13 -05:00
He Jie Xu
28bf8ddb06 Correct usage of API_MAX_VERSION and DEFAULT_OS_COMPUTE_API_VERSION
Commit d045019f0f2d28f26730b3617f7d7b993506b6e8 use the variables
API_MAX_VERSION and DEFAULT_OS_COMPUTE_API_VERSION with wrong way.

API_MAX_VERSION means the max version of client supported. This
variable only be changed when client support the new version. And
it's must bumped sequentially.

DEFAULT_OS_COMPUTE_API_VERSION is default value of option
'--os-compute-api-version', this value decided the default behaviour
of nova client. The nova client CLI behaviour should be that client
negotiate with server side to find out most recent version betweeyn
client and server. So the value should be '2.latest'. And it won't
be changed except we decided to change the default behaviour of nova
client CLI.

Change-Id: Iba9bfa136245bd2899c427ac0c231a30c00bd7f3
Closes-Bug: #1508244
2015-10-21 11:07:32 +08:00
Jenkins
095d72f652 Merge "Rely on devstack for clouds.yaml" 2015-10-20 23:52:59 +00:00
Jenkins
73de0478e4 Merge "Increase timeout when testing admin timeout" 2015-10-20 21:55:44 +00:00
Monty Taylor
727f1044bf Rely on devstack for clouds.yaml
Rather than copying it ourselves, just consume the one that
devstack is putting there for us.

Change-Id: Ifb9f8a55e0eb342db55a3518c375ea79679ff076
2015-10-21 05:20:34 +09:00
Kevin_Zheng
09bb834b05 Refactor parsing metadata to a common function
Currently the metadata is parsed using
dict(v.split('=', 1) for v in metadata)
and was used in several places, it could
be better if we refactor it to a common
function. It will make it more readable
and easier to use in the future.

Change-Id: Ib0fcaacdbef65cdcb85ecc0c304f4933bef2627c
Closes-Bug: #1503939
2015-10-20 11:27:20 +00:00