Пример #1
0
def create_event(ctx, **kwargs):
    values = {
        'timestamp': tu.utcnow(),
        'obj_id': 'FAKE_ID',
        'obj_name': 'FAKE_NAME',
        'obj_type': 'CLUSTER',
        'cluster_id': 'FAKE_CLUSTER',
        'level': '20',
        'user': ctx.user,
        'project': ctx.project,
        'action': 'DANCE',
        'status': 'READY',
        'status_reason': 'Just created.',
        'meta_data': {
            'air': 'polluted'
        }
    }

    values.update(kwargs)
    return db_api.event_create(ctx, values)
Пример #2
0
def create_event(ctx, **kwargs):
    values = {
        'timestamp': tu.utcnow(True),
        'obj_id': 'FAKE_ID',
        'obj_name': 'FAKE_NAME',
        'obj_type': 'CLUSTER',
        'cluster_id': 'FAKE_CLUSTER',
        'level': '20',
        'user': ctx.user,
        'project': ctx.project,
        'action': 'DANCE',
        'status': 'READY',
        'status_reason': 'Just created.',
        'meta_data': {
            'air': 'polluted'
        }
    }

    values.update(kwargs)
    return db_api.event_create(ctx, values)
Пример #3
0
    def create_event(self,
                     ctx,
                     timestamp=None,
                     level=logging.INFO,
                     entity=None,
                     action=None,
                     status=None,
                     status_reason=None):

        fake_timestamp = tu.parse_strtime('2014-12-19 11:51:54.670244',
                                          '%Y-%m-%d %H:%M:%S.%f')

        if entity:
            e_name = reflection.get_class_name(entity, fully_qualified=False)
            type_name = e_name.upper()
            if type_name == 'CLUSTER':
                cluster_id = entity.id
            elif type_name == 'NODE':
                cluster_id = entity.cluster_id
            else:
                cluster_id = ''
        else:
            type_name = ''
            cluster_id = ''

        values = {
            'timestamp': timestamp or fake_timestamp,
            'level': level,
            'obj_id': entity.id if entity else '',
            'obj_name': entity.name if entity else '',
            'obj_type': type_name,
            'cluster_id': cluster_id,
            'action': action or '',
            'status': status or '',
            'status_reason': status_reason or '',
            'user': ctx.user,
            'project': ctx.project,
        }

        # Make sure all fields can be customized
        return db_api.event_create(ctx, values)
Пример #4
0
    def create_event(self, ctx, timestamp=None, level=logging.INFO,
                     entity=None, action=None, status=None,
                     status_reason=None):

        fake_timestamp = tu.parse_strtime(
            '2014-12-19 11:51:54.670244', '%Y-%m-%d %H:%M:%S.%f')

        if entity:
            e_name = reflection.get_class_name(entity, fully_qualified=False)
            type_name = e_name.upper()
            if type_name == 'CLUSTER':
                cluster_id = entity.id
            elif type_name == 'NODE':
                cluster_id = entity.cluster_id
            else:
                cluster_id = ''
        else:
            type_name = ''
            cluster_id = ''

        values = {
            'timestamp': timestamp or fake_timestamp,
            'level': level,
            'oid': entity.id if entity else '',
            'oname': entity.name if entity else '',
            'otype': type_name,
            'cluster_id': cluster_id,
            'action': action or '',
            'status': status or '',
            'status_reason': status_reason or '',
            'user': ctx.user,
            'project': ctx.project,
        }

        # Make sure all fields can be customized
        return db_api.event_create(ctx, values)
Пример #5
0
    def create_event(self, ctx, timestamp=None, level=logging.INFO,
                     entity=None, action=None, status=None,
                     status_reason=None, deleted_time=None):

        fake_timestamp = datetime.datetime.strptime(
            '2014-12-19 11:51:54.670244', '%Y-%m-%d %H:%M:%S.%f')

        if entity:
            type_name = entity.__class__.__name__.upper()
            if type_name == 'CLUSTER':
                cluster_id = entity.id
            elif type_name == 'NODE':
                cluster_id = entity.cluster_id
            else:
                cluster_id = ''
        else:
            type_name = ''
            cluster_id = ''

        values = {
            'timestamp': timestamp or fake_timestamp,
            'level': level,
            'obj_id': entity.id if entity else '',
            'obj_name': entity.name if entity else '',
            'obj_type': type_name,
            'cluster_id': cluster_id,
            'action': action or '',
            'status': status or '',
            'status_reason': status_reason or '',
            'user': ctx.user_id,
            'project': ctx.tenant_id,
            'deleted_time': deleted_time,
        }

        # Make sure all fields can be customized
        return db_api.event_create(ctx, values)