~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/objects/node.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2015-03-30 11:14:57 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20150330111457-kr4ju3guf22m4vbz
Tags: 2015.1~b3-0ubuntu1
* New upstream release.
  + d/control: 
    - Align with upstream dependencies.
    - Add dh-python to build-dependencies.
    - Add psmisc as a dependency. (LP: #1358820)
  + d/p/fix-requirements.patch: Rediffed.
  + d/ironic-conductor.init.in: Fixed typos in LSB headers,
    thanks to JJ Asghar. (LP: #1429962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#    License for the specific language governing permissions and limitations
14
14
#    under the License.
15
15
 
 
16
from oslo_utils import strutils
 
17
from oslo_utils import uuidutils
 
18
 
16
19
from ironic.common import exception
17
 
from ironic.common import utils
18
20
from ironic.db import api as db_api
19
21
from ironic.objects import base
20
22
from ironic.objects import utils as obj_utils
32
34
    # Version 1.7: Add conductor_affinity
33
35
    # Version 1.8: Add maintenance_reason
34
36
    # Version 1.9: Add driver_internal_info
35
 
    VERSION = '1.9'
 
37
    # Version 1.10: Add name and get_by_name()
 
38
    # Version 1.11: Add clean_step
 
39
    VERSION = '1.11'
36
40
 
37
41
    dbapi = db_api.get_instance()
38
42
 
40
44
            'id': int,
41
45
 
42
46
            'uuid': obj_utils.str_or_none,
 
47
            'name': obj_utils.str_or_none,
43
48
            'chassis_id': obj_utils.int_or_none,
44
49
            'instance_uuid': obj_utils.str_or_none,
45
50
 
47
52
            'driver_info': obj_utils.dict_or_none,
48
53
            'driver_internal_info': obj_utils.dict_or_none,
49
54
 
 
55
            # A clean step dictionary, indicating the current clean step
 
56
            # being executed, or None, indicating cleaning is not in progress
 
57
            # or has not yet started.
 
58
            'clean_step': obj_utils.dict_or_none,
 
59
 
50
60
            'instance_info': obj_utils.dict_or_none,
51
61
            'properties': obj_utils.dict_or_none,
52
62
            'reservation': obj_utils.str_or_none,
75
85
            # that started but failed to finish.
76
86
            'last_error': obj_utils.str_or_none,
77
87
 
 
88
            'inspection_finished_at': obj_utils.datetime_or_str_or_none,
 
89
            'inspection_started_at': obj_utils.datetime_or_str_or_none,
 
90
 
78
91
            'extra': obj_utils.dict_or_none,
79
92
            }
80
93
 
93
106
        :param node_id: the id *or* uuid of a node.
94
107
        :returns: a :class:`Node` object.
95
108
        """
96
 
        if utils.is_int_like(node_id):
 
109
        if strutils.is_int_like(node_id):
97
110
            return cls.get_by_id(context, node_id)
98
 
        elif utils.is_uuid_like(node_id):
 
111
        elif uuidutils.is_uuid_like(node_id):
99
112
            return cls.get_by_uuid(context, node_id)
100
113
        else:
101
114
            raise exception.InvalidIdentity(identity=node_id)
123
136
        return node
124
137
 
125
138
    @base.remotable_classmethod
 
139
    def get_by_name(cls, context, name):
 
140
        """Find a node based on name and return a Node object.
 
141
 
 
142
        :param name: the logical name of a node.
 
143
        :returns: a :class:`Node` object.
 
144
        """
 
145
        db_node = cls.dbapi.get_node_by_name(name)
 
146
        node = Node._from_db_object(cls(context), db_node)
 
147
        return node
 
148
 
 
149
    @base.remotable_classmethod
126
150
    def get_by_instance_uuid(cls, context, instance_uuid):
127
151
        """Find a node based on the instance uuid and return a Node object.
128
152