Add parameters for container creation
This patch adds 'auto_remove', 'hostname' and 'runtime' parameters for container creation. Also, adds these parameters into details view. These parameters are not for update, so these are readonly in update dialog. Change-Id: I011008023158dabf6f69b3b1695d6ed3eaed849d Implements: blueprint add-create-options-for-queens
This commit is contained in:
parent
20c1196e2c
commit
a4cb8d1f24
@ -15,6 +15,7 @@ from horizon import exceptions
|
||||
from horizon.utils.memoized import memoized_with_request
|
||||
import logging
|
||||
from openstack_dashboard.api import base
|
||||
from zunclient import api_versions
|
||||
from zunclient.common import utils
|
||||
from zunclient.v1 import client as zun_client
|
||||
|
||||
@ -23,6 +24,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
CONTAINER_CREATE_ATTRS = zun_client.containers.CREATION_ATTRIBUTES
|
||||
IMAGE_PULL_ATTRS = zun_client.images.PULL_ATTRIBUTES
|
||||
API_VERSION = api_versions.APIVersion(api_versions.DEFAULT_API_VERSION)
|
||||
|
||||
|
||||
def get_auth_params_from_request(request):
|
||||
@ -58,7 +60,8 @@ def zunclient(request_auth_params):
|
||||
c = zun_client.Client(username=username,
|
||||
project_id=project_id,
|
||||
auth_token=token_id,
|
||||
endpoint_override=endpoint_override)
|
||||
endpoint_override=endpoint_override,
|
||||
api_version=API_VERSION)
|
||||
return c
|
||||
|
||||
|
||||
@ -74,7 +77,8 @@ def _cleanup_params(attrs, check, **params):
|
||||
elif key == "memory":
|
||||
args[key] = int(value)
|
||||
elif key == "interactive" or key == "nets" \
|
||||
or key == "security_groups" or key == "hints":
|
||||
or key == "security_groups" or key == "hints"\
|
||||
or key == "auto_remove":
|
||||
args[key] = value
|
||||
elif key == "restart_policy":
|
||||
args[key] = utils.check_restart_policy(value)
|
||||
|
@ -104,7 +104,7 @@
|
||||
// Not only "null", blank too.
|
||||
for (var key in model) {
|
||||
if (model.hasOwnProperty(key) && model[key] === null || model[key] === "" ||
|
||||
key === "tabs") {
|
||||
key === "tabs" || (key === "auto_remove" && model[key] === false)) {
|
||||
delete model[key];
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,8 @@
|
||||
? response.data.image_pull_policy : "";
|
||||
config.model.command = response.data.command
|
||||
? response.data.command : "";
|
||||
config.model.hostname = response.data.hostname
|
||||
? response.data.hostname : "";
|
||||
config.model.cpu = response.data.cpu
|
||||
? response.data.cpu : "";
|
||||
config.model.memory = response.data.memory
|
||||
@ -87,12 +89,16 @@
|
||||
? response.data.restart_policy.Name : "";
|
||||
config.model.restart_policy_max_retry = response.data.restart_policy.MaximumRetryCount
|
||||
? parseInt(response.data.restart_policy.MaximumRetryCount, 10) : null;
|
||||
config.model.runtime = response.data.runtime
|
||||
? response.data.runtime : "";
|
||||
config.model.workdir = response.data.workdir
|
||||
? response.data.workdir : "";
|
||||
config.model.environment = response.data.environment
|
||||
? hashToString(response.data.environment) : "";
|
||||
config.model.interactive = response.data.interactive
|
||||
? response.data.interactive : false;
|
||||
config.model.auto_remove = response.data.auto_remove
|
||||
? response.data.auto_remove : false;
|
||||
config.model.labels = response.data.labels
|
||||
? hashToString(response.data.labels) : "";
|
||||
}
|
||||
|
@ -4,5 +4,7 @@
|
||||
<dt translate>Environment Variables</dt>
|
||||
<dd translate>The environment variables in comma separated KEY=VALUE pairs</dd>
|
||||
<dt translate>Enable Interactive Mode</dt>
|
||||
<dd translate>Allocate pseudo-TTY and keep STDIN open even if not attatched. This also enables Web console in console tab on details view.</dd>
|
||||
<dd translate>Allocate pseudo-TTY and keep STDIN open even if not attached. This also enables Web console in console tab on details view.</dd>
|
||||
<dt translate>Auto remove</dt>
|
||||
<dd translate>Automatically remove the container when it exits</dd>
|
||||
</dl>
|
||||
|
@ -5,4 +5,6 @@
|
||||
<dd translate>The container memory size in MiB.</dd>
|
||||
<dt translate>Restart Policy</dt>
|
||||
<dd translate>Restart policy to apply when a container exits.</dd>
|
||||
<dt translate>Restart Policy</dt>
|
||||
<dd translate>The runtime to use for this container. Default: "runc"</dd>
|
||||
</dl>
|
||||
|
@ -51,6 +51,10 @@
|
||||
{value: "always", name: gettext("Always")},
|
||||
{value: "unless-stopped", name: gettext("Unless Stopped")}
|
||||
];
|
||||
var runtimes = [
|
||||
{value: "", name: gettext("Select runtime.")},
|
||||
{value: "runc", name: gettext("runc")}
|
||||
];
|
||||
|
||||
// schema
|
||||
schema = {
|
||||
@ -92,6 +96,10 @@
|
||||
type: "number",
|
||||
minimum: 4
|
||||
},
|
||||
hostname: {
|
||||
title: gettext("Hostname"),
|
||||
type: "string"
|
||||
},
|
||||
restart_policy: {
|
||||
title: gettext("Restart Policy"),
|
||||
type: "string"
|
||||
@ -101,6 +109,10 @@
|
||||
type: "number",
|
||||
minimum: 0
|
||||
},
|
||||
runtime: {
|
||||
title: gettext("Runtime"),
|
||||
type: "string"
|
||||
},
|
||||
// misc
|
||||
workdir: {
|
||||
title: gettext("Working Directory"),
|
||||
@ -114,6 +126,10 @@
|
||||
title: gettext("Enable interactive mode"),
|
||||
type: "boolean"
|
||||
},
|
||||
auto_remove: {
|
||||
title: gettext("Auto remove"),
|
||||
type: "boolean"
|
||||
},
|
||||
// labels
|
||||
labels: {
|
||||
title: gettext("Labels"),
|
||||
@ -183,8 +199,7 @@
|
||||
},
|
||||
{
|
||||
key: "run",
|
||||
readonly: action === "update",
|
||||
condition: action === "update"
|
||||
readonly: action === "update"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -199,12 +214,29 @@
|
||||
{
|
||||
type: "section",
|
||||
htmlClass: "col-xs-12",
|
||||
items: [
|
||||
{
|
||||
key: "hostname",
|
||||
placeholder: gettext("The host name of this container."),
|
||||
readonly: action === "update"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
htmlClass: "col-xs-6",
|
||||
items: [
|
||||
{
|
||||
key: "cpu",
|
||||
step: 0.1,
|
||||
placeholder: gettext("The number of virtual cpu for this container.")
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
htmlClass: "col-xs-6",
|
||||
items: [
|
||||
{
|
||||
key: "memory",
|
||||
placeholder: gettext("The container memory size in MiB.")
|
||||
@ -225,7 +257,7 @@
|
||||
if (readonly) {
|
||||
model.restart_policy_max_retry = "";
|
||||
}
|
||||
form[0].tabs[1].items[2].items[0].readonly = readonly;
|
||||
form[0].tabs[1].items[4].items[0].readonly = readonly;
|
||||
}
|
||||
}
|
||||
]
|
||||
@ -240,6 +272,18 @@
|
||||
readonly: true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
type: "section",
|
||||
htmlClass: "col-xs-6",
|
||||
items: [
|
||||
{
|
||||
key: "runtime",
|
||||
type: "select",
|
||||
readonly: action === "update",
|
||||
titleMap: runtimes
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@ -327,6 +371,10 @@
|
||||
{
|
||||
key: "interactive",
|
||||
readonly: action === "update"
|
||||
},
|
||||
{
|
||||
key: "auto_remove",
|
||||
readonly: action === "update"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -387,10 +435,12 @@
|
||||
command: "",
|
||||
run: true,
|
||||
// spec
|
||||
hostname: "",
|
||||
cpu: "",
|
||||
memory: "",
|
||||
restart_policy: "",
|
||||
restart_policy_max_retry: "",
|
||||
runtime: "",
|
||||
// networks
|
||||
networks: [],
|
||||
// ports
|
||||
@ -401,6 +451,7 @@
|
||||
workdir: "",
|
||||
environment: "",
|
||||
interactive: true,
|
||||
auto_remove: false,
|
||||
// labels
|
||||
labels: "",
|
||||
// hints
|
||||
|
@ -143,6 +143,7 @@
|
||||
function containerProperties() {
|
||||
return {
|
||||
'addresses': { label: gettext('Addresses'), filters: ['noValue', 'json'] },
|
||||
'auto_remove': { label: gettext('Auto Remove'), filters: ['yesno'] },
|
||||
'command': { label: gettext('Command'), filters: ['noValue'] },
|
||||
'cpu': { label: gettext('CPU'), filters: ['noValue'] },
|
||||
'environment': { label: gettext('Environment'), filters: ['noValue', 'json'] },
|
||||
@ -152,17 +153,18 @@
|
||||
'image': {label: gettext('Image'), filters: ['noValue'] },
|
||||
'image_driver': {label: gettext('Image Driver'), filters: ['noValue'] },
|
||||
'image_pull_policy': {label: gettext('Image Pull Policy'), filters: ['noValue'] },
|
||||
'interactive': {label: gettext('Interactive'), filters: ['yesno'] },
|
||||
'labels': {label: gettext('Labels'), filters: ['noValue', 'json'] },
|
||||
'links': {label: gettext('Links'), filters: ['noValue', 'json'] },
|
||||
'memory': {label: gettext('Memory'), filters: ['noValue'] },
|
||||
'name': {label: gettext('Name'), filters: ['noName'] },
|
||||
'ports': {label: gettext('Ports'), filters: ['noValue', 'json'] },
|
||||
'security_groups': {label: gettext('Security Groups'), filters: ['noValue', 'json'] },
|
||||
'restart_policy': {label: gettext('Restart Policy'), filters: ['noValue', 'json'] },
|
||||
'runtime': {label: gettext('Runtime'), filters: ['noName'] },
|
||||
'security_groups': {label: gettext('Security Groups'), filters: ['noValue', 'json'] },
|
||||
'status': {label: gettext('Status'), filters: ['noValue'] },
|
||||
'status_detail': {label: gettext('Status Detail'), filters: ['noValue'] },
|
||||
'status_reason': {label: gettext('Status Reason'), filters: ['noValue'] },
|
||||
'interactive': {label: gettext('Interactive'), filters: ['yesno'] },
|
||||
'task_state': {label: gettext('Task State'), filters: ['noValue'] },
|
||||
'workdir': {label: gettext('Workdir'), filters: ['noValue'] }
|
||||
};
|
||||
|
@ -19,7 +19,7 @@
|
||||
cls="dl-horizontal"
|
||||
item="ctrl.container"
|
||||
property-groups="[['image', 'image_driver', 'image_pull_policy',
|
||||
'cpu', 'memory', 'restart_policy',
|
||||
'cpu', 'memory', 'restart_policy', 'runtime',
|
||||
'hostname', 'addresses', 'ports', 'security_groups']]">
|
||||
</hz-resource-property-list>
|
||||
</div>
|
||||
@ -33,7 +33,7 @@
|
||||
cls="dl-horizontal"
|
||||
item="ctrl.container"
|
||||
property-groups="[['host', 'workdir', 'environment', 'interactive',
|
||||
'labels','links']]">
|
||||
'auto_remove', 'labels','links']]">
|
||||
</hz-resource-property-list>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user