<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure(self, status, cost):
 """ ensure link properties correspond to the specified ones perform save operation only if necessary """

        changed = False
        status_id = LINK_STATUS[status]
        if self.status != status_id:
            self.status = status_id
            changed = True
        if self.metric_value != cost:
            self.metric_value = cost
            changed = True
        if changed:
            self.save()