dashboard增加删除虚拟机按钮 博客分类: openstack
程序员文章站
2024-03-13 19:23:21
...
vim tables.py 新加如下内容
定义删除动作:
3.注册删除按钮
from django.utils.translation import ungettext_lazy from openstack_dashboard import policy
定义删除动作:
class DeleteSnapshotAction(policy.PolicyTargetMixin, tables.DeleteAction): @staticmethod def action_present(count): return ungettext_lazy( u"Delete Snapshot", u"Delete Snapshots", count ) @staticmethod def action_past(count): return ungettext_lazy( u"Deleted Snapshot", u"Deleted Snapshots", count ) #policy_rules = (("identity", "identity:delete_project"),) policy_rules = (("identity", "identity:delete_user"),) def allowed(self, request, datum): # if not api.keystone.keystone_can_edit_user() or \ # (datum and datum.id == request.user.id): # return False return True def delete(self, request, obj_id): LOG.info("dedebeeeeeeeeeeeeeeeeeeee!") api.nova.server_delete(request, obj_id) LOG.info("afterrrrrrrrrrrrrrrrrrrr!")
3.注册删除按钮
row_actions = (CreateSnapshotAction,DeleteSnapshotAction,)