import re

def personality( junos, facts ):
  
  model = facts['model']

  examine = model if model != 'Virtual Chassis' else facts['RE0']['model']

  if re.match("^(EX)|(QFX)", examine):
    persona = 'SWITCH'
  elif examine.startswith("MX"):
    persona = 'MX'
  elif examine.startswith("vMX"):
    facts['virtual'] = True
    persona = 'MX'
  elif examine.startswith("VJX"):
    facts['virtual'] = True
    persona = 'SRX_BRANCH'
  elif examine.startswith("M"):
    persona = "M"
  elif re.match("SRX\s?(\d){4}", examine):
    persona = 'SRX_HIGHEND'    
  elif re.match("SRX\s?(\d){3}", examine):
    persona = 'SRX_BRANCH'
  elif re.search("firefly", examine, re.IGNORECASE):
    facts['virtual'] = True
    persona = 'SRX_BRANCH'
  else:
    raise RuntimeError("Unknown device persona: %s" % examine)
  
  facts['personality'] = persona

@@ -72,24 +72,8 @@
 %0A%0A  
-examine = model 
 if m
@@ -101,35 +101,147 @@
 sis'
- else facts%5B'RE0'%5D%5B'model'%5D
+:%0A    examine = model%0A  else:%0A    for fact in facts:%0A      if re.match(%22%5ERE%5Cd%22, fact):%0A        examine = facts%5Bfact%5D%5B'model'%5D%0A        break
 %0A%0A  

Fix personality fact gathering for 'Virtual Chassis' without 'RE0' member.