mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Split migrator logic across migrations
This commit is contained in:
parent
71ee2a996e
commit
d223c01dcd
@ -68,8 +68,6 @@ def oc_circuittermination_termination(objectchange, reverting):
|
||||
'termination_type': provider_network_ct,
|
||||
'termination_id': provider_network_id,
|
||||
})
|
||||
data.pop('site', None)
|
||||
data.pop('provider_network', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
|
@ -86,3 +86,15 @@ class Migration(migrations.Migration):
|
||||
new_name='_provider_network',
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def oc_circuittermination_remove_fields(objectchange, reverting):
|
||||
for data in (objectchange.prechange_data, objectchange.postchange_data):
|
||||
if data is not None:
|
||||
data.pop('site', None)
|
||||
data.pop('provider_network', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
'circuits.circuittermination': oc_circuittermination_remove_fields,
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ def oc_prefix_scope(objectchange, reverting):
|
||||
'scope_type': site_ct,
|
||||
'scope_id': site_id,
|
||||
})
|
||||
data.pop('site', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
|
@ -60,3 +60,14 @@ class Migration(migrations.Migration):
|
||||
name='site',
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def oc_prefix_remove_fields(objectchange, reverting):
|
||||
for data in (objectchange.prechange_data, objectchange.postchange_data):
|
||||
if data is not None:
|
||||
data.pop('site', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
'ipam.prefix': oc_prefix_remove_fields,
|
||||
}
|
||||
|
@ -73,8 +73,6 @@ def oc_service_parent(objectchange, reverting):
|
||||
'parent_object_type': virtual_machine_ct,
|
||||
'parent_object_id': virtual_machine_id,
|
||||
})
|
||||
data.pop('device', None)
|
||||
data.pop('virtual_machine', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
|
@ -37,3 +37,15 @@ class Migration(migrations.Migration):
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def oc_service_remove_fields(objectchange, reverting):
|
||||
for data in (objectchange.prechange_data, objectchange.postchange_data):
|
||||
if data is not None:
|
||||
data.pop('device', None)
|
||||
data.pop('virtual_machine', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
'ipam.service': oc_service_remove_fields,
|
||||
}
|
||||
|
@ -56,7 +56,6 @@ def oc_cluster_scope(objectchange, reverting):
|
||||
'scope_type': site_ct,
|
||||
'scope_id': site_id,
|
||||
})
|
||||
data.pop('site', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
|
@ -87,3 +87,14 @@ class Migration(migrations.Migration):
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
def oc_cluster_remove_site(objectchange, reverting):
|
||||
for data in (objectchange.prechange_data, objectchange.postchange_data):
|
||||
if data is not None:
|
||||
data.pop('site', None)
|
||||
|
||||
|
||||
objectchange_migrators = {
|
||||
'virtualization.cluster': oc_cluster_remove_site,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user