4 require_once 'plc_login.php';
6 // Get session and API handles
7 require_once 'plc_session.php';
11 require_once 'plc_functions.php';
12 require_once 'plc_sorts.php';
15 $_person= $plc->person;
16 $_roles= $_person['role_ids'];
18 //print_r( $_person );
20 // if not a PI or admin then redirect to slice index
21 if( !in_array( '10', $_roles ) && !in_array( '20', $_roles ) )
22 header( "index.php" );
24 if( !$_POST['name'] ) {
25 // get default site base
26 $site_info= $api->GetSites( array( $_person['site_ids'][0] ), array( "login_base" ) );
27 $base= $site_info[0]['login_base'] ."_";
34 $instantiation= $_POST['instantiation'];
35 $name= $_POST['name'];
36 $description= $_POST['description'];
40 $error['name']= "<font color=red>You must enter a name for your slice.</font>";
43 // make sure slice name doesnt exist
44 $slice_info= $api->GetSlices( array( $slice_name ), array( "slice_id" ) );
46 if( !empty( $slice_info ) ) {
47 $error['name']= "<font color=red>Slice name already in use. Please choose another.</font>";
53 if( $url == "http://" || "" )
54 $error['url']= "<font color=red>You must enter a URL for your slice's info.</font>";
56 if( $description == "" )
57 $error['description']= "<font color=red>Your must enter a description for you slice.</font>";
59 // if no errors then add
61 $fields= array( "url" => $url, "instantiation" => $instantiation, "name" => $slice_name, "description" => $description );
62 echo "added: <pre>"; print_r( $fields ); echo "</pre>\n";
64 $slice_new_id= $api->AddSlice( $fields );
67 plc_redirect( "index.php?id=$slice_new_id" );
70 $error['api']= $api->error();
77 require_once 'plc_drupal.php';
78 drupal_set_title('Slices');
79 include 'plc_header.php';
85 // check for errors and set error styles
87 $name_error= " class='plc-warning'";
90 $url_error= " class='plc-warning'";
92 if( $error['description'] )
93 $desc_error= " class='plc-warning'";
96 // add javaScript code
97 echo "<script type='text/javascript'>
98 function update(str1) {
100 temp= str1.split('->');
101 var c= ( temp[1] + '_' )
102 document.getElementById('textbox').value = c;
108 echo "<form action='add_slice.php' method=post>\n";
111 echo "<font class='plc-warning'>". $error['api'] ."</font>\n";
113 echo "<h2>Create Slice</h2>\n";
115 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";
116 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";
117 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";
119 echo "<p><table><tbody>\n";
121 // displays a site select list for admins and multi-site users
122 if( count( $_person['site_ids'] ) > 1 || in_array( 10, $_roles ) ) {
123 // get sites depending on role and sites associated.
124 if( in_array( 10, $_roles ) )
125 $site_info= $api->GetSites( NULL, array( "name", "site_id", "login_base" ) );
126 elseif( count( $_person['site_ids'] ) > 1 )
127 $site_info= $api->GetSites( $_person['site_ids'], array( "name", "site_id", "login_base" ) );
129 echo "<tr><th>Site: </th><td><select onchange='update(this[selectedIndex].text)' name='site_id'>\n";
131 sort_sites( $site_info );
132 foreach( $site_info as $site ) {
133 echo "<option value=". $site['site_id'];
134 if( $site['site_id'] == $_person['site_ids'][0] )
136 echo ">". $site['name'] ."->". $site['login_base'] ."</option>\n";
139 echo "</select></td><td></td></tr>\n";
143 echo "<tr><th$name_error>Name: </th><td><input type=text id='textbox' name='name' size=40 value='";
148 echo "'></td><td>". $error['name'] ."</td></tr>\n";
149 echo "<tr><th$url_error>URL: </th><td> <input type=text name='url' size=50 value='$url'></td><td>". $error['url'] ."</td></tr>\n";
150 echo "<tr><th$desc_error>Description: </th><td> <textarea name='description' rows=5 cols=45>$description</textarea></td><td>". $error['description'] ."</td></tr>\n";
151 echo "<tr><th>Instantiation: </th><td> <select name='instantiation'>\n";
152 echo "<option value='plc-instantiated'"; if( $instantiation == 'plc-instantiated' ) echo " selected"; echo ">PLC</option>\n";
153 echo "<option value='delegated'"; if( $instantiation == 'delegated' ) echo " selected"; echo ">Delegated</option>\n";
154 echo "<option value='not-instantiated'"; if( $instantiation == 'not-instantiated' ) echo " selected"; echo ">None</option>\n";
155 echo "</select></td><td></td></tr>\n";
157 echo "</tbody></table>\n";
159 echo "<p><input type=submit name='add' value='Add Slice'>\n";
167 include 'plc_footer.php';