[devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
osaf/tools/safimm/immcfg/imm_cfg.c | 31 +++- osaf/tools/safimm/immcfg/imm_import.cc | 196 - osaf/tools/safimm/immdump/imm_dumper.cc| 170 +++- osaf/tools/safimm/immdump/imm_dumper.hh|2 + osaf/tools/safimm/immdump/imm_xmlw_dump.cc | 13 +- osaf/tools/safimm/immlist/Makefile.am |4 + osaf/tools/safimm/immlist/imm_list.c | 191 - osaf/tools/safimm/immload/imm_loader.cc| 164 - 8 files changed, 749 insertions(+), 22 deletions(-) For forwards compatibility, OpenSAF schema, where unknown attribute flags are defined, must be provided to IMM tools (immcfg, immlist, immfind) using -X flag. If immload finds unknown attribute flag, immload will try to find the attribute flag in the schema defined in the top element of the loading IMM XML file. diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c b/osaf/tools/safimm/immcfg/imm_cfg.c --- a/osaf/tools/safimm/immcfg/imm_cfg.c +++ b/osaf/tools/safimm/immcfg/imm_cfg.c @@ -56,7 +56,7 @@ typedef enum { #define VERBOSE_INFO(format, args...) if (verbose) { fprintf(stderr, format, ##args); } // The interface function which implements the -f opton (imm_import.cc) -int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe); +int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe, const char *xsdPath); const SaImmCcbFlagsT defCcbFlags = SA_IMM_CCB_REGISTERED_OI | SA_IMM_CCB_ALLOW_NULL_OI; @@ -86,6 +86,7 @@ static void usage(const char *progname) printf("\t--ignore-duplicates (only valid with -f/--file option, default)\n"); printf("\t--delete-class [classname2]... \n"); printf("\t-u, --unsafe\n"); + printf("\t-X, --xsd \n"); printf("\nEXAMPLE\n"); printf("\timmcfg -a saAmfNodeSuFailoverMax=7 safAmfNode=Node01,safAmfCluster=1\n"); @@ -102,6 +103,10 @@ static void usage(const char *progname) printf("\t\tremove a value from an attribute\n"); printf("\timmcfg -u .\n"); printf("\t\tThe CCBs generated by immcfg will have SA_IMM_CCB_REGISTERED_OI set to false, allowing ccb commit when OIs are missing\n"); + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully import imm.xml"); + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from the schema specified in imm.xml which is stored in /etc/opensaf, and use loaded flags to successfully import imm.xml"); } /* signal handler for SIGALRM */ @@ -682,6 +687,7 @@ int main(int argc, char *argv[]) {"timeout", required_argument, NULL, 't'}, {"verbose", no_argument, NULL, 'v'}, {"unsafe", no_argument, NULL, 'u'}, + {"xsd", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; SaAisErrorT error; @@ -703,9 +709,11 @@ int main(int argc, char *argv[]) int i; unsigned long timeoutVal = 60; + char *xsdPath = NULL; + while (1) { int option_index = 0; - c = getopt_long(argc, argv, "a:c:f:t:dhmvu", long_options, &option_index); + c = getopt_long(argc, argv, "a:c:f:t:dhmvuX:", long_options, &option_index); if (c == -1)/* have all command-line options have been parsed? */ break; @@ -751,6 +759,13 @@ int main(int argc, char *argv[]) op = verify_setoption(op, MODIFY_OBJECT); break; } + case 'X': + if(xsdPath) { + fprintf(stderr, "XSD path is already set\n"); + exit(EXIT_FAILURE); + } + xsdPath = strdup(optarg); + break; default: fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); exit(EXIT_FAILURE); @@ -767,7 +782,7 @@ int main(int argc, char *argv[]) if (op == LOAD_IMMFILE) { VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", xmlFilename, verbose); - rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe); + rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe, xsdPath); exit(rc); } @@ -854,10 +869,14 @@ int main(int argc, char *argv[]) done_om_finalize: error = immutil_saImmOmFinalize(immHandle); if (SA_AIS_OK != error) { -fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", saf_error(error)); -rc = EXIT_FAILURE; -
[devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
osaf/tools/safimm/immcfg/imm_cfg.c | 31 +++- osaf/tools/safimm/immcfg/imm_import.cc | 196 - osaf/tools/safimm/immdump/imm_dumper.cc| 168 +++- osaf/tools/safimm/immdump/imm_dumper.hh|2 + osaf/tools/safimm/immdump/imm_xmlw_dump.cc | 11 + osaf/tools/safimm/immlist/Makefile.am |4 + osaf/tools/safimm/immlist/imm_list.c | 191 - 7 files changed, 584 insertions(+), 19 deletions(-) For forwards compatibility, OpenSAF schema, where unknown attribute flags are defined, must be provided to IMM tools (immcfg, immlist, immfind) using -X flag. If immload finds unknown attribute flag, immload will try to find the attribute flag in the schema defined in the top element of the loading IMM XML file. diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c b/osaf/tools/safimm/immcfg/imm_cfg.c --- a/osaf/tools/safimm/immcfg/imm_cfg.c +++ b/osaf/tools/safimm/immcfg/imm_cfg.c @@ -65,7 +65,7 @@ typedef enum { #define VERBOSE_INFO(format, args...) if (verbose) { fprintf(stderr, format, ##args); } // Interface functions which implement -f and -L options (imm_import.cc) -int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe); +int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe, const char *xsdPath); int validateImmXML(const char *xmlfile, int verbose); @@ -103,6 +103,7 @@ static void usage(const char *progname) printf("\t-L, --validate \n"); printf("\t-o, --admin-owner \n"); printf("\t--admin-owner-clear\n"); + printf("\t-X, --xsd \n"); printf("\nEXAMPLE\n"); printf("\timmcfg -a saAmfNodeSuFailoverMax=7 safAmfNode=Node01,safAmfCluster=1\n"); @@ -127,6 +128,10 @@ static void usage(const char *progname) printf("\t\tuse 'myAdminOwnerName' as admin owner name for changing one attribute of one object\n"); printf("\timmcfg --admin-owner-clear safAmfNode=Node01,safAmfCluster=1\n"); printf("\t\tclear admin owner from one object\n"); + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully import imm.xml"); + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from the schema specified in imm.xml which is stored in /etc/opensaf, and use loaded flags to successfully import imm.xml"); } /* signal handler for SIGALRM */ @@ -854,6 +859,7 @@ int main(int argc, char *argv[]) {"disable-attr-notify", no_argument, NULL, 0}, {"admin-owner", required_argument, NULL, 'o'}, {"admin-owner-clear", no_argument, NULL, 0}, + {"xsd", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; SaAisErrorT error; @@ -879,9 +885,11 @@ int main(int argc, char *argv[]) unsigned long timeoutVal = 60; attr_notify_t attrNotify = NOTIFY_UNDEFINED; + char *xsdPath = NULL; + while (1) { int option_index = 0; - c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:", long_options, &option_index); + c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:X:", long_options, &option_index); if (c == -1)/* have all command-line options have been parsed? */ break; @@ -963,6 +971,13 @@ int main(int argc, char *argv[]) adminOwnerName = (SaImmAdminOwnerNameT)malloc(strlen(optarg) + 1); strcpy(adminOwnerName, optarg); break; + case 'X': + if(xsdPath) { + fprintf(stderr, "XSD path is already set\n"); + exit(EXIT_FAILURE); + } + xsdPath = strdup(optarg); + break; default: free(adminOwnerName); fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); @@ -994,7 +1009,7 @@ int main(int argc, char *argv[]) if (op == LOAD_IMMFILE) { VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", xmlFilename, verbose); - rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe); + rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe, xsdPath); free(adminOwnerName); exit(rc); } @@ -1113,10 +1128,14 @@ int main(int argc, char *argv[]) free(attributeNames); error = immutil_saImmOmFinalize(immHandle); if (SA_AIS_OK != error) { -fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", saf_error(error)); -
[devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
osaf/tools/safimm/immcfg/imm_cfg.c | 29 +++- osaf/tools/safimm/immcfg/imm_import.cc | 218 ++-- osaf/tools/safimm/immdump/imm_dumper.cc| 172 +- osaf/tools/safimm/immdump/imm_dumper.hh|2 + osaf/tools/safimm/immdump/imm_xmlw_dump.cc | 11 + osaf/tools/safimm/immlist/Makefile.am |4 + osaf/tools/safimm/immlist/imm_list.c | 192 +- 7 files changed, 597 insertions(+), 31 deletions(-) For forwards compatibility, OpenSAF schema, where unknown attribute flags are defined, must be provided to IMM tools (immcfg, immlist, immfind) using -X flag. If immload finds unknown attribute flag, immload will try to find the attribute flag in the schema defined in the top element of the loading IMM XML file. diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c b/osaf/tools/safimm/immcfg/imm_cfg.c --- a/osaf/tools/safimm/immcfg/imm_cfg.c +++ b/osaf/tools/safimm/immcfg/imm_cfg.c @@ -80,7 +80,8 @@ typedef enum { // Interface functions which implement -f and -L options (imm_import.cc) int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe, - SaImmHandleT *immHandle, SaImmAdminOwnerHandleT *ownerHandle, SaImmCcbHandleT *ccbHandle, int mode); + SaImmHandleT *immHandle, SaImmAdminOwnerHandleT *ownerHandle, + SaImmCcbHandleT *ccbHandle, int mode, const char *xsdPath); int validateImmXML(const char *xmlfile, int verbose, int mode); static int imm_operation(int argc, char *argv[]); @@ -129,6 +130,7 @@ static void usage(const char *progname) printf("\t--admin-owner-clear\n"); printf("\t--ccb-apply (only in a transaction mode)\n"); printf("\t--ccb-abort (only in a transaction mode)\n"); + printf("\t-X, --xsd \n"); printf("\nEXAMPLE\n"); printf("\timmcfg -a saAmfNodeSuFailoverMax=7 safAmfNode=Node01,safAmfCluster=1\n"); @@ -160,6 +162,10 @@ static void usage(const char *progname) printf("\timmcfg\n"); printf("\t\tRunning immcfg in explicit commit mode where immcfg accepts immcfg commands from command line\n"); printf("\t\tCtrl+D - commit changes and exit, Ctrl+C - abort CCB and exit\n"); + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully import imm.xml"); + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from the schema specified in imm.xml which is stored in /etc/opensaf, and use loaded flags to successfully import imm.xml"); } /* signal handler for SIGALRM */ @@ -1093,6 +1099,7 @@ static int imm_operation(int argc, char {"admin-owner-clear", no_argument, NULL, 0}, {"ccb-apply", no_argument, NULL, 0}, {"ccb-abort", no_argument, NULL, 0}, + {"xsd", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; SaAisErrorT error; @@ -1115,9 +1122,11 @@ static int imm_operation(int argc, char unsigned long timeoutVal = 60; attr_notify_t attrNotify = NOTIFY_UNDEFINED; + char *xsdPath = NULL; + while (1) { int option_index = 0; - c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:", long_options, &option_index); + c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:X:", long_options, &option_index); if (c == -1)/* have all command-line options have been parsed? */ break; @@ -1225,6 +1234,16 @@ static int imm_operation(int argc, char adminOwnerName = (SaImmAdminOwnerNameT)malloc(strlen(optarg) + 1); strcpy(adminOwnerName, optarg); break; + case 'X': + if(xsdPath) { + fprintf(stderr, "XSD path is already set\n"); + if(transaction_mode) + return -1; + else + exit(EXIT_FAILURE); + } + xsdPath = strdup(optarg); + break; default: fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); if(transaction_mode) @@ -1270,7 +1289,7 @@ static int imm_operation(int argc, char if (op == LOAD_IMMFILE) { VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", xmlFilename, verbose); rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe, - &immHandle, &ownerHandle, &ccbHandle, transaction_mode); + &immHa
[devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
osaf/tools/safimm/immcfg/imm_cfg.c | 31 - osaf/tools/safimm/immcfg/imm_import.cc | 178 ++- osaf/tools/safimm/immlist/imm_list.c|6 - osaf/tools/safimm/immload/imm_loader.cc | 150 +- 4 files changed, 333 insertions(+), 32 deletions(-) For forwards compatibility, OpenSAF schema, where unknown attribute flags are defined, must be provided to immcfg using -X flag. If immload finds unknown attribute flag, immload will try to find the attribute flag in the schema defined in the top element of the loading IMM XML file. diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c b/osaf/tools/safimm/immcfg/imm_cfg.c --- a/osaf/tools/safimm/immcfg/imm_cfg.c +++ b/osaf/tools/safimm/immcfg/imm_cfg.c @@ -56,7 +56,7 @@ typedef enum { #define VERBOSE_INFO(format, args...) if (verbose) { fprintf(stderr, format, ##args); } // The interface function which implements the -f opton (imm_import.cc) -int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe); +int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe, const char *xsdPath); const SaImmCcbFlagsT defCcbFlags = SA_IMM_CCB_REGISTERED_OI | SA_IMM_CCB_ALLOW_NULL_OI; @@ -86,6 +86,7 @@ static void usage(const char *progname) printf("\t--ignore-duplicates (only valid with -f/--file option, default)\n"); printf("\t--delete-class [classname2]... \n"); printf("\t-u, --unsafe\n"); + printf("\t-X, --xsd \n"); printf("\nEXAMPLE\n"); printf("\timmcfg -a saAmfNodeSuFailoverMax=7 safAmfNode=Node01,safAmfCluster=1\n"); @@ -102,6 +103,10 @@ static void usage(const char *progname) printf("\t\tremove a value from an attribute\n"); printf("\timmcfg -u .\n"); printf("\t\tThe CCBs generated by immcfg will have SA_IMM_CCB_REGISTERED_OI set to false, allowing ccb commit when OIs are missing\n"); + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully import imm.xml"); + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from the schema specified in imm.xml which is stored in /etc/opensaf, and use loaded flags to successfully import imm.xml"); } /* signal handler for SIGALRM */ @@ -682,6 +687,7 @@ int main(int argc, char *argv[]) {"timeout", required_argument, NULL, 't'}, {"verbose", no_argument, NULL, 'v'}, {"unsafe", no_argument, NULL, 'u'}, + {"xsd", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; SaAisErrorT error; @@ -703,9 +709,11 @@ int main(int argc, char *argv[]) int i; unsigned long timeoutVal = 60; + char *xsdPath = NULL; + while (1) { int option_index = 0; - c = getopt_long(argc, argv, "a:c:f:t:dhmvu", long_options, &option_index); + c = getopt_long(argc, argv, "a:c:f:t:dhmvuX:", long_options, &option_index); if (c == -1)/* have all command-line options have been parsed? */ break; @@ -751,6 +759,13 @@ int main(int argc, char *argv[]) op = verify_setoption(op, MODIFY_OBJECT); break; } + case 'X': + if(xsdPath) { + fprintf(stderr, "XSD path is already set\n"); + exit(EXIT_FAILURE); + } + xsdPath = strdup(optarg); + break; default: fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); exit(EXIT_FAILURE); @@ -767,7 +782,7 @@ int main(int argc, char *argv[]) if (op == LOAD_IMMFILE) { VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", xmlFilename, verbose); - rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe); + rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe, xsdPath); exit(rc); } @@ -854,10 +869,14 @@ int main(int argc, char *argv[]) done_om_finalize: error = immutil_saImmOmFinalize(immHandle); if (SA_AIS_OK != error) { -fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", saf_error(error)); -rc = EXIT_FAILURE; -} + fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", saf_error(error)); + rc = EXIT_FAILURE; + } + if(xsdPath) { + free(xsdPath); + xsdPath = NULL; + } exit(rc); } diff --git a/osaf/tools/safimm/immcfg
[devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
osaf/tools/safimm/immcfg/imm_cfg.c | 31 - osaf/tools/safimm/immcfg/imm_import.cc | 172 - 2 files changed, 193 insertions(+), 10 deletions(-) For forwards compatibility, OpenSAF schema, where unknown attribute flags are defined, must be provided to immcfg using -X flag. diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c b/osaf/tools/safimm/immcfg/imm_cfg.c --- a/osaf/tools/safimm/immcfg/imm_cfg.c +++ b/osaf/tools/safimm/immcfg/imm_cfg.c @@ -65,7 +65,7 @@ typedef enum { #define VERBOSE_INFO(format, args...) if (verbose) { fprintf(stderr, format, ##args); } // Interface functions which implement -f and -L options (imm_import.cc) -int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe); +int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe, const char *xsdPath); int validateImmXML(const char *xmlfile, int verbose); @@ -103,6 +103,7 @@ static void usage(const char *progname) printf("\t-L, --validate \n"); printf("\t-o, --admin-owner \n"); printf("\t--admin-owner-clear\n"); + printf("\t-X, --xsd \n"); printf("\nEXAMPLE\n"); printf("\timmcfg -a saAmfNodeSuFailoverMax=7 safAmfNode=Node01,safAmfCluster=1\n"); @@ -127,6 +128,10 @@ static void usage(const char *progname) printf("\t\tuse 'myAdminOwnerName' as admin owner name for changing one attribute of one object\n"); printf("\timmcfg --admin-owner-clear safAmfNode=Node01,safAmfCluster=1\n"); printf("\t\tclear admin owner from one object\n"); + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully import imm.xml"); + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from the schema specified in imm.xml which is stored in /etc/opensaf, and use loaded flags to successfully import imm.xml"); } /* signal handler for SIGALRM */ @@ -854,6 +859,7 @@ int main(int argc, char *argv[]) {"disable-attr-notify", no_argument, NULL, 0}, {"admin-owner", required_argument, NULL, 'o'}, {"admin-owner-clear", no_argument, NULL, 0}, + {"xsd", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; SaAisErrorT error; @@ -879,9 +885,11 @@ int main(int argc, char *argv[]) unsigned long timeoutVal = 60; attr_notify_t attrNotify = NOTIFY_UNDEFINED; + char *xsdPath = NULL; + while (1) { int option_index = 0; - c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:", long_options, &option_index); + c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:X:", long_options, &option_index); if (c == -1)/* have all command-line options have been parsed? */ break; @@ -963,6 +971,13 @@ int main(int argc, char *argv[]) adminOwnerName = (SaImmAdminOwnerNameT)malloc(strlen(optarg) + 1); strcpy(adminOwnerName, optarg); break; + case 'X': + if(xsdPath) { + fprintf(stderr, "XSD path is already set\n"); + exit(EXIT_FAILURE); + } + xsdPath = strdup(optarg); + break; default: free(adminOwnerName); fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); @@ -994,7 +1009,7 @@ int main(int argc, char *argv[]) if (op == LOAD_IMMFILE) { VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", xmlFilename, verbose); - rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe); + rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe, xsdPath); free(adminOwnerName); exit(rc); } @@ -1113,10 +1128,14 @@ int main(int argc, char *argv[]) free(attributeNames); error = immutil_saImmOmFinalize(immHandle); if (SA_AIS_OK != error) { -fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", saf_error(error)); -rc = EXIT_FAILURE; -} + fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", saf_error(error)); + rc = EXIT_FAILURE; + } + if(xsdPath) { + free(xsdPath); + xsdPath = NULL; + } exit(rc); } diff --git a/osaf/tools/safimm/immcfg/imm_import.cc b/osaf/tools/safimm/immcfg/imm_import.cc --- a/osaf/tools/safimm/immcfg/imm_import.cc +++ b/osaf/tools/safimm/immcfg/imm_import.cc @@ -21,6 +21,8 @@ #
[devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
osaf/tools/safimm/immcfg/imm_cfg.c | 29 - osaf/tools/safimm/immcfg/imm_import.cc | 191 ++-- 2 files changed, 200 insertions(+), 20 deletions(-) For forwards compatibility, OpenSAF schema, where unknown attribute flags are defined, must be provided to immcfg using -X flag. diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c b/osaf/tools/safimm/immcfg/imm_cfg.c --- a/osaf/tools/safimm/immcfg/imm_cfg.c +++ b/osaf/tools/safimm/immcfg/imm_cfg.c @@ -80,7 +80,8 @@ typedef enum { // Interface functions which implement -f and -L options (imm_import.cc) int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int ccb_safe, - SaImmHandleT *immHandle, SaImmAdminOwnerHandleT *ownerHandle, SaImmCcbHandleT *ccbHandle, int mode); + SaImmHandleT *immHandle, SaImmAdminOwnerHandleT *ownerHandle, + SaImmCcbHandleT *ccbHandle, int mode, const char *xsdPath); int validateImmXML(const char *xmlfile, int verbose, int mode); static int imm_operation(int argc, char *argv[]); @@ -129,6 +130,7 @@ static void usage(const char *progname) printf("\t--admin-owner-clear\n"); printf("\t--ccb-apply (only in a transaction mode)\n"); printf("\t--ccb-abort (only in a transaction mode)\n"); + printf("\t-X, --xsd \n"); printf("\nEXAMPLE\n"); printf("\timmcfg -a saAmfNodeSuFailoverMax=7 safAmfNode=Node01,safAmfCluster=1\n"); @@ -160,6 +162,10 @@ static void usage(const char *progname) printf("\timmcfg\n"); printf("\t\tRunning immcfg in explicit commit mode where immcfg accepts immcfg commands from command line\n"); printf("\t\tCtrl+D - commit changes and exit, Ctrl+C - abort CCB and exit\n"); + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully import imm.xml"); + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); + printf("\t\timmcfg will load unsupported attribute flags in the current OpenSAF version from the schema specified in imm.xml which is stored in /etc/opensaf, and use loaded flags to successfully import imm.xml"); } /* signal handler for SIGALRM */ @@ -1093,6 +1099,7 @@ static int imm_operation(int argc, char {"admin-owner-clear", no_argument, NULL, 0}, {"ccb-apply", no_argument, NULL, 0}, {"ccb-abort", no_argument, NULL, 0}, + {"xsd", required_argument, NULL, 'X'}, {0, 0, 0, 0} }; SaAisErrorT error; @@ -1115,9 +1122,11 @@ static int imm_operation(int argc, char unsigned long timeoutVal = 60; attr_notify_t attrNotify = NOTIFY_UNDEFINED; + char *xsdPath = NULL; + while (1) { int option_index = 0; - c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:", long_options, &option_index); + c = getopt_long(argc, argv, "a:c:f:t:dhmvuL:o:X:", long_options, &option_index); if (c == -1)/* have all command-line options have been parsed? */ break; @@ -1225,6 +1234,16 @@ static int imm_operation(int argc, char adminOwnerName = (SaImmAdminOwnerNameT)malloc(strlen(optarg) + 1); strcpy(adminOwnerName, optarg); break; + case 'X': + if(xsdPath) { + fprintf(stderr, "XSD path is already set\n"); + if(transaction_mode) + return -1; + else + exit(EXIT_FAILURE); + } + xsdPath = strdup(optarg); + break; default: fprintf(stderr, "Try '%s --help' for more information\n", argv[0]); if(transaction_mode) @@ -1270,7 +1289,7 @@ static int imm_operation(int argc, char if (op == LOAD_IMMFILE) { VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", xmlFilename, verbose); rc = importImmXML(xmlFilename, adminOwnerName, verbose, ccb_safe, - &immHandle, &ownerHandle, &ccbHandle, transaction_mode); + &immHandle, &ownerHandle, &ccbHandle, transaction_mode, xsdPath); if(transaction_mode) { if(rc) { fprintf(stderr, "CCB is aborted\n"); @@ -1478,6 +1497,10 @@ static int imm_operation(int argc, char } } } + if(xsdPath) { + free(xsdPath); + xsdPath = NULL; + } return rc; } diff --git a/osaf/tools/safimm/immcfg/imm_import.cc b/osaf/t
Re: [devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
General comment: In essence Good work! This was a complicated fix to do. But I have one big problem with the tools patches. Basically I dont undersand what we are trying to do with the tools. Comment inlined below. Zoran Milinkovic wrote: > osaf/tools/safimm/immcfg/imm_cfg.c | 31 +++- > osaf/tools/safimm/immcfg/imm_import.cc | 196 > - > osaf/tools/safimm/immdump/imm_dumper.cc| 170 +++- > osaf/tools/safimm/immdump/imm_dumper.hh|2 + > osaf/tools/safimm/immdump/imm_xmlw_dump.cc | 13 +- > osaf/tools/safimm/immlist/Makefile.am |4 + > osaf/tools/safimm/immlist/imm_list.c | 191 > - > osaf/tools/safimm/immload/imm_loader.cc| 164 - > 8 files changed, 749 insertions(+), 22 deletions(-) > > > For forwards compatibility, OpenSAF schema, where unknown attribute flags are > defined, must be provided to IMM tools (immcfg, immlist, immfind) using -X > flag. > If immload finds unknown attribute flag, immload will try to find the > attribute flag in the schema defined in the top element of the loading IMM > XML file. > > diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c > b/osaf/tools/safimm/immcfg/imm_cfg.c > --- a/osaf/tools/safimm/immcfg/imm_cfg.c > +++ b/osaf/tools/safimm/immcfg/imm_cfg.c > @@ -56,7 +56,7 @@ typedef enum { > #define VERBOSE_INFO(format, args...) if (verbose) { fprintf(stderr, format, > ##args); } > > // The interface function which implements the -f opton (imm_import.cc) > -int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int > ccb_safe); > +int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int > ccb_safe, const char *xsdPath); > > const SaImmCcbFlagsT defCcbFlags = SA_IMM_CCB_REGISTERED_OI | > SA_IMM_CCB_ALLOW_NULL_OI; > > @@ -86,6 +86,7 @@ static void usage(const char *progname) > printf("\t--ignore-duplicates (only valid with -f/--file option, > default)\n"); > printf("\t--delete-class [classname2]... \n"); > printf("\t-u, --unsafe\n"); > + printf("\t-X, --xsd \n"); > > printf("\nEXAMPLE\n"); > printf("\timmcfg -a saAmfNodeSuFailoverMax=7 > safAmfNode=Node01,safAmfCluster=1\n"); > @@ -102,6 +103,10 @@ static void usage(const char *progname) > printf("\t\tremove a value from an attribute\n"); > printf("\timmcfg -u .\n"); > printf("\t\tThe CCBs generated by immcfg will have > SA_IMM_CCB_REGISTERED_OI set to false, allowing ccb commit when OIs are > missing\n"); > + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); > + printf("\t\timmcfg will load unsupported attribute flags in the current > OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully > import imm.xml"); > + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); > + printf("\t\timmcfg will load unsupported attribute flags in the current > OpenSAF version from the schema specified in imm.xml which is stored in > /etc/opensaf, and use loaded flags to successfully import imm.xml"); > } > > /* signal handler for SIGALRM */ > @@ -682,6 +687,7 @@ int main(int argc, char *argv[]) > {"timeout", required_argument, NULL, 't'}, > {"verbose", no_argument, NULL, 'v'}, > {"unsafe", no_argument, NULL, 'u'}, > + {"xsd", required_argument, NULL, 'X'}, > {0, 0, 0, 0} > }; > SaAisErrorT error; > @@ -703,9 +709,11 @@ int main(int argc, char *argv[]) > int i; > unsigned long timeoutVal = 60; > > + char *xsdPath = NULL; > + > while (1) { > int option_index = 0; > - c = getopt_long(argc, argv, "a:c:f:t:dhmvu", long_options, > &option_index); > + c = getopt_long(argc, argv, "a:c:f:t:dhmvuX:", long_options, > &option_index); > > if (c == -1)/* have all command-line options have been > parsed? */ > break; > @@ -751,6 +759,13 @@ int main(int argc, char *argv[]) > op = verify_setoption(op, MODIFY_OBJECT); > break; > } > + case 'X': > + if(xsdPath) { > + fprintf(stderr, "XSD path is already set\n"); > + exit(EXIT_FAILURE); > + } > + xsdPath = strdup(optarg); > + break; > default: > fprintf(stderr, "Try '%s --help' for more > information\n", argv[0]); > exit(EXIT_FAILURE); > @@ -767,7 +782,7 @@ int main(int argc, char *argv[]) > > if (op == LOAD_IMMFILE) { > VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", > xmlFilename, verbose); > - rc = importImmXML(xmlFilename, adminOwnerName, verbose, > ccb_safe); > + rc = importImmXML(xmlFilename, admin
Re: [devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
Just to be clear: currently its a NACK from me for these patches. This untill the principle of how this should work is clear. There is a distinction between flags that impact integrity/validation (SA_IMM_ATTR_NO_DUPLICATES and SA_IMM_ATTR_NO_DANGLING) and flags that dont (SA_IMM_ATTR_NOTIFY). Only the latter (SA_IMM_ATTR_NOTIFY) can pass through an older system unscathed i.e. be loaded and then dumped. The consistency maintaining flags can only be coped with by older systems by Being discarded at loading and then of course they will not be dumped nor vissible in immlist At runtime. One then should also ask if we really want that kind of backwards forwards "compatibility" for the integrity maintaining flags ? You may then end up loading a backup from an older system on to a newer with the intefrity flags missing, or alternatively trying to incrementally load data from an older system (immcfg -f) but fail to do so because the data is not consistent with some integrity flags set in the newer system. You would have to be very carefull doing such "washing" of the data back and forth in an organisation. The "cleansing" of unsuported integrity maintaining flags has to be done at loading. Anything else would just cause confusion. I see no point in immlist printing a class Definition on a 4.2 system that includes NO_DUPLICATES or NO_DANGLING because it would just give the false impression that the flag is supported and enforced in the system. /AndersBj -Original Message- From: Anders Bjornerstedt [mailto:anders.bjornerst...@ericsson.com] Sent: den 18 februari 2014 18:09 To: Zoran Milinkovic Cc: opensaf-devel@lists.sourceforge.net Subject: Re: [devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116] General comment: In essence Good work! This was a complicated fix to do. But I have one big problem with the tools patches. Basically I dont undersand what we are trying to do with the tools. Comment inlined below. Zoran Milinkovic wrote: > osaf/tools/safimm/immcfg/imm_cfg.c | 31 +++- > osaf/tools/safimm/immcfg/imm_import.cc | 196 > - > osaf/tools/safimm/immdump/imm_dumper.cc| 170 +++- > osaf/tools/safimm/immdump/imm_dumper.hh|2 + > osaf/tools/safimm/immdump/imm_xmlw_dump.cc | 13 +- > osaf/tools/safimm/immlist/Makefile.am |4 + > osaf/tools/safimm/immlist/imm_list.c | 191 > - > osaf/tools/safimm/immload/imm_loader.cc| 164 - > 8 files changed, 749 insertions(+), 22 deletions(-) > > > For forwards compatibility, OpenSAF schema, where unknown attribute flags are > defined, must be provided to IMM tools (immcfg, immlist, immfind) using -X > flag. > If immload finds unknown attribute flag, immload will try to find the > attribute flag in the schema defined in the top element of the loading IMM > XML file. > > diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c > b/osaf/tools/safimm/immcfg/imm_cfg.c > --- a/osaf/tools/safimm/immcfg/imm_cfg.c > +++ b/osaf/tools/safimm/immcfg/imm_cfg.c > @@ -56,7 +56,7 @@ typedef enum { > #define VERBOSE_INFO(format, args...) if (verbose) { fprintf(stderr, > format, ##args); } > > // The interface function which implements the -f opton > (imm_import.cc) -int importImmXML(char* xmlfileC, char* > adminOwnerName, int verbose, int ccb_safe); > +int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, > +int ccb_safe, const char *xsdPath); > > const SaImmCcbFlagsT defCcbFlags = SA_IMM_CCB_REGISTERED_OI | > SA_IMM_CCB_ALLOW_NULL_OI; > > @@ -86,6 +86,7 @@ static void usage(const char *progname) > printf("\t--ignore-duplicates (only valid with -f/--file option, > default)\n"); > printf("\t--delete-class [classname2]... \n"); > printf("\t-u, --unsafe\n"); > + printf("\t-X, --xsd \n"); > > printf("\nEXAMPLE\n"); > printf("\timmcfg -a saAmfNodeSuFailoverMax=7 > safAmfNode=Node01,safAmfCluster=1\n"); > @@ -102,6 +103,10 @@ static void usage(const char *progname) > printf("\t\tremove a value from an attribute\n"); > printf("\timmcfg -u .\n"); > printf("\t\tThe CCBs generated by immcfg will have > SA_IMM_CCB_REGISTERED_OI set to false, allowing ccb commit when OIs > are missing\n"); > + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); > + printf("\t\timmcfg will load unsupported attribute flags in the current > OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully > import imm.xml"); > + printf("\timmcfg -X /etc/opensaf -f im
Re: [devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
Ack from me (4.2 patch 2). Zoran Milinkovic wrote: > osaf/tools/safimm/immcfg/imm_cfg.c | 31 - > osaf/tools/safimm/immcfg/imm_import.cc | 178 > ++- > osaf/tools/safimm/immlist/imm_list.c|6 - > osaf/tools/safimm/immload/imm_loader.cc | 150 +- > 4 files changed, 333 insertions(+), 32 deletions(-) > > > For forwards compatibility, OpenSAF schema, where unknown attribute flags are > defined, must be provided to immcfg using -X flag. > If immload finds unknown attribute flag, immload will try to find the > attribute flag in the schema defined in the top element of the loading IMM > XML file. > > diff --git a/osaf/tools/safimm/immcfg/imm_cfg.c > b/osaf/tools/safimm/immcfg/imm_cfg.c > --- a/osaf/tools/safimm/immcfg/imm_cfg.c > +++ b/osaf/tools/safimm/immcfg/imm_cfg.c > @@ -56,7 +56,7 @@ typedef enum { > #define VERBOSE_INFO(format, args...) if (verbose) { fprintf(stderr, format, > ##args); } > > // The interface function which implements the -f opton (imm_import.cc) > -int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int > ccb_safe); > +int importImmXML(char* xmlfileC, char* adminOwnerName, int verbose, int > ccb_safe, const char *xsdPath); > > const SaImmCcbFlagsT defCcbFlags = SA_IMM_CCB_REGISTERED_OI | > SA_IMM_CCB_ALLOW_NULL_OI; > > @@ -86,6 +86,7 @@ static void usage(const char *progname) > printf("\t--ignore-duplicates (only valid with -f/--file option, > default)\n"); > printf("\t--delete-class [classname2]... \n"); > printf("\t-u, --unsafe\n"); > + printf("\t-X, --xsd \n"); > > printf("\nEXAMPLE\n"); > printf("\timmcfg -a saAmfNodeSuFailoverMax=7 > safAmfNode=Node01,safAmfCluster=1\n"); > @@ -102,6 +103,10 @@ static void usage(const char *progname) > printf("\t\tremove a value from an attribute\n"); > printf("\timmcfg -u .\n"); > printf("\t\tThe CCBs generated by immcfg will have > SA_IMM_CCB_REGISTERED_OI set to false, allowing ccb commit when OIs are > missing\n"); > + printf("\timmcfg -X /etc/opensaf/schema.xsd -f imm.xml\n"); > + printf("\t\timmcfg will load unsupported attribute flags in the current > OpenSAF version from /etc/opensaf/schema.xsd, and use them to successfully > import imm.xml"); > + printf("\timmcfg -X /etc/opensaf -f imm.xml\n"); > + printf("\t\timmcfg will load unsupported attribute flags in the current > OpenSAF version from the schema specified in imm.xml which is stored in > /etc/opensaf, and use loaded flags to successfully import imm.xml"); > } > > /* signal handler for SIGALRM */ > @@ -682,6 +687,7 @@ int main(int argc, char *argv[]) > {"timeout", required_argument, NULL, 't'}, > {"verbose", no_argument, NULL, 'v'}, > {"unsafe", no_argument, NULL, 'u'}, > + {"xsd", required_argument, NULL, 'X'}, > {0, 0, 0, 0} > }; > SaAisErrorT error; > @@ -703,9 +709,11 @@ int main(int argc, char *argv[]) > int i; > unsigned long timeoutVal = 60; > > + char *xsdPath = NULL; > + > while (1) { > int option_index = 0; > - c = getopt_long(argc, argv, "a:c:f:t:dhmvu", long_options, > &option_index); > + c = getopt_long(argc, argv, "a:c:f:t:dhmvuX:", long_options, > &option_index); > > if (c == -1)/* have all command-line options have been > parsed? */ > break; > @@ -751,6 +759,13 @@ int main(int argc, char *argv[]) > op = verify_setoption(op, MODIFY_OBJECT); > break; > } > + case 'X': > + if(xsdPath) { > + fprintf(stderr, "XSD path is already set\n"); > + exit(EXIT_FAILURE); > + } > + xsdPath = strdup(optarg); > + break; > default: > fprintf(stderr, "Try '%s --help' for more > information\n", argv[0]); > exit(EXIT_FAILURE); > @@ -767,7 +782,7 @@ int main(int argc, char *argv[]) > > if (op == LOAD_IMMFILE) { > VERBOSE_INFO("importImmXML(xmlFilename=%s, verbose=%d)\n", > xmlFilename, verbose); > - rc = importImmXML(xmlFilename, adminOwnerName, verbose, > ccb_safe); > + rc = importImmXML(xmlFilename, adminOwnerName, verbose, > ccb_safe, xsdPath); > exit(rc); > } > > @@ -854,10 +869,14 @@ int main(int argc, char *argv[]) > done_om_finalize: > error = immutil_saImmOmFinalize(immHandle); > if (SA_AIS_OK != error) { > -fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", > saf_error(error)); > -rc = EXIT_FAILURE; > -} > + fprintf(stderr, "error - saImmOmFinalize FAILED: %s\n", > saf_error(error)); > + r
Re: [devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
Ack from me 4.3 patch 2. -- Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 2 of 2] IMMTOOLS: add support for forwards compatibility of attribute flags [#116]
Ack from me 4.4/4.5 patch 2. /AndersBj -- Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel