def run():
groups_client = sg_cli.SecurityGroupsClient()<EOL>xapi_client = xapi.XapiClient()<EOL>interfaces = set()<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>interfaces = xapi_client.get_interfaces()<EOL><DEDENT>except Exception:<EOL><INDENT>LOG.exception("<STR_LIT>")<EOL>_sleep()<EOL>continue<EOL><DEDENT>try:<EOL><INDENT>sg_states = groups_client.get_security_group_states(interfaces)<EOL>new_sg, updated_sg, removed_sg = partition_vifs(xapi_client,<EOL>interfaces,<EOL>sg_states)<EOL>xapi_client.update_interfaces(new_sg, updated_sg, removed_sg)<EOL>groups_to_ack = [v for v in new_sg + updated_sg if v.success]<EOL>sg_sts_curr = groups_client.get_security_group_states(interfaces)<EOL>groups_to_ack = get_groups_to_ack(groups_to_ack, sg_states,<EOL>sg_sts_curr)<EOL>ack_groups(groups_client, groups_to_ack)<EOL><DEDENT>except Exception:<EOL><INDENT>LOG.exception("<STR_LIT>"<EOL>"<STR_LIT>")<EOL>_sleep()<EOL>continue<EOL><DEDENT>_sleep()<EOL><DEDENT>
Fetches changes and applies them to VIFs periodically

    Process as of RM11449:
    * Get all groups from redis
    * Fetch ALL VIFs from Xen
    * Walk ALL VIFs and partition them into added, updated and removed
    * Walk the final "modified" VIFs list and apply flows to each