marsadm: add global uuid to cluster

This commit is contained in:
Thomas Schoebel-Theuer 2013-05-13 09:45:35 +02:00
parent a1920494b4
commit 7187462a6e
2 changed files with 24 additions and 0 deletions

View File

@ -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] = {

View File

@ -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";