mirror of https://github.com/schoebel/mars
marsadm: add global uuid to cluster
This commit is contained in:
parent
a1920494b4
commit
7187462a6e
|
@ -3604,6 +3604,8 @@ static int check_deleted(void *buf, struct mars_dent *dent)
|
|||
enum {
|
||||
// root element: this must have index 0
|
||||
CL_ROOT,
|
||||
// global ID
|
||||
CL_UUID,
|
||||
// global userspace
|
||||
CL_GLOBAL_USERSPACE,
|
||||
CL_GLOBAL_USERSPACE_ITEMS,
|
||||
|
@ -3655,6 +3657,15 @@ static const struct light_class light_classes[] = {
|
|||
[CL_ROOT] = {
|
||||
},
|
||||
|
||||
/* UUID, indentifying the whole cluster.
|
||||
*/
|
||||
[CL_UUID] = {
|
||||
.cl_name = "uuid",
|
||||
.cl_len = 4,
|
||||
.cl_type = 'l',
|
||||
.cl_father = CL_ROOT,
|
||||
},
|
||||
|
||||
/* Subdirectory for global userspace items...
|
||||
*/
|
||||
[CL_GLOBAL_USERSPACE] = {
|
||||
|
|
|
@ -680,6 +680,19 @@ sub is_module_loaded {
|
|||
sub _create_cluster {
|
||||
my ($cmd) = @_;
|
||||
system("mkdir $mars") unless -d $mars;
|
||||
my $old_uuid = get_link("$mars/uuid", 2);
|
||||
if ($cmd eq "create-cluster") {
|
||||
ldie "cluster was already created with uuid='$old_uuid'\n" if $old_uuid && !$force;
|
||||
my $uuid = `echo -n \$(hostname) \$(date)`;
|
||||
set_link($uuid, "$mars/uuid");
|
||||
finish_links(); # opportunity for errors => don't continue
|
||||
} elsif (!$old_uuid && !$force) {
|
||||
if ($user_version == 0.1) {
|
||||
my $uuid = `echo -n \$(hostname) \$(date)`;
|
||||
set_link($uuid, "$mars/uuid");
|
||||
}
|
||||
ldie "cluster has no uuid\n" if $user_version > 0.1;
|
||||
}
|
||||
system("mkdir $mars/ips") unless -d "$mars/ips";
|
||||
system("mkdir $mars/userspace") unless -d "$mars/userspace";
|
||||
system("mkdir $mars/defaults") unless -d "$mars/defaults";
|
||||
|
|
Loading…
Reference in New Issue