CrayNode.py 2.25 KB
Newer Older
1
2
"""Cray-specific node information"""

3
import logging
4
5
from Cobalt.Components.system.ClusterNode import ClusterNode

6
7
_logger = logging.getLogger(__name__)

8
class CrayNode(ClusterNode):
9
10
11
12
13
14
    '''Extension of ClusterNodes for Cray specific systems.  The first system
    targeted for this node type is Cray's XC-40 KNL nodes.


    Intended for use with ALPS.  Not Native mode.
    '''
15
16
17

    CRAY_STATE_MAP = {'UP': 'idle', 'DOWN':'down', 'UNAVAILABLE':'down',
            'ROUTING':'down', 'SUSPECT':'down', 'ADMIN':'down',
18
            'UNKNOWN':'down', 'UNAVAIL': 'down', 'SWDOWN': 'down',
19
            'REBOOTQ':'down', 'ADMINDOWN':'down'}
20
21
22

    def __init__(self, spec):
        super(CrayNode, self).__init__(spec)
23
        self._status = self.CRAY_STATE_MAP[spec['state'].upper()]
24
        self.node_id = spec['node_id']
25
        self.role = spec['role'].upper()
26
27
        self.attributes['architecture'] = spec['architecture']
        self.segment_details = spec['SocketArray']
28
        self.ALPS_status = 'UNKNOWN' #Assume unknown state.
29
        CrayNode.RESOURCE_STATUSES.append('alps-interactive')
30
31
32
33
34

    def to_dict(self):
        return self.__dict__

    def __str__(self):
35
36
        return str(self.to_dict())

37
38
39
40
41
    def reset_info(self, node):
        '''reset node information on restart from a stored node object'''
        super(CrayNode, self).reset_info(node)
        self.status = node.status

42
43
    @property
    def status(self):
44
        return super(CrayNode, self).status
45
46
47
48
49
50
51
52

    @status.setter
    def status(self, new_status):
        '''set status using cray states, as well as internal state.
        also, coerce to allocated if we are used by something, but still marked
        idle.

        '''
53
54
55
56
        #admin down wins.  If an admin says it's down, it's down.
        if self.admin_down:
            self._status = 'down'
            return
57
58
        if new_status.upper() in self.CRAY_STATE_MAP.keys():
            self._status = self.CRAY_STATE_MAP[new_status.upper()]
59
            self.ALPS_status = new_status
60
        elif new_status in CrayNode.RESOURCE_STATUSES:
61
62
            self._status = new_status
        else:
63
            raise KeyError('%s is not a valid state for Cray Nodes.' % new_status)
64
65
66
        if self._status == 'idle' and self.reserved:
            self.status == 'allocated'