pub fn refresh(&self) -> Self {
        // the config is immutable, so we construct a new one which is mutable
        // such that we can scribble in the current bdevs. The config
        // gets loaded with the current settings, as we know that these
        // are immutable, we can copy them with any locks held
        let mut current = Config {
            source: self.source.clone(),
            nvmf_tcp_tgt_conf: self.nvmf_tcp_tgt_conf.get(),
            iscsi_tgt_conf: self.iscsi_tgt_conf.get(),
            nvme_bdev_opts: self.nvme_bdev_opts.get(),
            bdev_opts: self.bdev_opts.get(),
            nexus_opts: self.nexus_opts.get(),
            base_bdevs: None,
            nexus_bdevs: None,
            pools: None,
            implicit_share_base: self.implicit_share_base,
            err_store_opts: self.err_store_opts.get(),
            sync_disable: self.sync_disable,
            socket_opts: self.socket_opts.get(),
        };

        // collect nexus bdevs and insert them into the config
        let nexus_bdevs = instances()
            .iter()
            .map(|nexus| NexusBdev {
                name: nexus.name.clone(),
                uuid: nexus.bdev.uuid_as_string(),
                size: nexus.bdev.size_in_bytes().to_string(),
                children: nexus
                    .children
                    .iter()
                    .map(|child| child.name.clone())
                    .collect::<Vec<_>>(),
            })
            .collect::<Vec<_>>();

        // collect base bdevs and insert them into the config
        if let Some(bdevs) = Bdev::bdev_first() {
            let result = bdevs
                .into_iter()
                .filter(|b| url::Url::try_from(b.clone()).is_ok())
                .map(|b| BaseBdev {
                    uri: url::Url::try_from(b.clone())
                        .map_or(b.name(), |u| u.to_string()),
                })
                .collect::<Vec<_>>();

            current.base_bdevs = Some(result);
        }

        current.nexus_bdevs = Some(nexus_bdevs);

        // collect any pools that are on the system, and insert them
        let pools = PoolsIter::new()
            .map(|p| {
                let base = p.get_base_bdev();
                Pool {
                    name: p.get_name().into(),
                    disks: vec![base.bdev_uri().unwrap_or_else(|| base.name())],
                    replicas: ReplicaIter::new()
                        .map(|p| Replica {
                            name: p.get_uuid().to_string(),
                            share: p.get_share_type(),
                        })
                        .collect::<Vec<_>>(),
                }
            })
            .collect::<Vec<_>>();

        current.pools = Some(pools);

        current
    }
/// collect current configuration snapshot into a new Config object that can
/// be exported to a file (YAML or JSON)
collect current configuration snapshot into a new Config object that can
be exported to a file (YAML or JSON)
collect current configuration snapshot into a new Config object that can be exported to a file ( YAML or JSON )
pub fn refresh(&self) -> Self {
        // the config is immutable, so we construct a new one which is mutable
        // such that we can scribble in the current bdevs. The config
        // gets loaded with the current settings, as we know that these
        // are immutable, we can copy them with any locks held
        let mut current = Config {
            source: self.source.clone(),
            nvmf_tcp_tgt_conf: self.nvmf_tcp_tgt_conf.get(),
            iscsi_tgt_conf: self.iscsi_tgt_conf.get(),
            nvme_bdev_opts: self.nvme_bdev_opts.get(),
            bdev_opts: self.bdev_opts.get(),
            nexus_opts: self.nexus_opts.get(),
            base_bdevs: None,
            nexus_bdevs: None,
            pools: None,
            implicit_share_base: self.implicit_share_base,
            err_store_opts: self.err_store_opts.get(),
            sync_disable: self.sync_disable,
            socket_opts: self.socket_opts.get(),
        };
        // collect nexus bdevs and insert them into the config
        let nexus_bdevs = instances()
            .iter()
            .map(|nexus| NexusBdev {
                name: nexus.name.clone(),
                uuid: nexus.bdev.uuid_as_string(),
                size: nexus.bdev.size_in_bytes().to_string(),
                children: nexus
                    .children
                    .iter()
                    .map(|child| child.name.clone())
                    .collect::<Vec<_>>(),
            })
            .collect::<Vec<_>>();
        // collect base bdevs and insert them into the config
        if let Some(bdevs) = Bdev::bdev_first() {
            let result = bdevs
                .into_iter()
                .filter(|b| url::Url::try_from(b.clone()).is_ok())
                .map(|b| BaseBdev {
                    uri: url::Url::try_from(b.clone())
                        .map_or(b.name(), |u| u.to_string()),
                })
                .collect::<Vec<_>>();
            current.base_bdevs = Some(result);
        }
        current.nexus_bdevs = Some(nexus_bdevs);
        // collect any pools that are on the system, and insert them
        let pools = PoolsIter::new()
            .map(|p| {
                let base = p.get_base_bdev();
                Pool {
                    name: p.get_name().into(),
                    disks: vec![base.bdev_uri().unwrap_or_else(|| base.name())],
                    replicas: ReplicaIter::new()
                        .map(|p| Replica {
                            name: p.get_uuid().to_string(),
                            share: p.get_share_type(),
                        })
                        .collect::<Vec<_>>(),
                }
            })
            .collect::<Vec<_>>();
        current.pools = Some(pools);
        current
    }
pub fn refresh ( & self ) -> Self { // the config is immutable, so we construct a new one which is mutable // such that we can scribble in the current bdevs. The config // gets loaded with the current settings, as we know that these // are immutable, we can copy them with any locks held let mut current = Config { source : self . source . clone ( ) , nvmf_tcp_tgt_conf : self . nvmf_tcp_tgt_conf . get ( ) , iscsi_tgt_conf : self . iscsi_tgt_conf . get ( ) , nvme_bdev_opts : self . nvme_bdev_opts . get ( ) , bdev_opts : self . bdev_opts . get ( ) , nexus_opts : self . nexus_opts . get ( ) , base_bdevs : None , nexus_bdevs : None , pools : None , implicit_share_base : self . implicit_share_base , err_store_opts : self . err_store_opts . get ( ) , sync_disable : self . sync_disable , socket_opts : self . socket_opts . get ( ) , } ; // collect nexus bdevs and insert them into the config let nexus_bdevs = instances ( ) . iter ( ) . map ( | nexus | NexusBdev { name : nexus . name . clone ( ) , uuid : nexus . bdev . uuid_as_string ( ) , size : nexus . bdev . size_in_bytes ( ) . to_string ( ) , children : nexus . children . iter ( ) . map ( | child | child . name . clone ( ) ) . collect :: < Vec < _ > > ( ) , } ) . collect :: < Vec < _ > > ( ) ; // collect base bdevs and insert them into the config if let Some ( bdevs ) = Bdev :: bdev_first ( ) { let result = bdevs . into_iter ( ) . filter ( | b | url :: Url :: try_from ( b . clone ( ) ) . is_ok ( ) ) . map ( | b | BaseBdev { uri : url :: Url :: try_from ( b . clone ( ) ) . map_or ( b . name ( ) , | u | u . to_string ( ) ) , } ) . collect :: < Vec < _ > > ( ) ; current . base_bdevs = Some ( result ) ; } current . nexus_bdevs = Some ( nexus_bdevs ) ; // collect any pools that are on the system, and insert them let pools = PoolsIter :: new ( ) . map ( | p | { let base = p . get_base_bdev ( ) ; Pool { name : p . get_name ( ) . into ( ) , disks : vec ! [ base bdev_uri ( ) unwrap_or_else ( base name ( ) ) ] , replicas : ReplicaIter :: new ( ) . map ( | p | Replica { name : p . get_uuid ( ) . to_string ( ) , share : p . get_share_type ( ) , } ) . collect :: < Vec < _ > > ( ) , } } ) . collect :: < Vec < _ > > ( ) ; current . pools = Some ( pools ) ; current }
collect current configuration snapshot into a new Config object that can
be exported to a file (YAML or JSON)
collect current configuration snapshot into a new Config object that can be exported to a file ( YAML or JSON )
&self