Fixed bugs in profile create/update
- A new context parameter is added for profile create; - Added default value (None) to name param in profile_update; - Fixed spec update logic errors -- the previous way of update was not working at all; - Fixed typo in updating tags for a profile.
This commit is contained in:
parent
274deb6d06
commit
f1df78619c
|
@ -10,13 +10,14 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import copy
|
||||||
import functools
|
import functools
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import oslo_messaging
|
import oslo_messaging
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
import six
|
||||||
|
|
||||||
from senlin.common import consts
|
from senlin.common import consts
|
||||||
from senlin.common import context
|
from senlin.common import context
|
||||||
|
@ -178,7 +179,7 @@ class EngineService(service.Service):
|
||||||
|
|
||||||
@request_context
|
@request_context
|
||||||
def profile_list(self, context, limit=None, marker=None, sort_keys=None,
|
def profile_list(self, context, limit=None, marker=None, sort_keys=None,
|
||||||
sort_dir=None, filters=None, show_deleted=None):
|
sort_dir=None, filters=None, show_deleted=False):
|
||||||
profiles = profile_base.Profile.load_all(context, limit=limit,
|
profiles = profile_base.Profile.load_all(context, limit=limit,
|
||||||
marker=marker,
|
marker=marker,
|
||||||
sort_keys=sort_keys,
|
sort_keys=sort_keys,
|
||||||
|
@ -198,7 +199,7 @@ class EngineService(service.Service):
|
||||||
'permission': perm,
|
'permission': perm,
|
||||||
'tags': tags,
|
'tags': tags,
|
||||||
}
|
}
|
||||||
profile = plugin(type, name, **kwargs)
|
profile = plugin(context, type, name, **kwargs)
|
||||||
profile.validate()
|
profile.validate()
|
||||||
profile.store(context)
|
profile.store(context)
|
||||||
return profile.to_dict()
|
return profile.to_dict()
|
||||||
|
@ -210,7 +211,7 @@ class EngineService(service.Service):
|
||||||
return profile.to_dict()
|
return profile.to_dict()
|
||||||
|
|
||||||
@request_context
|
@request_context
|
||||||
def profile_update(self, context, profile_id, name, spec=None,
|
def profile_update(self, context, profile_id, name=None, spec=None,
|
||||||
permission=None, tags=None):
|
permission=None, tags=None):
|
||||||
db_profile = self.profile_find(context, profile_id)
|
db_profile = self.profile_find(context, profile_id)
|
||||||
if spec is None:
|
if spec is None:
|
||||||
|
@ -231,14 +232,16 @@ class EngineService(service.Service):
|
||||||
|
|
||||||
plugin = environment.global_env().get_profile(db_profile.type)
|
plugin = environment.global_env().get_profile(db_profile.type)
|
||||||
|
|
||||||
new_spec = db_profile.spec.update(spec)
|
new_spec = copy.deepcopy(db_profile.spec)
|
||||||
|
new_spec.update(spec)
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'spec': new_spec,
|
'spec': new_spec,
|
||||||
'permission': permission or db_profile.permission,
|
'permission': permission or db_profile.permission,
|
||||||
'tags': tags or db_profile.permission,
|
'tags': tags or db_profile.tags,
|
||||||
}
|
}
|
||||||
|
|
||||||
profile = plugin(db_profile.type, name, **kwargs)
|
new_name = name or db_profile.name
|
||||||
|
profile = plugin(context, db_profile.type, new_name, **kwargs)
|
||||||
profile.validate()
|
profile.validate()
|
||||||
profile.store(context)
|
profile.store(context)
|
||||||
return profile.to_dict()
|
return profile.to_dict()
|
||||||
|
|
Loading…
Reference in New Issue