X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetlab%2Fslices%2Findex.php;h=4aebbbf55dd0aa55db1199380c47742add847e0f;hb=f2acbd7968767b8cc929d70f3d4257584c95b2e8;hp=1df026ab6bd401efb9efa12ce7f6b2cbff0ce0e1;hpb=a9184c050531eeb1c1bffc7efe78590cac7be520;p=plewww.git
diff --git a/planetlab/slices/index.php b/planetlab/slices/index.php
index 1df026a..4aebbbf 100644
--- a/planetlab/slices/index.php
+++ b/planetlab/slices/index.php
@@ -1,509 +1,11 @@
person;
-$_roles= $_person['role_ids'];
-
-//print_r( $_person );
-
-
-// if node_host is set then set id to that node's id.
-if( $_POST['slicename'] ) {
- $slicename= $_POST['slicename'];
-
- $slice_info= $api->GetSlices( array( $slicename ), array( "slice_id" ) );
-
- header( "location: index.php?id=". $slice_info[0]['slice_id'] );
- exit();
-
-}
-
-
-// if no slice id, display list of slices
-if( !$_GET['id'] ) {
- // diplay site select list for admins
- if( in_array( 10, $_roles ) ) {
- // auto complete box for finding a slice
-
- drupal_set_html_head('
-
- ');
-
- echo "
\n
-
\n";
-
- // get site info
- $site_info= $api->GetSites( NULL, array( "site_id", "name", "peer_id" ) );
- sort_sites( $site_info );
-
- // Thierry -- try to select only one entry
- // xxx still not right if _person in several sites, but that is good enough
- //if( $site['site_id'] == $_POST['site_id'] || in_array( $site['site_id'], $_person['site_ids'] ) )
- if ($_POST['site_id'])
- $selected_site_id = $_POST['site_id'];
- else if ($_GET['site_id'])
- $selected_site_id = $_GET['site_id'];
- else
- $selected_site_id = $_person['site_ids'][0];
-
- echo "Select a site to view slices from: ";
- echo "\n";
-
- }
-
- if( $_POST['site_id'] ) {
- $selection="Site";
- $site= array( intval( $_POST['site_id'] ) );
- } elseif( $_GET['site_id'] ) {
- $selection="Site";
- $site= array( intval( $_GET['site_id'] ) );
- } else {
- $selection="Person";
- $site= $_person['site_ids'];
- }
-
- // get site's slices
- $site_info= $api->GetSites( $site, array( "slice_ids","name" ) );
-
- if ( $selection == "Site" )
- drupal_set_title ("Slices for site " . $site_info[0]['name']);
- else
- drupal_set_title ("Slices for " . $_person['email'] . "'s sites");
-
- // make an array of all slices
- foreach( $site_info as $site ) {
- foreach( $site['slice_ids'] as $slice_id ) {
- $slice_ids[]= $slice_id;
- }
-
- }
-
- if (empty ($slice_ids)) {
- echo "No slice found, or all are expired.";
- } else {
-
- $slice_info= $api->GetSlices( $slice_ids, array( "slice_id", "name", "site_id", "state", "person_ids", "expires", "peer_id" ) );
- //print '
'; print_r( $api->trace() ) ; print '
';
-
- if ( ! $slice_info) {
- echo "No Slices on site, or all are expired.\n";
- } else {
- echo "
\n";
- echo "Slice list\n";
- echo "Slice Name | ";
- echo "Users | ";
- echo "Expiration |
";
- echo "\n";
-
- // create a list of person_ids
- $person_ids = array();
- foreach( $slice_info as $slice ) {
- if ( !empty($slice['person_ids']) )
- $person_ids = array_merge($person_ids, $slice['person_ids']);
- }
-
- // create an associative array of persons with person_id as the key
- $person_list = $api->GetPersons( $person_ids, array("person_id", "email") );
- $persons = array();
- foreach( $person_list as $person)
- {
- $persons[$person['person_id']] = $person;
- }
-
- foreach( $slice_info as $slice ) {
- $slice_id= $slice['slice_id'];
- $slice_name= $slice['name'];
- $slice_state= $slice['state'];
- $slice_expires= date( "M j, Y", $slice['expires'] );
- $peer_id = $slice['peer_id'];
-
- $extraclass="";
- if ( $peer_id )
- $extraclass="plc-foreign";
-
- echo "\n";
-
- }
-
- echo "
\n";
-
- }
- }
-
-
- echo "\n";
-
- echo "\n";
-
-}
-// if nothing else then show slice info
-else {
- $slice_id= intval( $_GET['id'] );
-
- // GetSlices API call
- $slice_info= $api->GetSlices( array( $slice_id ) );
-
- if( empty( $slice_info ) ) {
- header( "location: index.php" );
- exit();
- }
-
- // pull all slice info to vars
- $instantiation= $slice_info[0]['instantiation'];
- $name= $slice_info[0]['name'];
- $url= $slice_info[0]['url'];
- $expires= date( "M j, Y", $slice_info[0]['expires'] );
- $site_id= $slice_info[0]['site_id'];
- $description= $slice_info[0]['description'];
- $max_nodes= $slice_info[0]['max_nodes'];
- $node_ids=$slice_info[0]['node_ids'];
- $person_ids=$slice_info[0]['node_ids'];
-
- // get peer id
- $peer_id= $slice_info[0]['peer_id'];
-
- $person_ids= $slice_info[0]['person_ids'];
- $node_ids= $slice_info[0]['node_ids'];
- $slice_tag_ids= $slice_info[0]['slice_tag_ids'];
-
-
- // node info
-// looks unused
-// if( !empty( $node_ids ) )
-// $nodes= $api->GetNodes( $node_ids, array( "node_id", "hostname" ) );
-
- // site info
- $site_info= $api->GetSites( array( $site_id ), array( "site_id", "name", "person_ids" ) );
-
- // gets all persons from site_id
- // person info
- if( !empty( $person_ids ) )
- $persons= $api->GetPersons( $site_info[0]['person_ids'] , array( "person_id", "role_ids", "first_name", "last_name", "email" ) );
-
- if( $persons ) {
- // gets site contacts pis stores in dict
- foreach( $persons as $person )
- if( in_array( "20", $person['role_ids'] ) ) {
- $pis[]= array( "email" => $person['email'], "first_name" => $person['first_name'], "last_name" => $person['last_name'], "person_id" => $person['person_id'] );
-
- }
- if ($pis) {
- sort_persons( $pis );
- }
- }
-
- // slice attribute info
- if( !empty( $slice_tag_ids ) )
- $slice_attibs= $api->GetSliceTags( $slice_tag_ids,
- array( "slice_tag_id", "attribute_type_id", "value", "description", "min_role_id", "node_id" ) );
-
- // gets attrib type info and combines it to form all attrib info array
- if( $slice_attibs ) {
- foreach( $slice_attibs as $slice_attib ) {
- $attrib_type= $api->GetSliceTagTypes( array( $slice_attib['attribute_type_id'] ),
- array( "attribute_type_id", "name", "description" ) );
-
- $attributes[]= array( "slice_tag_id" => $slice_attib['slice_tag_id'],
- "attribute_type_id" => $slice_attib['attribute_type_id'],
- "name" => $attrib_type[0]['name'],
- "value" => $slice_attib['value'],
- "description" => $slice_attib['description'],
- "min_role_id" => $slice_attib['min_role_id'],
- "node_id" => $slice_attib['node_id'] );
- }
-
- }
-
- drupal_set_title("Slice details for " . $name);
- // start form
-
- if( $peer_id ) {
- echo "\n";
- }
-
- // basic slice menu
- if( ! $peer_id ) {
-
- $actions= array( ''=>'Choose Action' );
-
- if( in_array( 10, $_roles )
- || ( in_array( 20, $_roles ) && in_array( $site_id, $_person['site_ids'] ) )
- || in_array( $slice_id, $_person['slice_ids'] ) ) {
- $actions['renew']= "Renew $name";
- $actions['nodes']= "Manage Nodes";
- }
- if ( in_array( 10, $_roles )
- || ( in_array( 20, $_roles ) && in_array( $site_id, $_person['site_ids'] ) ) ) {
- $actions['users']= "Manage Users";
- $actions['delete']= "Delete $name";
- }
-
- echo "
\n";
- if (in_array( 10, $_roles )) {
- echo plc_event_button("slices","slice",$slice_id);
- echo " | ";
- }
- echo plc_comon_button("slice_id",$slice_id);
- echo " | \n";
-
- echo "\n";
-
- echo " |
\n";
- }
-
- echo "
\n
- Slice Name: | $name |
\n
- Description: | $description |
\n
- URL: | $url |
\n";
-
- if( gmmktime() > $slice_info[0]['expires'] ) {
- $class1= ' style="color:red;"';
- $msg1= '(slice is expired)';
- }
- echo "Expiration: | $expires $msg1 |
\n";
- echo "Instantiation: | ";
-
- echo " |
\n";
- echo "Site: | ". $site_info[0]['name'] ." |
\n";
- $href="'/db/nodes/index.php?slice_id=" . $slice_id . "'";
- printf (" # Nodes | Total %d nodes | \n",$href,$href,count($node_ids));
- $href="'/db/persons/index.php?slice_id=" . $slice_id . "'";
- printf ("
---|
# Users | Total %d users | \n",$href,$href,count($person_ids));
- echo "
---|
\n";
-
- if ( (!$class1) && in_array( $slice_id, $_person['slice_ids'] ) && (! $peer_id) )
- echo "
Update Information\n";
-
- echo "
\n";
-
-
- // slice attributes
- if( $attributes ) {
-
- // builds 2 arrays, one for attribs,one for slivers
- foreach( $attributes as $attribute ) {
- if( empty( $attribute['node_id'] ) ) {
- $slice_attrib[]= $attribute;
- }
- else {
- $sliver_attrib[]= $attribute;
- $sliver_nodes[]= $attribute['node_id'];
- }
- }
- }
-
- // Get node info for those slivers
- $sliver_node_info= $api->GetNodes( $sliver_nodes, array( "node_id", "hostname" ) );
-
- if( $sliver_node_info ) {
- foreach( $sliver_node_info as $sliv_node ) {
- $new_sliver_node_info[$sliv_node['node_id']]= $sliv_node;
- }
- }
-
- if( $peer_id ) {
- echo "
\n";
- }
-
- // slice attributes
- $is_admin=in_array( 10, $_roles );
- $is_in_slice=in_array( $slice_id, $_person['slice_ids'] );
- $is_pi=in_array( 20, $_roles );
- if( $slice_attrib ) {
- echo "Slice Attributes";
- echo "";
- if( $is_admin )
- echo " | ";
- echo "Attribute | Value | Description | ";
- echo "
\n";
-
- foreach( $attributes as $attribute ) {
- // ignore sliver attributes at this stage
- if( empty( $attribute['node_id'] ) ) {
- echo("");
- if( $is_admin ) {
- printf("");
- sprintf($label,"\\n [ %s = %s] \\n from %s",$attribute['name'],$attribute['value'],$name);
- echo plc_delete_link_button ('attrib_action.php?rem_id=' . $attribute['slice_tag_id'],
- $label);
- echo " | ";
- }
- if( $is_admin || ($is_pi && $is_in_slice) ) {
- printf ("%s | ",
- $attribute['slice_tag_id'],$attribute['name']);
- } else {
- printf("%s | ",$attribute['name']);
- }
- printf("%s | %s | ",
- $attribute['value'],$attribute['description']);
- echo "
";
- }
- }
-
-
- echo "
\n";
-
- }
- if( $is_admin || ($is_pi && $is_in_slice) )
- echo "Add a Slice Attribute\n";
-
-
-
- // sliver attributes
- if( $sliver_attrib ) {
- echo "Sliver Attributes";
- echo "";
- if( $is_admin )
- echo " | ";
- echo "Attribute | Value | Description | Node | ";
- echo "
\n";
-
- foreach( $attributes as $attribute ) {
- $nodename=$new_sliver_node_info[$attribute['node_id']]['hostname'];
- // consider only sliver attributes at this stage
- if( !empty( $attribute['node_id'] ) ) {
- echo("");
- if( $is_admin ) {
- echo("");
- $label=sprintf("\\n [ %s = %s ] \\n from %s \\n on node %s",
- $attribute['name'],$attribute['value'],$name,$nodename);
- echo plc_delete_link_label('/db/nodes/sliver_action.php?rem_id=' . $attribute['slice_tag_id'],
- $label);
- echo " | ";
- }
- if( $is_admin ) {
- printf("%s | ",$attribute['slice_tag_id'],$attribute['name']);
- } else {
- printf("%s | ",$attribute['name']);
- }
- printf("%s | %s | %s | ",
- $attribute['value'],$attribute['description'],$attribute['node_id'],$nodename);
-
- echo "
";
- }
- }
-
- echo "
\n";
-
- }
-
- echo "
\n";
-
- if( $pis && !$peer_id ) {
- // site contacts
- echo "Contacts
\n";
-
- $pi_rows= count( $pis );
- $tech_rows= count( $techs );
- $table_row= 0;
-
- echo "";
- if( $pis ) {
- echo "PI's: | \n";
-
- foreach( $pis as $pi ) {
- if( $table_row != 0 )
- echo "
";
- printf("%s %s | %s |
\n",
- $pi['person_id'],$pi['first_name'],$pi['last_name'],$pi['email'],$pi['email']);
- $table_row++;
- }
-
- }
-
- echo "
\n
\n";
-
- }
-
-
- echo "Back to slice list\n";
- }
-
-// Print footer
-include 'plc_footer.php';
+if ($_GET['id']) require ('slice.php') ;
+else require ('slices.php');
?>