@classmethod<EOL><INDENT>def get_or_create(cls, source, target, cost, topology=None):<DEDENT>
try:<EOL><INDENT>return cls.get_link(source, target, topology)<EOL><DEDENT>except LinkNotFound as e:<EOL><INDENT>pass<EOL><DEDENT>link = Link(interface_a=e.interface_a,<EOL>interface_b=e.interface_b,<EOL>status=LINK_STATUS['<STR_LIT>'],<EOL>metric_value=cost,<EOL>topology=topology)<EOL>link.full_clean()<EOL>link.save()<EOL>return link<EOL>
Tries to find a link with get_link, creates a new link if link not found.