Fix update action

This patch fixes patch creation for updating. Also, for that, the model
for update request from UI should have server_type attribute.

Change-Id: I9b2cabb42036077236374c839e854d5357302684
This commit is contained in:
Shu Muto 2017-07-21 14:53:23 +09:00
parent 39c504bd6f
commit 05f2ca6e5d
3 changed files with 15 additions and 3 deletions

View File

@ -34,14 +34,17 @@ CLUSTER_CREATE_ATTRS = clusters.CREATION_ATTRIBUTES
CERTIFICATE_CREATE_ATTRS = certificates.CREATION_ATTRIBUTES
def _cleanup_params(attrs, check, **params):
def _cleanup_params(attrs, create, **params):
args = {}
for (key, value) in params.items():
if key in attrs:
if value is None:
value = ''
if create:
value = ''
else:
continue
args[str(key)] = str(value)
elif check:
elif create:
raise exceptions.BadRequest(
"Key must be in %s" % ",".join(attrs))
if key == "labels":
@ -66,6 +69,7 @@ def _create_patches(old, new):
# new = {'a': 'A', 'c': 'c', 'd': None, 'e': '', 'f': 'F'}
# patch = [
# {'op': 'add', 'path': '/f', 'value': 'F'}
# {'op': 'remove', 'path': '/b'},
# {'op': 'remove', 'path': '/e'},
# {'op': 'remove', 'path': '/d'},
# {'op': 'replace', 'path': '/c', 'value': 'c'}
@ -84,6 +88,11 @@ def _create_patches(old, new):
elif key not in old:
patch.append({'op': 'add', 'path': path, 'value': new[key]})
for key in old:
path = '/' + key
if key not in new:
patch.append({'op': 'remove', 'path': path})
return patch

View File

@ -67,6 +67,8 @@
? response.data.name : "";
config.model.coe = response.data.coe
? response.data.coe : "";
config.model.server_type = response.data.server_type
? response.data.server_type : "";
config.model.public = response.data.public
? response.data.public : false;
config.model.registry_enabled = response.data.registry_enabled

View File

@ -445,6 +445,7 @@
model = {
name: "",
coe: "",
server_type: "",
public: "",
registry_enabled: "",
tls_disabled: "",