[pve-devel] [PATCH storage] Automatically create/delete CEPH keyring when adding/deleting RBD Storage

Dietmar Maurer dietmar at proxmox.com
Wed Jan 11 16:28:58 CET 2017


> When adding an RBD storage to Proxmox this patch checks if the
> /etc/pve/priv/ceph dir exists, if not it will create it.
> The the client.admin keyring will be copied to it with the
> correct name of the storage (storeid.keyring)

The /etc/pve/priv/ceph.client.admin.keyring is correct for a
local ceph installation, but always wrong for external servers.
Or do I miss something?

> 
> When deleting an RBD storage the keyring file will be removed.
> 
> Signed-off-by: Caspar Smit <casparsmit at supernas.eu>
> ---
>  PVE/API2/Storage/Config.pm | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/PVE/API2/Storage/Config.pm b/PVE/API2/Storage/Config.pm
> index 4668af6..e707efb 100755
> --- a/PVE/API2/Storage/Config.pm
> +++ b/PVE/API2/Storage/Config.pm
> @@ -3,6 +3,7 @@ package PVE::API2::Storage::Config;
>  use strict;
>  use warnings;
>  
> +use File::Copy qw(copy);
>  use PVE::SafeSyslog;
>  use PVE::Tools qw(extract_param);
>  use PVE::Cluster qw(cfs_read_file cfs_write_file);
> @@ -174,6 +175,15 @@ __PACKAGE__->register_method ({
>  	    
>  	    }, "create storage failed");
>  
> +	if ($type eq 'rbd') {
> +	    if (!-d "/etc/pve/priv/ceph") {
> +		mkdir "/etc/pve/priv/ceph";
> +	    }
> +	    if (-e "/etc/pve/priv/ceph.client.admin.keyring") {
> +		copy "/etc/pve/priv/ceph.client.admin.keyring",
> "/etc/pve/priv/ceph/$storeid.keyring";
> +	    }
> +	}
> +
>  	return undef;
>      }});
>  
> @@ -259,6 +269,8 @@ __PACKAGE__->register_method ({
>  
>  	PVE::AccessControl::remove_storage_access($storeid);
>  
> +	unlink "/etc/pve/priv/ceph/$storeid.keyring";
> +
>  	return undef;
>      }});
>  
> -- 
> 2.1.4
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list