Do not use non-existent 'app_id' attr in Environment->Services

Also make a couple of small fixes related to recent changes in murano-api.

Change-Id: Ia1002bd2d25eb479cc2abd81322ac851ea52e155
This commit is contained in:
Timur Sufiev 2014-04-18 19:54:11 +04:00 committed by Gerrit Code Review
parent 39212bd497
commit b3c6ac0f13
4 changed files with 16 additions and 20 deletions

View File

@ -12,8 +12,11 @@
# License for the specific language governing permissions and limitations
# under the License.
import re
import json
import copy
import logging
import re
from django import forms
from django.core.validators import RegexValidator, validate_ipv4_address
from netaddr import all_matching_cidrs, IPNetwork, IPAddress
@ -24,9 +27,6 @@ from horizon import exceptions, messages
from openstack_dashboard.api import glance
from openstack_dashboard.api.nova import novaclient
from django.template.defaultfilters import pluralize
import copy
import types
import logging
import horizon.tables as tables
import horizon.forms as hz_forms
import floppyforms
@ -669,7 +669,7 @@ def make_select_cls(fqn):
raise KeyError(msg.format(fqn))
self.widget.add_item_link_args = (environment_id, app_id)
self.choices = [('', _('Select Application'))]
apps = api.service_list_by_id(request, environment_id, app_id)
apps = api.service_list_by_fqn(request, environment_id, fqn)
self.choices.extend([(app['?']['id'], app.name) for app in apps])
return DynamicSelect

View File

@ -18,7 +18,6 @@ from django.conf import settings
from horizon.exceptions import ServiceCatalogException
from openstack_dashboard.api.base import url_for
import muranoclient.client as client
from muranodashboard.dynamic_ui.services import get_service_name
from muranoclient.common.exceptions import HTTPForbidden, HTTPNotFound
from consts import STATUS_ID_READY, STATUS_ID_NEW
from .network import get_network_params
@ -238,8 +237,6 @@ def services_list(request, environment_id):
for service_item in environment.services:
service_data = service_item
service_id = service_data['?']['id']
service_data['full_service_name'] = get_service_name(
request, service_data['app_id'])
if service_id in reports and reports[service_id]:
last_operation = strip(str(reports[service_id].text))
@ -267,17 +264,17 @@ def app_id_by_fqn(request, fqn):
return apps[0].id if apps else None
def service_list_by_id(request, environment_id, app_id):
def service_list_by_fqn(request, environment_id, fqn):
services = services_list(request, environment_id)
LOG.debug('Service::Instances::List')
return [service for service in services if service['app_id'] == app_id]
return [service for service in services if service['?']['type'] == fqn]
def service_create(request, environment_id, parameters):
# we should be able to delete session
# if we what add new services to this environment
session_id = Session.get_or_create_or_delete(request, environment_id)
LOG.debug('Service::Create {0}'.format(parameters['app_id']))
LOG.debug('Service::Create {0}'.format(parameters['?']['type']))
return muranoclient(request).services.post(environment_id,
path='/',
data=parameters,
@ -335,12 +332,7 @@ def get_deployment_descr(request, environment_id, deployment_id):
LOG.debug('Get deployment description')
for deployment in deployments:
if deployment.id == deployment_id:
descr = deployment.description
if 'services' in descr:
for service in descr['services']:
service['full_service_name'] = get_service_name(
request, service['app_id'])
return descr
return deployment.description
return None

View File

@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import tempfile
import os
from django.conf import settings
@ -30,7 +30,7 @@ IMAGE_CACHE_DIR = getattr(settings, 'IMAGE_CACHE_DIR',
CACHE_REFRESH_SECONDS_INTERVAL = 5
DASHBOARD_ATTRS_KEY = '26411a1861294160833743e45d0eaad9'
DASHBOARD_ATTRS_KEY = '_26411a1861294160833743e45d0eaad9'
#---- Forms Consts ----#
STATUS_ID_READY = 'ready'

View File

@ -244,12 +244,16 @@ def get_service_details_link(service):
args=(service.environment_id, service['?']['id']))
def get_service_type(datum):
return datum['?'].get(consts.DASHBOARD_ATTRS_KEY, {}).get('name')
class ServicesTable(tables.DataTable):
name = tables.Column('name',
verbose_name=_('Name'),
link=get_service_details_link)
_type = tables.Column('full_service_name',
_type = tables.Column(get_service_type,
verbose_name=_('Type'))
status = tables.Column('status',