Commit 96431562 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Switch to Haskell for group queries

This patch removes the group query implementation
in python in order to use the new Haskell implementation.
Signed-off-by: default avatarHelga Velroyen <>
Reviewed-by: default avatarHrvoje Ribicic <>
parent fbde16f0
......@@ -28,7 +28,6 @@ from ganeti import constants
from ganeti import errors
from ganeti import locking
from ganeti import objects
from ganeti import qlang
from ganeti import query
from ganeti import utils
from ganeti.masterd import iallocator
......@@ -289,80 +288,13 @@ class GroupQuery(QueryBase):
def ExpandNames(self, lu):
lu.needed_locks = {}
self._all_groups = lu.cfg.GetAllNodeGroupsInfo()
self._cluster = lu.cfg.GetClusterInfo()
name_to_uuid = dict((, g.uuid) for g in self._all_groups.values())
if not self.names:
self.wanted = [name_to_uuid[name]
for name in utils.NiceSort(name_to_uuid.keys())]
# Accept names to be either names or UUIDs.
missing = []
self.wanted = []
all_uuid = frozenset(self._all_groups.keys())
for name in self.names:
if name in all_uuid:
elif name in name_to_uuid:
if missing:
raise errors.OpPrereqError("Some groups do not exist: %s" %
raise NotImplementedError
def DeclareLocks(self, lu, level):
def _GetQueryData(self, lu):
"""Computes the list of node groups and their attributes.
do_nodes = query.GQ_NODE in self.requested_data
do_instances = query.GQ_INST in self.requested_data
group_to_nodes = None
group_to_instances = None
# For GQ_NODE, we need to map group->[nodes], and group->[instances] for
# GQ_INST. The former is attainable with just GetAllNodesInfo(), but for the
# latter GetAllInstancesInfo() is not enough, for we have to go through
# instance->node. Hence, we will need to process nodes even if we only need
# instance information.
if do_nodes or do_instances:
all_nodes = lu.cfg.GetAllNodesInfo()
group_to_nodes = dict((uuid, []) for uuid in self.wanted)
node_to_group = {}
for node in all_nodes.values():
if in group_to_nodes:
node_to_group[node.uuid] =
if do_instances:
all_instances = lu.cfg.GetAllInstancesInfo()
group_to_instances = dict((uuid, []) for uuid in self.wanted)
for instance in all_instances.values():
node = instance.primary_node
if node in node_to_group:
if not do_nodes:
# Do not pass on node information if it was not requested.
group_to_nodes = None
return query.GroupQueryData(self._cluster,
for uuid in self.wanted],
group_to_nodes, group_to_instances,
query.GQ_DISKPARAMS in self.requested_data)
raise NotImplementedError
class LUGroupQuery(NoHooksLU):
......@@ -372,17 +304,16 @@ class LUGroupQuery(NoHooksLU):
REQ_BGL = False
def CheckArguments(self): = GroupQuery(qlang.MakeSimpleFilter("name", self.op.names),
self.op.output_fields, False)
raise NotImplementedError
def ExpandNames(self):
raise NotImplementedError
def DeclareLocks(self, level):, level)
raise NotImplementedError
def Exec(self, feedback_fn):
raise NotImplementedError
class LUGroupSetParams(LogicalUnit):
......@@ -26,7 +26,6 @@ from ganeti import errors
from ganeti import query
from ganeti.cmdlib.base import NoHooksLU
from ganeti.cmdlib.cluster import ClusterQuery
from import GroupQuery
from ganeti.cmdlib.instance_query import InstanceQuery
from ganeti.cmdlib.misc import ExtStorageQuery
from ganeti.cmdlib.operating_system import OsQuery
......@@ -36,7 +35,6 @@ from ganeti.cmdlib.operating_system import OsQuery
constants.QR_CLUSTER: ClusterQuery,
constants.QR_INSTANCE: InstanceQuery,
constants.QR_GROUP: GroupQuery,
constants.QR_OS: OsQuery,
constants.QR_EXTSTORAGE: ExtStorageQuery,
......@@ -3338,13 +3338,13 @@ qrViaOp :: FrozenSet String
qrViaOp =
ConstantUtils.mkSet [qrCluster,
-- | List of resources which can be queried using Local UniX Interface
qrViaLuxi :: FrozenSet String
qrViaLuxi = ConstantUtils.mkSet [qrExport,
qrViaLuxi = ConstantUtils.mkSet [qrGroup,
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment