Merge "port BaremetalNodes API into v3 part2"
This commit is contained in:
commit
84b730b70f
@ -51,6 +51,7 @@
|
||||
"compute_extension:attach_interfaces": "",
|
||||
"compute_extension:v3:os-attach-interfaces": "",
|
||||
"compute_extension:baremetal_nodes": "rule:admin_api",
|
||||
"compute_extension:v3:os-baremetal-nodes": "rule:admin_api",
|
||||
"compute_extension:cells": "rule:admin_api",
|
||||
"compute_extension:v3:os-cells": "rule:admin_api",
|
||||
"compute_extension:certificates": "",
|
||||
|
@ -23,7 +23,9 @@ from nova.api.openstack import xmlutil
|
||||
from nova import exception
|
||||
from nova.virt.baremetal import db
|
||||
|
||||
authorize = extensions.extension_authorizer('compute', 'baremetal_nodes')
|
||||
ALIAS = 'os-baremetal-nodes'
|
||||
authorize = extensions.extension_authorizer('compute',
|
||||
'v3:' + ALIAS)
|
||||
|
||||
node_fields = ['id', 'cpus', 'local_gb', 'memory_mb', 'pm_address',
|
||||
'pm_user',
|
||||
@ -115,8 +117,8 @@ class BareMetalNodeController(wsgi.Controller):
|
||||
authorize(context)
|
||||
try:
|
||||
node = db.bm_node_get(context, id)
|
||||
except exception.NodeNotFound:
|
||||
raise webob.exc.HTTPNotFound()
|
||||
except exception.NodeNotFound as e:
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
try:
|
||||
ifs = db.bm_interface_get_all_by_bm_node_id(context, id)
|
||||
except exception.NodeNotFound:
|
||||
@ -150,15 +152,15 @@ class BareMetalNodeController(wsgi.Controller):
|
||||
authorize(context)
|
||||
try:
|
||||
db.bm_node_destroy(context, id)
|
||||
except exception.NodeNotFound:
|
||||
raise webob.exc.HTTPNotFound()
|
||||
except exception.NodeNotFound as e:
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
def _check_node_exists(self, context, node_id):
|
||||
try:
|
||||
db.bm_node_get(context, node_id)
|
||||
except exception.NodeNotFound:
|
||||
raise webob.exc.HTTPNotFound()
|
||||
except exception.NodeNotFound as e:
|
||||
raise webob.exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
||||
@wsgi.serializers(xml=InterfaceTemplate)
|
||||
@wsgi.action('add_interface')
|
||||
@ -201,18 +203,21 @@ class BareMetalNodeController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound()
|
||||
|
||||
|
||||
class Baremetal_nodes(extensions.ExtensionDescriptor):
|
||||
class BaremetalNodes(extensions.V3APIExtensionBase):
|
||||
"""Admin-only bare-metal node administration."""
|
||||
|
||||
name = "BareMetalNodes"
|
||||
alias = "os-baremetal-nodes"
|
||||
namespace = "http://docs.openstack.org/compute/ext/baremetal_nodes/api/v2"
|
||||
updated = "2013-01-04T00:00:00+00:00"
|
||||
alias = ALIAS
|
||||
namespace = "http://docs.openstack.org/compute/ext/baremetal_nodes/api/v3"
|
||||
version = 1
|
||||
|
||||
def get_resources(self):
|
||||
resources = []
|
||||
res = extensions.ResourceExtension('os-baremetal-nodes',
|
||||
res = extensions.ResourceExtension(ALIAS,
|
||||
BareMetalNodeController(),
|
||||
member_actions={"action": "POST", })
|
||||
resources.append(res)
|
||||
return resources
|
||||
|
||||
def get_controller_extensions(self):
|
||||
return []
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute.contrib import baremetal_nodes
|
||||
from nova.api.openstack.compute.plugins.v3 import baremetal_nodes
|
||||
from nova import context
|
||||
from nova import exception
|
||||
from nova import test
|
||||
|
@ -129,6 +129,7 @@ policy_data = """
|
||||
"compute_extension:attach_interfaces": "",
|
||||
"compute_extension:v3:os-attach-interfaces": "",
|
||||
"compute_extension:baremetal_nodes": "",
|
||||
"compute_extension:v3:os-baremetal-nodes": "",
|
||||
"compute_extension:cells": "",
|
||||
"compute_extension:v3:os-cells": "",
|
||||
"compute_extension:certificates": "",
|
||||
|
@ -59,6 +59,7 @@ nova.api.v3.extensions =
|
||||
aggregates = nova.api.openstack.compute.plugins.v3.aggregates:Aggregates
|
||||
attach_interfaces = nova.api.openstack.compute.plugins.v3.attach_interfaces:AttachInterfaces
|
||||
availability_zone = nova.api.openstack.compute.plugins.v3.availability_zone:AvailabilityZone
|
||||
baremetal_nodes = nova.api.openstack.compute.plugins.v3.baremetal_nodes:BaremetalNodes
|
||||
cells = nova.api.openstack.compute.plugins.v3.cells:Cells
|
||||
certificates = nova.api.openstack.compute.plugins.v3.certificates:Certificates
|
||||
config_drive = nova.api.openstack.compute.plugins.v3.config_drive:ConfigDrive
|
||||
|
Loading…
x
Reference in New Issue
Block a user