This looks very large, but the only manual change is in pyproject.toml
and the bump of the ruff pre-commit hook: the rest is entirely ruff
converting our use of e.g. 'typing.Union[X, Y]' to 'X | Y', as added by
PEP-604 [1].
[1] https://peps.python.org/pep-0604/
Change-Id: I3ed176018cf78c417e751834e57412d72884a69b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
We have kept hacking capped below 1.2 for quite awhile. Newer versions
of hacking pull in updated linters that have some good checks.
We want to limit the maximum version of hacking installed since the
global upper constraints does not do this for linters. Otherwise when a
new release of hacking is available in the future, stable branches may
suddenly be broken.
Change-Id: I0e0ee8a169ae93f7efb2cda2b1d2458c1d49e46b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This is super basic, but it's a starting point to us being able to
start adding typing info.
Adding it with python2 syntax for now, since we haven't dropped py2
yet.
Change-Id: I4f9b95b02d43c81acb60d224584d60331f5a7784
Add possibility to pass a hook in the vendor config, clouds-public.* or
upon building a connection. This should be a string parameter - function
name to be executed. This gives possibility to register new services of
the cloud automatically or alter behavior of the present services.
It would have not been necessary, if public clouds followed
upstream-first aproach.
While we are here fix warnings on not closed files in the test_json
Change-Id: Ifd6c0847102af4f46e361dcb1a665829c77553b9
There are timeout issues as well as sometimes something goes wrong in
the shade floating ip tests. Update the tests to try to make them more
stable.
This also fixes a bug in find_available_ip that was causing ips with
port_ids to be returned that was accidentally working in the functional
tests as a race condition.
While working on this, pycodestyle made a release and broke us. Add pep8
changes to allow landing this patch. Fix two of them, ignore two of them.
Change-Id: I128e85048b91f0508798d6c0c2a7e3aacb1c92c1
Although driving configuration from clouds.yaml and environment
variables is super handy for many use cases, there are also plenty where
avoiding config files or environment variables is important.
Add a flag, "load_envvars" which defaults to True but can be disabled.
Update the Connection constructor to set load_yaml_config and
load_envvars to False if a named cloud is not given.
Update the docs to make it clear which form should be used for which use
case. Also, move the profile backwards compat documentation to its own
document so that it doesn't present needless complexity to users.
Change-Id: I6e05da5e73aff4143550e1d18fb0f743d51f2b70
We don't want these where they look like supported interfaces just yet.
Move them below openstack.cloud.
Change-Id: I653e5aaba8084e8c226fd0e787dfff01050e7a6c
Having openstack/__init__.py referencing pbr is causing some problems
sometimes when invoking sdk apis. This patch propose using the version
definition from version module under openstack/.
This is a follow up of 2f05a3d066.
Change-Id: I3117becd0e91514447a426f2fec4d133dd11f404
shade and openstacksdk each have a logging doc and a logging setup helper
function. They both basically do the same thing, and we have a TODO item
about collapsing them.
This moves openstack.utils.enable_logging to openstack.enable_logging
(leaving behind a compat piece at openstack.utils.enable_logging) It
adds the shade functionality to it, and also changes the behavior to
match shade's WRT behavior when no parameters are passed (defaults to
logging to stdout)
Update the codebase to call openstack._log.setup_logging instead of
logging.getLogger directly, as setup_logging attaches a NullHandler by
default.
Collapse the docs into a single document.
There were only two places where openstacksdk was already logging to
something other than 'openstack'. Collapse those down to 'openstack'
until we come up with a reason to break them out more logically.
Change-Id: I45fd5ffd18255450d38a1f56c80f5c157ea19ae3
The name CloudConfig has always sucked. While working on the next patch,
it occurred to me that what a CloudConfig represents is the config for a
given region of a cloud. We even reference "Cloud Region" as a unit of
work when giving conference talks.
Take the opportunity while we're doing this sdk/occ merge to rename it.
Obviously we can provide naming compat shim in OCC itself.
Leave in *some* naming compat shims to get us past the 0.10 release so
that OSC continues to have the happies.
Change-Id: Ia0bbc20eb28a3a36e69adba3a4b45323e4aa284e
This is a large and invasive change to the underlying guts. Most casual
use should not notice a difference, but advanced users, especially those
using the Profile or Authenticator interfaces or making use of pluggable
providers will be broken.
The overall intent is to align directly on top of the mechanisms that
came from os-client-config for config and to use keystoneauth1's Adapter
interface to make use of the canonical implementations of such things as
service and version discovery. The end goal is that openstacksdk
provides the REST interaction layer for python-openstackclient, shade,
Ansible and nodepool.
Replace profile with openstack.config
os-client-config is used by shade and python-openstackclient to read
and process configuration. openstacksdk also can use the
os-client-config interface, but translates it internally into the
Profile object. As os-client-config has been injested into
openstack.config, remove Profile and just use the config classes.
Make proxy subclass of adapter
This gives every service a generic passthrough for REST calls, which
means we can map unknown service-type values to a generic proxy.
Strip endpoint_filter
We're passing Adapters around, not sessions. Doing so means that
self.service and endpoint_filter have become unnecessary.
Rename _Request.uri to _Request.url
This is a stepping-stone to replacing _Request with requests.Request and
using requests.Session.prepare_request inside of _prepare_request.
Rename service proxy instances to match their official service-type.
Aliases are kept for the old versions, but make the canonical versions
match the official name.
Rename bare_metal to baremetal
Rename cluster to clustering
Rename block_store to block_storage
Rename telemetry to meter
Create generic proxies for all services in STA
Every service listed in service types authority is an OpenStack service.
Even if we don't know about it in SDK, we should at the very least have
a low-level Adapter for it so that people can use REST calls while
waiting on the SDK to add higher-level constructs.
The pypy jobs are happily green. Run them as voting rather than
non-voting.
Add syntatic sugar alias for making connections
Typing:
import openstack.connection
conn = openstack.connection.Connection(cloud='example')
is annoying. This allows:
import openstack
conn = openstack.connect(cloud='example')
Use task_manager and Adapter from shade
As a stepping-stone towards shade and sdk codepaths being rationalized,
we need to get SDK using the Adapter from shade that submits requests
into the TaskManager. For normal operation this is a passthrough/no-op
sort of thing, but it's essential for high-volume consumers such as
nodepool.
This exposes a bunch of places in tests where we're mocking a bit too
deeply. We should go back through and fix all of those via
requests_mock, but that's WAY too much for today.
This was a 'for later' task, but it turns out that the move to Adapter
was causing exceptions to be thrown that were not the exceptions that
were intended to be caught in the SDK layer, which was causing
functional tests of things like GET operations to fail. So it became a
today task.
Change-Id: I7b46e263a76d84573bdfbbece57b1048764ed939
This sucks in the git history for both projects, then moves their files
in place. It should not introduce any behavior changes to any of the
existing openstacksdk code, nor to openstack.config and openstack.cloud
- other than the name change.
TODO(shade) comments have been left indicating places where further
integration work should be done.
It should not be assumed that these are the final places for either to
live. This is just about getting them in-tree so we can work with them.
The enforcer code for reasons surpassing understanding does not work
with python setup.py build_sphinx but it does work with sphinx-build
(what?) For now turn it off. We can turn it back on once the build
sphinx job is migrated to the new PTI.
Change-Id: I9523e4e281285360c61e9e0456a8e07b7ac1243c
The scheduler_hints attribute exists as a top-level key rather than
under the "server" key like most other things, so if we have it set,
shift it out of the resource_key body and into its own top-level key.
The availability_zone attribute exists with two different names,
depending on whether it's in a request or a response. When we're
preparing a request, include it in the request body as
availability_zone, otherwise expect OS-EXT-AZ:availability_zone in the
response body such as for a GET. The same goes for the user_data
attribute, which exists as OS-EXT-SRV-ATTR:user_data in responses.
Change-Id: Ifc261f982f8a13f8ab467350615e08f268a22049
Closes-Bug: 1671073
Closes-Bug: 1671886
There are several modules that end-users are expected to be
using--connection, profile, exceptions, and utils--which could be made
slightly more accessible by having them available in the top level
`openstack` namespace. This change proposes importing `from openstack
import <x>` in openstack.__init__.py so that end-users can do `import
openstack` and then work from there.
Nothing more than the typical end-user entry points are to be exposed
from there, so if you need to get the server resource you still need
to do `from openstack.compute.v2 import server`. Additionally, we should
continue documenting and using in tests everything in the `from
openstack import <x>` format ourselves as this is merely a convenience.
Change-Id: I24a7ce3636b18287fcb2246fbdfa9f8b6767f323
Having openstack/__init__.py referencing pbr is causing some problems
sometimes when invoking sdk apis. This patch propose moving the version
definition into a module under openstack/.
Close-Bug: 1588823
Change-Id: I587de91ea7f523bb923ed9ac665a0b46d40d722c