mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 22:07:36 -02:30
adds fact model
This commit is contained in:
31
awx/main/migrations/0003_auto_20160209_1615.py
Normal file
31
awx/main/migrations/0003_auto_20160209_1615.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import jsonbfield.fields
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('main', '0002_v300_changes'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Fact',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||||
|
('timestamp', models.DateTimeField(default=None, editable=False)),
|
||||||
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('modified', models.DateTimeField(auto_now=True)),
|
||||||
|
('module', models.CharField(max_length=128)),
|
||||||
|
('facts', jsonbfield.fields.JSONField(default={}, blank=True)),
|
||||||
|
('host', models.ForeignKey(related_name='facts', to='main.Host')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AlterIndexTogether(
|
||||||
|
name='fact',
|
||||||
|
index_together=set([('timestamp', 'module', 'host')]),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -17,6 +17,7 @@ from awx.main.models.schedules import * # noqa
|
|||||||
from awx.main.models.activity_stream import * # noqa
|
from awx.main.models.activity_stream import * # noqa
|
||||||
from awx.main.models.ha import * # noqa
|
from awx.main.models.ha import * # noqa
|
||||||
from awx.main.models.configuration import * # noqa
|
from awx.main.models.configuration import * # noqa
|
||||||
|
from awx.main.models.fact import * # noqa
|
||||||
|
|
||||||
# Monkeypatch Django serializer to ignore django-taggit fields (which break
|
# Monkeypatch Django serializer to ignore django-taggit fields (which break
|
||||||
# the dumpdata command; see https://github.com/alex/django-taggit/issues/155).
|
# the dumpdata command; see https://github.com/alex/django-taggit/issues/155).
|
||||||
|
|||||||
32
awx/main/models/fact.py
Normal file
32
awx/main/models/fact.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Copyright (c) 2016 Ansible, Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
|
||||||
|
from django.db import models
|
||||||
|
from jsonbfield.fields import JSONField
|
||||||
|
|
||||||
|
from awx.main.models import Host
|
||||||
|
|
||||||
|
__all__ = ('Fact', )
|
||||||
|
|
||||||
|
class Fact(models.Model):
|
||||||
|
"""A model representing a fact returned from Ansible.
|
||||||
|
Facts are stored as JSON dictionaries.
|
||||||
|
"""
|
||||||
|
host = models.ForeignKey(
|
||||||
|
Host,
|
||||||
|
related_name='facts',
|
||||||
|
db_index=True,
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
)
|
||||||
|
timestamp = models.DateTimeField(default=None, editable=False)
|
||||||
|
created = models.DateTimeField(editable=False, auto_now_add=True)
|
||||||
|
modified = models.DateTimeField(editable=False, auto_now=True)
|
||||||
|
module = models.CharField(max_length=128)
|
||||||
|
facts = JSONField(blank=True, default={})
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
app_label = 'main'
|
||||||
|
index_together = [
|
||||||
|
["timestamp", "module", "host"],
|
||||||
|
]
|
||||||
|
|
||||||
27
docs/licenses/django-jsonbfield.txt
Normal file
27
docs/licenses/django-jsonbfield.txt
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
Copyright (c) Django Software Foundation and individual contributors.
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of Django nor the names of its contributors may be used
|
||||||
|
to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
@@ -49,6 +49,7 @@ importlib==1.0.3
|
|||||||
ipaddress==1.0.14
|
ipaddress==1.0.14
|
||||||
iso8601==0.1.10
|
iso8601==0.1.10
|
||||||
isodate==0.5.1
|
isodate==0.5.1
|
||||||
|
git+https://github.com/chrismeyersfsu/django-jsonbfield@master#egg=django-jsonbfield
|
||||||
jsonpatch==1.11
|
jsonpatch==1.11
|
||||||
jsonpointer==1.9
|
jsonpointer==1.9
|
||||||
jsonschema==2.5.1
|
jsonschema==2.5.1
|
||||||
|
|||||||
Reference in New Issue
Block a user