~maas-committers/maas/1.2

« back to all changes in this revision

Viewing changes to src/maasserver/migrations/0010_add_node_netboot.py

[r=julian-edwards][bug=1208497][author=rvb] Backport revision 1624. Set netboot=False on the allocated nodes with netboot=True. in migration #10.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
# encoding: utf-8
6
6
import datetime
 
7
 
 
8
from django.db import models
 
9
from maasserver.enum import NODE_STATUS
7
10
from south.db import db
8
11
from south.v2 import SchemaMigration
9
 
from django.db import models
 
12
 
10
13
 
11
14
class Migration(SchemaMigration):
12
15
 
15
18
        # Adding field 'Node.netboot'
16
19
        db.add_column(u'maasserver_node', 'netboot', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False)
17
20
 
 
21
        # Find all the allocated nodes with netboot=True.
 
22
        allocated_nodes = orm['maasserver.node'].objects.filter(
 
23
            status=NODE_STATUS.ALLOCATED, netboot=True)
 
24
        # Set netboot=False on these nodes.
 
25
        allocated_nodes.update(netboot=False)
18
26
 
19
27
    def backwards(self, orm):
20
28