mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Extended primary models to include 'created' and 'last_updated' fields
This commit is contained in:
40
netbox/circuits/migrations/0004_auto_20160622_1410.py
Normal file
40
netbox/circuits/migrations/0004_auto_20160622_1410.py
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.7 on 2016-06-22 14:10
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('circuits', '0003_auto_20160621_1728'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='circuit',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='circuit',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 10, 28, 340517)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='provider',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='provider',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 10, 40, 964944)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
@ -2,9 +2,10 @@ from django.core.urlresolvers import reverse
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from dcim.models import Site, Interface
|
from dcim.models import Site, Interface
|
||||||
|
from utilities.models import CreatedUpdatedModel
|
||||||
|
|
||||||
|
|
||||||
class Provider(models.Model):
|
class Provider(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model
|
Each Circuit belongs to a Provider. This is usually a telecommunications company or similar organization. This model
|
||||||
stores information pertinent to the user's relationship with the Provider.
|
stores information pertinent to the user's relationship with the Provider.
|
||||||
@ -55,7 +56,7 @@ class CircuitType(models.Model):
|
|||||||
return "{}?type={}".format(reverse('circuits:circuit_list'), self.slug)
|
return "{}?type={}".format(reverse('circuits:circuit_list'), self.slug)
|
||||||
|
|
||||||
|
|
||||||
class Circuit(models.Model):
|
class Circuit(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
A communications circuit connects two points. Each Circuit belongs to a Provider; Providers may have multiple
|
A communications circuit connects two points. Each Circuit belongs to a Provider; Providers may have multiple
|
||||||
circuits. Each circuit is also assigned a CircuitType and a Site. A Circuit may be terminated to a specific device
|
circuits. Each circuit is also assigned a CircuitType and a Site. A Circuit may be terminated to a specific device
|
||||||
|
52
netbox/dcim/migrations/0009_auto_20160622_1408.py
Normal file
52
netbox/dcim/migrations/0009_auto_20160622_1408.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.7 on 2016-06-22 14:08
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('dcim', '0008_auto_20160621_1843'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='device',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='device',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 7, 52, 775280)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='rack',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='rack',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 8, 27, 534709)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='site',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='site',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 8, 37, 622017)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
@ -8,6 +8,7 @@ from django.db.models import Q, ObjectDoesNotExist
|
|||||||
|
|
||||||
from extras.rpc import RPC_CLIENTS
|
from extras.rpc import RPC_CLIENTS
|
||||||
from utilities.fields import NullableCharField
|
from utilities.fields import NullableCharField
|
||||||
|
from utilities.models import CreatedUpdatedModel
|
||||||
|
|
||||||
|
|
||||||
RACK_FACE_FRONT = 0
|
RACK_FACE_FRONT = 0
|
||||||
@ -82,7 +83,7 @@ RPC_CLIENT_CHOICES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class Site(models.Model):
|
class Site(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
A Site represents a geographic location within a network; typically a building or campus. The optional facility
|
A Site represents a geographic location within a network; typically a building or campus. The optional facility
|
||||||
field can be used to include an external designation, such as a data center name (e.g. Equinix SV6).
|
field can be used to include an external designation, such as a data center name (e.g. Equinix SV6).
|
||||||
@ -157,7 +158,7 @@ class RackGroup(models.Model):
|
|||||||
return "{}?group_id={}".format(reverse('dcim:rack_list'), self.pk)
|
return "{}?group_id={}".format(reverse('dcim:rack_list'), self.pk)
|
||||||
|
|
||||||
|
|
||||||
class Rack(models.Model):
|
class Rack(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
Devices are housed within Racks. Each rack has a defined height measured in rack units, and a front and rear face.
|
Devices are housed within Racks. Each rack has a defined height measured in rack units, and a front and rear face.
|
||||||
Each Rack is assigned to a Site and (optionally) a RackGroup.
|
Each Rack is assigned to a Site and (optionally) a RackGroup.
|
||||||
@ -456,7 +457,7 @@ class Platform(models.Model):
|
|||||||
return "{}?platform={}".format(reverse('dcim:device_list'), self.slug)
|
return "{}?platform={}".format(reverse('dcim:device_list'), self.slug)
|
||||||
|
|
||||||
|
|
||||||
class Device(models.Model):
|
class Device(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
A Device represents a piece of physical hardware mounted within a Rack. Each Device is assigned a DeviceType,
|
A Device represents a piece of physical hardware mounted within a Rack. Each Device is assigned a DeviceType,
|
||||||
DeviceRole, and (optionally) a Platform. Device names are not required, however if one is set it must be unique.
|
DeviceRole, and (optionally) a Platform. Device names are not required, however if one is set it must be unique.
|
||||||
|
76
netbox/ipam/migrations/0006_auto_20160622_1413.py
Normal file
76
netbox/ipam/migrations/0006_auto_20160622_1413.py
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.7 on 2016-06-22 14:13
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('ipam', '0005_delete_status'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='aggregate',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='aggregate',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 12, 29, 891569)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='ipaddress',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='ipaddress',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 12, 39, 666885)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='prefix',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='prefix',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 12, 48, 11411)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='vlan',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='vlan',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 12, 56, 963230)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='vrf',
|
||||||
|
name='created',
|
||||||
|
field=models.DateField(auto_now_add=True, default=datetime.date(2016, 6, 22)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='vrf',
|
||||||
|
name='last_updated',
|
||||||
|
field=models.DateTimeField(auto_now=True, default=datetime.datetime(2016, 6, 22, 14, 13, 4, 387113)),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
]
|
@ -6,6 +6,7 @@ from django.core.validators import MaxValueValidator, MinValueValidator
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from dcim.models import Interface
|
from dcim.models import Interface
|
||||||
|
from utilities.models import CreatedUpdatedModel
|
||||||
|
|
||||||
from .fields import IPNetworkField, IPAddressField
|
from .fields import IPNetworkField, IPAddressField
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ STATUS_CHOICE_CLASSES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class VRF(models.Model):
|
class VRF(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
A virtual routing and forwarding (VRF) table represents a discrete layer three forwarding domain (e.g. a routing
|
A virtual routing and forwarding (VRF) table represents a discrete layer three forwarding domain (e.g. a routing
|
||||||
table). Prefixes and IPAddresses can optionally be assigned to VRFs. (Prefixes and IPAddresses not assigned to a VRF
|
table). Prefixes and IPAddresses can optionally be assigned to VRFs. (Prefixes and IPAddresses not assigned to a VRF
|
||||||
@ -85,7 +86,7 @@ class RIR(models.Model):
|
|||||||
return "{}?rir={}".format(reverse('ipam:aggregate_list'), self.slug)
|
return "{}?rir={}".format(reverse('ipam:aggregate_list'), self.slug)
|
||||||
|
|
||||||
|
|
||||||
class Aggregate(models.Model):
|
class Aggregate(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
An aggregate exists at the root level of the IP address space hierarchy in NetBox. Aggregates are used to organize
|
An aggregate exists at the root level of the IP address space hierarchy in NetBox. Aggregates are used to organize
|
||||||
the hierarchy and track the overall utilization of available address space. Each Aggregate is assigned to a RIR.
|
the hierarchy and track the overall utilization of available address space. Each Aggregate is assigned to a RIR.
|
||||||
@ -206,7 +207,7 @@ class PrefixQuerySet(models.QuerySet):
|
|||||||
return filter(lambda p: p.depth <= limit, queryset)
|
return filter(lambda p: p.depth <= limit, queryset)
|
||||||
|
|
||||||
|
|
||||||
class Prefix(models.Model):
|
class Prefix(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
A Prefix represents an IPv4 or IPv6 network, including mask length. Prefixes can optionally be assigned to Sites and
|
A Prefix represents an IPv4 or IPv6 network, including mask length. Prefixes can optionally be assigned to Sites and
|
||||||
VRFs. A Prefix must be assigned a status and may optionally be assigned a used-define Role. A Prefix can also be
|
VRFs. A Prefix must be assigned a status and may optionally be assigned a used-define Role. A Prefix can also be
|
||||||
@ -268,7 +269,7 @@ class Prefix(models.Model):
|
|||||||
return STATUS_CHOICE_CLASSES[self.status]
|
return STATUS_CHOICE_CLASSES[self.status]
|
||||||
|
|
||||||
|
|
||||||
class IPAddress(models.Model):
|
class IPAddress(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
An IPAddress represents an individual IPV4 or IPv6 address and its mask. The mask length should match what is
|
An IPAddress represents an individual IPV4 or IPv6 address and its mask. The mask length should match what is
|
||||||
configured in the real world. (Typically, only loopback interfaces are configured with /32 or /128 masks.) Like
|
configured in the real world. (Typically, only loopback interfaces are configured with /32 or /128 masks.) Like
|
||||||
@ -323,7 +324,7 @@ class IPAddress(models.Model):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
class VLAN(models.Model):
|
class VLAN(CreatedUpdatedModel):
|
||||||
"""
|
"""
|
||||||
A VLAN is a distinct layer two forwarding domain identified by a 12-bit integer (1-4094). Each VLAN must be assigned
|
A VLAN is a distinct layer two forwarding domain identified by a 12-bit integer (1-4094). Each VLAN must be assigned
|
||||||
to a Site, however VLAN IDs need not be unique within a Site. Like Prefixes, each VLAN is assigned an operational
|
to a Site, however VLAN IDs need not be unique within a Site. Like Prefixes, each VLAN is assigned an operational
|
||||||
|
@ -11,6 +11,7 @@ from django.db import models
|
|||||||
from django.utils.encoding import force_bytes
|
from django.utils.encoding import force_bytes
|
||||||
|
|
||||||
from dcim.models import Device
|
from dcim.models import Device
|
||||||
|
from utilities.models import CreatedUpdatedModel
|
||||||
|
|
||||||
from .hashers import SecretValidationHasher
|
from .hashers import SecretValidationHasher
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
|
||||||
|
class CreatedUpdatedModel(models.Model):
|
||||||
|
created = models.DateField(auto_now_add=True)
|
||||||
|
last_updated = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
abstract = True
|
||||||
|
Reference in New Issue
Block a user