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 require_once 'plc_drupal.php';
15 include 'plc_header.php';
19 $_person= $plc->person;
20 $_roles= $_person['role_ids'];
22 //print_r( $_person );
24 // if not a PI or admin then redirect to slice index
25 if( !in_array( '10', $_roles ) && !in_array( '20', $_roles ) )
26 header( "index.php" );
28 if( !$_POST['name'] ) {
29 // get default site base
30 $site_info= $api->GetSites( array( $_person['site_ids'][0] ), array( "login_base" ) );
31 $base= $site_info[0]['login_base'] ."_";
38 $instantiation= $_POST['instantiation'];
39 $name= $_POST['name'];
40 $description= $_POST['description'];
44 $error['name']= "<font color=red>You must enter a name for your slice.</font>";
47 // make sure slice name doesnt exist
48 $slice_info= $api->GetSlices( array( $slice_name ), array( "slice_id" ) );
50 if( !empty( $slice_info ) ) {
51 $error['name']= "<font color=red>Slice name already in use. Please choose another.</font>";
57 if( $url == "http://" || "" )
58 $error['url']= "<font color=red>You must enter a URL for your slice's info.</font>";
60 if( $description == "" )
61 $error['description']= "<font color=red>Your must enter a description for you slice.</font>";
63 // if no errors then add
65 $fields= array( "url" => $url, "instantiation" => $instantiation, "name" => $slice_name, "description" => $description );
66 echo "added: <pre>"; print_r( $fields ); echo "</pre>\n";
68 $slice_new_id= $api->AddSlice( $fields );
71 plc_redirect( "index.php?id=$slice_new_id" );
74 $error['api']= $api->error();
81 require_once 'plc_drupal.php';
82 drupal_set_title('Slices');
83 include 'plc_header.php';
89 // check for errors and set error styles
91 $name_error= " class='plc-warning'";
94 $url_error= " class='plc-warning'";
96 if( $error['description'] )
97 $desc_error= " class='plc-warning'";
100 // add javaScript code
101 echo "<script type='text/javascript'>
102 function update(str1) {
103 var temp= new Array()
104 temp= str1.split('->');
105 var c= ( temp[1] + '_' )
106 document.getElementById('textbox').value = c;
112 echo "<form action='slice_add.php' method=post>\n";
115 echo "<font class='plc-warning'>". $error['api'] ."</font>\n";
117 echo "<h2>Create Slice</h2>\n";
119 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";
120 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";
121 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";
123 echo "<p><table><tbody>\n";
125 // displays a site select list for admins and multi-site users
126 if( count( $_person['site_ids'] ) > 1 || in_array( 10, $_roles ) ) {
127 // get sites depending on role and sites associated.
128 if( in_array( 10, $_roles ) )
129 $site_info= $api->GetSites( NULL, array( "name", "site_id", "login_base" ) );
130 elseif( count( $_person['site_ids'] ) > 1 )
131 $site_info= $api->GetSites( $_person['site_ids'], array( "name", "site_id", "login_base" ) );
133 echo "<tr><th>Site: </th><td><select onchange='update(this[selectedIndex].text)' name='site_id'>\n";
135 foreach( $site_info as $site ) {
136 echo "<option value=". $site['site_id'];
137 if( $site['site_id'] == $_person['site_ids'][0] )
139 echo ">". $site['name'] ."->". $site['login_base'] ."</option>\n";
142 echo "</select></td><td></td></tr>\n";
146 echo "<tr><th$name_error>Name: </th><td><input type=text id='textbox' name='name' size=40 value='";
151 echo "'></td><td>". $error['name'] ."</td></tr>\n";
152 echo "<tr><th$url_error>URL: </th><td> <input type=text name='url' size=50 value='$url'></td><td>". $error['url'] ."</td></tr>\n";
153 echo "<tr><th$desc_error>Description: </th><td> <textarea name='description' rows=5 cols=45>$description</textarea></td><td>". $error['description'] ."</td></tr>\n";
154 echo "<tr><th>Instantiation: </th><td> <select name='instantiation'>\n";
155 echo "<option value='plc-instantiated'"; if( $instantiation == 'plc-instantiated' ) echo " selected"; echo ">PLC</option>\n";
156 echo "<option value='delegated'"; if( $instantiation == 'delegated' ) echo " selected"; echo ">Delegated</option>\n";
157 echo "<option value='not-instantiated'"; if( $instantiation == 'not-instantiated' ) echo " selected"; echo ">None</option>\n";
158 echo "</select></td><td></td></tr>\n";
160 echo "</tbody></table>\n";
162 echo "<p><input type=submit name='add' value='Add Slice'>\n";
170 include 'plc_footer.php';