OpenStack Orchestration (Heat)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
3.8 KiB

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from webob import exc
from heat.api.openstack.v1 import util
from heat.common import serializers
from heat.common import wsgi
from heat.rpc import client as rpc_client
class SoftwareDeploymentController(object):
"""WSGI controller for Software deployments in Heat v1 API.
Implements the API actions.
REQUEST_SCOPE = 'software_deployments'
def __init__(self, options):
self.options = options
self.rpc_client = rpc_client.EngineClient()
def default(self, req, **args):
raise exc.HTTPNotFound()
def index(self, req):
"""List software deployments."""
whitelist = {
'server_id': util.PARAM_TYPE_SINGLE,
params = util.get_allowed_params(req.params, whitelist)
sds = self.rpc_client.list_software_deployments(req.context, **params)
return {'software_deployments': sds}
def metadata(self, req, server_id):
"""List software deployments grouped by the group name.
This is done for the requested server.
sds = self.rpc_client.metadata_software_deployments(
req.context, server_id=server_id)
return {'metadata': sds}
def show(self, req, deployment_id):
"""Gets detailed information for a software deployment."""
sd = self.rpc_client.show_software_deployment(req.context,
return {'software_deployment': sd}
def create(self, req, body):
"""Create a new software deployment."""
create_data = dict((k, body.get(k)) for k in (
'config_id', 'server_id', 'input_values',
'action', 'status', 'status_reason', 'stack_user_project_id'))
sd = self.rpc_client.create_software_deployment(req.context,
return {'software_deployment': sd}
def update(self, req, deployment_id, body):
"""Update an existing software deployment."""
update_data = dict((k, body.get(k)) for k in (
'config_id', 'input_values', 'output_values', 'action',
'status', 'status_reason')
if body.get(k, None) is not None)
sd = self.rpc_client.update_software_deployment(req.context,
return {'software_deployment': sd}
def delete(self, req, deployment_id):
"""Delete an existing software deployment."""
res = self.rpc_client.delete_software_deployment(req.context,
if res is not None:
raise exc.HTTPBadRequest(res['Error'])
raise exc.HTTPNoContent()
def create_resource(options):
"""Software deployments resource factory method."""
deserializer = wsgi.JSONRequestDeserializer()
serializer = serializers.JSONResponseSerializer()
return wsgi.Resource(
SoftwareDeploymentController(options), deserializer, serializer)