0041_napalm_integration.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # -*- coding: utf-8 -*-
  2. # Generated by Django 1.11.3 on 2017-07-14 17:26
  3. from __future__ import unicode_literals
  4. from django.db import migrations, models
  5. def rpc_client_to_napalm_driver(apps, schema_editor):
  6. """
  7. Migrate legacy RPC clients to their respective NAPALM drivers
  8. """
  9. Platform = apps.get_model('dcim', 'Platform')
  10. Platform.objects.filter(rpc_client='juniper-junos').update(napalm_driver='junos')
  11. Platform.objects.filter(rpc_client='cisco-ios').update(napalm_driver='ios')
  12. class Migration(migrations.Migration):
  13. dependencies = [
  14. ('dcim', '0040_inventoryitem_add_asset_tag_description'),
  15. ]
  16. operations = [
  17. migrations.AlterModelOptions(
  18. name='device',
  19. options={'ordering': ['name'], 'permissions': (('napalm_read', 'Read-only access to devices via NAPALM'), ('napalm_write', 'Read/write access to devices via NAPALM'))},
  20. ),
  21. migrations.AddField(
  22. model_name='platform',
  23. name='napalm_driver',
  24. field=models.CharField(blank=True, help_text='The name of the NAPALM driver to use when interacting with devices.', max_length=50, verbose_name='NAPALM driver'),
  25. ),
  26. migrations.AlterField(
  27. model_name='platform',
  28. name='rpc_client',
  29. field=models.CharField(blank=True, choices=[['juniper-junos', 'Juniper Junos (NETCONF)'], ['cisco-ios', 'Cisco IOS (SSH)'], ['opengear', 'Opengear (SSH)']], max_length=30, verbose_name='Legacy RPC client'),
  30. ),
  31. migrations.RunPython(rpc_client_to_napalm_driver),
  32. ]