Skip to content

Commit

Permalink
Introduce order in detect_scan command (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexTalker authored and jgrund committed Jan 8, 2019
1 parent f90710e commit ad7de14
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion chroma_agent/action_plugins/detect_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, target_devices):
# when we see a combined MGS+MDT
uuid_name_to_target = {}

for device in target_devices:
for device in sorted(target_devices, cmp=LocalTargets.comparator):
block_device = BlockDevice(device["type"], device["path"])

# If the target_device has no uuid then it doesn't have a filesystem and is of no use to use, but
Expand Down Expand Up @@ -80,6 +80,18 @@ def __init__(self, target_devices):

self.targets = uuid_name_to_target.values()

@classmethod
def comparator(cls, a, b):
value = cmp(a["type"], b["type"])

if value == 0:
value = cmp(a["uuid"], b["uuid"])

if value == 0:
value = cmp(a["path"], b["path"])

return value


class MgsTargets(object):
TARGET_NAME_REGEX = "([\w-]+)-(MDT|OST)\w+"
Expand Down

0 comments on commit ad7de14

Please sign in to comment.