721 Commits

Author SHA1 Message Date
Sahid Orentino Ferdjaoui
6374ee04a3 Nova aggregate-details should be more human friendly
'nova aggregate-details' shows Hosts, Availability Zone
and Metadata in the python unicode notation.

Change-Id: If0028347146439994265c60c429af05dd67912f9
Closes-Bug: #1132961
2013-10-25 17:46:19 +02:00
Jenkins
ae418392bb Merge "Revert "Add-in some re-auth logic when using os_cache"" 2013-10-15 20:24:00 +00:00
Joe Gordon
cbed4887c9 Revert "Add-in some re-auth logic when using os_cache"
This patch didn't do what it was supposed to do, make os_cache work. Instead it just adds complexity, so just remove it.

This reverts commit 8eed73ce20ff0808d350fc9af66d6ba55ebda017.

Change-Id: I7c118cbf8d8e2218e198d603f1984a9de18266c4
2013-10-10 08:14:50 +00:00
Kui Shi
b1e3753fdf Align mocking pattern for test case
Mock sys.stderr/sys.stdout with mock.patch()

In novaclient/tests/test_shell.py, ShellTest.shell(), it is another
case that should be aligned. But it may induce test error if changed.
So, let's keep it as is.

Close-Bug #1237093

Change-Id: I8908dc1593dbbbaf2813cc8fb034be32972140a0
2013-10-08 17:11:52 +08:00
Kui Shi
5f0363ad9d py33: use six.StringIO() to mock stdout/stderr
six.StringIO() is the right way to keep Python2/3 compatibiliby
while mocking stdout/stderr.

Close-Bug #1235086

Change-Id: I33d9223b2202896331d24339056d57d4ca9acdc5
2013-10-04 17:48:57 +08:00
Jenkins
9f928b29f9 Merge "py33: unify the input of request to json format" 2013-10-04 19:56:44 +00:00
Kui Shi
e5a193ac43 py33: unify the input of request to json format
In novaclient.client.HTTPClient.request, json.dumps() process the
body of "POST":
kwargs['data'] = json.dumps(kwargs['body'])

So, in test case, we should pass the same forat for mock.call().

Also, transform the "data" variable to json format.

Close-Bug #1234067

Change-Id: I3a0abaa8064b4360cb94b7b205454e26bddef8e4
2013-10-03 21:32:22 +08:00
Kui Shi
2c32e71720 py33: align the order of parameters for urlencode()
In Python 3.3, hash randomization is enabled by default. It causes the
iteration order of dicts and sets to be unpredictable and differ across
Python runs.

In the test case, the fixed expecting string will not match the test
result, it is relying on the dict order.

This change transforms the input dict to a sequence of two-element list,
with fixed order, and update the related expecitng string in test case.

Close-Bug #1234438

Change-Id: Ic7846279a9f508a856cd4ee70408d537088792f2
2013-10-03 16:30:25 +08:00
Jenkins
bec7d872a5 Merge "py33: sort dict for test_add_floating_ip_to_fixed" 2013-10-02 21:17:35 +00:00
Jenkins
af1f030ea6 Merge "py33: 'str' does not support the buffer interface" 2013-10-02 21:17:31 +00:00
Jenkins
f3bad8acee Merge "Add-in some re-auth logic when using os_cache" 2013-10-02 21:17:21 +00:00
Jenkins
d06b344dc7 Merge "Add shelve/unshelve/shelve-offload command" 2013-10-02 21:17:09 +00:00
Jenkins
350ba51aea Merge "assertEquals is deprecated, use assertEqual" 2013-10-02 20:14:10 +00:00
Jenkins
02886e2a4a Merge "py33: align the order of parameters for urlencode()" 2013-10-02 20:14:07 +00:00
Jenkins
397db8a79b Merge "py33: unknown encoding: base64 Edit" 2013-10-02 19:35:35 +00:00
Kui Shi
f7462f14a4 py33: sort dict for test_add_floating_ip_to_fixed
In Python 3, hash randomization is enabled by default. It causes the
iteration order of dicts and sets to be unpredictable and differ across
Python runs.

Sort the list and update the expecting result.

Close-Bug #1233406

Change-Id: Ib747824dad340534d484797afb87b5e92200e426
2013-10-02 07:06:30 +08:00
Kui Shi
0e3278d3a8 py33: 'str' does not support the buffer interface
Binary I/O expects and produces bytes objects. If sys.stdout is
assigned to io.BytesIO, print() output it stdout by default, then
there will be "TypeError".

For this case, mock.patch() decorator can not work well casually.
So this patch just update the six.StringIO() for stdout/stderr.

Close-Bug #1229163

Change-Id: Ieb29ad0774c9b7f2b691628d753b210640baca8d
2013-10-01 06:31:29 +08:00
Dirk Mueller
ebee5e91b7 assertEquals is deprecated, use assertEqual
Change-Id: I9b2aaed969b046e0203ffa0c7278dff206cb8cd2
2013-09-30 22:25:17 +02:00
Kui Shi
ecdd79b04a py33: align the order of parameters for urlencode()
In Python 3, hash randomization is enabled by default. It causes the
iteration order of dicts and sets to be unpredictable and differ across
Python runs.

In the test case, the fixed expecting string will not match the test
result, it is relying on the dict order.

This change transforms the input dict to a sequence of two-element list,
with fixed order, and update the related expecitng string.

Close-Bug #1231871

Change-Id: Ia998cdb6978fc024dd0d3c9bd161fbdebe68638a
2013-09-30 16:22:40 +08:00
Ken'ichi Ohmichi
ffb83222e5 Add shelve/unshelve/shelve-offload command
The "shelve" API, which powers off and snapshots a vm instance, has been
implemented by Nova-server side.
In addition, thare are two relational API "unshelve" and "shelveOffload".
This patch adds three commands for using these APIs.

Fixes bug #1231827

Change-Id: Ic2ad1bb537efb40a3155e9f3c7b63e09e82be7f1
2013-09-30 08:39:44 +09:00
Morgan Fainberg
8eed73ce20 Add-in some re-auth logic when using os_cache
When using os_cache for the auth_token, if username and password
are available when a token fails to validate/authenticate, attempt
a reauth behind the scenes.

The helper object for stashing the auth_token doesn't handle flushing
the cache.  This is valid behavior because the result would be the
same as if a bad username/password were issued (401 Unauthorized).

Fixes-bug: 1214658
Change-Id: I107fc999610bb7638cefcb5d195aeafdcd663ca6
2013-09-26 10:06:54 -07:00
Nicolas Simonds
9ff60119ed if we have a valid auth token, use it instead of generating a new one
If authenticating with a valid token (i.e., token auth, not
username/password auth), novaclient would instruct keystone to issue
a new token with an identical expiry to the one used, and pivot
onto it.  This makes it appear as though Nova is leaking Keystone
tokens.

Since there's zero benefit to issuing a new token that is ostensibly
identical to the perfectly good token used to authenticate, make
novaclient keep using the token it already has after successful
validation, and not issue a new one.

This patch set adds a new pair of tests to the
AuthenticateAgainstKeystoneTests class, which parrot the current
authentication pass/fail tests, but exercise the new code paths

Also adds a fix by Joe Gordon to make os_cache work correctly.

Change-Id: Ic4f0e6d506d8d81f0b1d46138e7e19d3b3392e1d
Fixes: Bug 1197201
Related-Bug: 1214658
2013-09-25 17:06:18 -07:00
Kui Shi
8b264fc61d py33: unknown encoding: base64 Edit
Python 3 doesn't support str.encode('base64'), we should use the
module "base64" instead.

Close-Bug #1229161

Change-Id: I1432952558f8c5c3cff39761306e91916d80207f
2013-09-25 06:24:14 +08:00
Alex Gaynor
991ab62ef1 Fixed several test failures on Python3
- Corrected places where `dict.keys()` was being treated as a list
- Corrected usage of `urllib.urlencode()`

Change-Id: I0a24b2f64fab6c905e20073ff7ebaa3c5ffe7c90
2013-09-23 17:55:24 -07:00
Jenkins
4a68e2f42c Merge "Corrected several usage of keys() for Python 3" 2013-09-24 00:24:21 +00:00
Jenkins
e1dcf8f982 Merge "py33: dict.keys() is not a list in python3" 2013-09-24 00:24:20 +00:00
Kui Shi
ac79703213 py33: dict.keys() is not a list in python3
Cast the dict.keys() to list when comparing its value with list.

Closes-Bug: #1228993

Change-Id: I59d13258935de3e9286845f857eaa602a5b690fb
2013-09-23 00:16:33 +08:00
Alex Gaynor
35e03a92e2 Corrected several usage of keys() for Python 3
Under Python2 dict.keys() returns a list, under Python 3 it returns an
iterator. Some places assumed that if they called keys() then it was
safe to modify the dict in a loop. Corrected this by calling list().

Change-Id: I7638263f288dd20590bd751d09194a919b921545
2013-09-22 09:04:20 -07:00
Kui Shi
f1c3b79c2b py33: 'dict_keys' object does not support indexing
In python 3, dict.keys() is a class of 'dict_keys', it does not
support indexing.

Cast the dict to list to get the "first" value of dict, which is
compatible with python 2&3.

Closes-Bug: #1229005

Change-Id: I561b7ada9e5ad936659a657b3161a9b93a15a788
2013-09-22 23:55:46 +08:00
Phil Day
8deaf3769d Novaclient shell list command should support a minimal server list
The Nova API supports both a basic (id and name) and detailed server
list, and this is supported in the client by the "detailed=True"
argument to servers.list().  However the shell do_list() method always
leaves this to its default value.  For administrators on a large
system, or where the tenants has a lot of instances a detailed list
can be painfully slow.

This change adds support for a --minimal option to list.

Fixes bug: 1228137

Change-Id: I3126ee6b372606a98f0d7a4e344556f8c05ae224
2013-09-20 13:59:14 +00:00
Jenkins
cafd5bf810 Merge "Add v3 HostManager" 2013-09-18 14:37:46 +00:00
Jenkins
0fd1ccc478 Merge "Create v3 tests directory" 2013-09-18 14:36:18 +00:00
Jenkins
45fcd6f7ba Merge "assertEquals is deprecated, use assertEqual" 2013-09-17 21:20:37 +00:00
Ben Nemec
57a22ec99c Add v3 HostManager
Some of the host code required changes to work with the v3 API.
This change adds a v3-compatible HostManager that inherits from
the 1_1 HostManager to make use of the functions that didn't
need to change.

bp v3-api

Change-Id: I3ef7ab4619d49c20ab1bdeb1185ad28b411d37a1
2013-09-17 14:35:43 -05:00
Ben Nemec
615ad3de54 Create v3 tests directory
Create a basic framework that inherits from v1_1 and can be
overridden as necessary in extension commits

bp v3-api

Change-Id: I611451e50a9e553a18777fa48f32e368b919605e
2013-09-17 14:35:43 -05:00
Jenkins
4e8caf8ed6 Merge "Add delete method to Flavor class" 2013-09-17 18:43:30 +00:00
Jenkins
ecb9b8bf3c Merge "Allow name argument to flavor-access-add" 2013-09-17 18:43:00 +00:00
Chang Bo Guo
889f5680a9 assertEquals is deprecated, use assertEqual
assertEquals is deprecated in Python 2.7 , need drop it

http://docs.python.org/2/library/unittest.html#deprecated-aliases

Change-Id: I5aeeb3b289e1d29f6338fc9fd47e680909f0a133
2013-09-16 17:20:54 -07:00
Vitaliy Kolosov
7edda206b1 Small bugfix for client v3
Client.__init__ method used self.os_cache variable in an internal method call
though this variable had not been initialized earlier.
In addition, unittests added for full coverage of client v3.

Change-Id: I421f82932b65f137932d933e04d42064bec0d08d
2013-09-16 11:38:00 +03:00
Jenkins
9a1304bfab Merge "Python3: Use six.StringIO for io.Bytes()" 2013-09-11 22:07:13 +00:00
Jenkins
500bb6244d Merge "Add support for os-assisted-volume-snapshots" 2013-09-10 16:47:32 +00:00
Vitaliy Kolosov
3523ba90f6 Unittests added for client v1_1
Unittests test_client_set_management_url_v1_1 and
 test_client_get_reset_timings_v1_1 added.
 New methods covered:
 * client.set_management_url()
 * client.get_timings()
 * client.reset_timings()

Change-Id: I46cac01864a11fbaffc284d26f63b8e00f2631f0
2013-09-09 12:14:09 +03:00
Chuck Short
28f9773420 Python3: Use six.StringIO for io.Bytes()
The newer version of six (1.4.1) provides six.StringIO which
is a fake file object for textual data. It's an alias for StringIO.StringIO
in python2 and io.StringIO in Python3.

Use the fake object where approiate.

Change-Id: I364001933b4f2305ac27b293a9a4a3fec36c8a49
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-07 12:28:46 -04:00
Ken'ichi Ohmichi
bec4e51df4 Add delete method to Flavor class
In tempest, some tests use delete() method of each resource class
(Server, SecurityGroup, etc.) for cleaning up when each test finishes.
Now we are adding some tests, which create a Flavor instance, to tempest
and we need the delete() method of Flavor class.

Fixes bug #1218156

Change-Id: I210d62aa45510858346315046cf57ea7b1de7b7b
2013-09-06 08:30:47 +09:00
Xavier Queralt
6a85c954c5 New syntax to boot from a block device mapping
Add new arguments and syntax for booting from a block device mapping
that use the new os-block-device-mapping-v2-boot extension. These
allow to:

 * boot from an image, volume or snapshot (--image, --boot-volume, --snapshot)
 * attach any type of block device (--block-device).
 * attach an swap disk on boot (--swap).
 * attach an ephemeral disk on boot (--ephemeral).

blueprint: improve-block-device-handling

DocImpact

Change-Id: I1aadeafed82b3bd1febcf0d1c3e64b258d6abeda
2013-09-04 17:12:21 +02:00
fujioka yuuichi
97da33fcf5 Allow name argument to flavor-access-add
Administrator cannot use the flavor name in arguments of
"nova flavor-access-add" and "nova flavor-access-remove".

This patch fixes this problem.

Change-Id: I68b267dc071382f1978efc2088cd8e837455e8b4
Related-Bug: #1205298
2013-09-03 02:07:35 +09:00
Jenkins
d770bb3aab Merge "Add interface for listing security groups of an instance" 2013-09-01 14:06:10 +00:00
Russell Bryant
69f8de69d5 Add support for os-assisted-volume-snapshots
This patch adds support for the assisted volume snapshots API extension.
This is used by Cinder to ask Nova to perform a volume snapshot on its
behalf.  It's required when the volume is actually file backed (like
qcow2) and the hypervisor needs to be involved in the snapshot
operation.

Required for blueprint qemu-assisted-snapshots

Change-Id: I50ee9bf92c8de98528638d1724fe35e07bed729e
2013-08-31 11:19:18 -04:00
Yufang Zhang
756a4333e6 Suport instance list pagination in novaclient, Part I
Bug 1209242

nova-api has supported pagination for long. A marker and limit
option could be passed to nova-api to get a slice of instances.
It makes sense to enable this feature in novaclient, so that
horizon could use it for pagination supporting. Modification to
shell.py would be submitted in a separate patch.

Further change will also pass 'sort_key' and 'sort_dir' to
nova-api, as long as nova supports this.

This is part of blueprint support-pagination-for-instance-list

Change-Id: Ieb5f2c1eb31b9f7e95b62b51ea7dc338e3970d04
2013-08-30 14:10:46 +08:00
Jenkins
72c0a13b0a Merge "Added 'nova migration-list' command" 2013-08-29 14:26:17 +00:00