コード例 #1
0
    def save(self, *args, **kwargs):
        self.full_clean()

        # Grab a copy of the outlet pre-save so that we can determine
        # which hosts need to have their fencing reconfigured.
        try:
            old_self = PowerControlDeviceOutlet.objects.get(pk=self.pk)
        except PowerControlDeviceOutlet.DoesNotExist:
            old_self = None

        super(PowerControlDeviceOutlet, self).save(*args, **kwargs)

        # Need to force a commit here to ensure that the updated outlet
        # configuration is available to other threads (e.g. fence reconfig).
        from django.db import transaction
        transaction.commit()

        reconfigure = {'reconfigure_fencing': True}
        previous = old_self.host if old_self else None
        for host in self._hosts_for_fence_reconfiguration(self.host, previous):
            if host.pacemaker_configuration:
                job_scheduler_notify.notify(host.pacemaker_configuration,
                                            tznow(), reconfigure)
            else:
                job_log.debug("Skipping reconfiguration of non-server %s" %
                              host)
コード例 #2
0
    def save(self, *args, **kwargs):
        self.full_clean()

        # Grab a copy of the outlet pre-save so that we can determine
        # which hosts need to have their fencing reconfigured.
        try:
            old_self = PowerControlDeviceOutlet.objects.get(pk=self.pk)
        except PowerControlDeviceOutlet.DoesNotExist:
            old_self = None

        super(PowerControlDeviceOutlet, self).save(*args, **kwargs)

        reconfigure = {"reconfigure_fencing": True}
        previous = old_self.host if old_self else None
        for host in self._hosts_for_fence_reconfiguration(self.host, previous):
            if host.pacemaker_configuration:
                job_scheduler_notify.notify(host.pacemaker_configuration,
                                            tznow(), reconfigure)
            else:
                job_log.debug("Skipping reconfiguration of non-server %s" %
                              host)
コード例 #3
0
    def _hosts_for_fence_reconfiguration(self, current, previous):
        hosts = []

        job_log.debug("Fence reconfiguration plan for new: %s, old: %s" %
                      (current, previous))
        if current:
            job_log.debug("* %s: add outlet %s" % (current, self.id))
            hosts.append(current)

        if previous and previous != current:
            job_log.debug("* %s: remove outlet %s" % (previous, self.id))
            hosts.append(previous)

        return hosts