summaryrefslogtreecommitdiff
path: root/ironic/objects/conductor.py
diff options
context:
space:
mode:
authorKaifeng Wang <kaifeng.w@gmail.com>2018-11-23 17:12:03 +0800
committerKaifeng Wang <kaifeng.w@gmail.com>2018-11-29 10:25:16 +0800
commite2a768f0cd2abf6f2ac456949a8c46628b27b5ef (patch)
tree1720abdd541c51c74973ff2d7ecf1da02f962de7 /ironic/objects/conductor.py
parentc5414620c5c3bd9b7085fd64f1dac40e83ec22df (diff)
downloadironic-e2a768f0cd2abf6f2ac456949a8c46628b27b5ef.tar.gz
Expose conductors: db and rpc
This patch lays some ground work around db and rpc to provide conductors information from the API. Changes in the db api and Conductor object is used to support the implementation of /v1/conductors. Adds an argument "online" to Conductor.get_by_hostname, so that we can get the conductor object from database even it's not online, this is required for the implementation of /v1/conductors/{hostname}. Adds a new interface get_conductor_for() to get the hostname of the conductor which is servicing the given node, it will be used for the implementation of /v1/nodes* endpoints, as well as listing nodes by given conductor. Story: 1724474 Task: 28064 Change-Id: I39a7a47c5ae649f6c3200e772a9357023f21a7c4
Diffstat (limited to 'ironic/objects/conductor.py')
-rw-r--r--ironic/objects/conductor.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/ironic/objects/conductor.py b/ironic/objects/conductor.py
index 78c8937a2..0c0e991a6 100644
--- a/ironic/objects/conductor.py
+++ b/ironic/objects/conductor.py
@@ -42,20 +42,42 @@ class Conductor(base.IronicObject, object_base.VersionedObjectDictCompat):
'conductor_group': object_fields.StringField(),
}
+ @classmethod
+ def list(cls, context, limit=None, marker=None, sort_key=None,
+ sort_dir=None):
+ """Return a list of Conductor objects.
+
+ :param cls: the :class:`Conductor`
+ :param context: Security context.
+ :param limit: maximum number of resources to return in a single result.
+ :param marker: pagination marker for large data sets.
+ :param sort_key: column to sort results by.
+ :param sort_dir: direction to sort. "asc" or "desc".
+ :returns: a list of :class:`Conductor` object.
+ """
+ db_conductors = cls.dbapi.get_conductor_list(limit=limit,
+ marker=marker,
+ sort_key=sort_key,
+ sort_dir=sort_dir)
+ return cls._from_db_object_list(context, db_conductors)
+
# NOTE(xek): We don't want to enable RPC on this call just yet. Remotable
# methods can be used in the future to replace current explicit RPC calls.
# Implications of calling new remote procedures should be thought through.
# @object_base.remotable_classmethod
@classmethod
- def get_by_hostname(cls, context, hostname):
+ def get_by_hostname(cls, context, hostname, online=True):
"""Get a Conductor record by its hostname.
:param cls: the :class:`Conductor`
:param context: Security context
:param hostname: the hostname on which a Conductor is running
+ :param online: Specify the expected ``online`` field value for the
+ conductor to be retrieved. The ``online`` field is
+ ignored if this value is set to None.
:returns: a :class:`Conductor` object.
"""
- db_obj = cls.dbapi.get_conductor(hostname)
+ db_obj = cls.dbapi.get_conductor(hostname, online=online)
conductor = cls._from_db_object(context, cls(), db_obj)
return conductor