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
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
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
Create a basic framework that inherits from v1_1 and can be
overridden as necessary in extension commits
bp v3-api
Change-Id: I611451e50a9e553a18777fa48f32e368b919605e
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
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>
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
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>
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>
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>
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>
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>
Update oslo from oslo-incubator includes various python3
fixes.
Change-Id: Ie30a4c319125c3d4fb704254f8553bc8fd960eae
Signed-off-by: Chuck Short <chuck.short@canonical.com>
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
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
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
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
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
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
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>
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
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>