1197 Commits

Author SHA1 Message Date
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" 2.15.0 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
Jenkins
ff97f4de78 Merge "python3: Fix Traceback while running unit tests" 2013-09-17 18:42:53 +00:00
Jenkins
0af541c727 Merge "python3: Compatibility for iteritems differences" 2013-09-17 18:42:19 +00:00
Jenkins
607e6e9aae Merge "python3: Fix traceback while running unit tests" 2013-09-17 18:42:17 +00:00
Jenkins
e9f2620a3e Merge "Modify --num-instances flag description to clarify limit upper bound" 2013-09-17 18:10:21 +00:00
Jenkins
ed817c8dc7 Merge "Add a block device for the image when using BDMv2" 2013-09-17 18:10:20 +00:00
Jenkins
80eb82792a Merge "Fix the print order of quota-show" 2013-09-17 17:37:33 +00:00
Ken'ichi Ohmichi
043ef5b757 Fix the print order of quota-show
Current "nova qouta-show" prints quotas by random order like the
following:

 $ nova quota-show
 +-----------------------------+-------+
 | Property                    | Value |
 +-----------------------------+-------+
 | metadata_items              | 128   |
 | injected_file_content_bytes | 10240 |
 | ram                         | 51200 |
 | floating_ips                | 10    |
 | key_pairs                   | 100   |
 | instances                   | 10    |
 | security_group_rules        | 20    |
 | injected_files              | 5     |
 | cores                       | 20    |
 | fixed_ips                   | -1    |
 | injected_file_path_bytes    | 255   |
 | security_groups             | 10    |
 +-----------------------------+-------+
 $

This patch fixes its order for fitting to the option order of
"nova quota-update" like the following:

 $ nova quota-show
 +-----------------------------+-------+
 | Quota                       | Limit |
 +-----------------------------+-------+
 | instances                   | 10    |
 | cores                       | 20    |
 | ram                         | 51200 |
 | floating_ips                | 10    |
 | fixed_ips                   | -1    |
 | metadata_items              | 128   |
 | injected_files              | 5     |
 | injected_file_content_bytes | 10240 |
 | injected_file_path_bytes    | 255   |
 | key_pairs                   | 100   |
 | security_groups             | 10    |
 | security_group_rules        | 20    |
 +-----------------------------+-------+

Fixes bug #1223233

Change-Id: I482fd26b9114ac718dc4a16753e7692213bd3690
2013-09-17 09:49:39 +09: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
Abhishek Lahiri
aeef15d6d3 Modify --num-instances flag description to clarify limit upper bound
Closes Bug:#1220703

Modified --num-instances flag description in shell.py to clarify that
number of instances spawned are limited by the quota.

Change-Id: I29fa175f310ab1e073dca5f453a3540dcdde933d
Signed-off-by: Abhishek Lahiri <aviostack@gmail.com>
2013-09-14 05:38:55 +00:00
Xavier Queralt
2e8900b6dc Add a block device for the image when using BDMv2
Right now the cli was already adding a block device when it was passed
an image_id to boot from and more than one block device mapping v2. This
is done because nova expects the image to be another block device
mapping and would ignore it otherwise.

This patch moves this functionality from the cli to the base module so
users of the module can benefit from this and also to prevent some
misunderstandings that may arise when using BDMv2 and the image gets
ignored by nova. In the future we should handle this in the nova side
assuming a new BDM when an image is provided.

Fixes bug #1225061

Change-Id: I29f31c24f958cfa8b68b33edc63e0d7031aa241f
2013-09-13 18:27:45 +02:00
Chuck Short
450f02efe3 python3: Compatibility for iteritems differences
In python3 dict.iteritems(), dict.iterkeys(), and
dict.itervalues() are no longer supported. So use
six.iteritems() where it is appropriate.

blueprint python3-novaclient

Change-Id: I8c39bfe426d08d36215b55c3245dcfc69ec72517
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-13 10:54:19 -04:00
Chuck Short
4f3c2c92a4 python3: Fix traceback while running unit tests
While running unit tests with python3, we get the following traceback:

TypeError: 'map' object is not subscriptable

In python3, a map returns an iterable object of type map,
and is not subscriptable.

Refactor to not use indicies so that it is python2 and python3
compat.

blueprint python3-novaclient

Change-Id: Iaf0de19f08fa3e91ee79c174ccc86a8bbe4acdc8
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-13 10:52:47 -04:00
Chuck Short
605a7ed2f2 python3: Fix Traceback while running unit tests
Python3 uses the the concepts of text and (binary) data
instead of Unicode strings and 8-bit strings. In python3
all text is unicode; however encoded unicode is represented
as binary data.

Use the six module to use six.binary_types and six.text_types
where apporiate:
- six.text_type unicode() in python2 and str in python3.
- six.basestring() in python2 and str in python3.

blueprint python3-novaclient

Change-Id: Ie7b393abe6beac22eaf127b7fc7bbc372c338211
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-13 10:51:13 -04:00
Jenkins
9a1304bfab Merge "Python3: Use six.StringIO for io.Bytes()" 2013-09-11 22:07:13 +00:00
Jenkins
447cf8d6e5 Merge "Python3: Fix traceback while running unit tests" 2013-09-11 18:09:43 +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
9d8869e01c Python3: Fix traceback while running unit tests
While running the unit tests with python3 the following
traceback appears:

TypeError: can't use a string pattern on a bytes-like object

This is due to the way that python2 and python3 handles unicodes.

Change-Id: I401f1cefed69780073222cae98d8da4c3d8031a8
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-07 12:35:13 -04: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
Chuck Short
cab4617225 Update oslo from oslo-incubator
Update oslo from oslo-incubator includes various python3
fixes.

Change-Id: Ie30a4c319125c3d4fb704254f8553bc8fd960eae
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-09-06 08:03:22 -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
Jenkins
9ce24f214b Merge "change 'Host' object's 'host' attribute to 'host_name'" 2013-08-29 12:04:52 +00:00
Jenkins
d6139aabda Merge "Added support for running the tests under PyPy with tox" 2013-08-29 12:03:49 +00:00
Jenkins
3851245ec4 Merge "Fix the help messages to specify image/flavor name" 2013-08-29 04:17:22 +00:00
Noorul Islam K M
12d5b9578b Add interface for listing security groups of an instance
This is already available in nova but not exposed via client.

* novaclient/v1_1/servers.py:
   New interface to list security groups of an instance.

* novaclient/v1_1/shell.py:
   New sub command list-secgroup.

* novaclient/tests/v1_1/fakes.py,
  novaclient/tests/v1_1/test_servers.py,
  novaclient/tests/v1_1/test_shell.py:
   Add corresponding tests.

Implements: blueprint servers-list-secgroup

Change-Id: I505bcffdbb15b84bfd73cae5ef5a8fb9c69bd7b9
2013-08-29 09:40:35 +05:30
Jenkins
c970dc3dd4 Merge "python3: Fix imports for py2/py3" 2013-08-29 01:17:12 +00:00
Jenkins
dc1b1cda06 Merge "Fix and gate on H501, no locals for string formatting" 2013-08-28 19:18:43 +00:00
Alex Gaynor
d9782457fc Added support for running the tests under PyPy with tox
This is a precursor to having them run under check and gate.

Change-Id: I105404d45cd4be93909ea5a272fc7e7c0c6d78cb
2013-08-28 09:35:28 -07:00
Jenkins
2e97eb7e53 Merge "Upgrade to Hacking 0.7" 2013-08-28 14:15:47 +00:00
Chuck Short
c450b39828 python3: Fix imports for py2/py3
Python3 reorganized the standard library and moved several functions
to different modules. Six provides a consistent interface
to them through the fake six.moves module.

However, the urlparse, urllib2, etc modules have been combined
into one module which Six does not support so we do it via
py3kcompat.

Modules such as StringIO and CStringIO have been removed
completely so we use the io module.

Change-Id: I53adac11b634de2c710fc39def36bcec96366710
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-08-27 14:50:34 -04:00
Joe Gordon
fe5f07e891 Upgrade to Hacking 0.7
There was a bug in hacking 0.6 that broke H202, assertRaises Exception
too broad, so switch to Hacking 0.7 and fix the one H202 bug.

Change-Id: I0ec9532ffbb6b3c8dbd775e6da7bc879b0a6737a
2013-08-23 16:51:46 -04:00
Chuck Short
61a8063954 Sync py3kcompat from oslo
Python3 reorganized the standard library and moved several
functions to different modules and combined modules. Six
provides a consistent interface to the module through
six.moves

However urllib/urlparse is not covered by six.moves so
py3kcompat adds python2/python3 compatibility layer for
urllib/urlparse.

Change-Id: If1436d2260f1c8b6df8c514c8730e7bcf0e648b8
Signed-off-by: Chuck Short <chuck.short@canonical.com>
2013-08-23 14:39:23 -04:00
Jenkins
27700f9b36 Merge "Allow name argument to flavor-access-add" 2013-08-23 01:33:06 +00:00
Jenkins
5e8957a2b7 Merge "Update mailmap" 2013-08-23 01:29:37 +00:00