Delete a vritual MFA device given its serial number

    :param iam_client:
    :param mfa_serial:
    :return:
185453
def delete_virtual_mfa_device(iam_client, mfa_serial):
    
    try:
        printInfo('Deleting MFA device %s...' % mfa_serial)
        iam_client.delete_virtual_mfa_device(SerialNumber = mfa_serial)
    except Exception as e:
        printException(e)
        printError('Failed to delete MFA device %s' % mfa_serial)
        pass
934775
def _delete_device(device):
    '''
    
    '''
    log.trace('Deleting device with type %s', type(device))
    device_spec = vim.vm.device.VirtualDeviceSpec()
    device_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.remove
    device_spec.device = device
    return device_spec
342621
def remove(self, processor_identity):
        
        with self._condition:
            processor_types = self._identities.get(processor_identity)
            if processor_types is None:
                LOGGER.warning("transaction processor with identity %s tried "
                               "to unregister but was not registered",
                               processor_identity)
                return
            for processor_type in processor_types:
                if processor_type not in self._processors:
                    LOGGER.warning("processor type %s not a known processor "
                                   "type but is associated with identity %s",
                                   processor_type,
                                   processor_identity)
                    continue
                self._processors[processor_type].remove_processor(
                    processor_identity=processor_identity)
                if not self._processors[processor_type]:
                    del self._processors[processor_type]
1090
def erase_device(passcode = '', preserve_data_plan: false)
      self.class.erase_device @id, passcode: passcode, preserve_data_plan: preserve_data_plan, api: @api
    end
911653
def delete_certificate(ctx, slot, management_key, pin):
    
    controller = ctx.obj['controller']
    _ensure_authenticated(ctx, controller, pin, management_key)
    controller.delete_certificate(slot)
601057
async def delete(self, device, remove=True):
        
        device = self._find_device(device)
        if not self.is_handleable(device) or not device.is_loop:
            self._log.warn(_('not deleting {0}: unhandled device', device))
            return False
        if remove:
            await self.auto_remove(device, force=True)
        self._log.debug(_('deleting {0}', device))
        await device.delete()
        self._log.info(_('deleted {0}', device))
        return True
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
651244
def deactivate_mfa_device(self, user_name, serial_number):
        """"""
        user = self.get_user(user_name)
        if serial_number not in user.mfa_devices:
            raise IAMNotFoundException(
                "Device {0} not found".format(serial_number)
            )

        user.deactivate_mfa_device(serial_number)
92051
def delete_user(iam_client, user, mfa_serial = None, keep_user = False, terminated_groups = []):
    
    errors = []
    printInfo('Deleting user %s...' % user)
    # Delete access keys
    try:
        aws_keys = get_access_keys(iam_client, user)
        for aws_key in aws_keys:
            try:
                printInfo('Deleting access key ID %s... ' % aws_key['AccessKeyId'], False)
                iam_client.delete_access_key(AccessKeyId = aws_key['AccessKeyId'], UserName = user)
                printInfo('Success')
            except Exception as e:
                printInfo('Failed')
                printException(e)
                errors.append(e.response['Error']['Code'])
    except Exception as e:
        printException(e)
        printError('Failed to get access keys for user %s.' % user)
    # Deactivate and delete MFA devices
    try:
        mfa_devices = iam_client.list_mfa_devices(UserName = user)['MFADevices']
        for mfa_device in mfa_devices:
            serial = mfa_device['SerialNumber']
            try:
                printInfo('Deactivating MFA device %s... ' % serial, False)
                iam_client.deactivate_mfa_device(SerialNumber = serial, UserName = user)
                printInfo('Success')
            except Exception as e:
                printInfo('Failed')
                printException(e)
                errors.append(e.response['Error']['Code'])
            delete_virtual_mfa_device(iam_client, serial)
        if mfa_serial:
            delete_virtual_mfa_device(iam_client, mfa_serial)
    except Exception as e:
        printException(e)
        printError('Faile to fetch/delete MFA device serial number for user %s.' % user)
        errors.append(e.response['Error']['Code'])
    # Remove IAM user from groups
    try:
        groups = iam_client.list_groups_for_user(UserName = user)['Groups']
        for group in groups:
            try:
                printInfo('Removing from group %s... ' % group['GroupName'], False)
                iam_client.remove_user_from_group(GroupName = group['GroupName'], UserName = user)
                printInfo('Success')
            except Exception as e:
                printInfo('Failed')
                printException(e)
                errors.append(e.response['Error']['Code'])
    except Exception as e:
        printException(e)
        printError('Failed to fetch IAM groups for user %s.' % user)
        errors.append(e.response['Error']['Code'])
    # Delete login profile
    login_profile = []
    try:
        login_profile = iam_client.get_login_profile(UserName = user)['LoginProfile']
    except Exception as e:
        pass
    try:
        if len(login_profile):
            printInfo('Deleting login profile... ', False)
            iam_client.delete_login_profile(UserName = user)
            printInfo('Success')
    except Exception as e:
        printInfo('Failed')
        printException(e)
        errors.append(e.response['Error']['Code'])
    # Delete inline policies
    try:
        printInfo('Deleting inline policies... ', False)
        policies = iam_client.list_user_policies(UserName = user)
        for policy in policies['PolicyNames']:
            iam_client.delete_user_policy(UserName = user, PolicyName = policy)
        printInfo('Success')
    except Exception as e:
        printInfo('Failed')
        printException(e)
        errors.append(e.response['Error']['Code'])
    # Detach managed policies
    try:
        printInfo('Detaching managed policies... ', False)
        policies = iam_client.list_attached_user_policies(UserName = user)
        for policy in policies['AttachedPolicies']:
            iam_client.detach_user_policy(UserName = user, PolicyArn = policy['PolicyArn'])
        printInfo('Success')
    except Exception as e:
        printInfo('Failed')
        printException(e)
        errors.append(e.response['Error']['Code'])
    # Delete IAM user
    try:
        if not keep_user:
            iam_client.delete_user(UserName = user)
            printInfo('User %s deleted.' % user)
        else:
            for group in terminated_groups:
                add_user_to_group(iam_client, group, user)
    except Exception as e:
        printException(e)
        printError('Failed to delete user.')
        errors.append(e.response['Error']['Code'])
        pass
    return errors
1299878
def RemoveDevice(self, object_path):
    ''' '''

    adapter = mockobject.objects[self.path]
    adapter.EmitSignal(ADAPTER_IFACE, 'DeviceRemoved',
                       'o', [object_path])
142137
def delete(self, svc_rec=None, ipaddr=None, proto=None, port=None):
        
        return self.send.service_del(svc_rec, ipaddr, proto, port)
648008
def delete_invalid_route(self):
        
        try:
            routing = self._engine.routing.get(self.interface_id)
            for route in routing:
                if route.invalid or route.to_delete:
                    route.delete()
        except InterfaceNotFound: # Only VLAN identifiers, so no routing
            pass
321594
def rmi(self, force=False, via_name=False):
        
        return os.remove(self.local_location)
896680
def delete(instance_id, profile=None, **kwargs):
    '''
    

    '''
    conn = _auth(profile, **kwargs)
    return conn.delete(instance_id)
241267
def DeleteInstance(self, si, logger, session, vcenter_data_model, vm_uuid, vm_name):
        
        # find vm
        vm = self.pv_service.find_by_uuid(si, vm_uuid)
        if vm is not None:
            # destroy vm
            result = self.pv_service.destroy_vm(vm=vm, logger=logger)
        else:
            resource___format = "Could not find the VM {0},will remove the resource.".format(vm_name)
            logger.info(resource___format)
            result = resource___format

        return result
341632
def delete_credential(self, identifier, credential_id=None):
        
        credential = {
            'id': credential_id
        }

        return self.client.call('SoftLayer_Network_Storage_Hub_Cleversafe_Account', 'credentialDelete',
                                credential, id=identifier)
704801
def on_remove_vrf_conf(self, evt):
        
        vrf_conf = evt.value
        # Detach VrfConf change listener.
        vrf_conf.remove_listener(VrfConf.VRF_CHG_EVT, self.on_chg_vrf_conf)

        self._table_manager.remove_vrf_by_vrf_conf(vrf_conf)

        # Update local RT NLRIs
        self._rt_manager.update_local_rt_nlris()

        self._signal_bus.vrf_removed(vrf_conf.route_dist)

        # Remove AttributeMaps under the removed vrf
        rd = vrf_conf.route_dist
        rf = vrf_conf.route_family
        peers = self._peer_manager.iterpeers
        for peer in peers:
            key = ':'.join([rd, rf])
            peer.attribute_maps.pop(key, None)