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)
| 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 | """ |
no outgoing calls