Beispiel #1
0
    def setup(self):
        cf_defs = CassandraControllerStore.get_column_families()
        ks = cassandra.get_keyspace(cf_defs)
        self.cassandra_manager = cassandra.CassandraSchemaManager(ks)

        yield self.cassandra_manager.create()

        controller_name = str(uuid.uuid4())[:8]
        host, port = cassandra.get_host_port()
        username, password = cassandra.get_credentials()
        self.store = CassandraControllerStore(controller_name, host, port,
                                              username, password, ks.name,
                                              CoreInstance, SensorItem)
        self.store.initialize()
        self.store.activate()
        defer.returnValue(self.store)
Beispiel #2
0
    def setup(self):
        cf_defs = CassandraControllerStore.get_column_families()
        ks = cassandra.get_keyspace(cf_defs)
        self.cassandra_manager = cassandra.CassandraSchemaManager(ks)

        yield self.cassandra_manager.create()

        controller_name = str(uuid.uuid4())[:8]
        host, port = cassandra.get_host_port()
        username, password = cassandra.get_credentials()
        self.store = CassandraControllerStore(controller_name, host, port,
                                              username, password, ks.name,
                                              CoreInstance, SensorItem)
        self.store.initialize()
        self.store.activate()
        defer.returnValue(self.store)
Beispiel #3
0
class CassandraFixture(object):
    def __init__(self):
        self.store = None
        self.cassandra_manager = None

    @defer.inlineCallbacks
    def setup(self):
        cf_defs = CassandraControllerStore.get_column_families()
        ks = cassandra.get_keyspace(cf_defs)
        self.cassandra_manager = cassandra.CassandraSchemaManager(ks)

        yield self.cassandra_manager.create()

        controller_name = str(uuid.uuid4())[:8]
        host, port = cassandra.get_host_port()
        username, password = cassandra.get_credentials()
        self.store = CassandraControllerStore(controller_name, host, port,
                                              username, password, ks.name,
                                              CoreInstance, SensorItem)
        self.store.initialize()
        self.store.activate()
        defer.returnValue(self.store)

    @defer.inlineCallbacks
    def teardown(self):
        if self.store:
            self.store.terminate()

        yield self.cassandra_manager.teardown()
        self.cassandra_manager.disconnect()
        self.store  = None
        self.cassandra_manager = None
Beispiel #4
0
class CassandraFixture(object):
    def __init__(self):
        self.store = None
        self.cassandra_manager = None

    @defer.inlineCallbacks
    def setup(self):
        cf_defs = CassandraControllerStore.get_column_families()
        ks = cassandra.get_keyspace(cf_defs)
        self.cassandra_manager = cassandra.CassandraSchemaManager(ks)

        yield self.cassandra_manager.create()

        controller_name = str(uuid.uuid4())[:8]
        host, port = cassandra.get_host_port()
        username, password = cassandra.get_credentials()
        self.store = CassandraControllerStore(controller_name, host, port,
                                              username, password, ks.name,
                                              CoreInstance, SensorItem)
        self.store.initialize()
        self.store.activate()
        defer.returnValue(self.store)

    @defer.inlineCallbacks
    def teardown(self):
        if self.store:
            self.store.terminate()

        yield self.cassandra_manager.teardown()
        self.cassandra_manager.disconnect()
        self.store = None
        self.cassandra_manager = None
Beispiel #5
0
def get_epu_keyspace_definition():
    """Gathers column family definitions from EPU components
    """
    name = get_keyspace_name()

    from epu.provisioner.store import CassandraProvisionerStore
    provisioner_cfs = CassandraProvisionerStore.get_column_families(name)

    from epu.epucontroller.controller_store import CassandraControllerStore
    controller_cfs = CassandraControllerStore.get_column_families(name)

    all_cfs = []
    all_cfs.extend(provisioner_cfs)
    all_cfs.extend(controller_cfs)

    return get_keyspace(all_cfs)
Beispiel #6
0
def get_epu_keyspace_definition():
    """Gathers column family definitions from EPU components
    """
    name = get_keyspace_name()

    from epu.provisioner.store import CassandraProvisionerStore
    provisioner_cfs = CassandraProvisionerStore.get_column_families(name)

    from epu.epucontroller.controller_store import CassandraControllerStore
    controller_cfs = CassandraControllerStore.get_column_families(name)

    all_cfs = []
    all_cfs.extend(provisioner_cfs)
    all_cfs.extend(controller_cfs)

    return get_keyspace(all_cfs)
Beispiel #7
0
    def slc_init(self):

        scoped_name = self.get_scoped_name("system", self.svc_name)
        self.scoped_name = scoped_name

        queue_name_work = self.spawn_args.get("queue_name_work")
        if queue_name_work:
            self.queue_name_work = self.get_scoped_name("system", queue_name_work)

            extradict = {"queue_name_work":self.queue_name_work}
            cei_events.event(self.svc_name, "init_begin", extra=extradict)
            yield self._make_queue(queue_name_work)

            queuestat_client = QueueStatClient(self)
            yield queuestat_client.watch_queue(self.queue_name_work, self.scoped_name, 'sensor_info')
            cei_events.event(self.svc_name, "queue_watched")

        else:
            self.worker_queue_receiver = None
            self.queue_name_work = None
            extradict = None
            cei_events.event(self.svc_name, "init_begin", extra=extradict)

        engineclass = "epu.decisionengine.impls.NpreservingEngine"
        if self.spawn_args.has_key("engine_class"):
            engineclass = self.spawn_args["engine_class"]
            log.info("Using configured decision engine: %s" % engineclass)
        else:
            log.info("Using default decision engine: %s" % engineclass)

        if self.spawn_args.has_key("engine_conf"):
            engine_conf = self.spawn_args["engine_conf"]
            if isinstance(engine_conf, str):
                engine_conf = json.loads(engine_conf)
        else:
            engine_conf = None

        if self.spawn_args.has_key("cassandra"):
            cass = self.spawn_args["cassandra"]
            host = cass['hostname']
            username = cass['username']
            password = cass['password']
            port = cass['port']
            keyspace = cass['keyspace']

            store = CassandraControllerStore(self.svc_name, host, port,
                                             username, password, keyspace,
                                             CoreInstance, SensorItem)
            store.initialize()
            store.activate()
        elif self.spawn_args.has_key('store'):
            store = self.spawn_args['store']
        else:
            store = ControllerStore()

        self.core = ControllerCore(ProvisionerClient(self), engineclass,
                                   scoped_name, conf=engine_conf, store=store)

        # run state recovery and engine initialization

        # this one needs to run before any messages start arriving. It pulls
        # information from persistence and refreshes local caches.
        yield self.core.run_recovery()

        # temporarily doing this later due to a potential bug in ioncore where
        # queues may not be bound before slc_init runs. This means  if the
        # provisioner is quck to reply to dump_state some messages may be
        # missed.
        reactor.callLater(1, self._delayed_init)
Beispiel #8
0
    def slc_init(self):

        scoped_name = self.get_scoped_name("system", self.svc_name)
        self.scoped_name = scoped_name

        queue_name_work = self.spawn_args.get("queue_name_work")
        if queue_name_work:
            self.queue_name_work = self.get_scoped_name(
                "system", queue_name_work)

            extradict = {"queue_name_work": self.queue_name_work}
            cei_events.event(self.svc_name, "init_begin", extra=extradict)
            yield self._make_queue(queue_name_work)

            queuestat_client = QueueStatClient(self)
            yield queuestat_client.watch_queue(self.queue_name_work,
                                               self.scoped_name, 'sensor_info')
            cei_events.event(self.svc_name, "queue_watched")

        else:
            self.worker_queue_receiver = None
            self.queue_name_work = None
            extradict = None
            cei_events.event(self.svc_name, "init_begin", extra=extradict)

        engineclass = "epu.decisionengine.impls.NpreservingEngine"
        if self.spawn_args.has_key("engine_class"):
            engineclass = self.spawn_args["engine_class"]
            log.info("Using configured decision engine: %s" % engineclass)
        else:
            log.info("Using default decision engine: %s" % engineclass)

        if self.spawn_args.has_key("engine_conf"):
            engine_conf = self.spawn_args["engine_conf"]
            if isinstance(engine_conf, str):
                engine_conf = json.loads(engine_conf)
        else:
            engine_conf = None

        if self.spawn_args.has_key("cassandra"):
            cass = self.spawn_args["cassandra"]
            host = cass['hostname']
            username = cass['username']
            password = cass['password']
            port = cass['port']
            keyspace = cass['keyspace']

            store = CassandraControllerStore(self.svc_name, host, port,
                                             username, password, keyspace,
                                             CoreInstance, SensorItem)
            store.initialize()
            store.activate()
        elif self.spawn_args.has_key('store'):
            store = self.spawn_args['store']
        else:
            store = ControllerStore()

        self.core = ControllerCore(ProvisionerClient(self),
                                   engineclass,
                                   scoped_name,
                                   conf=engine_conf,
                                   store=store)

        # run state recovery and engine initialization

        # this one needs to run before any messages start arriving. It pulls
        # information from persistence and refreshes local caches.
        yield self.core.run_recovery()

        # temporarily doing this later due to a potential bug in ioncore where
        # queues may not be bound before slc_init runs. This means  if the
        # provisioner is quck to reply to dump_state some messages may be
        # missed.
        reactor.callLater(1, self._delayed_init)