예제 #1
0
    def validate_switch_rules(self):
        diff = flow_utils.validate_switch_rules(self.payload['switch_id'],
                                                self.payload['flows'])
        logger.debug('Switch rules validation result: %s', diff)

        message_utils.send_validation_rules_response(diff["missing_rules"],
                                                     diff["excess_rules"],
                                                     diff["proper_rules"],
                                                     self.correlation_id)
        return True
예제 #2
0
    def validate_and_sync_switch_rules(self):
        switch_id = self.payload['switch_id']

        diff = flow_utils.validate_switch_rules(switch_id,
                                                self.payload['flows'])
        logger.debug('Switch rules validation result: %s', diff)

        sync_actions = flow_utils.build_commands_to_sync_rules(switch_id,
                                                               diff["missing_rules"])
        commands = sync_actions["commands"]
        if commands:
            logger.info('Install commands for switch %s are to be sent: %s',
                        switch_id, commands)
            message_utils.send_force_install_commands(switch_id, commands,
                                                      self.correlation_id)

        return True