(self)
on Windows, in order to collect statistics on remote (SMB/NFS) drives, the drive must be mounted
        as the agent user in the agent context, otherwise the agent can't 'see' the drive.  If so configured,
        attempt to mount desired drives
on Windows, in order to collect statistics on remote (SMB/NFS) drives, the drive must be mounted
        as the agent user in the agent context, otherwise the agent can't 'see' the drive.  If so configured,
        attempt to mount desired drives
on Windows in order to collect statistics on remote ( SMB / NFS ) drives the drive must be mounted as the agent user in the agent context otherwise the agent can t see the drive . If so configured attempt to mount desired drives
def _create_manual_mounts(self):
        """
        on Windows, in order to collect statistics on remote (SMB/NFS) drives, the drive must be mounted
        as the agent user in the agent context, otherwise the agent can't 'see' the drive.  If so configured,
        attempt to mount desired drives
        """
        if not self._manual_mounts:
            self.log.debug("No manual mounts")
        else:
            self.log.debug("Attempting to create %d mounts: ", len(self._manual_mounts))
            for manual_mount in self._manual_mounts:
                remote_machine = manual_mount.get('host')
                share = manual_mount.get('share')
                uname = manual_mount.get('user')
                pword = manual_mount.get('password')
                mtype = manual_mount.get('type')
                mountpoint = manual_mount.get('mountpoint')

                nr = win32wnet.NETRESOURCE()
                if not remote_machine or not share:
                    self.log.error("Invalid configuration.  Drive mount requires remote machine and share point")
                    continue

                if mtype and mtype.lower() == "nfs":
                    nr.lpRemoteName = r"{}:{}".format(remote_machine, share)
                    self.log.debug("Attempting NFS mount: %s", nr.lpRemoteName)
                else:
                    nr.lpRemoteName = r"\\{}\{}".format(remote_machine, share).rstrip('\\')
                    self.log.debug("Attempting SMB mount: %s", nr.lpRemoteName)

                nr.dwType = 0
                nr.lpLocalName = mountpoint
                try:
                    win32wnet.WNetAddConnection2(nr, pword, uname, 0)
                    self.log.debug("Successfully mounted %s as %s", mountpoint, nr.lpRemoteName)
                except Exception as e:
                    self.log.error("Failed to mount %s %s", nr.lpRemoteName, str(e))
                    pass
def _create_manual_mounts ( self ) : if not self . _manual_mounts : self . log . debug ( "No manual mounts" ) else : self . log . debug ( "Attempting to create %d mounts: " , len ( self . _manual_mounts ) ) for manual_mount in self . _manual_mounts : remote_machine = manual_mount . get ( 'host' ) share = manual_mount . get ( 'share' ) uname = manual_mount . get ( 'user' ) pword = manual_mount . get ( 'password' ) mtype = manual_mount . get ( 'type' ) mountpoint = manual_mount . get ( 'mountpoint' ) nr = win32wnet . NETRESOURCE ( ) if not remote_machine or not share : self . log . error ( "Invalid configuration.  Drive mount requires remote machine and share point" ) continue if mtype and mtype . lower ( ) == "nfs" : nr . lpRemoteName = r"{}:{}" . format ( remote_machine , share ) self . log . debug ( "Attempting NFS mount: %s" , nr . lpRemoteName ) else : nr . lpRemoteName = r"\\{}\{}" . format ( remote_machine , share ) . rstrip ( '\\' ) self . log . debug ( "Attempting SMB mount: %s" , nr . lpRemoteName ) nr . dwType = 0 nr . lpLocalName = mountpoint try : win32wnet . WNetAddConnection2 ( nr , pword , uname , 0 ) self . log . debug ( "Successfully mounted %s as %s" , mountpoint , nr . lpRemoteName ) except Exception as e : self . log . error ( "Failed to mount %s %s" , nr . lpRemoteName , str ( e ) ) pass