summaryrefslogtreecommitdiff
path: root/tuskar_ui/infrastructure/nodes/tables.py
blob: 317153b381bbdd6732b91253566b8dc6f3e89c84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- coding: utf8 -*-
#
#    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.

from django.template import defaultfilters as filters
from django.utils.translation import ugettext_lazy as _

from horizon import tables


class NodesTable(tables.DataTable):

    uuid = tables.Column("uuid",
                         verbose_name=_("UUID"))
    mac_addresses = tables.Column("addresses",
                                  verbose_name=_("MAC Addresses"),
                                  wrap_list=True,
                                  filters=(filters.unordered_list,))
    ipmi_address = tables.Column(lambda node: node.driver_info['ipmi_address'],
                                 verbose_name=_("IPMI Address"))
    cpu = tables.Column(lambda node: node.properties['cpu'],
                        verbose_name=_("CPU"))
    ram = tables.Column(lambda node: node.properties['ram'],
                        verbose_name=_("RAM (GB)"))
    local_disk = tables.Column(lambda node: node.properties['local_disk'],
                               verbose_name=_("Local Disk (TB)"))
    status = tables.Column("power_state",
                           verbose_name=_("Status"),
                           status=True,
                           status_choices=(
                               ('on', True),
                               ('off', False),
                               ('rebooting', None)
                           ))

    class Meta:
        name = "nodes_table"
        verbose_name = _("Nodes")
        table_actions = ()
        row_actions = ()

    def get_object_id(self, datum):
        return datum.uuid

    def get_object_display(self, datum):
        return datum.uuid


class FreeNodesTable(NodesTable):

    class Meta:
        name = "free_nodes"
        verbose_name = _("Free Nodes")
        table_actions = ()
        row_actions = ()


class ResourceNodesTable(NodesTable):

    class Meta:
        name = "resource_nodes"
        verbose_name = _("Resource Nodes")
        table_actions = ()
        row_actions = ()