[pbs-devel] [PATCH proxmox-backup v8 06/23] api: removable datastore creation

Dietmar Maurer dietmar at proxmox.com
Mon Apr 22 09:28:43 CEST 2024


comments inline

>  /// Create new datastore config.
>  pub fn create_datastore(
> -    config: DataStoreConfig,
> +    mut config: DataStoreConfig,
>      rpcenv: &mut dyn RpcEnvironment,
>  ) -> Result<String, Error> {
>      let lock = pbs_config::datastore::lock_config()?;
> @@ -122,6 +149,31 @@ pub fn create_datastore(
>          param_bail!("name", "datastore '{}' already exists.", config.name);
>      }
>  
> +    if let Some(uuid) = &config.backing_device {
> +        let already_used_by = section_config
> +            .sections
> +            .iter()
> +            .flat_map(|(datastore_name, (_, config))| {
> +                config
> +                    .as_object()
> +                    .and_then(|cfg| cfg.get("backing-device"))
> +                    .and_then(|backing_device| backing_device.as_str())
> +                    .filter(|&device_uuid| device_uuid == uuid)
> +                    .map(|_| datastore_name)
> +            })
> +            .next();
> +
> +        if let Some(datastore_name) = already_used_by {
> +            param_bail!(
> +                "backing-device",
> +                "device already in use by datastore '{datastore_name}'",
> +            );
> +        }
> +        if let Some(mount_point) = config.get_mount_point() {
> +            config.path = format!("{mount_point}/{}", config.path.trim_start_matches('/'));

This looks redundant for me. I don't want to store the mount point
in the datastore path.

> +        }
> +    }
> +
>      let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
>      let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
>  
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel




More information about the pbs-devel mailing list