Eject a device after unmounting all its mounted filesystems.

        :param device: device object, block device path or mount path
        :param bool force: remove child devices before trying to eject
        :returns: whether the operation succeeded
168698
async def eject(self, device, force=False):
        
        device = self._find_device(device)
        if not self.is_handleable(device):
            self._log.warn(_('not ejecting {0}: unhandled device'))
            return False
        drive = device.drive
        if not (drive.is_drive and drive.is_ejectable):
            self._log.warn(_('not ejecting {0}: drive not ejectable', drive))
            return False
        if force:
            # Can't autoremove 'device.drive', because that will be filtered
            # due to block=False:
            await self.auto_remove(device.root, force=True)
        self._log.debug(_('ejecting {0}', device))
        await drive.eject()
        self._log.info(_('ejected {0}', device))
        return True
312334
async def remove(self, *, node_id: str, force: bool = False) -> Mapping[str, Any]:
        

        params = {"force": force}

        response = await self.docker._query_json(
            "nodes/{node_id}".format(node_id=node_id), method="DELETE", params=params
        )
        return response
921996
def _force_close(self):
        """"""
        if self._sock:
            try:
                self._sock.close()
            except:  # noqa
                pass
        self._sock = None
        self._rfile = None
1313562
def _unmount_devicemapper(self, cid):
        
        mountpoint = self.mountpoint
        Mount.unmount_path(mountpoint)

        cinfo = self.client.inspect_container(cid)
        dev_name = cinfo['GraphDriver']['Data']['DeviceName']

        Mount.remove_thin_device(dev_name)
        self._cleanup_container(cinfo)
264071
def __mount_device(action):
    '''
    
    '''
    @functools.wraps(action)
    def wrapper(*args, **kwargs):
        name = kwargs['name']
        device = kwargs['device']

        ret = {
            'name': name,
            'result': False,
            'changes': {},
            'comment': ['Some error happends during the operation.'],
        }
        try:
            dest = _mount(device)
            if not dest:
                msg = 'Device {} cannot be mounted'.format(device)
                ret['comment'].append(msg)
            kwargs['__dest'] = dest
            ret = action(*args, **kwargs)
        except Exception as e:
            log.exception('Encountered error mounting %s', device)
            ret['comment'].append(six.text_type(e))
        finally:
            _umount(dest)
        return ret
    return wrapper
1126150
def destroy(device):
    '''
    
    '''
    try:
        details = detail(device)
    except CommandExecutionError:
        return False

    stop_cmd = ['mdadm', '--stop', device]
    zero_cmd = ['mdadm', '--zero-superblock']

    if __salt__['cmd.retcode'](stop_cmd, python_shell=False) == 0:
        for number in details['members']:
            zero_cmd.append(details['members'][number]['device'])
        __salt__['cmd.retcode'](zero_cmd, python_shell=False)

    # Remove entry from config file:
    if __grains__.get('os_family') == 'Debian':
        cfg_file = '/etc/mdadm/mdadm.conf'
    else:
        cfg_file = '/etc/mdadm.conf'

    try:
        __salt__['file.replace'](cfg_file, 'ARRAY {0} .*'.format(device), '')
    except SaltInvocationError:
        pass

    if __salt__['raid.list']().get(device) is None:
        return True
    else:
        return False
1166402
def deleteFrom(self, organization, devices):
        
        for device in devices:
            url = self.BASE_URL+self.BASE_PATH+self.ORGS_PATH+"/"+ str(organization["id"]) + self.DEVICES_PATH+ "/" + str(device["id"]) + self.USER_QUERY
            response = self.requests.delete(url, auth=(self.__username, self.__password))
            response.raise_for_status()
736326
def reboot(self, devices):
        
        for device in devices:
            self.logger.info('Rebooting: %s', device.id)
            try:
                device.reboot()
            except packet.baseapi.Error:
                raise PacketManagerException('Unable to reboot instance "{}"'.format(device.id))
231626
def remove_device(self, path):
        ""
        if self.__get_control_socket():
            self.sock.sendall("-%s\r\n\x00" % path)
            self.sock.recv(12)
            self.sock.close()
756371
async def destroy(self, force=False):
        
        facade = client.ClientFacade.from_connection(self.connection)

        log.debug(
            'Destroying machine %s', self.id)

        await facade.DestroyMachines(force, [self.id])
        return await self.model._wait(
            'machine', self.id, 'remove')
384083
async def async_delete_device(self, device_id: int) -> None:
        

        # Lookup device using zone to obtain an accurate index, which is
        # needed to perform the delete command
        device = self._devices[device_id]
        response = await self._protocol.async_execute(
            GetDeviceCommand(device.category, device.group_number, device.unit_number))
        if isinstance(response, DeviceInfoResponse):
            response = await self._protocol.async_execute(
                DeleteDeviceCommand(device.category, response.index))
            if isinstance(response, DeviceDeletedResponse):
                self._devices._delete(device) # pylint: disable=protected-access
                if self._on_device_deleted:
                    try:
                        self._on_device_deleted(self, device)  # pylint: disable=protected-access
                    except Exception: # pylint: disable=broad-except
                        _LOGGER.error(
                            "Unhandled exception in on_device_deleted callback",
                            exc_info=True)
        if isinstance(response, DeviceNotFoundResponse):
            raise ValueError("Device to be deleted was not found")
412409
def delete(self, force=False, **kwargs):
        
        cmdline = ["podman", "rm", "--force" if force else "", self.get_name()]
        run_cmd(cmdline)
546300
def remove_container(self, container_id, force=False):
        
        logger.info("removing container '%s' from filesystem", container_id)
        logger.debug("container_id = '%s'", container_id)
        self.d.remove_container(container_id, force=force)
248092
def umount(self, forced=True):
        
        if self.is_mounted():
            if is_osx():
                cmd = ["/usr/sbin/diskutil", "unmount",
                       self.connection["mount_point"]]
                if forced:
                    cmd.insert(2, "force")
                subprocess.check_call(cmd)
            else:
                cmd = ["umount", self.connection["mount_point"]]
                if forced:
                    cmd.insert(1, "-f")
                subprocess.check_call(cmd)
580880
def detach(self):
        
        self._client.post('{}/detach'.format(Volume.api_endpoint), model=self)

        return True
256497
def remove(self, force=False):
        
        if force:
            _fs, filename = opener.parse(self.uri)
            _fs.remove(filename)
        self.uri = None
492188
def close(self, force=False):
        
        if self.__write:
            self.write = self.__write_adhoc
            self.__write = False

        if not self._is_buffer or force:
            self._file.close()