finalize configuration replication
This commit is contained in:
parent
e1517bbf28
commit
fa66d1ba9c
30 changed files with 8867 additions and 1560 deletions
|
|
@ -28,6 +28,7 @@ const char* argp_program_bug_address = BUG_EMAIL;
|
|||
#define OPT_CONF_KEEP_N 257
|
||||
#define OPT_CONF_STALE_TIMEOUT 258
|
||||
#define OPT_VCPUS 259
|
||||
#define OPT_CERTDIR 260
|
||||
|
||||
struct arguments {
|
||||
char* myname;
|
||||
|
|
@ -38,6 +39,7 @@ struct arguments {
|
|||
int conf_keep_n;
|
||||
long conf_stale_timeout;
|
||||
int vcpus;
|
||||
char* certdir;
|
||||
};
|
||||
|
||||
static struct argp_option options[] = {
|
||||
|
|
@ -54,6 +56,8 @@ static struct argp_option options[] = {
|
|||
"Seconds before saved config is flagged stale (0=disabled, default: 86400)" },
|
||||
{ "vcpus", OPT_VCPUS, "N", 0,
|
||||
"Number of virtual CPUs for the task manager (must be >= 1)" },
|
||||
{ "certdir", OPT_CERTDIR, "DIR", 0,
|
||||
"Directory containing xce.crt and xce.key (default: <workdir>/certs)" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
|
|
@ -93,6 +97,9 @@ static error_t parse_opt(int key, char* arg, struct argp_state* state)
|
|||
if (validate_vcpus(arguments->vcpus) != 0)
|
||||
argp_error(state, "--vcpus must be >= 1 (got: %s)", arg);
|
||||
break;
|
||||
case OPT_CERTDIR:
|
||||
arguments->certdir = arg;
|
||||
break;
|
||||
default:
|
||||
return ARGP_ERR_UNKNOWN;
|
||||
}
|
||||
|
|
@ -147,8 +154,15 @@ int main(int argc, char* argv[])
|
|||
|
||||
INFO("My name is %s", arguments.myname);
|
||||
|
||||
snprintf(key_file, XCE_MAXPATH_LEN, "%s/certs/xce.key", arguments.workdir);
|
||||
snprintf(cert_file, XCE_MAXPATH_LEN, "%s/certs/xce.crt", arguments.workdir);
|
||||
const char *certdir = arguments.certdir;
|
||||
char certdir_buf[XCE_MAXPATH_LEN + 1];
|
||||
if (!certdir) {
|
||||
snprintf(certdir_buf, sizeof(certdir_buf),
|
||||
"%s/certs", arguments.workdir);
|
||||
certdir = certdir_buf;
|
||||
}
|
||||
snprintf(key_file, XCE_MAXPATH_LEN, "%s/xce.key", certdir);
|
||||
snprintf(cert_file, XCE_MAXPATH_LEN, "%s/xce.crt", certdir);
|
||||
|
||||
myconf.cluster_config = NULL;
|
||||
myconf.conffile = NULL; /* set by load_primary_config() or fetch_config_from_primary() */
|
||||
|
|
@ -180,10 +194,10 @@ int main(int argc, char* argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* CA cert derived from workdir — same infrastructure as certfile/keyfile */
|
||||
/* CA cert from certdir (same certificate as certfile) */
|
||||
snprintf(myconf.peers_cfg.ca_cert_path,
|
||||
sizeof(myconf.peers_cfg.ca_cert_path),
|
||||
"%s/certs/xce.crt", arguments.workdir);
|
||||
"%s/xce.crt", certdir);
|
||||
strncpy(myconf.peers_cfg.identity, arguments.myname,
|
||||
sizeof(myconf.peers_cfg.identity) - 1);
|
||||
INFO("HA mode: %d controller candidates, identity=%s",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue