Add containers panel for admin
Add containers panel into admin dashboard with actions that restricted for admin. In details view, admin should not see logs tab and console tab. Allowed actions for admin - update - rebuild - start / stop / restart - kill - delete with force Not allowed actions for admin - create - manage security group - pause / unpause - execute - delete - delete with stop Not allowed view for admin - logs tab on details view - console tab on details view To enable containers panel for admin, copy following[1] into horizon's enabled folder[2]. [1] zun_ui/enabled/_2333_admin_container_containers_panel.py [2] openstack_dashboard/local/enabled/ Change-Id: I1f96464b0103e099bd58bc2889087e1b55f4ed97 Implement: blueprint add-admin-containers-panel
This commit is contained in:
parent
eac9c36117
commit
c2ffde0903
@ -21,3 +21,8 @@ from zun_ui.api import rest_api # noqa: F401
|
|||||||
class Containers(horizon.Panel):
|
class Containers(horizon.Panel):
|
||||||
name = _("Containers")
|
name = _("Containers")
|
||||||
slug = "container.containers"
|
slug = "container.containers"
|
||||||
|
|
||||||
|
|
||||||
|
class ContainersForAdmin(horizon.Panel):
|
||||||
|
name = _("Containers")
|
||||||
|
slug = "container.containers"
|
||||||
|
21
zun_ui/enabled/_2333_admin_container_containers_panel.py
Normal file
21
zun_ui/enabled/_2333_admin_container_containers_panel.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
# The slug of the panel to be added to HORIZON_CONFIG. Required.
|
||||||
|
PANEL = 'container.containers'
|
||||||
|
# The slug of the panel group the PANEL is associated with.
|
||||||
|
PANEL_GROUP = 'container'
|
||||||
|
# The slug of the dashboard the PANEL associated with. Required.
|
||||||
|
PANEL_DASHBOARD = 'admin'
|
||||||
|
|
||||||
|
# Python panel class of the PANEL to be added.
|
||||||
|
ADD_PANEL = 'zun_ui.content.container.containers.panel.ContainersForAdmin'
|
@ -25,8 +25,10 @@
|
|||||||
.factory('horizon.dashboard.container.containers.create.service', createService);
|
.factory('horizon.dashboard.container.containers.create.service', createService);
|
||||||
|
|
||||||
createService.$inject = [
|
createService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.policy',
|
'horizon.app.core.openstack-service-api.policy',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.workflow',
|
'horizon.dashboard.container.containers.workflow',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
@ -37,7 +39,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function createService(
|
function createService(
|
||||||
policy, zun, resourceType, workflow,
|
$q, policy, zun, adminActions, resourceType, workflow,
|
||||||
actionResult, gettext, $qExtensions, modal, toast
|
actionResult, gettext, $qExtensions, modal, toast
|
||||||
) {
|
) {
|
||||||
var message = {
|
var message = {
|
||||||
@ -66,7 +68,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed() {
|
function allowed() {
|
||||||
return policy.ifAllowed({ rules: [['container', 'add_container']] });
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("create") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
policy.ifAllowed({ rules: [['container', 'add_container']] }),
|
||||||
|
$qExtensions.booleanAsPromise(adminAction)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function submit(context) {
|
function submit(context) {
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
'horizon.framework.util.q.extensions',
|
'horizon.framework.util.q.extensions',
|
||||||
'horizon.framework.widgets.modal.deleteModalService',
|
'horizon.framework.widgets.modal.deleteModalService',
|
||||||
'horizon.framework.widgets.toast.service',
|
'horizon.framework.widgets.toast.service',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.events',
|
'horizon.dashboard.container.containers.events',
|
||||||
'horizon.dashboard.container.containers.validStates'
|
'horizon.dashboard.container.containers.validStates'
|
||||||
@ -44,7 +45,7 @@
|
|||||||
|
|
||||||
function deleteForceService(
|
function deleteForceService(
|
||||||
$location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
|
$location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
|
||||||
toast, resourceType, events, validStates
|
toast, adminActions, resourceType, events, validStates
|
||||||
) {
|
) {
|
||||||
var scope;
|
var scope;
|
||||||
var context = {
|
var context = {
|
||||||
@ -67,9 +68,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("delete_force") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.delete_force.indexOf(container.status) >= 0
|
validStates.delete_force.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete selected resource objects
|
// delete selected resource objects
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
'horizon.framework.util.q.extensions',
|
'horizon.framework.util.q.extensions',
|
||||||
'horizon.framework.widgets.modal.deleteModalService',
|
'horizon.framework.widgets.modal.deleteModalService',
|
||||||
'horizon.framework.widgets.toast.service',
|
'horizon.framework.widgets.toast.service',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.events',
|
'horizon.dashboard.container.containers.events',
|
||||||
'horizon.dashboard.container.containers.validStates'
|
'horizon.dashboard.container.containers.validStates'
|
||||||
@ -44,7 +45,7 @@
|
|||||||
|
|
||||||
function deleteStopService(
|
function deleteStopService(
|
||||||
$location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
|
$location, $q, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
|
||||||
toast, resourceType, events, validStates
|
toast, adminActions, resourceType, events, validStates
|
||||||
) {
|
) {
|
||||||
var scope;
|
var scope;
|
||||||
var context = {
|
var context = {
|
||||||
@ -67,9 +68,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("delete_stop") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.delete_stop.indexOf(container.status) >= 0
|
validStates.delete_stop.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete selected resource objects
|
// delete selected resource objects
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
'horizon.framework.widgets.modal.deleteModalService',
|
'horizon.framework.widgets.modal.deleteModalService',
|
||||||
'horizon.framework.widgets.table.events',
|
'horizon.framework.widgets.table.events',
|
||||||
'horizon.framework.widgets.toast.service',
|
'horizon.framework.widgets.toast.service',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.events',
|
'horizon.dashboard.container.containers.events',
|
||||||
'horizon.dashboard.container.containers.validStates'
|
'horizon.dashboard.container.containers.validStates'
|
||||||
@ -46,7 +47,7 @@
|
|||||||
|
|
||||||
function deleteService(
|
function deleteService(
|
||||||
$location, $q, $rootScope, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
|
$location, $q, $rootScope, zun, policy, actionResult, gettext, $qExtensions, deleteModal,
|
||||||
tableEvents, toast, resourceType, events, validStates
|
tableEvents, toast, adminActions, resourceType, events, validStates
|
||||||
) {
|
) {
|
||||||
var scope;
|
var scope;
|
||||||
var context = {
|
var context = {
|
||||||
@ -69,15 +70,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("delete") >= 0;
|
||||||
|
}
|
||||||
// only row actions pass in container
|
// only row actions pass in container
|
||||||
// otherwise, assume it is a batch action
|
// otherwise, assume it is a batch action
|
||||||
|
var state;
|
||||||
if (container) {
|
if (container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
state = $qExtensions.booleanAsPromise(
|
||||||
validStates.delete.indexOf(container.status) >= 0
|
validStates.delete.indexOf(container.status) >= 0
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return $qExtensions.booleanAsPromise(true);
|
state = $qExtensions.booleanAsPromise(true);
|
||||||
}
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
state
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete selected resource objects
|
// delete selected resource objects
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
executeContainerService);
|
executeContainerService);
|
||||||
|
|
||||||
executeContainerService.$inject = [
|
executeContainerService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
@ -40,7 +42,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function executeContainerService(
|
function executeContainerService(
|
||||||
zun, resourceType, validStates, actionResult, gettext, $qExtensions, modal, waitSpinner, toast
|
$q, zun, adminActions, resourceType, validStates, actionResult,
|
||||||
|
gettext, $qExtensions, modal, waitSpinner, toast
|
||||||
) {
|
) {
|
||||||
// schema
|
// schema
|
||||||
var schema = {
|
var schema = {
|
||||||
@ -123,9 +126,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("execute") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.execute.indexOf(container.status) >= 0
|
validStates.execute.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -28,7 +28,9 @@
|
|||||||
killContainerService);
|
killContainerService);
|
||||||
|
|
||||||
killContainerService.$inject = [
|
killContainerService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.basePath',
|
'horizon.dashboard.container.containers.basePath',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
@ -40,7 +42,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function killContainerService(
|
function killContainerService(
|
||||||
zun, basePath, resourceType, validStates, actionResult, gettext, $qExtensions, modal, toast
|
$q, zun, adminActions, basePath, resourceType, validStates,
|
||||||
|
actionResult, gettext, $qExtensions, modal, toast
|
||||||
) {
|
) {
|
||||||
// schema
|
// schema
|
||||||
var schema = {
|
var schema = {
|
||||||
@ -98,9 +101,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("kill") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.kill.indexOf(container.status) >= 0
|
validStates.kill.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -21,10 +21,12 @@
|
|||||||
manageSecurityGroup);
|
manageSecurityGroup);
|
||||||
|
|
||||||
manageSecurityGroup.$inject = [
|
manageSecurityGroup.$inject = [
|
||||||
|
"$q",
|
||||||
"horizon.app.core.openstack-service-api.neutron",
|
"horizon.app.core.openstack-service-api.neutron",
|
||||||
"horizon.app.core.openstack-service-api.security-group",
|
"horizon.app.core.openstack-service-api.security-group",
|
||||||
"horizon.app.core.openstack-service-api.zun",
|
"horizon.app.core.openstack-service-api.zun",
|
||||||
"horizon.dashboard.container.basePath",
|
"horizon.dashboard.container.basePath",
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
@ -35,8 +37,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function manageSecurityGroup(
|
function manageSecurityGroup(
|
||||||
neutron, securityGroup, zun, basePath, resourceType, validStates, actionResult,
|
$q, neutron, securityGroup, zun, basePath, adminActions, resourceType, validStates,
|
||||||
gettext, $qExtensions, modal, toast
|
actionResult, gettext, $qExtensions, modal, toast
|
||||||
) {
|
) {
|
||||||
// title for dialog
|
// title for dialog
|
||||||
var title = gettext("Manage Security Groups: container %s");
|
var title = gettext("Manage Security Groups: container %s");
|
||||||
@ -93,9 +95,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("manage_security_groups") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.manage_security_groups.indexOf(container.status) >= 0
|
validStates.manage_security_groups.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
.factory('horizon.dashboard.container.containers.pause.service', pauseService);
|
.factory('horizon.dashboard.container.containers.pause.service', pauseService);
|
||||||
|
|
||||||
pauseService.$inject = [
|
pauseService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
@ -35,7 +37,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function pauseService(
|
function pauseService(
|
||||||
zun, resourceType, validStates, actionResult, $qExtensions, toast
|
$q, zun, adminActions, resourceType, validStates, actionResult, $qExtensions, toast
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
@ -58,9 +60,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("pause") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.pause.indexOf(container.status) >= 0
|
validStates.pause.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
.factory('horizon.dashboard.container.containers.rebuild.service', rebuildService);
|
.factory('horizon.dashboard.container.containers.rebuild.service', rebuildService);
|
||||||
|
|
||||||
rebuildService.$inject = [
|
rebuildService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.basePath',
|
'horizon.dashboard.container.containers.basePath',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
@ -38,7 +40,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function rebuildService(
|
function rebuildService(
|
||||||
zun, basePath, resourceType, validStates, actionResult, gettext, $qExtensions, modal, toast
|
$q, zun, adminActions, basePath, resourceType, validStates,
|
||||||
|
actionResult, gettext, $qExtensions, modal, toast
|
||||||
) {
|
) {
|
||||||
var imageDrivers = [
|
var imageDrivers = [
|
||||||
{value: "", name: gettext("Select image driver for changing image.")},
|
{value: "", name: gettext("Select image driver for changing image.")},
|
||||||
@ -115,9 +118,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("rebuild") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.rebuild.indexOf(container.status) >= 0
|
validStates.rebuild.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
.factory('horizon.dashboard.container.containers.restart.service', restartService);
|
.factory('horizon.dashboard.container.containers.restart.service', restartService);
|
||||||
|
|
||||||
restartService.$inject = [
|
restartService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.basePath',
|
'horizon.dashboard.container.containers.basePath',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
@ -38,7 +40,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function restartService(
|
function restartService(
|
||||||
zun, basePath, resourceType, validStates, actionResult, gettext, $qExtensions, modal, toast
|
$q, zun, adminActions, basePath, resourceType, validStates,
|
||||||
|
actionResult, gettext, $qExtensions, modal, toast
|
||||||
) {
|
) {
|
||||||
// schema
|
// schema
|
||||||
var schema = {
|
var schema = {
|
||||||
@ -95,9 +98,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("restart") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.restart.indexOf(container.status) >= 0
|
validStates.restart.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
.factory('horizon.dashboard.container.containers.start.service', startService);
|
.factory('horizon.dashboard.container.containers.start.service', startService);
|
||||||
|
|
||||||
startService.$inject = [
|
startService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
@ -35,7 +37,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function startService(
|
function startService(
|
||||||
zun, resourceType, validStates, actionResult, $qExtensions, toast
|
$q, zun, adminActions, resourceType, validStates, actionResult, $qExtensions, toast
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
@ -58,9 +60,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("start") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.start.indexOf(container.status) >= 0
|
validStates.start.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
.factory('horizon.dashboard.container.containers.stop.service', stopService);
|
.factory('horizon.dashboard.container.containers.stop.service', stopService);
|
||||||
|
|
||||||
stopService.$inject = [
|
stopService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.basePath',
|
'horizon.dashboard.container.containers.basePath',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
@ -38,7 +40,8 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function stopService(
|
function stopService(
|
||||||
zun, basePath, resourceType, validStates, actionResult, gettext, $qExtensions, modal, toast
|
$q, zun, adminActions, basePath, resourceType, validStates,
|
||||||
|
actionResult, gettext, $qExtensions, modal, toast
|
||||||
) {
|
) {
|
||||||
// schema
|
// schema
|
||||||
var schema = {
|
var schema = {
|
||||||
@ -95,9 +98,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("stop") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.stop.indexOf(container.status) >= 0
|
validStates.stop.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -26,7 +26,9 @@
|
|||||||
.factory('horizon.dashboard.container.containers.unpause.service', unpauseService);
|
.factory('horizon.dashboard.container.containers.unpause.service', unpauseService);
|
||||||
|
|
||||||
unpauseService.$inject = [
|
unpauseService.$inject = [
|
||||||
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
'horizon.framework.util.actions.action-result.service',
|
'horizon.framework.util.actions.action-result.service',
|
||||||
@ -35,7 +37,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function unpauseService(
|
function unpauseService(
|
||||||
zun, resourceType, validStates, actionResult, $qExtensions, toast
|
$q, zun, adminActions, resourceType, validStates, actionResult, $qExtensions, toast
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
@ -58,9 +60,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
return $qExtensions.booleanAsPromise(
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("unpause") >= 0;
|
||||||
|
}
|
||||||
|
return $q.all([
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.unpause.indexOf(container.status) >= 0
|
validStates.unpause.indexOf(container.status) >= 0
|
||||||
);
|
)
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function perform(selected) {
|
function perform(selected) {
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
'$q',
|
'$q',
|
||||||
'horizon.app.core.openstack-service-api.policy',
|
'horizon.app.core.openstack-service-api.policy',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.dashboard.container.containers.adminActions',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.validStates',
|
'horizon.dashboard.container.containers.validStates',
|
||||||
'horizon.dashboard.container.containers.workflow',
|
'horizon.dashboard.container.containers.workflow',
|
||||||
@ -39,7 +40,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function updateService(
|
function updateService(
|
||||||
$q, policy, zun, resourceType, validStates, workflow,
|
$q, policy, zun, adminActions, resourceType, validStates, workflow,
|
||||||
actionResult, gettext, $qExtensions, modal, toast
|
actionResult, gettext, $qExtensions, modal, toast
|
||||||
) {
|
) {
|
||||||
var message = {
|
var message = {
|
||||||
@ -70,8 +71,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function allowed(container) {
|
function allowed(container) {
|
||||||
|
var adminAction = true;
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
adminAction = adminActions.indexOf("update") >= 0;
|
||||||
|
}
|
||||||
return $q.all([
|
return $q.all([
|
||||||
policy.ifAllowed({ rules: [['container', 'edit_container']] }),
|
policy.ifAllowed({ rules: [['container', 'edit_container']] }),
|
||||||
|
$qExtensions.booleanAsPromise(adminAction),
|
||||||
$qExtensions.booleanAsPromise(
|
$qExtensions.booleanAsPromise(
|
||||||
validStates.update.indexOf(container.status) >= 0
|
validStates.update.indexOf(container.status) >= 0
|
||||||
)
|
)
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
])
|
])
|
||||||
.constant('horizon.dashboard.container.containers.events', events())
|
.constant('horizon.dashboard.container.containers.events', events())
|
||||||
.constant('horizon.dashboard.container.containers.validStates', validStates())
|
.constant('horizon.dashboard.container.containers.validStates', validStates())
|
||||||
|
.constant('horizon.dashboard.container.containers.adminActions', adminActions())
|
||||||
.constant('horizon.dashboard.container.containers.resourceType', 'OS::Zun::Container')
|
.constant('horizon.dashboard.container.containers.resourceType', 'OS::Zun::Container')
|
||||||
.run(run)
|
.run(run)
|
||||||
.config(config);
|
.config(config);
|
||||||
@ -66,6 +67,10 @@
|
|||||||
execute: [states.RUNNING],
|
execute: [states.RUNNING],
|
||||||
kill: [states.RUNNING],
|
kill: [states.RUNNING],
|
||||||
delete: [states.CREATED, states.ERROR, states.STOPPED, states.DELETED, states.DEAD],
|
delete: [states.CREATED, states.ERROR, states.STOPPED, states.DELETED, states.DEAD],
|
||||||
|
/* NOTE(shu-mutow): Docker does not allow us to delete PAUSED container.
|
||||||
|
* There are ways to delete paused container in server,
|
||||||
|
* but we are according to Docker's policy as now.
|
||||||
|
*/
|
||||||
delete_force: [
|
delete_force: [
|
||||||
states.CREATED, states.CREATING, states.ERROR, states.RUNNING,
|
states.CREATED, states.CREATING, states.ERROR, states.RUNNING,
|
||||||
states.STOPPED, states.UNKNOWN, states.DELETED, states.DEAD,
|
states.STOPPED, states.UNKNOWN, states.DELETED, states.DEAD,
|
||||||
@ -79,6 +84,10 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function adminActions() {
|
||||||
|
return ["update", "start", "stop", "restart", "rebuild", "kill", "delete_force"];
|
||||||
|
}
|
||||||
|
|
||||||
run.$inject = [
|
run.$inject = [
|
||||||
'horizon.framework.conf.resource-type-registry.service',
|
'horizon.framework.conf.resource-type-registry.service',
|
||||||
'horizon.app.core.openstack-service-api.zun',
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
@ -91,7 +100,7 @@
|
|||||||
registry.getResourceType(resourceType)
|
registry.getResourceType(resourceType)
|
||||||
.setNames(gettext('Container'), gettext('Containers'))
|
.setNames(gettext('Container'), gettext('Containers'))
|
||||||
.setSummaryTemplateUrl(basePath + 'details/drawer.html')
|
.setSummaryTemplateUrl(basePath + 'details/drawer.html')
|
||||||
.setDefaultIndexUrl('/project/container/containers/')
|
.setDefaultIndexUrl(containerService.getDefaultIndexUrl())
|
||||||
.setProperties(containerProperties())
|
.setProperties(containerProperties())
|
||||||
.setListFunction(containerService.getContainersPromise)
|
.setListFunction(containerService.getContainersPromise)
|
||||||
.tableColumns
|
.tableColumns
|
||||||
@ -196,7 +205,11 @@
|
|||||||
function config($provide, $windowProvider, $routeProvider) {
|
function config($provide, $windowProvider, $routeProvider) {
|
||||||
var path = $windowProvider.$get().STATIC_URL + 'dashboard/container/containers/';
|
var path = $windowProvider.$get().STATIC_URL + 'dashboard/container/containers/';
|
||||||
$provide.constant('horizon.dashboard.container.containers.basePath', path);
|
$provide.constant('horizon.dashboard.container.containers.basePath', path);
|
||||||
$routeProvider.when('/project/container/containers', {
|
$routeProvider
|
||||||
|
.when('/project/container/containers', {
|
||||||
|
templateUrl: path + 'panel.html'
|
||||||
|
})
|
||||||
|
.when('/admin/container/containers', {
|
||||||
templateUrl: path + 'panel.html'
|
templateUrl: path + 'panel.html'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,10 @@
|
|||||||
.factory('horizon.dashboard.container.containers.service', containersService);
|
.factory('horizon.dashboard.container.containers.service', containersService);
|
||||||
|
|
||||||
containersService.$inject = [
|
containersService.$inject = [
|
||||||
|
'$location',
|
||||||
'horizon.app.core.detailRoute',
|
'horizon.app.core.detailRoute',
|
||||||
'horizon.app.core.openstack-service-api.zun'
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
|
'horizon.framework.util.navigations.service'
|
||||||
];
|
];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -31,13 +33,30 @@
|
|||||||
* This service provides functions that are used through
|
* This service provides functions that are used through
|
||||||
* the containers features.
|
* the containers features.
|
||||||
*/
|
*/
|
||||||
function containersService(detailRoute, zun) {
|
function containersService($location, detailRoute, zun, navigation) {
|
||||||
return {
|
return {
|
||||||
|
getDefaultIndexUrl: getDefaultIndexUrl,
|
||||||
getDetailsPath: getDetailsPath,
|
getDetailsPath: getDetailsPath,
|
||||||
getContainerPromise: getContainerPromise,
|
getContainerPromise: getContainerPromise,
|
||||||
getContainersPromise: getContainersPromise
|
getContainersPromise: getContainersPromise
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getDefaultIndexUrl() {
|
||||||
|
var dashboard, breadcrumbDashboard;
|
||||||
|
var path = "/container/containers";
|
||||||
|
if (zun.isAdmin()) {
|
||||||
|
dashboard = "/admin";
|
||||||
|
breadcrumbDashboard = gettext("Admin");
|
||||||
|
} else {
|
||||||
|
dashboard = "/project";
|
||||||
|
breadcrumbDashboard = gettext("Project");
|
||||||
|
}
|
||||||
|
var url = dashboard + path + "/";
|
||||||
|
navigation.setBreadcrumb([
|
||||||
|
breadcrumbDashboard, gettext("Container"), gettext("Containers")]);
|
||||||
|
navigation.expandNavigationByUrl(url);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* @ngdoc function
|
* @ngdoc function
|
||||||
* @name getDetailsPath
|
* @name getDetailsPath
|
||||||
@ -46,7 +65,11 @@
|
|||||||
* Returns the relative path to the details view.
|
* Returns the relative path to the details view.
|
||||||
*/
|
*/
|
||||||
function getDetailsPath(item) {
|
function getDetailsPath(item) {
|
||||||
return detailRoute + 'OS::Zun::Container/' + item.id;
|
var detailsPath = detailRoute + 'OS::Zun::Container/' + item.id;
|
||||||
|
if ($location.url() === '/admin/container/containers') {
|
||||||
|
detailsPath = detailsPath + "?nav=/admin/container/containers/";
|
||||||
|
}
|
||||||
|
return detailsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
.run(registerDetails);
|
.run(registerDetails);
|
||||||
|
|
||||||
registerDetails.$inject = [
|
registerDetails.$inject = [
|
||||||
|
'horizon.app.core.openstack-service-api.zun',
|
||||||
'horizon.dashboard.container.containers.basePath',
|
'horizon.dashboard.container.containers.basePath',
|
||||||
'horizon.dashboard.container.containers.resourceType',
|
'horizon.dashboard.container.containers.resourceType',
|
||||||
'horizon.dashboard.container.containers.service',
|
'horizon.dashboard.container.containers.service',
|
||||||
@ -34,6 +35,7 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
function registerDetails(
|
function registerDetails(
|
||||||
|
zun,
|
||||||
basePath,
|
basePath,
|
||||||
resourceType,
|
resourceType,
|
||||||
containerService,
|
containerService,
|
||||||
@ -46,7 +48,10 @@
|
|||||||
id: 'containerDetailsOverview',
|
id: 'containerDetailsOverview',
|
||||||
name: gettext('Overview'),
|
name: gettext('Overview'),
|
||||||
template: basePath + 'details/overview.html'
|
template: basePath + 'details/overview.html'
|
||||||
})
|
});
|
||||||
|
if (!zun.isAdmin()) {
|
||||||
|
registry.getResourceType(resourceType)
|
||||||
|
.detailsViews
|
||||||
.append({
|
.append({
|
||||||
id: 'containerDetailsLogs',
|
id: 'containerDetailsLogs',
|
||||||
name: gettext('Logs'),
|
name: gettext('Logs'),
|
||||||
@ -58,5 +63,6 @@
|
|||||||
template: basePath + 'details/console.html'
|
template: basePath + 'details/console.html'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -19,12 +19,13 @@
|
|||||||
.factory('horizon.app.core.openstack-service-api.zun', ZunAPI);
|
.factory('horizon.app.core.openstack-service-api.zun', ZunAPI);
|
||||||
|
|
||||||
ZunAPI.$inject = [
|
ZunAPI.$inject = [
|
||||||
|
'$location',
|
||||||
'horizon.framework.util.http.service',
|
'horizon.framework.util.http.service',
|
||||||
'horizon.framework.widgets.toast.service',
|
'horizon.framework.widgets.toast.service',
|
||||||
'horizon.framework.util.i18n.gettext'
|
'horizon.framework.util.i18n.gettext'
|
||||||
];
|
];
|
||||||
|
|
||||||
function ZunAPI(apiService, toastService, gettext) {
|
function ZunAPI($location, apiService, toastService, gettext) {
|
||||||
var containersPath = '/api/zun/containers/';
|
var containersPath = '/api/zun/containers/';
|
||||||
var zunAvailabilityZonesPath = '/api/zun/availability_zones/';
|
var zunAvailabilityZonesPath = '/api/zun/availability_zones/';
|
||||||
var capsulesPath = '/api/zun/capsules/';
|
var capsulesPath = '/api/zun/capsules/';
|
||||||
@ -61,7 +62,8 @@
|
|||||||
getImages: getImages,
|
getImages: getImages,
|
||||||
deleteImage: deleteImage,
|
deleteImage: deleteImage,
|
||||||
getHosts: getHosts,
|
getHosts: getHosts,
|
||||||
getHost: getHost
|
getHost: getHost,
|
||||||
|
isAdmin: isAdmin
|
||||||
};
|
};
|
||||||
return service;
|
return service;
|
||||||
|
|
||||||
@ -270,5 +272,15 @@
|
|||||||
toastService.add('error', message);
|
toastService.add('error', message);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isAdmin() {
|
||||||
|
var isAdmin = false;
|
||||||
|
if ($location.url().startsWith("/admin") ||
|
||||||
|
$location.url().endsWith("?nav=%2Fadmin%2Fcontainer%2Fcontainers%2F")
|
||||||
|
) {
|
||||||
|
isAdmin = true;
|
||||||
|
}
|
||||||
|
return isAdmin;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user