From 8ff8e27713aa612796683dba2c170af4c0ac75ba Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 11 Nov 2020 09:35:53 +0100 Subject: [PATCH] api/config: fix indentation Signed-off-by: Thomas Lamprecht --- PVE/API2/Storage/Config.pm | 67 ++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/PVE/API2/Storage/Config.pm b/PVE/API2/Storage/Config.pm index 09ba747..e197dab 100755 --- a/PVE/API2/Storage/Config.pm +++ b/PVE/API2/Storage/Config.pm @@ -161,35 +161,33 @@ __PACKAGE__->register_method ({ my $plugin = PVE::Storage::Plugin->lookup($type); my $opts = $plugin->check_config($storeid, $param, 1, 1); - PVE::Storage::lock_storage_config( - sub { + PVE::Storage::lock_storage_config(sub { + my $cfg = PVE::Storage::config(); - my $cfg = PVE::Storage::config(); + if (my $scfg = PVE::Storage::storage_config($cfg, $storeid, 1)) { + die "storage ID '$storeid' already defined\n"; + } - if (my $scfg = PVE::Storage::storage_config($cfg, $storeid, 1)) { - die "storage ID '$storeid' already defined\n"; - } + $cfg->{ids}->{$storeid} = $opts; - $cfg->{ids}->{$storeid} = $opts; - - $plugin->on_add_hook($storeid, $opts, %$sensitive); - - eval { - # try to activate if enabled on local node, - # we only do this to detect errors/problems sooner - if (PVE::Storage::storage_check_enabled($cfg, $storeid, undef, 1)) { - PVE::Storage::activate_storage($cfg, $storeid); - } - }; - if (my $err = $@) { - eval { $plugin->on_delete_hook($storeid, $opts) }; - warn "$@\n" if $@; - die $err; + $plugin->on_add_hook($storeid, $opts, %$sensitive); + + eval { + # try to activate if enabled on local node, + # we only do this to detect errors/problems sooner + if (PVE::Storage::storage_check_enabled($cfg, $storeid, undef, 1)) { + PVE::Storage::activate_storage($cfg, $storeid); } + }; + if (my $err = $@) { + eval { $plugin->on_delete_hook($storeid, $opts) }; + warn "$@\n" if $@; + die $err; + } - PVE::Storage::write_config($cfg); + PVE::Storage::write_config($cfg); - }, "create storage failed"); + }, "create storage failed"); return undef; }}); @@ -217,7 +215,6 @@ __PACKAGE__->register_method ({ } PVE::Storage::lock_storage_config(sub { - my $cfg = PVE::Storage::config(); PVE::SectionConfig::assert_if_modified($cfg, $digest); @@ -279,25 +276,23 @@ __PACKAGE__->register_method ({ my $storeid = extract_param($param, 'storage'); - PVE::Storage::lock_storage_config( - sub { - - my $cfg = PVE::Storage::config(); + PVE::Storage::lock_storage_config(sub { + my $cfg = PVE::Storage::config(); - my $scfg = PVE::Storage::storage_config($cfg, $storeid); + my $scfg = PVE::Storage::storage_config($cfg, $storeid); - die "can't remove storage - storage is used as base of another storage\n" - if PVE::Storage::storage_is_used($cfg, $storeid); + die "can't remove storage - storage is used as base of another storage\n" + if PVE::Storage::storage_is_used($cfg, $storeid); - my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); + my $plugin = PVE::Storage::Plugin->lookup($scfg->{type}); - $plugin->on_delete_hook($storeid, $scfg); + $plugin->on_delete_hook($storeid, $scfg); - delete $cfg->{ids}->{$storeid}; + delete $cfg->{ids}->{$storeid}; - PVE::Storage::write_config($cfg); + PVE::Storage::write_config($cfg); - }, "delete storage failed"); + }, "delete storage failed"); PVE::AccessControl::remove_storage_access($storeid); -- 2.39.2