X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PlanetLabConf%2Fget_plc_config.php;h=482c612d19c3968135817004a35d52b1afbc21d0;hb=6552abf59a332977e10520772dab68fe31f0c95c;hp=6102a159b2d70be1773d14985c2712faf9748a98;hpb=f73a0e144564186625f70c711fcc4622f2c3f659;p=nodeconfig.git diff --git a/PlanetLabConf/get_plc_config.php b/PlanetLabConf/get_plc_config.php index 6102a15..482c612 100755 --- a/PlanetLabConf/get_plc_config.php +++ b/PlanetLabConf/get_plc_config.php @@ -6,11 +6,11 @@ // Mark Huang // Copyright (C) 2006 The Trustees of Princeton University // -// $Id$ -// // Try the new plc_config.php file first include 'plc_config.php'; +require_once 'plc_api.php'; +global $adm; if (isset($_REQUEST['perl'])) { $shebang = '#!/usr/bin/perl'; @@ -31,21 +31,69 @@ if (isset($_REQUEST['perl'])) { } echo $shebang . "\n"; +$limit_view = True; + +if (isset($_REQUEST['node_id']) ) { + $node_id = intval($_REQUEST['node_id']); +} else { + $node_id = 0; +} + -foreach (array('PLC_API_HOST', 'PLC_API_PATH', 'PLC_API_PORT', - 'PLC_WWW_HOST', 'PLC_BOOT_HOST', 'PLC_PLANETFLOW_HOST', - 'PLC_NAME', 'PLC_SLICE_PREFIX', - 'PLC_MAIL_SUPPORT_ADDRESS', - 'PLC_MAIL_MOM_LIST_ADDRESS', - 'PLC_MAIL_SLICE_ADDRESS') - as $name) { - if (defined($name)) { - // Perl, PHP, Python, and sh all support strong single quoting - $value = "'" . str_replace("'", "\\'", constant($name)) . "'"; - printf($format, $name, $value); - } +if ($node_id) { + $nodes = $adm->GetNodes($node_id); + if (!empty($nodes)) { + $node = $nodes[0]; + $tags = $adm->GetNodeTags(array('node_id' => $node_id, + 'tagname' => 'infrastructure')); + if (!empty($tags)) { + $tag = $tags[0]; + if ( intval($tag['value']) == 1 ) { + $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR'])); + if (!empty($interfaces)) { + $nodes = $adm->GetNodes(array($interfaces[0]['node_id'])); + if (!empty($nodes)) { + $node = $nodes[0]; + if ( $node['node_id'] == $node_id ) + { + # NOTE: only provide complete view if + # node exists + # node has infrastrucure tag + # infrastructure tag value == 1 + # Check that the requestor is the node. + $limit_view = False; + } + } + } + } + } + } } +if ( $limit_view ) { + $plc_constants = array('PLC_API_HOST', 'PLC_API_PATH', 'PLC_API_PORT', + 'PLC_WWW_HOST', 'PLC_BOOT_HOST', 'PLC_PLANETFLOW_HOST', + 'PLC_NAME', 'PLC_SLICE_PREFIX', 'PLC_MONITOR_HOST', + 'PLC_MAIL_SUPPORT_ADDRESS', + 'PLC_MAIL_MOM_LIST_ADDRESS', + 'PLC_MAIL_SLICE_ADDRESS'); +} else { + $plc_constants = array(); + $const = get_defined_constants(true); + foreach ( $const['user'] as $name => $v ){ + if ( preg_match('/^PLC_/', $name) == 1 ){ + $plc_constants[] = $name; + } + } +} + +foreach ($plc_constants as $name) { + if (defined($name)) { + // Perl, PHP, Python, and sh all support strong single quoting + $value = "'" . str_replace("'", "\\'", constant($name)) . "'"; + printf($format, $name, $value); + } +} printf($format, 'PLC_API_CA_SSL_CRT', "'/usr/boot/cacert.pem'"); printf($format, 'PLC_ROOT_GPG_KEY_PUB', "'/usr/boot/pubring.gpg'");