mirror of https://gitlab.federez.net/re2o/re2o
committed by
chirac
10 changed files with 189 additions and 42 deletions
@ -0,0 +1,30 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0048_ap_machine'), |
||||
|
] |
||||
|
|
||||
|
|
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='NewSw', |
||||
|
fields=[ |
||||
|
('machine_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='machines.Machine')), |
||||
|
('location', models.CharField(max_length=255)), |
||||
|
('number', models.PositiveIntegerField()), |
||||
|
('stack_member_id', models.PositiveIntegerField(blank=True, null=True)), |
||||
|
('model', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='topologie.ModelSwitch')), |
||||
|
('stack', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='topologie.Stack')), |
||||
|
], |
||||
|
bases=('machines.machine',), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,21 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-03-25 00:52 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0049_switchs_machine'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.AddField( |
||||
|
model_name='port', |
||||
|
name='new_sw', |
||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='ports', to='topologie.NewSw'), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,33 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2017-12-31 19:53 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0050_port_new_switch'), |
||||
|
] |
||||
|
|
||||
|
def transfer_port(apps, schema_editor): |
||||
|
db_alias = schema_editor.connection.alias |
||||
|
port = apps.get_model("topologie", "Port") |
||||
|
switch = apps.get_model("topologie", "NewSw") |
||||
|
port_list = port.objects.using(db_alias).all() |
||||
|
for p in port_list: |
||||
|
p.new_sw = switch.objects.filter(machine_ptr=p.switch.machine).first() |
||||
|
p.save() |
||||
|
|
||||
|
def untransfer_port(apps, schema_editor): |
||||
|
return |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(transfer_port, untransfer_port), |
||||
|
migrations.RemoveField( |
||||
|
model_name='port', |
||||
|
name='switch', |
||||
|
), |
||||
|
migrations.RenameField('Port', 'new_sw', 'switch') |
||||
|
] |
||||
@ -0,0 +1,42 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0051_transferports'), |
||||
|
] |
||||
|
|
||||
|
def transfer_sw(apps, schema_editor): |
||||
|
db_alias = schema_editor.connection.alias |
||||
|
newswitch = apps.get_model("topologie", "NewSw") |
||||
|
switch = apps.get_model("topologie", "Switch") |
||||
|
machine = apps.get_model("machines", "Machine") |
||||
|
sw_list = switch.objects.using(db_alias).all() |
||||
|
for sw in sw_list: |
||||
|
new_sw = newswitch() |
||||
|
new_sw.location = sw.location |
||||
|
new_sw.number = sw.number |
||||
|
new_sw.details = sw.details |
||||
|
new_sw.stack = sw.stack |
||||
|
new_sw.stack_member_id = sw.stack_member_id |
||||
|
new_sw.model = sw.model |
||||
|
new_sw.machine_ptr_id = sw.interface_ptr.machine.pk |
||||
|
new_sw.__dict__.update(sw.interface_ptr.machine.__dict__) |
||||
|
new_sw.save() |
||||
|
|
||||
|
def untransfer_sw(apps, schema_editor): |
||||
|
return |
||||
|
|
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(transfer_sw, untransfer_sw), |
||||
|
migrations.DeleteModel( |
||||
|
name='Switch', |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.10.7 on 2018-03-23 01:18 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('topologie', '0052_switchs_machine'), |
||||
|
] |
||||
|
|
||||
|
|
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RenameModel( |
||||
|
old_name='NewSw', |
||||
|
new_name='Switch', |
||||
|
), |
||||
|
] |
||||
Loading…
Reference in new issue