'Pull the remote configuration data'

def _pullRemoteConf(self):

    uniqueHostnames = []
    res = None
    try:
        res = urllib2.urlopen(self.confUrl)
        resBson = None
        try:
            resBson = bson.decode_all(res.read())
        finally:
            if (res is not None):
                res.close()
                res = None
        if (len(resBson) != 1):
            return
        confResponse = resBson[0]
        if ('hosts' not in confResponse):
            self.mmsAgent.stopAll()
            return
        if ('disableDbstats' in confResponse):
            self.mmsAgent.disableDbstats = confResponse['disableDbstats']
        else:
            self.mmsAgent.disableDbstats = False
        hosts = confResponse['hosts']
        self.mmsAgent.serverHostDefsLock.acquire()
        try:
            if (hosts is not None):
                for host in hosts:
                    (hostDef, hostDefLast) = self.mmsAgent.extractHostDef(host)
                    hostKey = hostDef['hostKey']
                    uniqueHostnames.append(hostKey)
                    if (hostKey not in self.mmsAgent.serverHostDefs):
                        self.mmsAgent.startMonitoringThreads(hostDef)
                    else:
                        self.mmsAgent.checkChangedHostDef(hostDef, hostDefLast)
                    hostDef = None
                    hostDefLast = None
            for hostDef in self.mmsAgent.serverHostDefs.values():
                if (hostDef['hostKey'] not in uniqueHostnames):
                    self.mmsAgent.stopAndClearHost(hostDef['hostKey'])
        finally:
            self.mmsAgent.serverHostDefsLock.release()
    except Exception as e:
        if (res is not None):
            try:
                res.close()
                res = None
            except:
                pass
        self.logger.warning(('Problem    pulling    configuration    data    from    MMS    (check    firewall    and    network):    ' + traceback.format_exc(e)))
