| 1 |
import re |
| 2 |
|
| 3 |
|
| 4 |
def facts_personality(junos, facts): |
| 5 |
model = facts["model"] |
| 6 |
|
| 7 |
if model != "Virtual Chassis": |
| 8 |
examine = model |
| 9 |
else: |
| 10 |
for fact in facts: |
| 11 |
if re.match(r"^RE\d", fact): |
| 12 |
examine = facts[fact]["model"] |
| 13 |
break |
| 14 |
|
| 15 |
examine = examine.upper() |
| 16 |
|
| 17 |
if re.match("^(EX)|(QFX)", examine): |
| 18 |
persona = "SWITCH" |
| 19 |
elif examine.startswith("MX"): |
| 20 |
persona = "MX" |
| 21 |
elif examine.startswith("VMX"): |
| 22 |
facts["virtual"] = True |
| 23 |
persona = "MX" |
| 24 |
elif examine.startswith("VJX"): |
| 25 |
facts["virtual"] = True |
| 26 |
persona = "SRX_BRANCH" |
| 27 |
elif "VRR" == examine: |
| 28 |
persona = "MX" |
| 29 |
facts["virtual"] = True |
| 30 |
elif examine.startswith("M"): |
| 31 |
persona = "M" |
| 32 |
elif examine.startswith("T"): |
| 33 |
persona = "T" |
| 34 |
elif examine.startswith("PTX"): |
| 35 |
persona = "PTX" |
| 36 |
elif re.match(r"SRX\s?(\d){4}", examine): |
| 37 |
persona = "SRX_HIGHEND" |
| 38 |
elif re.match(r"SRX\s?(\d){3}", examine): |
| 39 |
persona = "SRX_BRANCH" |
| 40 |
elif re.search("firefly", examine, re.IGNORECASE): |
| 41 |
facts["virtual"] = True |
| 42 |
persona = "SRX_BRANCH" |
| 43 |
elif "OLIVE" == examine: |
| 44 |
facts["virtual"] = True |
| 45 |
persona = "OLIVE" |
| 46 |
else: |
| 47 |
persona = "UNKNOWN" |
| 48 |
|
| 49 |
facts["personality"] = persona |