Пример #1
0
c_bool
u_userGetSPBFromEnvUri() {
    char *uri = NULL;
    c_bool spb = FALSE;
    cf_element platformConfig = NULL;
    cf_element dc = NULL;
    cf_element elemName = NULL;
    cf_element singleProcess = NULL;
    cf_data elementData = NULL;
    cf_data dataName;
    c_value value;
    cfgprs_status r;

    uri = os_getenv ("OSPL_URI");
    r = cfg_parse_ospl (uri, &platformConfig);
    if (r == CFGPRS_OK)
    {
       dc = cf_element (cf_elementChild (platformConfig, CFG_DOMAIN));
       if (dc) {
      singleProcess = cf_element(cf_elementChild(dc, CFG_SINGLEPROCESS));
      if (singleProcess != NULL) {
         elementData = cf_data(cf_elementChild(singleProcess, "#text"));
         if (elementData != NULL) {
            value = cf_dataValue(elementData);
        if (os_strncasecmp(value.is.String, "TRUE", 4) == 0) {
           /* A SingleProcess value of True implies that Heap is to be used */
          spb = TRUE;
        }
         }
      }
       }
    }
    return spb;

}
Пример #2
0
int
u_userGetDomainIdFromEnvUri() {
    char *uri = NULL;
    int domainId = 0;
    cf_element platformConfig = NULL;
    cf_element dc = NULL;
    cf_element elemName = NULL;
    cf_data dataName;
    c_value value;
    cfgprs_status r;

    uri = os_getenv ("OSPL_URI");
    r = cfg_parse_ospl (uri, &platformConfig);
    if (r == CFGPRS_OK)
    {
       dc = cf_element (cf_elementChild (platformConfig, CFG_DOMAIN));
       if (dc) {
      elemName = cf_element(cf_elementChild(dc, CFG_ID));
      if (elemName) {
         dataName = cf_data(cf_elementChild(elemName, "#text"));
         if (dataName != NULL) {
            value = cf_dataValue(dataName);
        sscanf(value.is.String, "%d", &domainId);
         }
      }
       }
    }
    return domainId;

}
Пример #3
0
char *
u_userGetDomainNameFromEnvUri() {
    char *uri = NULL;
    char * domainName = NULL;
    cf_element platformConfig = NULL;
    cf_element dc = NULL;
    cf_element elemName = NULL;
    cf_data dataName;
    c_value value;
    cfgprs_status r;

    uri = os_getenv ("OSPL_URI");
    if ( uri != NULL )
    {
       domainName = os_strdup(uri);
    }
    else
    {
       r = cfg_parse_ospl (uri, &platformConfig);
       if (r == CFGPRS_OK)
       {
          dc = cf_element (cf_elementChild (platformConfig, CFG_DOMAIN));
          if (dc)
          {
             elemName = cf_element(cf_elementChild(dc, CFG_NAME));
             if (elemName)
             {
                dataName = cf_data(cf_elementChild(elemName, "#text"));
                if (dataName != NULL)
                {
                   value = cf_dataValue(dataName);
                   domainName = os_strdup(value.is.String);
                }
             }
          }
       }
    }
    return domainName;
}
Пример #4
0
int
main(
   int argc,
   char *argv[])
{
   int opt;
   int ret;
   int i = 0;
   char *uri = NULL;
   char *env[MAX_EVN_ARRAY];
   config_t cfg = { NULL, NULL, NULL, NULL, 0, 0};
   cf_element root = NULL;
   cfgprs_status parser_status = CFGPRS_OK;

   while ((opt = getopt(argc, argv, "hdxo:u:e:")) != -1)
   {
      switch (opt)
      {
         case 'h':
         {
            print_usage(argv[0]);
            return(0);
         }
         case 'd':
         {
            cfg.enableDynamicLoad = 1;
            break;
         }
         case 'x':
         {
            cfg.excludeXML = 1;
            break;
         }
         case 'o':
         {
            if (cfg.ofname)
            {
               print_usage(argv[0]);
               return -1;
            }
            cfg.ofname = optarg;
            break;
         }
         case 'u':
         {
            if (uri)
            {
               print_usage(argv[0]);
               return -1;
            }
            uri = optarg;
            break;
         }
         case 'e':
         {
            if ( i < MAX_EVN_ARRAY )
            {
               env[i++] = optarg;
            }
            break;
         }
      }
   }
   if ( cfg.excludeXML && !cfg.enableDynamicLoad )
   {
      fprintf(stderr, "Error: Use of the option -x requires the -d option.\n");
      print_usage(argv[0]);
      return -1;
   }
   env[i] = NULL;
   if ( i >= MAX_EVN_ARRAY )
   {
      print_usage(argv[0]);
      fprintf(stderr,"Max env array reached : %d\n", MAX_EVN_ARRAY - 1);
   }

   cfg.env = env;
   cfg.progname = argv[0];
   /* if uri is not set on the command line use environment variable to
    * discover configuration file
    */
   if (!uri)
   {
      uri = os_getenv("OSPL_URI");
   }
   cfg.ifuri = uri;

   if (!cfg.ofname)
   {
      cfg.ofname = DEFAULT_CFILE_NAME;
   }

   if ( cfg.excludeXML )
   {
      cfg.ifuri = NULL;
      ret = ! generate_cf_file( &cfg, root );
   }
   else
   {

     /* At this point uri must be set and valid otherwise the xml parser
      * will return CFGPRS_NO_INPUT.
      */
     parser_status = cfg_parse_ospl((const char *)uri, &root);

     switch (parser_status)
     {
        case CFGPRS_OK: /* do nothing as we are ok for now */
        {
           break;
        }
        case CFGPRS_NO_INPUT:
        {
           fprintf(stderr, "No valid URI specified:\n");
           fprintf(stderr, "1. on command line\n");
           fprintf(stderr, "2. OSPL_URI environment variable\n");
           print_usage(argv[0]);
           return -1;
        }
        case CFGPRS_ERROR:
        {
           fprintf(stderr, "Failure reading %s, please check syntax of configuration file.\n", uri);
           fprintf(stderr, "\n");
           return -1;
        }
     }
     ret = ! generate_cf_file( &cfg, root );
     cf_nodeFree(cf_node(root));

   }
   return(ret);
}
Пример #5
0
int
main(
    int argc,
    char *argv[])
{
    int opt;
    int retCode = OSPL_EXIT_CODE_OK;
    char *uri = NULL;
    char *command = NULL;
    char start_command[2048];
    cf_element domain = NULL;
    cfgprs_status r;
    os_boolean blocking = OS_FALSE;
    os_boolean blockingDefined = OS_FALSE;
    os_time serviceTerminatePeriod;
    char *vg_cmd = NULL;

    ospl_setsignals();
    os_osInit();
    os_procAtExit(os_osExit);

    uri = os_getenv ("OSPL_URI");
    vg_cmd = os_getenv("VG_SPLICED");
    if (!vg_cmd)
    {
       vg_cmd = "";
    }

    while ((opt = getopt (argc, argv, "hvafd:")) != -1)
    {
        switch (opt)
        {
        case 'h':
            print_usage (argv[0]);
            exit (OSPL_EXIT_CODE_OK);
            break;
        case 'v':
            printf ("OpenSplice version : %s\n", VERSION);
            exit (OSPL_EXIT_CODE_OK);
            break;
        case 'd':
            if (domain_name)
            {
                print_usage (argv[0]);
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
            domain_name = optarg;
            break;
        case 'a':
            if (domain_name)
            {
                print_usage (argv[0]);
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
            uri = NULL;
            domain_name = "*";
            break;
        case 'f':
            if(blockingDefined)
            {
                print_usage (argv[0]);
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
            blocking = OS_TRUE;
            blockingDefined = OS_TRUE;
            break;
        case '?':
            print_usage (argv[0]);
            exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            break;
        default:
            break;
        }
    }
    if ((argc-optind) > 3)
    {
        print_usage (argv[0]);
        exit(OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
    }
    command = argv[optind];
    if (command && argv[optind+1])
    {
        uri = argv[optind+1];
    }

    if (uri && (strlen(uri) > 0))
    {
        r = cfg_parse_ospl (uri, &platformConfig);
        if (r == CFGPRS_OK)
        {
            domain_name = findDomain (platformConfig, &domain);
            if (domain_name == NULL)
            {
                printf ("The domain name could not be determined from the configuration\n");
                exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
            }
        } else
        {
            if (r == CFGPRS_NO_INPUT)
            {
                printf ("Error: Cannot open URI \"%s\". Exiting now...\n", uri);
            }
            else
            {
                printf ("Errors are detected in the configuration. Exiting now...\n");
            }
            exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
        }
    }
    if ((command == NULL) || (strcmp (command, "stop") == 0))
    {
        if (domain_name == NULL)
        {
            domain_name = "The default Domain";
        }
        findServiceTerminatePeriod(domain, &serviceTerminatePeriod);
        retCode = findSpliceSystemAndRemove (domain_name, serviceTerminatePeriod);
    } else if (strcmp (command, "start") == 0)
    {
#ifdef OS_LINUX_DEFS_H
        check_for_LD_ASSUME_KERNEL ();
#endif
        if (domain_name == NULL)
        {
            domain_name = "The default Domain";
        }
        if (!spliceSystemRunning (domain_name))
        {
            if(!blocking)
            {
                printf ("\nStarting up domain \"%s\" .", domain_name);
            } else
            {
                printf ("\nStarting up domain \"%s\" and blocking.", domain_name);
            }
            if (uri)
            {
                if(!blocking)
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced \"%s\" &", vg_cmd, uri);
                } else
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced \"%s\"", vg_cmd, uri);
                }
            } else
            {
                if(!blocking)
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced &", vg_cmd);
                } else
                {
                   snprintf (start_command, sizeof(start_command), "%s spliced", vg_cmd);
                }
            }

            printf (" Ready\n");

            /* Display locations of info and error files */
            os_reportDisplayLogLocations();

            retCode = WEXITSTATUS(system (start_command));
            if(!blocking)
            {
                sleep (2); /* take time to first show the license message from spliced */
            }
        } else
        {
            printf ("Splice System with domain name \"%s\" is found running, ignoring command\n",
            domain_name);
        }
    } else if (strcmp (command, "list") == 0)
    {
        retCode = findSpliceSystemAndShow (domain_name);
    } else
    {
        print_usage (argv[0]);
        exit (OSPL_EXIT_CODE_UNRECOVERABLE_ERROR);
    }
    return retCode;
}