예제 #1
0
    def update_cluster(self, info, data, callback):
        """
        updates an individual Cluster, this is the actual work function

        @param info - info from ganeti
        @param data - data from database
        @param callback - callback fired when method is complete.
        """
        mtime = data['mtime']
        if not mtime or mtime < info['mtime']:
            print '    Cluster (updated) : %(hostname)s' % data
            #print '        %s :: %s' % (mtime, datetime.fromtimestamp(info['mtime']))
            # only update the whole object if it is new or modified.
            #
            parsed = Cluster.parse_persistent_info(info)
            Cluster.objects.filter(pk=data['id']) \
                .update(serialized_info=cPickle.dumps(info), **parsed)
        callback(data['id'])