Skip to content

Commit

Permalink
api: Remove 'os-agents' API
Browse files Browse the repository at this point in the history
This was only useful with XenAPI and can therefore be removed.

Change-Id: I9512f605dd2b3b0e88c951ed086250d57056303d
Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Sep 11, 2020
1 parent 8aea747 commit 7ac52e6
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 1,072 deletions.
17 changes: 13 additions & 4 deletions api-ref/source/os-agents.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ hypervisor-specific extension is currently only for the Xen driver. Use of
guest agents is possible only if the underlying service provider uses
the Xen driver.

.. warning::

These APIs only works with the Xen virt driver, which was deprecated in the
20.0.0 (Train) release.
They were removed in the 22.0.0 (Victoria) release.

List Agent Builds
=================

Expand All @@ -20,7 +26,7 @@ Lists agent builds.

Normal response codes: 200

Error response codes: unauthorized(401), forbidden(403)
Error response codes: unauthorized(401), forbidden(403), gone(410)

Request
-------
Expand Down Expand Up @@ -58,7 +64,8 @@ Creates an agent build.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403), conflict(409)
Error response codes: badRequest(400), unauthorized(401), forbidden(403),
conflict(409), gone(410)

Request
-------
Expand Down Expand Up @@ -106,7 +113,8 @@ Updates an agent build.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403), itemNotFound(404)
Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), gone(410)

Request
-------
Expand Down Expand Up @@ -150,7 +158,8 @@ Deletes an existing agent build.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403), itemNotFound(404)
Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404), gone(410)

Request
-------
Expand Down
147 changes: 11 additions & 136 deletions nova/api/openstack/compute/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,153 +13,28 @@
# under the License.


import webob.exc
from webob import exc

from nova.api.openstack.compute.schemas import agents as schema
from nova.api.openstack import wsgi
from nova.api import validation
from nova import exception
from nova import objects
from nova.policies import agents as agents_policies
from nova import utils


class AgentController(wsgi.Controller):
"""The agent is talking about guest agent.The host can use this for
things like accessing files on the disk, configuring networking,
or running other applications/scripts in the guest while it is
running. Typically this uses some hypervisor-specific transport
to avoid being dependent on a working network configuration.
Xen, VMware, and VirtualBox have guest agents,although the Xen
driver is the only one with an implementation for managing them
in openstack. KVM doesn't really have a concept of a guest agent
(although one could be written).
"""(Removed) Controller for agent resources.
You can find the design of agent update in this link:
http://wiki.openstack.org/AgentUpdate
In this design We need update agent in guest from host, so we need
some interfaces to update the agent info in host.
You can find more information about the design of the GuestAgent in
the following link:
http://wiki.openstack.org/GuestAgent
http://wiki.openstack.org/GuestAgentXenStoreCommunication
This was removed during the Victoria release along with the XenAPI driver.
"""
@validation.query_schema(schema.index_query_275, '2.75')
@validation.query_schema(schema.index_query, '2.0', '2.74')
@wsgi.expected_errors(())
@wsgi.expected_errors(410)
def index(self, req):
"""Return a list of all agent builds. Filter by hypervisor."""
context = req.environ['nova.context']
context.can(agents_policies.BASE_POLICY_NAME % 'list', target={})
hypervisor = None
agents = []
if 'hypervisor' in req.GET:
hypervisor = req.GET['hypervisor']

builds = objects.AgentList.get_all(context, hypervisor=hypervisor)
for agent_build in builds:
agents.append({'hypervisor': agent_build.hypervisor,
'os': agent_build.os,
'architecture': agent_build.architecture,
'version': agent_build.version,
'md5hash': agent_build.md5hash,
'agent_id': agent_build.id,
'url': agent_build.url})
raise exc.HTTPGone()

return {'agents': agents}

@wsgi.expected_errors((400, 404))
@validation.schema(schema.update)
@wsgi.expected_errors(410)
def update(self, req, id, body):
"""Update an existing agent build."""
context = req.environ['nova.context']
context.can(agents_policies.BASE_POLICY_NAME % 'update', target={})

# TODO(oomichi): This parameter name "para" is different from the ones
# of the other APIs. Most other names are resource names like "server"
# etc. This name should be changed to "agent" for consistent naming
# with v2.1+microversions.
para = body['para']

url = para['url']
md5hash = para['md5hash']
version = para['version']

try:
utils.validate_integer(id, 'id')
except exception.InvalidInput as exc:
raise webob.exc.HTTPBadRequest(explanation=exc.format_message())

agent = objects.Agent(context=context, id=id)
agent.obj_reset_changes()
agent.version = version
agent.url = url
agent.md5hash = md5hash
try:
agent.save()
except exception.AgentBuildNotFound as ex:
raise webob.exc.HTTPNotFound(explanation=ex.format_message())
raise exc.HTTPGone()

# TODO(alex_xu): The agent_id should be integer that consistent with
# create/index actions. But parameter 'id' is string type that parsed
# from url. This is a bug, but because back-compatibility, it can't be
# fixed for v2 API. This will be fixed in v2.1 API by Microversions in
# the future. lp bug #1333494
return {"agent": {'agent_id': id, 'version': version,
'url': url, 'md5hash': md5hash}}

# TODO(oomichi): Here should be 204(No Content) instead of 200 by v2.1
# +microversions because the resource agent has been deleted completely
# when returning a response.
@wsgi.expected_errors((400, 404))
@wsgi.response(200)
@wsgi.expected_errors(410)
def delete(self, req, id):
"""Deletes an existing agent build."""
context = req.environ['nova.context']
context.can(agents_policies.BASE_POLICY_NAME % 'delete', target={})

try:
utils.validate_integer(id, 'id')
except exception.InvalidInput as exc:
raise webob.exc.HTTPBadRequest(explanation=exc.format_message())

try:
agent = objects.Agent(context=context, id=id)
agent.destroy()
except exception.AgentBuildNotFound as ex:
raise webob.exc.HTTPNotFound(explanation=ex.format_message())
raise exc.HTTPGone()

# TODO(oomichi): Here should be 201(Created) instead of 200 by v2.1
# +microversions because the creation of a resource agent finishes
# when returning a response.
@wsgi.expected_errors(409)
@wsgi.response(200)
@validation.schema(schema.create)
@wsgi.expected_errors(410)
def create(self, req, body):
"""Creates a new agent build."""
context = req.environ['nova.context']
context.can(agents_policies.BASE_POLICY_NAME % 'create', target={})

agent = body['agent']
hypervisor = agent['hypervisor']
os = agent['os']
architecture = agent['architecture']
version = agent['version']
url = agent['url']
md5hash = agent['md5hash']

agent_obj = objects.Agent(context=context)
agent_obj.hypervisor = hypervisor
agent_obj.os = os
agent_obj.architecture = architecture
agent_obj.version = version
agent_obj.url = url
agent_obj.md5hash = md5hash

try:
agent_obj.create()
agent['agent_id'] = agent_obj.id
except exception.AgentBuildExists as ex:
raise webob.exc.HTTPConflict(explanation=ex.format_message())
return {'agent': agent}
raise exc.HTTPGone()
100 changes: 0 additions & 100 deletions nova/api/openstack/compute/schemas/agents.py

This file was deleted.

4 changes: 4 additions & 0 deletions nova/objects/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
from nova.objects import fields


# TODO(stephenfin): Remove this object; it's not necessary since the removal of
# XenAPI
@base.NovaObjectRegistry.register
class Agent(base.NovaPersistentObject, base.NovaObject):
VERSION = '1.0'
Expand Down Expand Up @@ -69,6 +71,8 @@ def save(self):
self.obj_reset_changes()


# TODO(stephenfin): Remove this object; it's not necessary since the removal of
# XenAPI
@base.NovaObjectRegistry.register
class AgentList(base.ObjectListBase, base.NovaObject):
VERSION = '1.0'
Expand Down
2 changes: 0 additions & 2 deletions nova/policies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from nova.policies import admin_actions
from nova.policies import admin_password
from nova.policies import agents
from nova.policies import aggregates
from nova.policies import assisted_volume_snapshots
from nova.policies import attach_interfaces
Expand Down Expand Up @@ -75,7 +74,6 @@ def list_rules():
base.list_rules(),
admin_actions.list_rules(),
admin_password.list_rules(),
agents.list_rules(),
aggregates.list_rules(),
assisted_volume_snapshots.list_rules(),
attach_interfaces.list_rules(),
Expand Down
Loading

0 comments on commit 7ac52e6

Please sign in to comment.