OpenStack Dashboard (Horizon)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tables.py 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # vim: tabstop=4 shiftwidth=4 softtabstop=4
  2. # Copyright 2012 Nebula, Inc.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. import logging
  16. from django.utils.translation import ugettext as _
  17. from horizon import api
  18. from horizon import tables
  19. LOG = logging.getLogger(__name__)
  20. class DeleteKeyPairs(tables.DeleteAction):
  21. data_type_singular = _("Keypair")
  22. data_type_plural = _("Keypairs")
  23. def delete(self, request, obj_id):
  24. api.nova.keypair_delete(request, obj_id)
  25. class ImportKeyPair(tables.LinkAction):
  26. name = "import"
  27. verbose_name = _("Import Keypair")
  28. url = "horizon:nova:access_and_security:keypairs:import"
  29. attrs = {"class": "ajax-modal btn"}
  30. class CreateKeyPair(tables.LinkAction):
  31. name = "create"
  32. verbose_name = _("Create Keypair")
  33. url = "horizon:nova:access_and_security:keypairs:create"
  34. attrs = {"class": "ajax-modal btn"}
  35. class KeypairsTable(tables.DataTable):
  36. name = tables.Column("name")
  37. fingerprint = tables.Column("fingerprint")
  38. def get_object_id(self, keypair):
  39. return keypair.name
  40. class Meta:
  41. name = "keypairs"
  42. verbose_name = _("Keypairs")
  43. table_actions = (CreateKeyPair, ImportKeyPair, DeleteKeyPairs,)
  44. row_actions = (DeleteKeyPairs,)