3 // Deprecated. Generates an XML file that the old PlanetLabConf script understands.
5 // Aaron Klingaman <alk@absarokasoft.com>
6 // Mark Huang <mlhuang@cs.princeton.edu>
8 // Copyright (C) 2006 The Trustees of Princeton University
13 // Get admin API handle
14 require_once 'plc_api.php';
17 function writeXMLHeader()
19 print( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n\n" );
22 define("ENT_UNPARSED", 0); // i.e., CDATA
23 define("ENT_PARSED", 1); // i.e., PCDATA (attributes)
25 function xmlspecialchars_decode($string, $parsed = ENT_UNPARSED)
27 if ($parsed == ENT_PARSED) {
33 return str_replace('&', '&',
34 str_replace(array(''', '<', '>', '"'),
35 array("'", '<', '>', '"'),
44 return str_replace('&', '&',
45 str_replace(array(''', '<', '>', '\"', '\\'),
46 array("'", '<', '>', '"', "\\"),
51 function xmlspecialchars($string, $parsed = ENT_UNPARSED)
53 if ($parsed == ENT_PARSED) {
59 $string = str_replace(array("'", '<', '>', '"'),
60 array(''', '<', '>', '"'),
61 str_replace('&', '&', $string));
69 $string = str_replace(array("'", '<', '>', '"'),
70 array(''', '<', '>', '\"'),
71 str_replace(array('&', "\\"),
76 return utf8_encode($string);
80 if (!empty($_REQUEST['node_id'])) {
81 $node = $adm->GetSlivers(intval($_REQUEST['node_id']));
83 $interfaces = $adm->GetInterfaces(array('ip' => $_SERVER['REMOTE_ADDR']));
84 if (!empty($interfaces)) {
85 $node = $adm->GetSlivers($interfaces[0]['node_id']);
92 $node_id = $node['node_id'];
96 print( "<planetlab_conf version=\"0.1\" time=\"$curtime\">\n" );
97 print( "<node id=\"$node_id\">\n" );
99 foreach( $node['conf_files'] as $conf_file )
101 $source = xmlspecialchars($conf_file["source"]);
102 $dest = xmlspecialchars($conf_file["dest"]);
103 $file_permissions = xmlspecialchars($conf_file["file_permissions"]);
104 $file_owner = xmlspecialchars($conf_file["file_owner"]);
105 $file_group = xmlspecialchars($conf_file["file_group"]);
106 $preinstall_cmd = xmlspecialchars($conf_file["preinstall_cmd"]);
107 $postinstall_cmd = xmlspecialchars($conf_file["postinstall_cmd"]);
108 $error_cmd = xmlspecialchars($conf_file["error_cmd"]);
109 $ignore_cmd_errors = $conf_file["ignore_cmd_errors"];
110 $always_update = $conf_file["always_update"];
112 if( $ignore_cmd_errors == 1 )
113 $ignore_cmd_errors= "y";
115 $ignore_cmd_errors= "n";
117 if( $always_update == 1 )
122 print( "<file always_update=\"$always_update\" ignore_cmd_errors=\"$ignore_cmd_errors\">\n" );
123 print( "<source>$source</source>\n" );
124 print( "<destination>$dest</destination>\n" );
125 print( "<permissions>$file_permissions</permissions>\n" );
126 print( "<owner>$file_owner</owner>\n" );
127 print( "<group>$file_group</group>\n" );
128 print( "<preinstall_cmd>$preinstall_cmd</preinstall_cmd>\n" );
129 print( "<postinstall_cmd>$postinstall_cmd</postinstall_cmd>\n" );
130 print( "<error_cmd>$error_cmd</error_cmd>\n" );
131 print( "</file>\n" );
134 print( "</node>\n" );
135 print( "</planetlab_conf>\n" );