Access to heat API via python-heatclient
This adds python-heatclient as a dependency and a simple function to get a client reference. Required for blueprint: heat-ui Change-Id: I5f7d8c7c17f6e78d3f88cc39d50826416b48ad2c
This commit is contained in:
parent
6b6f97f7a8
commit
c949b6fbd5
@ -35,6 +35,7 @@ Keystone/Nova/Glance/Swift et. al.
|
|||||||
"""
|
"""
|
||||||
from openstack_dashboard.api import base
|
from openstack_dashboard.api import base
|
||||||
from openstack_dashboard.api import cinder
|
from openstack_dashboard.api import cinder
|
||||||
|
from openstack_dashboard.api import heat
|
||||||
from openstack_dashboard.api import glance
|
from openstack_dashboard.api import glance
|
||||||
from openstack_dashboard.api import keystone
|
from openstack_dashboard.api import keystone
|
||||||
from openstack_dashboard.api import network
|
from openstack_dashboard.api import network
|
||||||
|
85
openstack_dashboard/api/heat.py
Normal file
85
openstack_dashboard/api/heat.py
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||||
|
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from heatclient import client as heat_client
|
||||||
|
from openstack_dashboard.api.base import url_for
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def format_parameters(params):
|
||||||
|
parameters = {}
|
||||||
|
for count, p in enumerate(params, 1):
|
||||||
|
parameters['Parameters.member.%d.ParameterKey' % count] = p
|
||||||
|
parameters['Parameters.member.%d.ParameterValue' % count] = params[p]
|
||||||
|
return parameters
|
||||||
|
|
||||||
|
|
||||||
|
def heatclient(request):
|
||||||
|
api_version = "1"
|
||||||
|
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
|
||||||
|
endpoint = url_for(request, 'orchestration')
|
||||||
|
LOG.debug('heatclient connection created using token "%s" and url "%s"' %
|
||||||
|
(request.user.token.id, endpoint))
|
||||||
|
kwargs = {
|
||||||
|
'token': request.user.token.id,
|
||||||
|
'insecure': insecure,
|
||||||
|
'username': request.user.username
|
||||||
|
#'timeout': args.timeout,
|
||||||
|
#'ca_file': args.ca_file,
|
||||||
|
#'cert_file': args.cert_file,
|
||||||
|
#'key_file': args.key_file,
|
||||||
|
}
|
||||||
|
client = heat_client.Client(api_version, endpoint, **kwargs)
|
||||||
|
client.format_parameters = format_parameters
|
||||||
|
return client
|
||||||
|
|
||||||
|
|
||||||
|
def stacks_list(request):
|
||||||
|
return heatclient(request).stacks.list()
|
||||||
|
|
||||||
|
|
||||||
|
def stack_delete(request, stack_id):
|
||||||
|
return heatclient(request).stacks.delete(stack_id)
|
||||||
|
|
||||||
|
|
||||||
|
def stack_get(request, stack_id):
|
||||||
|
return heatclient(request).stacks.get(stack_id)
|
||||||
|
|
||||||
|
|
||||||
|
def stack_create(request, **kwargs):
|
||||||
|
return heatclient(request).stacks.create(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def events_list(request, stack_name):
|
||||||
|
return heatclient(request).events.list(stack_name)
|
||||||
|
|
||||||
|
|
||||||
|
def resources_list(request, stack_name):
|
||||||
|
return heatclient(request).resources.list(stack_name)
|
||||||
|
|
||||||
|
|
||||||
|
def resource_get(request, stack_id, resource_name):
|
||||||
|
return heatclient(request).resources.get(stack_id, resource_name)
|
||||||
|
|
||||||
|
|
||||||
|
def resource_metadata_get(request, stack_id, resource_name):
|
||||||
|
return heatclient(request).resources.metadata(stack_id, resource_name)
|
||||||
|
|
||||||
|
|
||||||
|
def template_validate(request, **kwargs):
|
||||||
|
return heatclient(request).stacks.validate(**kwargs)
|
@ -6,7 +6,7 @@ set -o errexit
|
|||||||
# Increment me any time the environment should be rebuilt.
|
# Increment me any time the environment should be rebuilt.
|
||||||
# This includes dependncy changes, directory renames, etc.
|
# This includes dependncy changes, directory renames, etc.
|
||||||
# Simple integer secuence: 1, 2, 3...
|
# Simple integer secuence: 1, 2, 3...
|
||||||
environment_version=33
|
environment_version=34
|
||||||
#--------------------------------------------------------#
|
#--------------------------------------------------------#
|
||||||
|
|
||||||
function usage {
|
function usage {
|
||||||
|
@ -9,6 +9,7 @@ iso8601>=0.1.4
|
|||||||
netaddr
|
netaddr
|
||||||
python-cinderclient>=1.0.2,<2.0.0
|
python-cinderclient>=1.0.2,<2.0.0
|
||||||
python-glanceclient<2
|
python-glanceclient<2
|
||||||
|
python-heatclient>=0.2.2
|
||||||
python-keystoneclient>=0.2,<0.3
|
python-keystoneclient>=0.2,<0.3
|
||||||
python-novaclient>=2.12.0,<3
|
python-novaclient>=2.12.0,<3
|
||||||
python-quantumclient>=2.2.0,<3.0.0
|
python-quantumclient>=2.2.0,<3.0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user