Add 'run' attribute to create action
To corresponse 'run' command of python-zunclient, this patch adds 'run' attribute to creation action. Change-Id: I80d478951c019284441093fa50f2d41bd970c473
This commit is contained in:
parent
f44f68aa9f
commit
dc4ed360f8
@ -43,7 +43,11 @@ def zunclient(request):
|
||||
|
||||
def container_create(request, **kwargs):
|
||||
args = {}
|
||||
run = False
|
||||
for (key, value) in kwargs.items():
|
||||
if key == "run":
|
||||
run = value
|
||||
continue
|
||||
if key in CONTAINER_CREATE_ATTRS:
|
||||
args[str(key)] = str(value)
|
||||
else:
|
||||
@ -63,7 +67,12 @@ def container_create(request, **kwargs):
|
||||
kv = v.split("=", 1)
|
||||
labels[kv[0]] = kv[1]
|
||||
args["labels"] = labels
|
||||
return zunclient(request).containers.create(**args)
|
||||
response = None
|
||||
if run:
|
||||
response = zunclient(request).containers.run(**args)
|
||||
else:
|
||||
response = zunclient(request).containers.create(**args)
|
||||
return response
|
||||
|
||||
|
||||
def container_delete(request, id, force=False):
|
||||
|
@ -108,6 +108,7 @@ class Containers(generic.View):
|
||||
"""Create a new Container.
|
||||
|
||||
Returns the new Container object on success.
|
||||
If 'run' attribute is set true, do 'run' instead 'create'
|
||||
"""
|
||||
new_container = client.container_create(request, **request.DATA)
|
||||
return rest_utils.CreatedResponse(
|
||||
|
@ -42,7 +42,8 @@
|
||||
memory: null,
|
||||
environment: null,
|
||||
workdir: null,
|
||||
labels: null
|
||||
labels: null,
|
||||
run: true
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -28,5 +28,14 @@
|
||||
placeholder="{$ 'A command that will be sent to the container.'|translate $}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<div class="themable-checkbox">
|
||||
<input name="container-run" type="checkbox" class="form-control" id="container-run"
|
||||
ng-model="model.newContainerSpec.run">
|
||||
<label class="control-label" for="container-run" translate>Start container after creation</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user