Skip to content

Commit

Permalink
Medium: tools: crm_resource - Support metadata querying
Browse files Browse the repository at this point in the history
  • Loading branch information
beekhof committed Jun 26, 2012
1 parent c9bfb02 commit 22efc79
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tools/crm_resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,7 @@ static struct crm_option long_options[] = {
{"list-ocf-providers", 0, 0, 0, "List all available OCF providers"},
{"list-agents", 1, 0, 0, "List all agents available for the named standard and/or provider."},
{"list-ocf-alternatives", 1, 0, 0, "List all available providers for the named OCF agent\n"},
{"show-metadata", 1, 0, 0, "Show the metadata for the named class:provider:agent"},

{"query-xml", 0, 0, 'q', "\tQuery the definition of a resource (template expanded)"},
{"query-xml-raw", 0, 0, 'w', "\tQuery the definition of a resource (raw xml)"},
Expand Down Expand Up @@ -1320,6 +1321,36 @@ main(int argc, char **argv)
return -1;
}

} else if(safe_str_eq("show-metadata", longname)) {
char standard[512];
char provider[512];
char type[512];
char *metadata = NULL;

rc = sscanf(optarg, "%[^:]:%[^:]:%s", standard, provider, type);
if(rc == 3) {
rc = lrmd_conn->cmds->get_metadata(lrmd_conn, standard, provider, type, &metadata, 0);
if(metadata) {
printf("%s\n", metadata);
return 0;
}
fprintf(stderr, "Metadata query for %s failed: %d\n", optarg, rc);
return rc;

} else if(rc == 2) {
rc = lrmd_conn->cmds->get_metadata(lrmd_conn, standard, NULL, provider, &metadata, 0);
if(metadata) {
printf("%s\n", metadata);
return 0;
}
fprintf(stderr, "Metadata query for %s failed: %d\n", optarg, rc);
return rc;

} else if(rc < 2) {
fprintf(stderr, "Please specify standard:type or standard:provider:type, not %s\n", optarg);
return -1;
}

} else if(safe_str_eq("list-agents", longname)) {
lrmd_list_t *list = NULL;
lrmd_list_t *iter = NULL;
Expand Down

0 comments on commit 22efc79

Please sign in to comment.