Revision 76a429fb

b/README.deploy
142 142
      VNCAUTHPROXY_CTRL_SOCKET.
143 143

  
144 144

  
145
-Administration
146
    * Reconciliation process: On certain occasions, such as a Ganeti or
147
      RabbitMQ failure, the VM state in the system's database may differ from
148
      that in the Ganeti installation. The reconciliation process is designed
149
      to bring the system's database in sync with what Ganeti knows about
150
      each VM.
151

  
152
      The reconciliation process can be triggered for all VMs using the command
153

  
154
          ./manage.py reconcile --all
155

  
156
      It is advised, though not strictly necessary, to run the reconciliation
157
      process periodically, through cron. To avoid overloading the Ganeti
158
      master, the periodic reconciliation process takes a staggered approach
159
      to updating the VMs, which is configured through the following
160
      parameters:
161

  
162
        * The settings.py parameter: RECONCILIATION_MIN, which specifies the
163
        maximum time a VM can remain ``non-reconciled''. (default: 30 mins)
164

  
165
        * The --interval option to the reconcile command, which declares the
166
         interval time between reconciliation attempts (default: 1 min)
167

  
168
      On each invocation of the reconcile command, the system will trigger a
169
      reconciliation for ((num_all_vms/RECONCILIATION_MIN) * interval)
170
      machines. Obviously the less the interval value and the more the
171
      RECONCILIATION_MIN setting, the less load is going to be put on Ganeti.
172

  
173

  
145 174
- OS Specific instructions
146 175

  
147 176
    * Debian Squeeze
b/conf/ci/pip-1.2.conf
9 9
amqplib==0.6.1
10 10
daemon==1.0
11 11
pycrypto==2.1.0
12

  
b/logic/management/commands/reconcile.py
29 29
#
30 30
# Reconcile VM state - Management Script
31 31

  
32

  
33
from django.core.management.base import NoArgsCommand
34 32
from synnefo.db.models import VirtualMachine
35 33
from django.conf import settings
36 34
from datetime import datetime, timedelta
35
from optparse import make_option
36
from django.core.management.base import BaseCommand
37 37

  
38 38
from synnefo.logic import amqp_connection
39 39
from synnefo.logic.amqp_connection import AMQPError
......
41 41
import json
42 42
import sys
43 43

  
44
class Command(NoArgsCommand):
44
class Command(BaseCommand):
45 45
    help = 'Reconcile VM status with the backend'
46 46

  
47
    def handle_noargs(self, **options):
47
    option_list = BaseCommand.option_list +  (
48
         make_option('--all', action='store_true', dest='all_vms', default=False,
49
                     help='Run the reconciliation function for all VMs, now'),
50
         make_option('--interval', action='store', dest='interval', default=1,
51
                     help='Interval in minutes between reconciliations'),
52
    )
53

  
54
    def handle(self, all_vms = False, interval = 1, **options):
55
        all =  VirtualMachine.objects.all()
48 56

  
49
        now = datetime.now()
50
        last_update = timedelta(minutes = settings.RECONCILIATION_MIN)
51
        not_updated = VirtualMachine.objects \
57
        if not all_vms:
58
            now = datetime.now()
59
            last_update = timedelta(minutes = settings.RECONCILIATION_MIN)
60
            not_updated = VirtualMachine.objects \
52 61
                                    .filter(deleted = False) \
53 62
                                    .filter(suspended = False) \
54 63
                                    .filter(updated__lte = (now - last_update))
55
        all =  VirtualMachine.objects.all()
56 64

  
57
        to_update = all.count() / settings.RECONCILIATION_MIN
65
            to_update = ((all.count() / settings.RECONCILIATION_MIN) * interval)
66
        else:
67
            to_update = all.count()
68
            not_updated = all
69

  
58 70
        vm_ids = map(lambda x: x.id, not_updated[:to_update])
59 71

  
60 72
        for vmid in vm_ids :

Also available in: Unified diff