0001_initial.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. import django.contrib.postgres.fields
  2. import django.core.serializers.json
  3. import django.core.validators
  4. from django.db import migrations, models
  5. import django.db.models.deletion
  6. import django.db.models.expressions
  7. import ipam.fields
  8. import taggit.managers
  9. class Migration(migrations.Migration):
  10. initial = True
  11. dependencies = [
  12. ('contenttypes', '0002_remove_content_type_name'),
  13. ('dcim', '0002_auto_20160622_1821'),
  14. ('extras', '0001_initial'),
  15. ('tenancy', '0001_initial'),
  16. ]
  17. operations = [
  18. migrations.CreateModel(
  19. name='Aggregate',
  20. fields=[
  21. ('created', models.DateField(auto_now_add=True, null=True)),
  22. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  23. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  24. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  25. ('prefix', ipam.fields.IPNetworkField()),
  26. ('date_added', models.DateField(blank=True, null=True)),
  27. ('description', models.CharField(blank=True, max_length=200)),
  28. ],
  29. options={
  30. 'ordering': ('prefix', 'pk'),
  31. },
  32. ),
  33. migrations.CreateModel(
  34. name='IPAddress',
  35. fields=[
  36. ('created', models.DateField(auto_now_add=True, null=True)),
  37. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  38. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  39. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  40. ('address', ipam.fields.IPAddressField()),
  41. ('status', models.CharField(default='active', max_length=50)),
  42. ('role', models.CharField(blank=True, max_length=50)),
  43. ('assigned_object_id', models.PositiveIntegerField(blank=True, null=True)),
  44. ('dns_name', models.CharField(blank=True, max_length=255, validators=[django.core.validators.RegexValidator(code='invalid', message='Only alphanumeric characters, hyphens, periods, and underscores are allowed in DNS names', regex='^[0-9A-Za-z._-]+$')])),
  45. ('description', models.CharField(blank=True, max_length=200)),
  46. ],
  47. options={
  48. 'verbose_name': 'IP address',
  49. 'verbose_name_plural': 'IP addresses',
  50. 'ordering': ('address', 'pk'),
  51. },
  52. ),
  53. migrations.CreateModel(
  54. name='Prefix',
  55. fields=[
  56. ('created', models.DateField(auto_now_add=True, null=True)),
  57. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  58. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  59. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  60. ('prefix', ipam.fields.IPNetworkField()),
  61. ('status', models.CharField(default='active', max_length=50)),
  62. ('is_pool', models.BooleanField(default=False)),
  63. ('description', models.CharField(blank=True, max_length=200)),
  64. ],
  65. options={
  66. 'verbose_name_plural': 'prefixes',
  67. 'ordering': (django.db.models.expressions.OrderBy(django.db.models.expressions.F('vrf'), nulls_first=True), 'prefix', 'pk'),
  68. },
  69. ),
  70. migrations.CreateModel(
  71. name='RIR',
  72. fields=[
  73. ('created', models.DateField(auto_now_add=True, null=True)),
  74. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  75. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  76. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  77. ('name', models.CharField(max_length=100, unique=True)),
  78. ('slug', models.SlugField(max_length=100, unique=True)),
  79. ('is_private', models.BooleanField(default=False)),
  80. ('description', models.CharField(blank=True, max_length=200)),
  81. ],
  82. options={
  83. 'verbose_name': 'RIR',
  84. 'verbose_name_plural': 'RIRs',
  85. 'ordering': ['name'],
  86. },
  87. ),
  88. migrations.CreateModel(
  89. name='Role',
  90. fields=[
  91. ('created', models.DateField(auto_now_add=True, null=True)),
  92. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  93. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  94. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  95. ('name', models.CharField(max_length=100, unique=True)),
  96. ('slug', models.SlugField(max_length=100, unique=True)),
  97. ('weight', models.PositiveSmallIntegerField(default=1000)),
  98. ('description', models.CharField(blank=True, max_length=200)),
  99. ],
  100. options={
  101. 'ordering': ['weight', 'name'],
  102. },
  103. ),
  104. migrations.CreateModel(
  105. name='RouteTarget',
  106. fields=[
  107. ('created', models.DateField(auto_now_add=True, null=True)),
  108. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  109. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  110. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  111. ('name', models.CharField(max_length=21, unique=True)),
  112. ('description', models.CharField(blank=True, max_length=200)),
  113. ],
  114. options={
  115. 'ordering': ['name'],
  116. },
  117. ),
  118. migrations.CreateModel(
  119. name='VRF',
  120. fields=[
  121. ('created', models.DateField(auto_now_add=True, null=True)),
  122. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  123. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  124. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  125. ('name', models.CharField(max_length=100)),
  126. ('rd', models.CharField(blank=True, max_length=21, null=True, unique=True)),
  127. ('enforce_unique', models.BooleanField(default=True)),
  128. ('description', models.CharField(blank=True, max_length=200)),
  129. ('export_targets', models.ManyToManyField(blank=True, related_name='exporting_vrfs', to='ipam.RouteTarget')),
  130. ('import_targets', models.ManyToManyField(blank=True, related_name='importing_vrfs', to='ipam.RouteTarget')),
  131. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  132. ('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vrfs', to='tenancy.tenant')),
  133. ],
  134. options={
  135. 'verbose_name': 'VRF',
  136. 'verbose_name_plural': 'VRFs',
  137. 'ordering': ('name', 'rd', 'pk'),
  138. },
  139. ),
  140. migrations.CreateModel(
  141. name='VLANGroup',
  142. fields=[
  143. ('created', models.DateField(auto_now_add=True, null=True)),
  144. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  145. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  146. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  147. ('name', models.CharField(max_length=100)),
  148. ('slug', models.SlugField(max_length=100)),
  149. ('scope_id', models.PositiveBigIntegerField(blank=True, null=True)),
  150. ('description', models.CharField(blank=True, max_length=200)),
  151. ('scope_type', models.ForeignKey(blank=True, limit_choices_to=models.Q(('model__in', ('region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster'))), null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
  152. ],
  153. options={
  154. 'verbose_name': 'VLAN group',
  155. 'verbose_name_plural': 'VLAN groups',
  156. 'ordering': ('name', 'pk'),
  157. },
  158. ),
  159. migrations.CreateModel(
  160. name='VLAN',
  161. fields=[
  162. ('created', models.DateField(auto_now_add=True, null=True)),
  163. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  164. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  165. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  166. ('vid', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4094)])),
  167. ('name', models.CharField(max_length=64)),
  168. ('status', models.CharField(default='active', max_length=50)),
  169. ('description', models.CharField(blank=True, max_length=200)),
  170. ('group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlans', to='ipam.vlangroup')),
  171. ('role', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='vlans', to='ipam.role')),
  172. ('site', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlans', to='dcim.site')),
  173. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  174. ('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='vlans', to='tenancy.tenant')),
  175. ],
  176. options={
  177. 'verbose_name': 'VLAN',
  178. 'verbose_name_plural': 'VLANs',
  179. 'ordering': ('site', 'group', 'vid', 'pk'),
  180. },
  181. ),
  182. migrations.CreateModel(
  183. name='Service',
  184. fields=[
  185. ('created', models.DateField(auto_now_add=True, null=True)),
  186. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  187. ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder)),
  188. ('id', models.BigAutoField(primary_key=True, serialize=False)),
  189. ('name', models.CharField(max_length=100)),
  190. ('protocol', models.CharField(max_length=50)),
  191. ('ports', django.contrib.postgres.fields.ArrayField(base_field=models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(65535)]), size=None)),
  192. ('description', models.CharField(blank=True, max_length=200)),
  193. ('device', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='services', to='dcim.device')),
  194. ('ipaddresses', models.ManyToManyField(blank=True, related_name='services', to='ipam.IPAddress')),
  195. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  196. ],
  197. options={
  198. 'ordering': ('protocol', 'ports', 'pk'),
  199. },
  200. ),
  201. ]