3 // Print a subset of the variables from the PLC configuration store in
4 // various formats (Perl, Python, PHP, sh)
6 // Mark Huang <mlhuang@cs.princeton.edu>
7 // Copyright (C) 2006 The Trustees of Princeton University
12 // Try the new plc_config.php file first
13 include 'plc_config.php';
14 require_once 'plc_api.php';
17 if (isset($_REQUEST['perl'])) {
18 $shebang = '#!/usr/bin/perl';
19 $format = "our $%s=%s;\n";
21 } elseif (isset($_REQUEST['python'])) {
22 $shebang = '#!/usr/bin/python';
25 } elseif (isset($_REQUEST['php'])) {
27 $format = "define('%s', %s);\n";
30 $shebang = '#!/bin/sh';
38 if (isset($_REQUEST['node_id']) ) {
39 $node_id = intval($_REQUEST['node_id']);
46 $nodes = $adm->GetNodes($node_id);
49 $tags = $adm->GetNodeTags(array('node_id' => $node_id,
50 'tagname' => 'infrastructure'));
53 if ( intval($tag['value']) == 1 ) {
54 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
55 if (!empty($interfaces)) {
56 $nodes = $adm->GetNodes(array($interfaces[0]['node_id']));
59 if ( $node['node_id'] == $node_id )
61 # NOTE: only provide complete view if
63 # node has infrastrucure tag
64 # infrastructure tag value == 1
65 # Check that the requestor is the node.
76 $plc_constants = array('PLC_API_HOST', 'PLC_API_PATH', 'PLC_API_PORT',
77 'PLC_WWW_HOST', 'PLC_BOOT_HOST', 'PLC_PLANETFLOW_HOST',
78 'PLC_NAME', 'PLC_SLICE_PREFIX', 'PLC_MONITOR_HOST',
79 'PLC_MAIL_SUPPORT_ADDRESS',
80 'PLC_MAIL_MOM_LIST_ADDRESS',
81 'PLC_MAIL_SLICE_ADDRESS');
83 $plc_constants = array();
84 $const = get_defined_constants(true);
85 foreach ( $const['user'] as $name => $v ){
86 if ( preg_match('/^PLC_/', $name) == 1 ){
87 $plc_constants[] = $name;
92 foreach ($plc_constants as $name) {
94 // Perl, PHP, Python, and sh all support strong single quoting
95 $value = "'" . str_replace("'", "\\'", constant($name)) . "'";
96 printf($format, $name, $value);
99 printf($format, 'PLC_API_CA_SSL_CRT', "'/usr/boot/cacert.pem'");
100 printf($format, 'PLC_ROOT_GPG_KEY_PUB', "'/usr/boot/pubring.gpg'");