def ensure(self, status, cost):
changed = False<EOL>status_id = LINK_STATUS[status]<EOL>if self.status != status_id:<EOL><INDENT>self.status = status_id<EOL>changed = True<EOL><DEDENT>if self.metric_value != cost:<EOL><INDENT>self.metric_value = cost<EOL>changed = True<EOL><DEDENT>if changed:<EOL><INDENT>self.save()<EOL><DEDENT>
ensure link properties correspond to the specified ones
perform save operation only if necessary