def update(self):
from .link import Link  <EOL>diff = self.diff()<EOL>status = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>for section in ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>if not diff[section]:<EOL><INDENT>continue<EOL><DEDENT>for link_dict in diff[section]['<STR_LIT>']:<EOL><INDENT>try:<EOL><INDENT>link = Link.get_or_create(source=link_dict['<STR_LIT:source>'],<EOL>target=link_dict['<STR_LIT:target>'],<EOL>cost=link_dict['<STR_LIT>'],<EOL>topology=self)<EOL><DEDENT>except (LinkDataNotFound, ValidationError) as e:<EOL><INDENT>msg = '<STR_LIT>'.format(self.__repr__())<EOL>logger.exception(msg)<EOL>print('<STR_LIT>'.format(msg, e))<EOL>continue<EOL><DEDENT>link.ensure(status=status[section],<EOL>cost=link_dict['<STR_LIT>'])<EOL><DEDENT><DEDENT>
Updates topology
Links are not deleted straightaway but set as "disconnected"