marsadm: fix join-cluster dir creation

This commit is contained in:
Thomas Schoebel-Theuer 2020-11-27 20:48:10 +01:00
parent 94df66a3c1
commit 74f0da534b
1 changed files with 12 additions and 7 deletions

View File

@ -3796,20 +3796,25 @@ sub create_uuid {
lprint "New cluster UUID is '$uuid'\n"; lprint "New cluster UUID is '$uuid'\n";
} }
sub _create_cluster { sub _create_dirs {
my ($cmd) = @_; my ($cmd) = @_;
ldie "The $mars directory does not exist.\n" unless -d $mars;
my $ip = _get_ip($host);
create_uuid(@_) if $cmd eq "create-cluster";
system("mkdir $mars/ips") unless -d "$mars/ips"; system("mkdir $mars/ips") unless -d "$mars/ips";
system("mkdir $mars/userspace") unless -d "$mars/userspace"; system("mkdir $mars/userspace") unless -d "$mars/userspace";
system("mkdir $mars/defaults") unless -d "$mars/defaults"; system("mkdir $mars/defaults") unless -d "$mars/defaults";
system("mkdir $mars/defaults-$host") unless -d "$mars/defaults-$host"; system("mkdir $mars/defaults-$host") unless -d "$mars/defaults-$host";
set_link("0", "$mars/defaults-$host/sync-limit");
set_link("(none)", "$mars/defaults-$host/sync-pref-list");
system("mkdir $mars/todo-global") unless -d "$mars/todo-global"; system("mkdir $mars/todo-global") unless -d "$mars/todo-global";
mkdir("$mars/actual-$host") unless -d "$mars/actual-$host"; mkdir("$mars/actual-$host") unless -d "$mars/actual-$host";
set_link($marsadm_version, "$mars/actual-$host/marsadm-version"); set_link($marsadm_version, "$mars/actual-$host/marsadm-version");
}
sub _create_cluster {
my ($cmd) = @_;
ldie "The $mars directory does not exist.\n" unless -d $mars;
my $ip = _get_ip($host);
_create_dirs($cmd);
create_uuid(@_) if $cmd eq "create-cluster";
set_link("0", "$mars/defaults-$host/sync-limit");
set_link("(none)", "$mars/defaults-$host/sync-pref-list");
set_link($ip, "$mars/ips/ip-$host"); set_link($ip, "$mars/ips/ip-$host");
set_link("1", "$mars/todo-global/deleted-$host"); set_link("1", "$mars/todo-global/deleted-$host");
} }
@ -3829,7 +3834,7 @@ sub join_cluster {
lwarn "DANGER: some resources already exist!\n"; lwarn "DANGER: some resources already exist!\n";
ldie "DANGER: If you are sure that no resource clash is possible, re-invoke $cmd with '--force' option\n" unless $force; ldie "DANGER: If you are sure that no resource clash is possible, re-invoke $cmd with '--force' option\n" unless $force;
} }
set_link($marsadm_version, "$mars/actual-$host/marsadm-version"); _create_dirs($cmd);
$peer_ip = _get_ip($peer) unless $peer_ip; $peer_ip = _get_ip($peer) unless $peer_ip;
# try new join method # try new join method
if (is_module_loaded()) { if (is_module_loaded()) {