4 require_once 'plc_login.php';
6 // Get session and API handles
7 require_once 'plc_session.php';
11 require_once 'plc_functions.php';
14 $_person= $plc->person;
15 $_roles= $_person['role_ids'];
17 //print_r( $_person );
19 // if not a PI or admin then redirect to slice index
20 if( !in_array( '10', $_roles ) && !in_array( '20', $_roles ) )
21 header( "index.php" );
23 if( !$_POST['name'] ) {
24 // get default site base
25 $site_info= $api->GetSites( array( $_person['site_ids'][0] ), array( "login_base" ) );
26 $base= $site_info[0]['login_base'] ."_";
33 $instantiation= $_POST['instantiation'];
34 $name= $_POST['name'];
35 $description= $_POST['description'];
39 $error['name']= "<font color=red>You must enter a name for your slice.</font>";
42 // make sure slice name doesnt exist
43 $slice_info= $api->GetSlices( array( $slice_name ), array( "slice_id" ) );
45 if( !empty( $slice_info ) ) {
46 $error['name']= "<font color=red>Slice name already in use. Please choose another.</font>";
52 if( $url == "http://" || "" )
53 $error['url']= "<font color=red>You must enter a URL for your slice's info.</font>";
55 if( $description == "" )
56 $error['description']= "<font color=red>Your must enter a description for you slice.</font>";
58 // if no errors then add
60 $fields= array( "url" => $url, "instantiation" => $instantiation, "name" => $slice_name, "description" => $description );
61 echo "added: <pre>"; print_r( $fields ); echo "</pre>\n";
63 $slice_new_id= $api->AddSlice( $fields );
66 plc_redirect( "index.php?id=$slice_new_id" );
69 $error['api']= $api->error();
76 require_once 'plc_drupal.php';
77 drupal_set_title('Slices');
78 include 'plc_header.php';
84 // check for errors and set error styles
86 $name_error= " class='plc-warning'";
89 $url_error= " class='plc-warning'";
91 if( $error['description'] )
92 $desc_error= " class='plc-warning'";
95 // add javaScript code
96 echo "<script type='text/javascript'>
97 function update(str1) {
99 temp= str1.split('->');
100 var c= ( temp[1] + '_' )
101 document.getElementById('textbox').value = c;
107 echo "<form action='slice_add.php' method=post>\n";
110 echo "<font class='plc-warning'>". $error['api'] ."</font>\n";
112 echo "<h2>Create Slice</h2>\n";
114 echo "<p>You must provide a short description of the new slice as well as a link to a project website before creating it. Do <strong>not</strong> provide bogus information; if a complaint is lodged against your slice and PlanetLab Operations is unable to determine what the normal behavior of your slice is, your slice may be deleted to resolve the complaint.\n";
115 echo "<p>There are three possible \"instantiation\" states for a slice. <strong>PLC</strong> creates a slice with default settings. <strong>Delegated</strong> creates a ticket to use on each node. <strong>None</strong> allows you to reserve a slice name; you may instantiate the slice later.\n";
116 echo "<p><strong>NOTE</strong>: All PlanetLab users are <strong>strongly</strong> encouraged to join the PlanetLab <a href='https://lists.planet-lab.org/mailman/listinfo/users'>Users</a> mailing list. Most questions about running software on PlanetLab can be answered by posting to this list. Site administrators often use this list to post announcements about service outages. New software releases and available services are announced here as well.\n";
118 echo "<p><table><tbody>\n";
120 // displays a site select list for admins and multi-site users
121 if( count( $_person['site_ids'] ) > 1 || in_array( 10, $_roles ) ) {
122 // get sites depending on role and sites associated.
123 if( in_array( 10, $_roles ) )
124 $site_info= $api->GetSites( NULL, array( "name", "site_id", "login_base" ) );
125 elseif( count( $_person['site_ids'] ) > 1 )
126 $site_info= $api->GetSites( $_person['site_ids'], array( "name", "site_id", "login_base" ) );
128 echo "<tr><th>Site: </th><td><select onchange='update(this[selectedIndex].text)' name='site_id'>\n";
130 sort_sites( $site_info );
131 foreach( $site_info as $site ) {
132 echo "<option value=". $site['site_id'];
133 if( $site['site_id'] == $_person['site_ids'][0] )
135 echo ">". $site['name'] ."->". $site['login_base'] ."</option>\n";
138 echo "</select></td><td></td></tr>\n";
142 echo "<tr><th$name_error>Name: </th><td><input type=text id='textbox' name='name' size=40 value='";
147 echo "'></td><td>". $error['name'] ."</td></tr>\n";
148 echo "<tr><th$url_error>URL: </th><td> <input type=text name='url' size=50 value='$url'></td><td>". $error['url'] ."</td></tr>\n";
149 echo "<tr><th$desc_error>Description: </th><td> <textarea name='description' rows=5 cols=45>$description</textarea></td><td>". $error['description'] ."</td></tr>\n";
150 echo "<tr><th>Instantiation: </th><td> <select name='instantiation'>\n";
151 echo "<option value='plc-instantiated'"; if( $instantiation == 'plc-instantiated' ) echo " selected"; echo ">PLC</option>\n";
152 echo "<option value='delegated'"; if( $instantiation == 'delegated' ) echo " selected"; echo ">Delegated</option>\n";
153 echo "<option value='not-instantiated'"; if( $instantiation == 'not-instantiated' ) echo " selected"; echo ">None</option>\n";
154 echo "</select></td><td></td></tr>\n";
156 echo "</tbody></table>\n";
158 echo "<p><input type=submit name='add' value='Add Slice'>\n";
166 include 'plc_footer.php';