Merge "Add container operations 'reboot', 'pause' and 'unpause'"
This commit is contained in:
commit
340c4d98be
@ -97,3 +97,15 @@ def container_start(request, id):
|
||||
|
||||
def container_stop(request, id):
|
||||
return zunclient(request).containers.stop(id)
|
||||
|
||||
|
||||
def container_reboot(request, id):
|
||||
return zunclient(request).containers.reboot(id)
|
||||
|
||||
|
||||
def container_pause(request, id):
|
||||
return zunclient(request).containers.pause(id)
|
||||
|
||||
|
||||
def container_unpause(request, id):
|
||||
return zunclient(request).containers.unpause(id)
|
||||
|
@ -57,6 +57,12 @@ class ContainerActions(generic.View):
|
||||
return client.container_start(request, id)
|
||||
elif action == 'stop':
|
||||
return client.container_stop(request, id)
|
||||
elif action == 'reboot':
|
||||
return client.container_reboot(request, id)
|
||||
elif action == 'pause':
|
||||
return client.container_pause(request, id)
|
||||
elif action == 'unpause':
|
||||
return client.container_unpause(request, id)
|
||||
|
||||
|
||||
@urls.register
|
||||
|
@ -32,6 +32,9 @@
|
||||
'horizon.dashboard.container.containers.delete.service',
|
||||
'horizon.dashboard.container.containers.start.service',
|
||||
'horizon.dashboard.container.containers.stop.service',
|
||||
'horizon.dashboard.container.containers.reboot.service',
|
||||
'horizon.dashboard.container.containers.pause.service',
|
||||
'horizon.dashboard.container.containers.unpause.service',
|
||||
'horizon.dashboard.container.containers.resourceType',
|
||||
];
|
||||
|
||||
@ -42,6 +45,9 @@
|
||||
deleteContainerService,
|
||||
startContainerService,
|
||||
stopContainerService,
|
||||
rebootContainerService,
|
||||
pauseContainerService,
|
||||
unpauseContainerService,
|
||||
resourceType)
|
||||
{
|
||||
var containersResourceType = registry.getResourceType(resourceType);
|
||||
@ -60,6 +66,27 @@
|
||||
text: gettext('Stop Container')
|
||||
}
|
||||
})
|
||||
.append({
|
||||
id: 'rebootContainerAction',
|
||||
service: rebootContainerService,
|
||||
template: {
|
||||
text: gettext('Reboot Container')
|
||||
}
|
||||
})
|
||||
.append({
|
||||
id: 'pauseContainerAction',
|
||||
service: pauseContainerService,
|
||||
template: {
|
||||
text: gettext('Pause Container')
|
||||
}
|
||||
})
|
||||
.append({
|
||||
id: 'unpauseContainerAction',
|
||||
service: unpauseContainerService,
|
||||
template: {
|
||||
text: gettext('Unpause Container')
|
||||
}
|
||||
})
|
||||
.append({
|
||||
id: 'deleteContainerAction',
|
||||
service: deleteContainerService,
|
||||
|
@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use self 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.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('horizon.dashboard.container.containers')
|
||||
.factory('horizon.dashboard.container.containers.pause.service', pauseService);
|
||||
|
||||
pauseService.$inject = [
|
||||
'horizon.framework.util.q.extensions',
|
||||
'horizon.framework.widgets.toast.service',
|
||||
'horizon.app.core.openstack-service-api.zun',
|
||||
'horizon.framework.widgets.modal-wait-spinner.service'
|
||||
];
|
||||
|
||||
/**
|
||||
* @ngDoc factory
|
||||
* @name horizon.dashboard.container.containers.pause.service
|
||||
* @Description
|
||||
* pause container.
|
||||
*/
|
||||
function pauseService($qExtensions, toast, zun, modalWaitSpinnerService) {
|
||||
|
||||
var message = {
|
||||
success: gettext('Container %s was successfully paused.')
|
||||
};
|
||||
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
allowed: allowed,
|
||||
perform: perform
|
||||
};
|
||||
|
||||
return service;
|
||||
|
||||
//////////////
|
||||
|
||||
// include this function in your service
|
||||
// if you plan to emit events to the parent controller
|
||||
function initScope() {
|
||||
}
|
||||
|
||||
function allowed() {
|
||||
return $qExtensions.booleanAsPromise(true);
|
||||
}
|
||||
|
||||
function perform(selected) {
|
||||
// pause selected container
|
||||
return zun.pauseContainer(selected.id).then(success);
|
||||
|
||||
function success(response) {
|
||||
toast.add('success', interpolate(message.success, [selected.name]));
|
||||
};
|
||||
}
|
||||
}
|
||||
})();
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use self 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.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('horizon.dashboard.container.containers')
|
||||
.factory('horizon.dashboard.container.containers.reboot.service', rebootService);
|
||||
|
||||
rebootService.$inject = [
|
||||
'horizon.framework.util.q.extensions',
|
||||
'horizon.framework.widgets.toast.service',
|
||||
'horizon.app.core.openstack-service-api.zun'
|
||||
];
|
||||
|
||||
/**
|
||||
* @ngDoc factory
|
||||
* @name horizon.dashboard.container.containers.reboot.service
|
||||
* @Description
|
||||
* reboot container.
|
||||
*/
|
||||
function rebootService(
|
||||
$qExtensions, toast, zun
|
||||
) {
|
||||
|
||||
var message = {
|
||||
success: gettext('Container %s was successfully rebooted.')
|
||||
};
|
||||
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
allowed: allowed,
|
||||
perform: perform
|
||||
};
|
||||
|
||||
return service;
|
||||
|
||||
//////////////
|
||||
|
||||
// include this function in your service
|
||||
// if you plan to emit events to the parent controller
|
||||
function initScope() {
|
||||
}
|
||||
|
||||
function allowed() {
|
||||
return $qExtensions.booleanAsPromise(true);
|
||||
}
|
||||
|
||||
function perform(selected) {
|
||||
// reboot selected container
|
||||
return zun.rebootContainer(selected.id).success(function(response) {
|
||||
toast.add('success', interpolate(message.success, [selected.name]));
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use self 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.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
angular
|
||||
.module('horizon.dashboard.container.containers')
|
||||
.factory('horizon.dashboard.container.containers.unpause.service', unpauseService);
|
||||
|
||||
unpauseService.$inject = [
|
||||
'horizon.framework.util.q.extensions',
|
||||
'horizon.framework.widgets.toast.service',
|
||||
'horizon.app.core.openstack-service-api.zun'
|
||||
];
|
||||
|
||||
/**
|
||||
* @ngDoc factory
|
||||
* @name horizon.dashboard.container.containers.unpause.service
|
||||
* @Description
|
||||
* unpause container.
|
||||
*/
|
||||
function unpauseService(
|
||||
$qExtensions, toast, zun
|
||||
) {
|
||||
|
||||
var message = {
|
||||
success: gettext('Container %s was successfully unpaused.')
|
||||
};
|
||||
|
||||
var service = {
|
||||
initScope: initScope,
|
||||
allowed: allowed,
|
||||
perform: perform
|
||||
};
|
||||
|
||||
return service;
|
||||
|
||||
//////////////
|
||||
|
||||
// include this function in your service
|
||||
// if you plan to emit events to the parent controller
|
||||
function initScope() {
|
||||
}
|
||||
|
||||
function allowed() {
|
||||
return $qExtensions.booleanAsPromise(true);
|
||||
}
|
||||
|
||||
function perform(selected) {
|
||||
// unpause selected container
|
||||
return zun.unpauseContainer(selected.id).success(function(response) {
|
||||
toast.add('success', interpolate(message.success, [selected.name]));
|
||||
});
|
||||
}
|
||||
}
|
||||
})();
|
@ -34,6 +34,9 @@
|
||||
startContainer: startContainer,
|
||||
stopContainer: stopContainer,
|
||||
logsContainer: logsContainer,
|
||||
rebootContainer: rebootContainer,
|
||||
pauseContainer: pauseContainer,
|
||||
unpauseContainer: unpauseContainer
|
||||
};
|
||||
|
||||
return service;
|
||||
@ -128,5 +131,26 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rebootContainer(id) {
|
||||
return apiService.post('/api/zun/containers/' + id + '/reboot')
|
||||
.error(function() {
|
||||
toastService.add('error', gettext('Unable to reboot Container'));
|
||||
});
|
||||
}
|
||||
|
||||
function pauseContainer(id) {
|
||||
return apiService.post('/api/zun/containers/' + id + '/pause')
|
||||
.error(function() {
|
||||
toastService.add('error', gettext('Unable to pause Container'));
|
||||
});
|
||||
}
|
||||
|
||||
function unpauseContainer(id) {
|
||||
return apiService.post('/api/zun/containers/' + id + '/unpause')
|
||||
.error(function() {
|
||||
toastService.add('error', gettext('Unable to unpause of Container'));
|
||||
});
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
Loading…
Reference in New Issue
Block a user