0001_initial.py 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. from django.db import migrations, models
  2. import django.db.models.deletion
  3. import taggit.managers
  4. import utilities.json
  5. class Migration(migrations.Migration):
  6. initial = True
  7. dependencies = [
  8. ('contenttypes', '0002_remove_content_type_name'),
  9. ('extras', '0099_cachedvalue_ordering'),
  10. ('ipam', '0054_squashed_0067'),
  11. ('tenancy', '0012_contactassignment_custom_fields'),
  12. ]
  13. operations = [
  14. # IKE
  15. migrations.CreateModel(
  16. name='IKEProposal',
  17. fields=[
  18. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  19. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  20. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  21. (
  22. 'custom_field_data',
  23. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  24. ),
  25. ('description', models.CharField(blank=True, max_length=200)),
  26. ('comments', models.TextField(blank=True)),
  27. ('name', models.CharField(max_length=100, unique=True)),
  28. ('authentication_method', models.CharField()),
  29. ('encryption_algorithm', models.CharField()),
  30. ('authentication_algorithm', models.CharField(blank=True)),
  31. ('group', models.PositiveSmallIntegerField()),
  32. ('sa_lifetime', models.PositiveIntegerField(blank=True, null=True)),
  33. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  34. ],
  35. options={
  36. 'verbose_name': 'IKE proposal',
  37. 'verbose_name_plural': 'IKE proposals',
  38. 'ordering': ('name',),
  39. },
  40. ),
  41. migrations.CreateModel(
  42. name='IKEPolicy',
  43. fields=[
  44. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  45. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  46. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  47. (
  48. 'custom_field_data',
  49. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  50. ),
  51. ('description', models.CharField(blank=True, max_length=200)),
  52. ('comments', models.TextField(blank=True)),
  53. ('name', models.CharField(max_length=100, unique=True)),
  54. ('version', models.PositiveSmallIntegerField(default=2)),
  55. ('mode', models.CharField()),
  56. ('preshared_key', models.TextField(blank=True)),
  57. ],
  58. options={
  59. 'verbose_name': 'IKE policy',
  60. 'verbose_name_plural': 'IKE policies',
  61. 'ordering': ('name',),
  62. },
  63. ),
  64. migrations.AddField(
  65. model_name='ikepolicy',
  66. name='proposals',
  67. field=models.ManyToManyField(related_name='ike_policies', to='vpn.ikeproposal'),
  68. ),
  69. migrations.AddField(
  70. model_name='ikepolicy',
  71. name='tags',
  72. field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
  73. ),
  74. # IPSec
  75. migrations.CreateModel(
  76. name='IPSecProposal',
  77. fields=[
  78. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  79. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  80. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  81. (
  82. 'custom_field_data',
  83. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  84. ),
  85. ('description', models.CharField(blank=True, max_length=200)),
  86. ('comments', models.TextField(blank=True)),
  87. ('name', models.CharField(max_length=100, unique=True)),
  88. ('encryption_algorithm', models.CharField(blank=True)),
  89. ('authentication_algorithm', models.CharField(blank=True)),
  90. ('sa_lifetime_seconds', models.PositiveIntegerField(blank=True, null=True)),
  91. ('sa_lifetime_data', models.PositiveIntegerField(blank=True, null=True)),
  92. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  93. ],
  94. options={
  95. 'verbose_name': 'IPSec proposal',
  96. 'verbose_name_plural': 'IPSec proposals',
  97. 'ordering': ('name',),
  98. },
  99. ),
  100. migrations.CreateModel(
  101. name='IPSecPolicy',
  102. fields=[
  103. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  104. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  105. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  106. (
  107. 'custom_field_data',
  108. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  109. ),
  110. ('description', models.CharField(blank=True, max_length=200)),
  111. ('comments', models.TextField(blank=True)),
  112. ('name', models.CharField(max_length=100, unique=True)),
  113. ('pfs_group', models.PositiveSmallIntegerField(blank=True, null=True)),
  114. ],
  115. options={
  116. 'verbose_name': 'IPSec policy',
  117. 'verbose_name_plural': 'IPSec policies',
  118. 'ordering': ('name',),
  119. },
  120. ),
  121. migrations.AddField(
  122. model_name='ipsecpolicy',
  123. name='proposals',
  124. field=models.ManyToManyField(related_name='ipsec_policies', to='vpn.ipsecproposal'),
  125. ),
  126. migrations.AddField(
  127. model_name='ipsecpolicy',
  128. name='tags',
  129. field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
  130. ),
  131. migrations.CreateModel(
  132. name='IPSecProfile',
  133. fields=[
  134. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  135. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  136. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  137. (
  138. 'custom_field_data',
  139. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  140. ),
  141. ('description', models.CharField(blank=True, max_length=200)),
  142. ('comments', models.TextField(blank=True)),
  143. ('name', models.CharField(max_length=100, unique=True)),
  144. ('mode', models.CharField()),
  145. (
  146. 'ike_policy',
  147. models.ForeignKey(
  148. on_delete=django.db.models.deletion.PROTECT, related_name='ipsec_profiles', to='vpn.ikepolicy'
  149. ),
  150. ),
  151. (
  152. 'ipsec_policy',
  153. models.ForeignKey(
  154. on_delete=django.db.models.deletion.PROTECT, related_name='ipsec_profiles', to='vpn.ipsecpolicy'
  155. ),
  156. ),
  157. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  158. ],
  159. options={
  160. 'verbose_name': 'IPSec profile',
  161. 'verbose_name_plural': 'IPSec profiles',
  162. 'ordering': ('name',),
  163. },
  164. ),
  165. # Tunnels
  166. migrations.CreateModel(
  167. name='TunnelGroup',
  168. fields=[
  169. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  170. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  171. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  172. (
  173. 'custom_field_data',
  174. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  175. ),
  176. ('name', models.CharField(max_length=100, unique=True)),
  177. ('slug', models.SlugField(max_length=100, unique=True)),
  178. ('description', models.CharField(blank=True, max_length=200)),
  179. ],
  180. options={
  181. 'verbose_name': 'tunnel group',
  182. 'verbose_name_plural': 'tunnel groups',
  183. 'ordering': ('name',),
  184. },
  185. ),
  186. migrations.AddField(
  187. model_name='tunnelgroup',
  188. name='tags',
  189. field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
  190. ),
  191. migrations.CreateModel(
  192. name='Tunnel',
  193. fields=[
  194. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  195. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  196. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  197. (
  198. 'custom_field_data',
  199. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  200. ),
  201. ('description', models.CharField(blank=True, max_length=200)),
  202. ('comments', models.TextField(blank=True)),
  203. ('name', models.CharField(max_length=100, unique=True)),
  204. ('status', models.CharField(default='active', max_length=50)),
  205. (
  206. 'group',
  207. models.ForeignKey(
  208. blank=True,
  209. null=True,
  210. on_delete=django.db.models.deletion.PROTECT,
  211. related_name='tunnels',
  212. to='vpn.tunnelgroup',
  213. ),
  214. ),
  215. ('encapsulation', models.CharField(max_length=50)),
  216. ('tunnel_id', models.PositiveBigIntegerField(blank=True, null=True)),
  217. (
  218. 'ipsec_profile',
  219. models.ForeignKey(
  220. blank=True,
  221. null=True,
  222. on_delete=django.db.models.deletion.PROTECT,
  223. related_name='tunnels',
  224. to='vpn.ipsecprofile',
  225. ),
  226. ),
  227. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  228. (
  229. 'tenant',
  230. models.ForeignKey(
  231. blank=True,
  232. null=True,
  233. on_delete=django.db.models.deletion.PROTECT,
  234. related_name='tunnels',
  235. to='tenancy.tenant',
  236. ),
  237. ),
  238. ],
  239. options={
  240. 'verbose_name': 'tunnel',
  241. 'verbose_name_plural': 'tunnels',
  242. 'ordering': ('name',),
  243. },
  244. ),
  245. migrations.AddConstraint(
  246. model_name='tunnel',
  247. constraint=models.UniqueConstraint(fields=('group', 'name'), name='vpn_tunnel_group_name'),
  248. ),
  249. migrations.AddConstraint(
  250. model_name='tunnel',
  251. constraint=models.UniqueConstraint(
  252. condition=models.Q(('group__isnull', True)), fields=('name',), name='vpn_tunnel_name'
  253. ),
  254. ),
  255. migrations.CreateModel(
  256. name='TunnelTermination',
  257. fields=[
  258. ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
  259. ('created', models.DateTimeField(auto_now_add=True, null=True)),
  260. ('last_updated', models.DateTimeField(auto_now=True, null=True)),
  261. (
  262. 'custom_field_data',
  263. models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder),
  264. ),
  265. ('role', models.CharField(default='peer', max_length=50)),
  266. ('termination_id', models.PositiveBigIntegerField(blank=True, null=True)),
  267. (
  268. 'termination_type',
  269. models.ForeignKey(
  270. on_delete=django.db.models.deletion.PROTECT, related_name='+', to='contenttypes.contenttype'
  271. ),
  272. ),
  273. (
  274. 'outside_ip',
  275. models.OneToOneField(
  276. blank=True,
  277. null=True,
  278. on_delete=django.db.models.deletion.PROTECT,
  279. related_name='tunnel_termination',
  280. to='ipam.ipaddress',
  281. ),
  282. ),
  283. ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
  284. (
  285. 'tunnel',
  286. models.ForeignKey(
  287. on_delete=django.db.models.deletion.CASCADE, related_name='terminations', to='vpn.tunnel'
  288. ),
  289. ),
  290. ],
  291. options={
  292. 'verbose_name': 'tunnel termination',
  293. 'verbose_name_plural': 'tunnel terminations',
  294. 'ordering': ('tunnel', 'role', 'pk'),
  295. },
  296. ),
  297. migrations.AddIndex(
  298. model_name='tunneltermination',
  299. index=models.Index(fields=['termination_type', 'termination_id'], name='vpn_tunnelt_termina_c1f04b_idx'),
  300. ),
  301. migrations.AddConstraint(
  302. model_name='tunneltermination',
  303. constraint=models.UniqueConstraint(
  304. fields=('termination_type', 'termination_id'),
  305. name='vpn_tunneltermination_termination',
  306. violation_error_message='An object may be terminated to only one tunnel at a time.',
  307. ),
  308. ),
  309. ]