Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Medium: Tools: crm_simulate - Implement the support of granting/revoking tickets for crm_simulate #41

Merged
merged 1 commit into from over 2 years ago

2 participants

Gao,Yan Andrew Beekhof
Gao,Yan

No description provided.

Andrew Beekhof beekhof merged commit a7c6f85 into from
Andrew Beekhof beekhof closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 08, 2012
Gao,Yan gao-yan Medium: Tools: crm_simulate - Implement the support of granting/revok…
…ing tickets for crm_simulate
575e196
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 43 additions and 2 deletions. Show diff stats Hide diff stats

  1. +43 2 tools/crm_inject.c
45 tools/crm_inject.c
@@ -758,7 +758,7 @@ create_dotfile(pe_working_set_t * data_set, const char *dot_file, gboolean all_a
758 758 static void
759 759 modify_configuration(pe_working_set_t * data_set,
760 760 const char *quorum, GListPtr node_up, GListPtr node_down, GListPtr node_fail,
761   - GListPtr op_inject)
  761 + GListPtr op_inject, GListPtr ticket_grant, GListPtr ticket_revoke)
762 762 {
763 763 int rc = cib_ok;
764 764 GListPtr gIter = NULL;
@@ -817,6 +817,34 @@ modify_configuration(pe_working_set_t * data_set,
817 817 CRM_ASSERT(rc == cib_ok);
818 818 }
819 819
  820 + for (gIter = ticket_grant; gIter != NULL; gIter = gIter->next) {
  821 + char *ticket = (char *)gIter->data;
  822 + char *attr_name = crm_concat("granted-ticket", ticket, '-');
  823 +
  824 + quiet_log(" + Granting ticket %s\n", ticket);
  825 + rc = update_attr(global_cib, cib_sync_call | cib_scope_local,
  826 + XML_CIB_TAG_TICKETS, NULL, NULL, NULL, NULL,
  827 + attr_name, "true", TRUE);
  828 +
  829 + crm_free(attr_name);
  830 +
  831 + CRM_ASSERT(rc == cib_ok);
  832 + }
  833 +
  834 + for (gIter = ticket_revoke; gIter != NULL; gIter = gIter->next) {
  835 + char *ticket = (char *)gIter->data;
  836 + char *attr_name = crm_concat("granted-ticket", ticket, '-');
  837 +
  838 + quiet_log(" + Revoking ticket %s\n", ticket);
  839 + rc = update_attr(global_cib, cib_sync_call | cib_scope_local,
  840 + XML_CIB_TAG_TICKETS, NULL, NULL, NULL, NULL,
  841 + attr_name, "false", TRUE);
  842 +
  843 + crm_free(attr_name);
  844 +
  845 + CRM_ASSERT(rc == cib_ok);
  846 + }
  847 +
820 848 for (gIter = op_inject; gIter != NULL; gIter = gIter->next) {
821 849 char *spec = (char *)gIter->data;
822 850
@@ -971,6 +999,8 @@ static struct crm_option long_options[] = {
971 999 {"op-fail", 1, 0, 'F', "\t$rsc_$task_$interval@$node=$rc - Fail the specified task while running the simulation"},
972 1000 {"set-datetime", 1, 0, 't', "Set date/time"},
973 1001 {"quorum", 1, 0, 'q', "\tSpecify a value for quorum"},
  1002 + {"ticket-grant", 1, 0, 'g', "Grant a ticket"},
  1003 + {"ticket-revoke",1, 0, 'r', "Revoke a ticket"},
974 1004
975 1005 {"-spacer-", 0, 0, '-', "\nOutput Options:"},
976 1006
@@ -1090,6 +1120,8 @@ main(int argc, char **argv)
1090 1120 GListPtr node_down = NULL;
1091 1121 GListPtr node_fail = NULL;
1092 1122 GListPtr op_inject = NULL;
  1123 + GListPtr ticket_grant = NULL;
  1124 + GListPtr ticket_revoke = NULL;
1093 1125
1094 1126 xmlNode *input = NULL;
1095 1127
@@ -1163,6 +1195,14 @@ main(int argc, char **argv)
1163 1195 modified++;
1164 1196 quorum = optarg;
1165 1197 break;
  1198 + case 'g':
  1199 + modified++;
  1200 + ticket_grant = g_list_append(ticket_grant, optarg);
  1201 + break;
  1202 + case 'r':
  1203 + modified++;
  1204 + ticket_revoke = g_list_append(ticket_revoke, optarg);
  1205 + break;
1166 1206 case 'a':
1167 1207 all_actions = TRUE;
1168 1208 break;
@@ -1249,7 +1289,8 @@ main(int argc, char **argv)
1249 1289
1250 1290 if (modified) {
1251 1291 quiet_log("Performing requested modifications\n");
1252   - modify_configuration(&data_set, quorum, node_up, node_down, node_fail, op_inject);
  1292 + modify_configuration(&data_set, quorum, node_up, node_down, node_fail, op_inject,
  1293 + ticket_grant, ticket_revoke);
1253 1294
1254 1295 rc = global_cib->cmds->query(global_cib, NULL, &input, cib_sync_call);
1255 1296 if (rc != cib_ok) {

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.