Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
03f5d4bb
Commit
03f5d4bb
authored
Dec 09, 2013
by
Christos Stavrakakis
Browse files
cyclades: Speedup db data migrations
parent
c024d130
Changes
2
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/db/migrations/0077_migrate_networks_to_subnets.py
View file @
03f5d4bb
...
...
@@ -10,7 +10,7 @@ class Migration(DataMigration):
def
forwards
(
self
,
orm
):
"Write your forwards methods here."
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
for
network
in
orm
.
Network
.
objects
.
all
():
for
network
in
orm
.
Network
.
objects
.
select_related
(
'pool'
).
all
():
if
network
.
subnet
:
subnet
=
orm
.
Subnet
.
objects
.
create
(
network
=
network
,
ipversion
=
4
,
...
...
@@ -18,14 +18,16 @@ class Migration(DataMigration):
gateway
=
network
.
gateway
,
dhcp
=
network
.
dhcp
,
deleted
=
network
.
deleted
)
ip_pool
=
network
.
pool
if
ip_pool
is
None
:
ip_pool
=
orm
.
IPPoolTable
()
ip_pool
.
subnet
=
subnet
ip_pool
.
base
=
subnet
.
cidr
ip_pool
.
offset
=
0
ip_pool
.
size
=
ipaddr
.
IPNetwork
(
network
.
subnet
).
numhosts
ip_pool
.
save
()
if
not
network
.
deleted
:
ip_pool
=
network
.
pool
if
ip_pool
is
None
:
ip_pool
=
orm
.
IPPoolTable
()
ip_pool
.
subnet
=
subnet
ip_pool
.
base
=
subnet
.
cidr
ip_pool
.
offset
=
0
ip_pool
.
size
=
ipaddr
.
IPNetwork
(
network
.
subnet
).
numhosts
ip_pool
.
save
()
if
network
.
subnet6
:
orm
.
Subnet
.
objects
.
create
(
network
=
network
,
...
...
snf-cyclades-app/synnefo/db/migrations/0080_nics_to_ips.py
View file @
03f5d4bb
...
...
@@ -11,7 +11,8 @@ class Migration(DataMigration):
# Note: Remember to use orm['appname.ModelName'] rather than "from appname.models..."
# Delete stale NICs
orm
.
NetworkInterface
.
objects
.
filter
(
machine__deleted
=
True
).
delete
()
for
nic
in
orm
.
NetworkInterface
.
objects
.
all
():
for
nic
in
orm
.
NetworkInterface
.
objects
.
select_related
(
'machine'
,
'network'
).
all
():
userid
=
nic
.
machine
.
userid
nic
.
userid
=
userid
nic
.
save
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment