<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_or_create(cls, source, target, cost, topology=None):
 """ Tries to find a link with get_link, creates a new link if link not found. """

        try:
            return cls.get_link(source, target, topology)
        except LinkNotFound as e:
            pass
        # create link
        link = Link(interface_a=e.interface_a,
                    interface_b=e.interface_b,
                    status=LINK_STATUS['active'],
                    metric_value=cost,
                    topology=topology)
        link.full_clean()
        link.save()
        return link