Esempio n. 1
0
def stop_recording(recording_id):
    updated_recording = flask.current_app.system_control_service.stop_recording(recording_id)

    if updated_recording is None:
        flask.abort(404)

    return flask.make_response(
        json.dumps(util.deep_asdict(updated_recording)), 200)
Esempio n. 2
0
def recording_details(recording_id):
    recording = flask.current_app.system_control_service.get_recording(
            recording_id)
    if recording is not None:
        return flask.make_response(
            json.dumps(util.deep_asdict(recording)), 200)
    else:
        flask.abort(404)
Esempio n. 3
0
def start_recording():
    recording_config = domain.RecordingConfig(
            gateway_recording_configs=map(
            jem_data.dal.json_marshalling.unmarshall_gateway_recording_config,
            flask.request.json))
    try:
        updated_recording = flask.current_app.system_control_service.start_recording(recording_config)
        return flask.make_response(json.dumps(util.deep_asdict(updated_recording)), 201)
    except jem_exceptions.SystemConflict, e:
        flask.abort(409)
Esempio n. 4
0
    def create(self, recording):
        '''Inserts a new recording, and creates a collection for its results.
        '''
        data = util.deep_asdict(recording)
        self._collection.insert(data)
        new_id = str(data['_id'])

        try:
            self._db.create_collection('archive-%s' % new_id)
        except pymongo.errors.CollectionInvalid, e:
            raise jem_exceptions.PersistenceException(str(e))
Esempio n. 5
0
def _insert_into_collection(msgs, mongo_collection):
    '''Write a bunch of messages to the given collection.

    Massages the data into the form expected to be stored.  Ie, if the domain
    model changes, then this step keeps backward-compatibility.
    '''
    ds = [util.deep_asdict(msg) for msg in msgs]

    # Rename a few fields, and promote some data up a level.
    for d in ds:
        d['device'] = d['table_addr']['device_addr']
        d['device']['gateway'] = d['device']['gateway_addr']
        del d['device']['gateway_addr']
        d['table_id'] = d['table_addr']['id']
        del d['table_addr']
    mongo_collection.insert(ds)
Esempio n. 6
0
def _merge_config_with_defaults(config):
    config = config[:]
    default_device_configs = devices.ALL
    for gateway in config:
        for device in gateway['devices']:
            if device['type'] not in default_device_configs:
                raise ValidationException(
                        "Unknown device type: %s" % device['type'])

            table_defaults = dict(
                (t['id'], t) for t in util.deep_asdict(
                    default_device_configs[device['type']]))

            table_overrides = dict(
                (t['id'], t) for t in device.get('tables', []))

            _merge_tables(table_defaults, table_overrides)
            device['tables'] = table_defaults.values()

    gateways = _unmarshall_gateways(config)
    return gateways
Esempio n. 7
0
def _raw_a40_tables():
    return util.deep_asdict(devices.A40)