Beispiel #1
0
    def test_cassandra_accessor(self):
        settings = {"BG_DRIVER": "cassandra"}
        settings["BG_CASSANDRA_CONTACT_POINTS"] = "localhost"
        settings["BG_CASSANDRA_COMPRESSION"] = True
        settings["BG_CASSANDRA_TIMEOUT"] = 5

        settings = bg_utils.settings_from_confattr(settings)
        accessor = bg_utils.accessor_from_settings(settings)
        self.assertNotEquals(accessor, None)

        settings["BG_CASSANDRA_COMPRESSION"] = False
        settings = bg_utils.settings_from_confattr(settings)
        accessor = bg_utils.accessor_from_settings(settings)
        self.assertNotEquals(accessor, None)
Beispiel #2
0
    def test_cassandra_accessor(self):
        settings = {"BG_DRIVER": "cassandra"}
        settings["BG_CASSANDRA_CONTACT_POINTS"] = "localhost"
        settings["BG_CASSANDRA_COMPRESSION"] = True
        settings["BG_CASSANDRA_TIMEOUT"] = 5

        settings = bg_utils.settings_from_confattr(settings)
        accessor = bg_utils.accessor_from_settings(settings)
        self.assertNotEquals(accessor, None)

        settings["BG_CASSANDRA_COMPRESSION"] = False
        settings = bg_utils.settings_from_confattr(settings)
        accessor = bg_utils.accessor_from_settings(settings)
        self.assertNotEquals(accessor, None)
 def __init__(self, opts):
     settings = bg_utils.settings_from_args(opts)
     bg_utils.set_log_level(settings)
     self._accessor = bg_utils.accessor_from_settings(settings)
     self._opts = opts
     self.time_start = time.mktime(self._opts.time_start.timetuple())
     self.time_end = time.mktime(self._opts.time_end.timetuple())
Beispiel #4
0
def main(args=None):
    """Entry point for the module."""
    if not args:
        args = sys.argv[1:]

    opts = _parse_opts(args)
    settings = bg_utils.settings_from_args(opts)
    bg_utils.set_log_level(settings)
    accessor = bg_utils.accessor_from_settings(settings)
    opts.func(accessor, opts)
Beispiel #5
0
def main(args=None, accessor=None):
    """Entry point for the module."""
    if not args:
        args = sys.argv[1:]

    opts = _parse_opts(args)
    settings = bg_utils.settings_from_args(opts)
    bg_utils.set_log_level(settings)
    accessor = accessor or bg_utils.accessor_from_settings(settings)
    opts.func(accessor, opts)
    accessor.flush()
Beispiel #6
0
def accessor_from_settings(settings):
    """Get Accessor from Graphite-related configuration object.

    Args:
      settings: either carbon_conf.Settings or a Django-like settings object.

    Returns:
      Accessor (not connected).
    """
    settings = bg_utils.settings_from_confattr(settings)
    bg_utils.set_log_level(settings)
    return bg_utils.accessor_from_settings(settings)
Beispiel #7
0
def accessor_from_settings(settings):
    """Get Accessor from configuration.

    Args:
      settings: either carbon_conf.Settings or a Django-like settings object

    Returns:
      Accessor (not connected)
    """
    settings = bg_utils.settings_from_confattr(settings)
    bg_utils.set_log_level(settings)
    return bg_utils.accessor_from_settings(settings)
Beispiel #8
0
def main(args=None, accessor=None):
    """Entry point for the module."""
    if not args:
        args = sys.argv[1:]

    opts = _parse_opts(args)
    if not getattr(opts, "func", None):
        opts.func = command_shell.CommandShell().run

    settings = bg_utils.settings_from_args(opts)
    bg_utils.set_log_level(settings)
    accessor = accessor or bg_utils.accessor_from_settings(settings)
    opts.func(accessor, opts)
    accessor.flush()
    accessor.shutdown()
Beispiel #9
0
    def setUpClass(cls):
        """Create the test Accessor."""
        # TODO (t.chataigner) Handle hybrid accessor here.
        driver_name = cls.ACCESSOR_SETTINGS.get('driver',
                                                bg_utils.DEFAULT_DRIVER)
        if "cassandra" in driver_name:
            cls.cassandra_helper = CassandraHelper()
            cls.cassandra_helper.setUpClass()
            cls.ACCESSOR_SETTINGS.update(
                cls.cassandra_helper.get_accessor_settings())
        if "elasticsearch" in driver_name:
            cls.elasticsearch_helper = ElasticsearchHelper()
            cls.elasticsearch_helper.setUpClass()
            cls.ACCESSOR_SETTINGS.update(
                cls.elasticsearch_helper.get_accessor_settings())

        cls.accessor = bg_utils.accessor_from_settings(cls.ACCESSOR_SETTINGS)
        cls.accessor.syncdb()
        cls.accessor.connect()
Beispiel #10
0
 def test_memory_accessor(self):
     settings = {"BG_DRIVER": "memory"}
     settings = bg_utils.settings_from_confattr(settings)
     accessor = bg_utils.accessor_from_settings(settings)
     self.assertNotEquals(accessor, None)
Beispiel #11
0
 def test_memory_accessor(self):
     settings = {"BG_DRIVER": "memory"}
     settings = bg_utils.settings_from_confattr(settings)
     accessor = bg_utils.accessor_from_settings(settings)
     self.assertNotEquals(accessor, None)