From a6f3090d147a8083f4800e4714b275abfb58ad4d Mon Sep 17 00:00:00 2001 From: huangtianhua Date: Mon, 2 Feb 2015 16:41:52 +0800 Subject: [PATCH] Some small nits for profiles.py --- etc/senlin/policy.json | 1 + senlin/api/openstack/v1/profiles.py | 18 ++++-------------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/etc/senlin/policy.json b/etc/senlin/policy.json index 4b6e31e29..73cdfc378 100644 --- a/etc/senlin/policy.json +++ b/etc/senlin/policy.json @@ -15,6 +15,7 @@ "profiles:create": "", "profiles:get": "rule:admin_or_owner", "profiles:delete": "rule:admin_or_owner", + "profiles:update": "rule:admin_or_owner", "nodes:index": "rule:admin_or_owner", "nodes:create": "", "nodes:get": "rule:admin_or_owner", diff --git a/senlin/api/openstack/v1/profiles.py b/senlin/api/openstack/v1/profiles.py index 3db19d504..b5063797f 100644 --- a/senlin/api/openstack/v1/profiles.py +++ b/senlin/api/openstack/v1/profiles.py @@ -20,14 +20,11 @@ from senlin.api.openstack.v1 import util from senlin.common.i18n import _ from senlin.common import serializers from senlin.common import wsgi -from senlin.openstack.common import log as logging from senlin.rpc import client as rpc_client -LOG = logging.getLogger(__name__) - class ProfileData(object): - '''The data accompanying a PUT/POST request to create/update a profile.''' + '''The data accompanying a POST/PUT request to create/update a profile.''' PARAMS = ( NAME, SPEC, TYPE, PERMISSION, TAGS, @@ -54,14 +51,10 @@ class ProfileData(object): return self.data[self.TYPE] def permission(self): - if self.PERMISSION not in self.data: - return None - return self.data[self.PERMISSION] + return self.data.get(self.PERMISSION) def tags(self): - if self.TAGS not in self.data: - return None - return self.data[self.TAGS] + return self.data.get(self.TAGS) class ProfileController(object): @@ -125,10 +118,7 @@ class ProfileController(object): profile = self.rpc_client.profile_get(req.context, profile_id) - if not profile: - raise exc.HTTPInternalServerError() - - return profile + return {'profile': profile} @util.policy_enforce def update(self, req, profile_id, body):