MCPcopy
hub / github.com/rueckstiess/mtools / get_tagged

Method get_tagged

mtools/mlaunch/mlaunch.py:1380–1417  ·  view source on GitHub ↗

Tag format. The format for the tags list is tuples for tags: mongos, config, shard, secondary tags of the form (tag, number), e.g. ('mongos', 2) which references the second mongos in the list. For all other tags, it is simply the string, e.g. 'primary'.

(self, tags)

Source from the content-addressed store, hash-verified

1378 return False
1379
1380 def get_tagged(self, tags):
1381 """
1382 Tag format.
1383
1384 The format for the tags list is tuples for tags: mongos, config, shard,
1385 secondary tags of the form (tag, number), e.g. ('mongos', 2) which
1386 references the second mongos in the list. For all other tags, it is
1387 simply the string, e.g. 'primary'.
1388 """
1389 # if tags is a simple string, make it a list (note: tuples like
1390 # ('mongos', 2) must be in a surrounding list)
1391 if not hasattr(tags, '__iter__') and type(tags) == str:
1392 tags = [tags]
1393
1394 nodes = set(self.cluster_tags['all'])
1395
1396 for tag in tags:
1397 if re.match(r"\w+ \d{1,2}", tag):
1398 # special case for tuple tags: mongos, config, shard,
1399 # secondary. These can contain a number
1400 tag, number = tag.split()
1401
1402 try:
1403 branch = self.cluster_tree[tag][int(number) - 1]
1404 except (IndexError, KeyError):
1405 continue
1406
1407 if hasattr(branch, '__iter__'):
1408 subset = set(branch)
1409 else:
1410 subset = set([branch])
1411 else:
1412 # otherwise use tags dict to get the subset
1413 subset = set(self.cluster_tags[tag])
1414
1415 nodes = nodes.intersection(subset)
1416
1417 return nodes
1418
1419 def get_tags_of_port(self, port):
1420 """

Callers 15

initMethod · 0.95
startMethod · 0.95
listMethod · 0.95
_get_ports_from_argsMethod · 0.95
_get_processesMethod · 0.95
teardown_methodMethod · 0.80
test_single_mongosMethod · 0.80
test_multiple_mongosMethod · 0.80
test_stopMethod · 0.80
test_kill_defaultMethod · 0.80

Calls

no outgoing calls

Tested by 13

teardown_methodMethod · 0.64
test_single_mongosMethod · 0.64
test_multiple_mongosMethod · 0.64
test_stopMethod · 0.64
test_kill_defaultMethod · 0.64
test_kill_sigtermMethod · 0.64
test_kill_sigkillMethod · 0.64
test_stop_startMethod · 0.64
test_kill_partialMethod · 0.64