Ensure that a Physical Device is not being used by lvm

    name
        The device name to initialize.
183776
def pv_absent(name):
    '''
    
    '''
    ret = {'changes': {},
           'comment': '',
           'name': name,
           'result': True}

    if not __salt__['lvm.pvdisplay'](name, quiet=True):
        ret['comment'] = 'Physical Volume {0} does not exist'.format(name)
    elif __opts__['test']:
        ret['comment'] = 'Physical Volume {0} is set to be removed'.format(name)
        ret['result'] = None
        return ret
    else:
        changes = __salt__['lvm.pvremove'](name)

        if __salt__['lvm.pvdisplay'](name, quiet=True):
            ret['comment'] = 'Failed to remove Physical Volume {0}'.format(name)
            ret['result'] = False
        else:
            ret['comment'] = 'Removed Physical Volume {0}'.format(name)
            ret['changes']['removed'] = changes
    return ret
899622
def _exclusively_used(self, context, hosting_device, tenant_id):
        """"""
        return (context.session.query(hd_models.SlotAllocation).filter(
            hd_models.SlotAllocation.hosting_device_id == hosting_device['id'],
            hd_models.SlotAllocation.logical_resource_owner != tenant_id).
            first() is None)
449420
def oem_init(self):
        
        if self._oemknown:
            return
        self._oem, self._oemknown = get_oem_handler(self._get_device_id(),
                                                    self)
292554
def pvremove(devices, override=True):
    '''
    
    '''
    if isinstance(devices, six.string_types):
        devices = devices.split(',')

    cmd = ['pvremove', '-y']
    for device in devices:
        if pvdisplay(device):
            cmd.append(device)
        elif not override:
            raise CommandExecutionError('{0} is not a physical volume'.format(device))

    if not cmd[2:]:
        # Nothing to do
        return True

    out = __salt__['cmd.run_all'](cmd, python_shell=False)
    if out.get('retcode'):
        raise CommandExecutionError(out.get('stderr'))

    # Verify pvcremove was successful
    for device in devices:
        if pvdisplay(device, quiet=True):
            raise CommandExecutionError('Device "{0}" was not affected.'.format(device))

    return True
601983
def set_vm_status(self, device='FLOPPY',
                      boot_option='BOOT_ONCE', write_protect='YES'):
        
        return self._call_method('set_vm_status', device, boot_option,
                                 write_protect)
1311309
def manage_extant(self, **kwargs):
        '''
        '''

        self._check_device_number(kwargs['devices'])
        self.trust_domain = TrustDomain(
            devices=kwargs['devices'],
            partition=kwargs['device_group_partition']
        )
        self.device_group = DeviceGroup(**kwargs)
        self.cluster = Cluster(**kwargs)
756381
def device_unmounted(self, device):
        """"""
        if not self._mounter.is_handleable(device):
            return
        self._show_notification(
            'device_unmounted',
            _('Device unmounted'),
            _('{0.ui_label} unmounted', device),
            device.icon_name)
493903
def set_device_name(self, new_name):
        

        device_name = self.get_characteristic_handle_from_uuid(UUID_DEVICE_NAME)
        if device_name is None:
            logger.warn('Failed to find handle for device name')
            return False
        
        if len(new_name) > MAX_DEVICE_NAME_LEN:
            logger.error('Device name exceeds maximum length ({} > {})'.format(len(new_name), MAX_DEVICE_NAME_LEN))
            return False

        if self.dongle._write_attribute(self.conn_handle, device_name, new_name.encode('ascii')):
            self.name = new_name
            return True

        return False
661820
def deactivate_lvm_volume_group(block_device):
    '''
    
    '''
    vg = list_lvm_volume_group(block_device)
    if vg:
        cmd = ['vgchange', '-an', vg]
        check_call(cmd)
905957
def id(self, value):
        
        if value == self._defaults['ai.device.id'] and 'ai.device.id' in self._values:
            del self._values['ai.device.id']
        else:
            self._values['ai.device.id'] = value
1325751
def get_strict_value(self, name):
        
        dev_info = self.json_state.get('deviceInfo')
        return dev_info.get(name, None)
1279676
def name(self):
		

		pchar = self._libinput.libinput_device_get_name(self._handle)
		return string_at(pchar).decode()
1270552
def _erase_vm_info(name):
    '''
    
    '''
    try:
        # delete the machine record
        vm_ = get_vm_info(name)
        if vm_['machine']:
            key = _build_machine_uri(vm_['machine'], vm_.get('cwd', '.'))
            try:
                __utils__['sdb.sdb_delete'](key, __opts__)
            except KeyError:
                # no delete method found -- load a blank value
                __utils__['sdb.sdb_set'](key, None, __opts__)
    except Exception:
        pass

    uri = _build_sdb_uri(name)
    try:
        # delete the name record
        __utils__['sdb.sdb_delete'](uri, __opts__)
    except KeyError:
        # no delete method found -- load an empty dictionary
        __utils__['sdb.sdb_set'](uri, {}, __opts__)
    except Exception:
        pass
1260681
def get_device_names_to_objects(devices):
    '''
    '''

    name_to_object = {}
    for device in devices:
        device_name = get_device_info(device).name
        name_to_object[device_name] = device
    return name_to_object
1231454
def _remove_trustee(self, device):
        '''
        '''

        trustee_name = get_device_info(device).name
        name_object_map = get_device_names_to_objects(self.devices)
        delete_func = self._get_delete_trustee_cmd

        for truster in self.domain:
            if trustee_name in self.domain[truster] and \
                    truster != trustee_name:
                truster_obj = name_object_map[truster]
                self._modify_trust(truster_obj, delete_func, trustee_name)
            self._populate_domain()

        for trustee in self.domain[trustee_name]:
            if trustee_name != trustee:
                self._modify_trust(device, delete_func, trustee)

        self.devices.remove(name_object_map[trustee_name])
473822
def power_on(env, identifier):
    """"""

    mgr = SoftLayer.HardwareManager(env.client)
    hw_id = helpers.resolve_id(mgr.resolve_ids, identifier, 'hardware')
    env.client['Hardware_Server'].powerOn(id=hw_id)
105616
def _lock(self):
        """"""
        if not self.locked:
            try:
                self.device.cu.lock()
                self.locked = True
            except JnprLockError as jle:
                raise LockError(py23_compat.text_type(jle))