'Make the necessary changes'

def run(self):

    changed = False
    try:
        if (self.state == 'absent'):
            if self.exists():
                self.delete()
                changed = True
        elif (self.state == 'present'):
            if (not self.exists()):
                self.add()
                changed = True
            if (not changed):
                changed = (self.set(self.set_opt) or changed)
                items = self.module.params['external_ids'].items()
                for (key, value) in items:
                    value = value.replace('"', '')
                    fmt_opt = 'Interface    %s    external_ids:%s=%s'
                    external_id = (fmt_opt % (self.port, key, value))
                    changed = (self.set(external_id) or changed)
    except Exception:
        earg = get_exception()
        self.module.fail_json(msg=str(earg))
    self.module.exit_json(changed=changed)
