function checkForDisconnectedDevices(bigIp) {
        return bigIp.cluster.getCmSyncStatus()
            .then((response) => {
                logger.silly('cmSyncStatus:', response);

                const disconnected = response ? response.disconnected : [];
                const hostnames = [];
                const hostnamesToRemove = [];

                // response is an object of two lists (connected/disconnected) from getCmSyncStatus()
                if (disconnected.length > 0) {
                    logger.info('Possibly disconnected devices:', disconnected);

                    // get a list of hostnames still in the instances list
                    Object.keys(this.instances).forEach((instanceId) => {
                        if (this.instances[instanceId].hostname) {
                            hostnames.push(this.instances[instanceId].hostname);
                        }
                    });

                    // make sure this is not still in the instances list
                    disconnected.forEach((hostname) => {
                        if (hostnames.indexOf(hostname) === -1) {
                            logger.info('Disconnected device:', hostname);
                            hostnamesToRemove.push(hostname);
                        }
                    });

                    if (hostnamesToRemove.length > 0) {
                        logger.info('Removing devices from cluster:', hostnamesToRemove);
                        return bigIp.cluster.removeFromCluster(hostnamesToRemove);
                    }
                }
                return q();
            })
            .catch((err) => {
                logger.warn('Could not get sync status');
                return q.reject(err);
            });
    }
function checkForDisconnectedDevices(bigIp) {
        return bigIp.cluster.getCmSyncStatus()
            .then((response) => {
                logger.silly('cmSyncStatus:', response);

                const disconnected = response ? response.disconnected : [];
                const hostnames = [];
                const hostnamesToRemove = [];

                
                if (disconnected.length > 0) {
                    logger.info('Possibly disconnected devices:', disconnected);

                    
                    Object.keys(this.instances).forEach((instanceId) => {
                        if (this.instances[instanceId].hostname) {
                            hostnames.push(this.instances[instanceId].hostname);
                        }
                    });

                    
                    disconnected.forEach((hostname) => {
                        if (hostnames.indexOf(hostname) === -1) {
                            logger.info('Disconnected device:', hostname);
                            hostnamesToRemove.push(hostname);
                        }
                    });

                    if (hostnamesToRemove.length > 0) {
                        logger.info('Removing devices from cluster:', hostnamesToRemove);
                        return bigIp.cluster.removeFromCluster(hostnamesToRemove);
                    }
                }
                return q();
            })
            .catch((err) => {
                logger.warn('Could not get sync status');
                return q.reject(err);
            });
    }
function checkForDisconnectedDevices ( bigIp ) { return bigIp . cluster . getCmSyncStatus ( ) . then ( ( response ) => { logger . silly ( 'cmSyncStatus:' , response ) ; const disconnected = response ? response . disconnected : [ ] ; const hostnames = [ ] ; const hostnamesToRemove = [ ] ; // response is an object of two lists (connected/disconnected) from getCmSyncStatus() if ( disconnected . length > 0 ) { logger . info ( 'Possibly disconnected devices:' , disconnected ) ; // get a list of hostnames still in the instances list Object . keys ( this . instances ) . forEach ( ( instanceId ) => { if ( this . instances [ instanceId ] . hostname ) { hostnames . push ( this . instances [ instanceId ] . hostname ) ; } } ) ; // make sure this is not still in the instances list disconnected . forEach ( ( hostname ) => { if ( hostnames . indexOf ( hostname ) === - 1 ) { logger . info ( 'Disconnected device:' , hostname ) ; hostnamesToRemove . push ( hostname ) ; } } ) ; if ( hostnamesToRemove . length > 0 ) { logger . info ( 'Removing devices from cluster:' , hostnamesToRemove ) ; return bigIp . cluster . removeFromCluster ( hostnamesToRemove ) ; } } return q ( ) ; } ) . catch ( ( err ) => { logger . warn ( 'Could not get sync status' ) ; return q . reject ( err ) ; } ) ; }
Called with this bound to the caller
Called with this bound to the caller