When server_groups is present for retrieved server, this ends up
with the following exception [1]. So we should rather have
regular list instead of dict.
[1] http://paste.openstack.org/show/797758/
Change-Id: I40c4c5241d02aa9d6e61a8064b48a91bde5e6e77
Story: 2007710
Task: 39843
In order to switch OSC to SDK for managing consoles add few missing
(optimize existing) bits:
- add server.get_console_url (deprecated, but still might functional)
- add tests for server_remote_console
- add compute.create_console, which depending on the supported
microversion invokes appropriate underlaying operation.
- add some console type validations to fail early
Change-Id: I63e752e70fb394fadf88057d71669514532cdddf
Nova API doesn't require name and admin password as mandatory
arguments for rebuilding server. Make them optional for SDK too.
Change-Id: I002101b21827005a7945fcc3669ccca1481204a5
Neutron API supports using If-Match HTTP header to do compare-and-swap
updates and deletes of several resources [1]. This feature is based on
revision_number property.
This commit implements that by adding the if_revision argument to
supported update_* and delete_* resources.
[1] https://docs.openstack.org/api-ref/network/v2/?expanded=list-routers-detail#revisions
Change-Id: I5c4ff42796cc860c0a99a431cac84bb75a2d9236
- add fetch_server_security_groups to the compute proxy
- fix add/remove security_group of server to properly pass SG name and
not ID according to docs
- force usage of resource layer in cloud for respective methods
Change-Id: I5c46169de436b9fe4df31a12f3a6246063a7d342
- Add current supported list filters
- Add missing attributes (from newer microversions)
- Sort attributes in the resource
- Use example response from compute docs in unittest (not to miss new
attributes)
- add _max_microversion (and respective discovery calls in tests)
Change-Id: Iad1b57aee0affa345a2812c2b504d00a60441f27
This patch exposes the property for the openstack.compute.v2.Server class,
making them available for inspection.
Change-Id: I53e45622f145971ef7efb220084419ed72c0a715
We have recently introduced possibility to alter base_path for
operations on the resource and shifted some of the services to use it.
For compute.servers(details) we still use an inherited class with
modified base_path. Remove this class and instead alter the base_path
for the list servers operation. This also has an advantage, that we get
a list of servers with details and are immediately able to execute
operations on the instance without any conversion or re-fetch by id.
Change-Id: I4c4649ee1390676f3ccc6bf19e4b11b1964b5aaa
All resources have a location property now that describes the
location of the object in the cloud, but the majority of that
information is taken directly from the connection that is in
use. Some resources contain server-side project_id or availability
zone information. When those exist, they should override the
project_id implied by the connection.
Change-Id: I48c116bf62d726be8d906c3d232e1ee203347b0a
The shade layer pulls the az and project_id info out of the server
record and feeds it into the location field. This is because the
location field should be where the resource is, and the existing token
should only be a fallback.
This isn't happening in the resource layer, so start doing that.
As a result of digging, make sure we always pass in the connection
object to the Resources when we make them. And stop creating a bare
resource in order to use the 'new' class method. It's a class method, we
don't need to instantiate.
Change-Id: Ic8850cd2863e2c806464b92cde2c749f6cc01a91
We currently have multiple places, where we inherit resource just to be
able to request it's Details or so under different url. With 619594
a change has been introduced to improve this by having possibility
to override base_path for a single resource operation.
This was done only for list operations. However there are also cases
when such possibility would be nice for create/update/etc operations.
One example is dry-run for heat, where the endpoint receives "/preview"
part. This is currently implemented by creating
additional resource StackPreview with different base_path. For create
it might be ok, but dry-run stack update would require another url.
With this change a possibility to override base_path for individual
operation on resource object is added. It can be given to proxy
function, which would pass it to resource and use it during URI
calculation.
Change-Id: Id8c8212249cb985d2e47eb1d4fb23ebf19b3871b
align different services to comply the same `tag` standard:
https://specs.openstack.org/openstack/api-wg/guidelines/tags.html
Currently not all services support tags, but we can prepare SDK for
that.
There are some changes/issues to know:
- image.add_tag and image.remove_tag return the image entity
- server.query_params for tags are renamed to be compliant with rest of
services (the ones from network are reused)
- cinder does support only setting of the tags, but not getting (API
limitation)
As of now the only services with tagging API available:
- compute.server
- network.{net, subnet, ip, port, qos_policy, router, sg, sg_rule,
subnet_pool, trunk}
- image.image
- identity.project
Change-Id: I7368c48baf414af325dad2b0579b094c803321bf
Now that we support both server-side and client-side names for
parameters, we can add an all_projects alias. We already use project_id
in resources instead of tenant_id.
Put in logic to only pass all_projects along to the underlying list if
it's True. That way we can easily use the interface with True/False and
only send query parameters when we need to. Pehaps we could enhance
QueryParameters to understand default values of parameters and that they
don't need to be sent?
Change-Id: I66117ab4c82d30ae3700e17f7598b3d3fbbac60d
Sometimes one can be too clever. The win of generating methods here
doesn't really outweigh the complexity or the increased difficulty
understanding the codebase. Additionally, we run in to an EXCELLENTLY
obtuse error:
TypeError: metaclass conflict: the metaclass of a derived class must be
a (non-strict) subclass of the metaclasses of all its bases
when trying to make an abstract base class for the image proxy base
class.
Just get rid of the metaclass and restore the (very few) generated
methods.
Change-Id: Ib53d7b29526a734f1dcf4088bf156e9a29746f5b
Since the dawn of time we've labored under the crippling burden of
needing to explicitly request a version via configuration in order to
get a usable handle to the cloud. This is despite the hilarity of the
existence of a system for discovering available versions since basically
the beginning of the entire OpenStack project.
Today we shall be liberated from the tyranny of terrible past life
decisions on the part of our forefathers and shall usher forth the
shining freedom of actually using the discovery system.
Change-Id: I11c16d37d3ab3d77bed3a0bcbd98f1fa33b9555f
The next change is going to make Resource a subclass of dict so that we
can return Resource objects in the shade layer. Unfortunately, the
Resource base class has two methods, get and update, that conflict with
standard dict method names. To keep things reviewable, just change the
method names.
Most consumers should not be using either of these methods directly.
They are mostly there for lower-level things to use. However, they COULD
be using them, so it's important to note that this is a breaking change.
Change-Id: I2fedeea6e405dcbd333482c1964173ade98ca04d
Previously, disk_over_commit was not exposed and was defaulted to
False. At least one future SDK user (openstackclient) will need
disk_over_commit support from the SDK. This patch adds
disk_over_commit to the live_migrate parameters, and sends it to the
server if running with api < 2.25.
Change-Id: I3f1c6eab41432b9db79ad147cfac3ff63eb70efa
Story: #2002963
Task: #23177
force isn't supported until microversion 2.30. Add a test for that
microversion and only send it if the server supports it.
Change-Id: Ic45e9cccac10d432162d27f9b42da4f4eb1ff167
Story: 2002752
Task: 22608
Each service has a set of Resources which define the fundamental
qualities of the remote resources. Because of this, a large portion
of the methods on Proxy classes are (or can be) boilerplate.
Add a metaclass (two in a row!) that reads the definition of the
Proxy class and looks for Resource classes attached to it. It then checks
them to see which operations are allowed by looking at the Resource's
allow_ flags. Based on that, it generates the standard methods and doc
strings from a template and adds them to the class.
If a method exists on the class when it is read, the generated method
does not overwrite the existing method. Instead, it is attached as
``_generated_{method_name}``. This allows people to either write
specific proxy methods and completely ignore the generated method,
or to write specialized methods that then delegate action to the generated
method.
Since this is done as a metaclass at class object creation time,
things like sphinx continue to work.
One of the results of this is the addition of a reference to each
resource class on the proxy object. I've wanted one of those before (I
don't remember right now why I wanted it)
This makes a change to just a few methods/resources in Server as an
example of impact. If we like it we can go through and remove all of the
boilerplate methods and leave only methods that are special.
openstack.compute.v2._proxy.Proxy.servers is left in place largely
because it has a special doc string. I think we could (and should)
update the generation to look at the query parameters to find and
document in the docstring for list methods what the supported parameters
are.
This stems from some thinking we had in shade about being able to
generate most of the methods that fit the pattern. It's likely we'll
want to do that for shade methods as well - but we should actually be
able to piggyback shade methods on top of the proxy methods, or at least
use a similar approach to reduce most of the boilerplate in the shade
layer.
Change-Id: I9bee095d90cad25acadbf311d4dd8af2e76ba00a
This caps off a bunch of work to get to the new and improved
Resouce2/Proxy2 interfaces. All of the services have been migrated and
the old classes have been removed. Rename openstack.resource2 to
openstack.resource and openstack.proxy2 to openstack.proxy.
Change-Id: I0b7e1c679358e1f60b5316a255aad3a59fbbc8a9
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
Server.block_device_mapping is a list instead of a dict, if create
a server with this attribute set, to_dict() won't work.
Change-Id: Iddd5ad44d21fa4e7e25728a2be1aaf5821df3f13
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
This patch exposes these properties for the openstack.compute.v2.Server class,
making them available for inspection.
Change-Id: I4958450e9853ad52e817da382907517dc3b46e6a
Several query parameters have been added or were previously
undocumented, so they are now up-to-date.
Change-Id: I98b734bd4f8c981eca2c4bc1e9f5d08a3a06f5a6
The compute v2 API accepts ?all_tenants=bool for operators to list all
projects' servers.
This change adds this capability.
Change-Id: Ifbe960751c86fd8c1f187c1c293abbb87561aefc
The 'config_drive' property was missing fro the compute server class.
This patch adds it. The 'networks' property is allowed to be specified
as 'auto', 'none' or a list of network properties. It was forced to be a
dict previously. This patch removes that constraint.
Change-Id: I1d8673935a751d8a319eb711e9592c6ffd8929ef
The exposed server delete is a soft action, which will cause unexpected
result if admin wants to delete the instance immediately. This patch
is to add interfaces for this purpose.
Change-Id: Ibfc4887e4bc367739b8945251e26d6d62117e3f2
The Json response from nova server now contains a 'image' key and a
'flavor' key both of which are maps. When doing a server GET, we are
supposed to get those attributes directly. This patch adds the 'image'
and the 'flavor' properties.
Change-Id: I99bce08c80124d3b420785410b63e46c02ea6259
This change refactors the compute resources and proxy to work with the
newly refactored classes.
Additionally, it adds several properties to the Server resource that
have been documented since it was originally implemented. Several of
these have been requested lately by users, including security_groups,
availability_zone, and admin_password.
Change-Id: I387c9573234c3ed08eb966e388cc2e1a3d891c2d
This change removes the UNIXEpoch and ISO8601 Format classes from
openstack.format as well as all of their usages in Resource classes and
their tests. Additionally, this removes the need to depend on oslo.utils
and iso8601.
Change-Id: I617fb9f0739490a3401f14a654e30b33a476ca59
This patch set updates all compute objects to use consistent
resource.prop for timestamps and booleans. In particular, the
following changes were made:
- Clarify documentation for timestamp and boolean attributes
- Use 'is_' prefix and boolean type for boolean attributes
- Use '_at' suffix and timestamp type for timestamp attributes
Change-Id: I6dbb946dad0d9daee5fd766fab6577e9701edb35
Partial-Bug: #1544584
Fix unit, functional and examples tests for [1]. Also
fix the documentation for the server image_id and flavor_id
properties.
[1] https://review.openstack.org/#/c/279618/
Change-Id: Ia37ecc7c9dccb90fabf7bf73601a6ad519212556
Partial-Bug: #1461200
This patch set updates all compute resource objects to use basic
properties for ID attributes. In particular, the following changes
were made:
- Use basic *_id resource.prop for ID attributes
- Clarify documentation for ID attributes
Change-Id: I48662698e9a272a9e42a46f6108ed79f5107d8fe
Partial-Bug: #1461200
Metadata for both Servers and Images as seen from the Compute
service is less than optimal. This approach uses a mixin class
and allows both the Server and Image resources to leverage the
same code, as they both work with metadata in the same way.
Change-Id: I1d6b1f4c840d1127257244472243e4fa170baa8d
Closes-Bug: #1467732
Currently, action resource call of nova server doesn't work
correctly in case where action API doesn't have response body.
This patch fixes this issue.
Change-Id: I016f74507f7d5b5792c77879969bdc271c25f829
Closes-Bug: #1528145
As description in nova api document, server action request should use
the post method, with no response body return.
Fix this bug by modified request method from 'put' to 'post', and
also add a boolean parameter 'has_response' in action method to avoid
empty response body exception in response parsing.
Change-Id: Ie37e9745b3c924049f7fd563e43e5de55c711af7
Closes-Bug:#1509141
This patch proposes a revision to the resource class and the server
resource so that 'scheduler_hints' will be passed in a format expected
by Nova server.
Change-Id: I01d50fcc2869c3a65253534c7a02e11640f4d54e