diff --git a/openstack_dashboard/static/app/core/images/actions/launch-instance.service.js b/openstack_dashboard/static/app/core/images/actions/launch-instance.service.js index e54fd072d1..5a6ced5fdd 100644 --- a/openstack_dashboard/static/app/core/images/actions/launch-instance.service.js +++ b/openstack_dashboard/static/app/core/images/actions/launch-instance.service.js @@ -23,6 +23,7 @@ launchInstanceService.$inject = [ '$q', 'horizon.app.core.images.non_bootable_image_types', + 'horizon.app.core.openstack-service-api.policy', 'horizon.dashboard.project.workflow.launch-instance.modal.service', 'horizon.framework.util.q.extensions' ]; @@ -44,6 +45,7 @@ function launchInstanceService( $q, nonBootableImageTypes, + policy, launchInstanceModal, $qExtensions ) { @@ -66,7 +68,11 @@ } function allowed(image) { - return $q.all([isBootable(image), isActive(image)]); + return $q.all([ + isBootable(image), + isActive(image), + policy.ifAllowed({ rules: [['compute', 'compute:create']] }) + ]); } function isActive(image) { diff --git a/openstack_dashboard/static/app/core/images/actions/launch-instance.service.spec.js b/openstack_dashboard/static/app/core/images/actions/launch-instance.service.spec.js index 91f8dbab71..fa40ed54c1 100644 --- a/openstack_dashboard/static/app/core/images/actions/launch-instance.service.spec.js +++ b/openstack_dashboard/static/app/core/images/actions/launch-instance.service.spec.js @@ -22,6 +22,16 @@ open: function () {} }; + var policyAPI = { + ifAllowed: function() { + return { + success: function(callback) { + callback({allowed: true}); + } + }; + } + }; + var service, $scope; /////////////////////// @@ -31,6 +41,7 @@ $provide.value( 'horizon.dashboard.project.workflow.launch-instance.modal.service', launchInstanceModalMock ); + $provide.value('horizon.app.core.openstack-service-api.policy', policyAPI); })); beforeEach(inject(function($injector, _$rootScope_) {