The subclass of ManagerWithFind implements get() function, and all
the get() functions returns an object with request_ids. Let's expose
these request_ids to users directly.
Change-Id: Icb3c480c637c39412ed085f4523fb93e36fea0a7
Closes-Bug: 1541694
'request_ids' is a function of class RequestIdMixin.
Resource().__dict__.keys() doesn't contains a function. So it not
necessary to filter it.
Change-Id: I73af5d1be39769f70cbe4c1ec83144d56f94f91a
Added wrapper classes which are inherited from base data types str,
list, tuple and dict. Each of these wrapper classes and
the Resource class contain a 'request_ids' attribute
which is populated with a 'x-compute-request-id' or
a 'x-openstack-request-id' received in a header from a response body.
This change is required to return 'request_id' from
client to log request_id mappings of cross projects.
This patch is one of a series of patches for implementing
return-request-id-to-caller.
Co-authored-by: Ankit Agrawal <ankit11.agrawal@nttdata.com>
Change-Id: I422c4f4ee59991ca89a0a16f548b537c8b61bb97
Implements: blueprint return-request-id-to-caller
when we try to restore an instance, it's already deleted state,
so we need to add 'delete=True' as default to restore command,
otherwise, the search function can't find the instance
whose state is deleted with the given name
Change-Id: I81cdc46897d76333452069a691824264ad504518
Closes-Bug: 1534644
oslo-incubator was deprecated and all modules used by novaclient were
removed from oslo-incubator master branch. This patch removes all unused
code from novaclient's repo.
Change-Id: Ie3c542d19da6ed4d25ec490faf6a86a82f48cd34
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 below files-
-api_versions.py
-base.py
-client.py
As there are lot of violations and cannot be fixed in single patches,
So separating those in multiple patches for easy review.
Change-Id: I30a714fc3b0b317f7ffa4a99fbb224b4d5f5477b
Partial-Bug: #1521899
Commit 5153dcda807c554769081626c10c43d16adea671 removed bdm v2-only
request parameters to pass nova api v2.1 schema validation, but also
removed the ability to boot with legacy bdm specifying volume_id only.
This adds volume_id back to the request for legacy bdm when
no other parameters are specified.
Closes-Bug: #1501435
Change-Id: Ie8c56c28492793990ef7ed6dc54768cef9e28a98
Currently, novaclient's gates are broken due to missed 'volume' service_type.
This patch changes default service type for all volume related managers to
"volumev2" and leave ability to set "volume" service_type.
Change-Id: Ia1e1d3def1e6127cc2b97797c577c15265f879bd
Closes-Bug: #1501258
`_parse_block_device_mapping` method was design to support both
bdm v1 and v2. The implementation is based on the fact that API side
ignores unknown/incorrect parameters, so `_parse_block_device_mapping` compose
equal parameter for bdm v1 and bdm v2. Since Nova V2.1 contains schema checks,
such implementation stoped working.
Despite the fact that novaclient.v2.servers contains separate logic for bdm v2,
we can make `_parse_block_device_mapping` works only with legacy bdm and
in future patches make it works for both bdm v1 and bdm v2.
Change-Id: I37c00ac77b1a3b500221d779533532e9f43e5277
Closes-Bug: #1491737
New decorator "novaclient.api_versions.wraps" replaces original method with
substitution. This substitution searches for methods which desire specified
api version.
Also, this patch updates novaclient shell to discover versioned methods and
arguments.
Related to bp api-microversion-support
Co-Authored-By: Alex Xu <hejie.xu@intel.com>
Change-Id: I1939c19664e58e2def684380d64c465dc1cfc132
Changes include:
e782594 Add last_request_id only if it is not none
18bf5ca Fix usage of NotFound exception in apiclient.base
3bc8231 deprecate apiclient package
Depends-On: Ia83ef6136da1c551ea947679dc546a0d7ad2f876
Change-Id: I0b5917c657d6adc3d34229b14833a5224c168e07
Currently, several of the volumes apis depend on callers to pass
service_type='volume' as a parameter when creating a client object,
to route correctly. The problem is, it makes it impossible for
callers to work with both the compute and volume endpoints at the
same time. They can either work with compute and have volumes.* calls
return 404, or they can work with volume and have servers.* images.*
flavors.* calls return 404.
The CLI sets service_type='volume' for client objects for the
following commands via a decorator:
volume-list
volume-show
volume-create
volume-delete
volume-snapshot-list
volume-snapshot-show
volume-snapshot-create
volume-snapshot-delete
volume-type-list
volume-type-create
volume-type-delete
With this change, the service_type 'volume' is set in the api,
so the decorators on the shell commands are no longer needed.
Closes-Bug: #1431154
Change-Id: I11b48ac14fa4c64d8aae528552ec5b363be384c5
This reverts commit 4c8cefb98a425382204df2f38f24e6b5b71520dd.
The cache completion was causing a bug where 'nova volume-attach' would
then try to query Nova for volume information using a URL that was not
valid. This caused it to appear that the attach had failed.
Additionally the idea of making extra API queries for a bash completion
cache should be thought through more.
Conflicts:
novaclient/client.py
novaclient/shell.py
novaclient/v2/client.py
novaclient/v3/client.py
Closes-Bug: #1423695
Change-Id: I6676a11f9b5318a1cda2d03a5d4550bda549d5c2
Nova delete command deletes an instance by name
or ID. Nova delete command is able to delete an
instance within the same the tenant by name or
ID. When admin credentials are sourced and try
to delete a non admin tenant instances, nova
delete command is able to delete an instance by
ID only, it is not able to delete an instance by
name.
Nova delete command deletes an instances by id
using following api call
/v2/{tenant_id}/servers/{server_id}
But to delete an instance by name, nova delete
command first find the resources by name using
following api call
/servers?name={server_name}
This api call is not able to retrive the list
of other tenant instances.
Adding all tenants parameter to this api call
will retrive the list of other tenant
instances. The following will be new api
call
/servers?all_tenants=1&name={server_name}
Closes-Bug: #1247030
Change-Id: I03e578d58214c835d9a411752bd618d77ced37ff
Module `novaclient.utils` contains a lot of functions which are
presented in modules from common code.
* service_type -> novaclient.openstack.common.cliutils.service_type
* get_service_type -> novaclient.openstack.common.cliutils.get_service_type
* pretty_choice_list ->
novaclient.openstack.common.cliutils.pretty_choice_list
* import_class -> oslo.utils.importutils.importclass
* HookableMixin -> novaclient.openstack.common.apiclient.base.HookableMixin
Change-Id: Ia6cac058da12c852d92f26875a66ae31cc4c63d4
Instead of listing all servers and doing clientside filtering, use the servers
filtering on name.the server's list already supports filtering
so just pass a search_opts dictionary into list().
This should speed up nova commands when a user has large numbers of servers.
Change-Id: I6deea8523754ff213f43bd059fb00f34fc0e1a12
Closes-Bug: #1202179
This reverts commit 4e1ee661083bd672a884fd13fdb1ffaadea5252a.
This change is a part of a series that is not backwards compatible,
and caused breakage in applications that use the client library.
Change-Id: If614826fb0832602110c1ac8be2c0e6324a5a248
Partial-Bug: #1340596
The current code in novaclient/base.py, class BootingManagerWithFind
do not take in account the differences required to boot an instance from
a volume in API v3. V3 expects UUID as volume id and also the source type
to be set.
Change-Id: Id8cfb2d7811aead27cb26cf7ff615c7a9ed05d54
Close-bug: 1325303
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
Since exceptions from oslo is used, ClientException doesn't have any
attributes related to HTTP, so `HttpError` should be set as default
http-based exception.
Also, attribute `code` is used in several project, so it should be
returned and marked as deprecated.
Partial-Bug: #1322183
Change-Id: I3c71e2d25d6e36b5bac0f2b3add74d6747cf7c25
Creates an images client when attached to the the servers
client. This is necessary because the Nova V3 API no longer
proxies image queries to glance but when preparing a request to
boot a server it is necessary to retreive information about
images so we need to talk to both Nova and Glance in the same
command.
This is a bit ugly, but not much more than the already existing
ugliness of using the client class designed to talk to
Nova to talk to Glance and Cinder. The long term clean solution
is probably to a unified client that is designed to talk to
multiple openstack services.
Differences between the V2 and V3 API are described here:
https://wiki.openstack.org/wiki/NovaAPIv2tov3
Partially implements blueprint v3-api
Change-Id: Ib43682f38cd7a3e0f910b75e96685591246e7f67
All methods of Resource class novaclient is equal to common code.
In the process of unification of the clients code we should
reuse common functionality from Oslo.
Related to blueprint common-client-library-2
Change-Id: I2b72c6b34a44dec3572ca8ad70e41e42a32d48c0
This patchset updates modules based on the config file:
openstack-common.conf
Notes: Some corrections has been added to work with
new files.
+ utils.py: The method safe_decode from strutils.py
was updated and it is now not necessary to check for
decode string with py33.
+ base.py: base64 needs a 8-bit string for py33
+ test_shell.py: stdin.encoding is needed for strutils
Change-Id: Iebe474f1226f8b5faa7fb5722e65f41b80d1973c
Related to blueprint common-client-library-2
Closes-Bug: #1265473
If image has no name, human_id can't be built.
Also slugify raises ValueError if None argument passed.
It affects Docker images.
Closes-Bug: #1267429
Closes-Bug: #1267130
Change-Id: Ib975775b441917eef2a650049cee9991d10c50d7
The bash completion code is the sole user of the slugify() function
in utils, which is substantially similar to to_slug() provided in
strutils from oslo.
Change-Id: Ib4eb7e4c0fa0e9bc5c4a0856f6391911d8f8fd3b
Closes-bug: #1266118
Previously, completion caches were not thread-safe and multiple
threads could not make calls to python-novaclient simultaneously.
With locking, the completion caches are now thread-safe.
Closes-Bug: #1213958
Change-Id: I201c2ed0f1eb09b1c2a74de96119cbae9ed6f4b0
The way to using metaclass has changed in Python3.
Python 2.7 way:
class Foo(object):
__metaclass__ = FooMeta
Python 3 way:
class Foo(object, metaclass=FooMeta):
...
The six.add_metaclass() decorator allows us to use one syntax that
works for both Python 2.7 and Python 3.
Change-Id: Ibd31a9f91bac6ec220d802f16c77ee0306e211b3
Closes-Bug: #1236648
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.
Sort the files parameters when multiple files are designated.
Close-Bug #1235096
Change-Id: I0db645b3fb92408bd8c6780bfabe7ce8265a65a8
Python 3 doesn't support str.encode('base64'), we should use the
module "base64" instead.
Close-Bug #1229161
Change-Id: I1432952558f8c5c3cff39761306e91916d80207f
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>
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
Administrator cannot use the flavor name in arguments of
"nova flavor-access-add" and "nova flavor-access-remove"
in following conditions.
1. The flavor is non-public.
2. The falvor doesn't belong administrator's tenant.
This patch fixes this problem.
Change-Id: Ic5e3222d0ff62667e003a61e6a94e85833da5d11
Fixes: bug #1205298
Fix:
TypeError: Unicode-objects must be encoded before hashing
while running tests. This is due to the fact in python3 hashlib.md5
works with bytes and we are passing unicode strings.
Change-Id: I27a57d6afb2412e11bc2802e4559d56c5b5592a9
Signed-off-by: Chuck Short <chuck.short@canonical.com>
Allow servers to be created, resized, and rebuilt with the disk_config
option:
http://api.openstack.org/api-ref.html#ext-os-disk-config
There is a separate extension that exists for disk config already, but
it only works via the novaclient CLI interface, not via programmatic use
of python-novaclient as a library.
assert changes in tests/v1_1/fakes allow for other data in rebuild
and resize requests.
Change-Id: I8051ffb8747cf5c67b0199d22fbbe80306b01499
Use /resources instead of /resources/detail to resolve
the resource ID by the name and load the details of the
resource in a separate step. This reduces the overhead
to resolve the resource ID and results in a better runtime
performance.
This patch does not solve the issue that the name resolving
takes place on the client side. For solving this issue new
Nova API methods are necessary.
fixes bug #1202179
Change-Id: Ib753b1d090cb74b2d137c68f6899dad4ae2ec1ca
This class was forked from novaclient.base when adding v1.1 support and
and because v1.0 is no longer supported it can be merged again.
blueprint: improve-block-device-handling
Change-Id: I3113eff522a9dc280f48053001afa9e1a0cad3e3
As a project we do not support python 2.4 or python 2.5
and these versions of python are not tested, so remove
the compatibility code.
Change-Id: I267d9e7e83d85322c45d56d9c5256b514224ad8c
Signed-off-by: Chuck Short <chuck.short@canonical.com>
In python3 dict.iteritems(), dict.iterkeys(), and
dict.itervalues() are no longer supported. So use
six.iteritems() where it is appropriate.
Change-Id: I8b07dc2a89d790ec275d45f859e1644e9b00c837
Signed-off-by: Chuck Short <chuck.short@canonical.com>
ManagerWithFind requires list() method in its descendants.
Make it abstract and fix its improper descendants that do
not implement list() (SecurityGroupRuleManager and many others).
Fixes: bug #1180393
Change-Id: Ic8b466a57554018092c31c6d6b3ea62f181d7000
Having the _info get out of sync with the actual attributes is kind of a
trap for the unwary. _info is used in preference to the attributes in
many places, and letting it get out of sync means that the method of
retrieval (get() vs. list()) influences the result.
Change-Id: I9d9bf086fa790b811c520b2fa317f95cb1921805