~vishvananda/nova/lp720393

« back to all changes in this revision

Viewing changes to nova/network/manager.py

  • Committer: Vishvananda Ishaya
  • Date: 2011-02-17 22:39:36 UTC
  • Revision ID: vishvananda@gmail.com-20110217223936-xv3q10tmy4aie0q6
move periodic tasks to base class based on class variable as per review

Show diffs side-by-side

added added

removed removed

Lines of Context:
110
110
 
111
111
    This class must be subclassed to support specific topologies.
112
112
    """
 
113
    timeout_fixed_ips = True
113
114
 
114
115
    def __init__(self, network_driver=None, *args, **kwargs):
115
116
        if not network_driver:
138
139
                self.driver.ensure_floating_forward(floating_ip['address'],
139
140
                                                    fixed_address)
140
141
 
 
142
    def periodic_tasks(self, context=None):
 
143
        """Tasks to be run at a periodic interval."""
 
144
        super(NetworkManager, self).periodic_tasks(context)
 
145
        if self.timeout_fixed_ips:
 
146
            now = utils.utcnow()
 
147
            timeout = FLAGS.fixed_ip_disassociate_timeout
 
148
            time = now - datetime.timedelta(seconds=timeout)
 
149
            num = self.db.fixed_ip_disassociate_all_by_timeout(context,
 
150
                                                               self.host,
 
151
                                                               time)
 
152
            if num:
 
153
                LOG.debug(_("Dissassociated %s stale fixed ip(s)"), num)
 
154
 
141
155
    def set_network_host(self, context, network_id):
142
156
        """Safely sets the host of the network."""
143
157
        LOG.debug(_("setting network host"), context=context)
306
320
    not do any setup in this mode, it must be done manually.  Requests to
307
321
    169.254.169.254 port 80 will need to be forwarded to the api server.
308
322
    """
 
323
    timeout_fixed_ips = False
309
324
 
310
325
    def allocate_fixed_ip(self, context, instance_id, *args, **kwargs):
311
326
        """Gets a fixed ip from the pool."""
397
412
    def periodic_tasks(self, context=None):
398
413
        """Tasks to be run at a periodic interval."""
399
414
        super(FlatDHCPManager, self).periodic_tasks(context)
400
 
        now = datetime.datetime.utcnow()
401
 
        timeout = FLAGS.fixed_ip_disassociate_timeout
402
 
        time = now - datetime.timedelta(seconds=timeout)
403
 
        num = self.db.fixed_ip_disassociate_all_by_timeout(context,
404
 
                                                           self.host,
405
 
                                                           time)
406
 
        if num:
407
 
            LOG.debug(_("Dissassociated %s stale fixed ip(s)"), num)
 
415
        self._disassociate_old_ips(context)
408
416
 
409
417
    def init_host(self):
410
418
        """Do any initialization that needs to be run if this is a
463
471
    instances in its subnet.
464
472
    """
465
473
 
466
 
    def periodic_tasks(self, context=None):
467
 
        """Tasks to be run at a periodic interval."""
468
 
        super(VlanManager, self).periodic_tasks(context)
469
 
        now = datetime.datetime.utcnow()
470
 
        timeout = FLAGS.fixed_ip_disassociate_timeout
471
 
        time = now - datetime.timedelta(seconds=timeout)
472
 
        num = self.db.fixed_ip_disassociate_all_by_timeout(context,
473
 
                                                           self.host,
474
 
                                                           time)
475
 
        if num:
476
 
            LOG.debug(_("Dissassociated %s stale fixed ip(s)"), num)
477
 
 
478
474
    def init_host(self):
479
475
        """Do any initialization that needs to be run if this is a
480
476
        standalone service.