mirror of
https://github.com/ceph/ceph
synced 2025-03-30 15:31:01 +00:00
mon: take '--fsid foo' arg with --mkfs
This will set the seed monmap's fsid. This is useful if the monmap is dynamically generated (e.g., based on ceph.conf or --mon-host list). Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
This commit is contained in:
parent
0c731ed7a9
commit
b51d817e23
src
@ -63,6 +63,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
global_init(args, CEPH_ENTITY_TYPE_MON, CODE_ENVIRONMENT_DAEMON, 0);
|
||||
|
||||
uuid_d fsid;
|
||||
std::string val;
|
||||
for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
|
||||
if (ceph_argparse_double_dash(args, i)) {
|
||||
@ -76,6 +77,11 @@ int main(int argc, const char **argv)
|
||||
osdmapfn = val;
|
||||
} else if (ceph_argparse_witharg(args, i, &val, "--inject_monmap", (char*)NULL)) {
|
||||
inject_monmap = val;
|
||||
} else if (ceph_argparse_witharg(args, i, &val, "--fsid", (char*)NULL)) {
|
||||
if (!fsid.parse(val.c_str())) {
|
||||
cerr << "unable to parse fsid '" << val << "'" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
++i;
|
||||
}
|
||||
@ -122,6 +128,16 @@ int main(int argc, const char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (!fsid.is_zero()) {
|
||||
cout << argv[0] << ": setting fsid to " << fsid << std::endl;
|
||||
monmap.fsid = fsid;
|
||||
}
|
||||
|
||||
if (monmap.fsid.is_zero()) {
|
||||
cerr << argv[0] << ": generated monmap has no fsid; use --fsid" << std::endl;
|
||||
exit(10);
|
||||
}
|
||||
|
||||
// osdmap
|
||||
err = osdmapbl.read_file(osdmapfn.c_str(), &error);
|
||||
if (err < 0) {
|
||||
|
@ -15,6 +15,10 @@ extern "C" {
|
||||
struct uuid_d {
|
||||
uuid_t uuid;
|
||||
|
||||
uuid_d() {
|
||||
memset(&uuid, 0, sizeof(uuid));
|
||||
}
|
||||
|
||||
bool is_zero() {
|
||||
return uuid_is_null(uuid);
|
||||
}
|
||||
@ -23,7 +27,7 @@ struct uuid_d {
|
||||
uuid_generate(uuid);
|
||||
}
|
||||
|
||||
bool parse(char *s) {
|
||||
bool parse(const char *s) {
|
||||
return uuid_parse(s, uuid) == 0;
|
||||
}
|
||||
void print(char *s) {
|
||||
|
Loading…
Reference in New Issue
Block a user