fn mmds_config(&self) -> Option<MmdsConfig> {
        // If the data store is not initialised, we can be sure that the user did not configure
        // mmds.
        let mmds = self.mmds.as_ref()?;

        let mut mmds_config = None;
        let net_devs_with_mmds: Vec<_> = self
            .net_builder
            .iter()
            .filter(|net| net.lock().expect("Poisoned lock").mmds_ns().is_some())
            .collect();

        if !net_devs_with_mmds.is_empty() {
            let mut inner_mmds_config = MmdsConfig {
                version: mmds.lock().expect("Poisoned lock").version(),
                network_interfaces: vec![],
                ipv4_address: None,
            };

            for net_dev in net_devs_with_mmds {
                let net = net_dev.lock().unwrap();
                inner_mmds_config.network_interfaces.push(net.id().clone());
                // Only need to get one ip address, as they will all be equal.
                if inner_mmds_config.ipv4_address.is_none() {
                    // Safe to unwrap the mmds_ns as the filter() explicitly checks for
                    // its existence.
                    inner_mmds_config.ipv4_address = Some(net.mmds_ns().unwrap().ipv4_addr());
                }
            }

            mmds_config = Some(inner_mmds_config);
        }

        mmds_config
    }
// Repopulate the MmdsConfig based on information from the data store
// and the associated net devices.
Repopulate the MmdsConfig based on information from the data store
and the associated net devices.
Repopulate the MmdsConfig based on information from the data store and the associated net devices .
fn mmds_config(&self) -> Option<MmdsConfig> {
        // If the data store is not initialised, we can be sure that the user did not configure
        // mmds.
        let mmds = self.mmds.as_ref()?;
        let mut mmds_config = None;
        let net_devs_with_mmds: Vec<_> = self
            .net_builder
            .iter()
            .filter(|net| net.lock().expect("Poisoned lock").mmds_ns().is_some())
            .collect();
        if !net_devs_with_mmds.is_empty() {
            let mut inner_mmds_config = MmdsConfig {
                version: mmds.lock().expect("Poisoned lock").version(),
                network_interfaces: vec![],
                ipv4_address: None,
            };
            for net_dev in net_devs_with_mmds {
                let net = net_dev.lock().unwrap();
                inner_mmds_config.network_interfaces.push(net.id().clone());
                // Only need to get one ip address, as they will all be equal.
                if inner_mmds_config.ipv4_address.is_none() {
                    // Safe to unwrap the mmds_ns as the filter() explicitly checks for
                    // its existence.
                    inner_mmds_config.ipv4_address = Some(net.mmds_ns().unwrap().ipv4_addr());
                }
            }
            mmds_config = Some(inner_mmds_config);
        }
        mmds_config
    }
fn mmds_config ( & self ) -> Option < MmdsConfig > { // If the data store is not initialised, we can be sure that the user did not configure // mmds. let mmds = self . mmds . as_ref ( ) ? ; let mut mmds_config = None ; let net_devs_with_mmds : Vec < _ > = self . net_builder . iter ( ) . filter ( | net | net . lock ( ) . expect ( " " ) . mmds_ns ( ) . is_some ( ) ) . collect ( ) ; if ! net_devs_with_mmds . is_empty ( ) { let mut inner_mmds_config = MmdsConfig { version : mmds . lock ( ) . expect ( " " ) . version ( ) , network_interfaces : vec ! [ ] , ipv4_address : None , } ; for net_dev in net_devs_with_mmds { let net = net_dev . lock ( ) . unwrap ( ) ; inner_mmds_config . network_interfaces . push ( net . id ( ) . clone ( ) ) ; // Only need to get one ip address, as they will all be equal. if inner_mmds_config . ipv4_address . is_none ( ) { // Safe to unwrap the mmds_ns as the filter() explicitly checks for // its existence. inner_mmds_config . ipv4_address = Some ( net . mmds_ns ( ) . unwrap ( ) . ipv4_addr ( ) ) ; } } mmds_config = Some ( inner_mmds_config ) ; } mmds_config }
Repopulate the MmdsConfig based on information from the data store
and the associated net devices.
Repopulate the MmdsConfig based on information from the data store and the associated net devices .
&self
&self