Exemple #1
0
 public static function createSampleDowntime($severity = 'OUTAGE', $classification = 'SCHEDULED')
 {
     $downtime = new Downtime();
     $downtime->setDescription("A sample skeleton downtime");
     $downtime->setSeverity($severity);
     $downtime->setClassification($classification);
     return $downtime;
 }
 public function load()
 {
     parent::load();
     $downtime_model = new Downtime();
     $this->downtimes = $downtime_model->getindex(array("start_time" => time(), "end_time" => time()));
     $this->view->statuses = array("Operational" => array($this->getStatus(246, "https://twiki.grid.iu.edu/bin/view/Operations/MyOSGServiceLevelAgreement"), $this->getStatus(266, "https://twiki.grid.iu.edu/bin/view/Operations/OIMServiceLevelAgreement"), $this->getStatus(325, "https://twiki.grid.iu.edu/bin/view/Operations/SoftwareRepoServiceLevelAgreement"), $this->getStatus(250, "https://twiki.grid.iu.edu/bin/view/Operations/RSVServiceLevelAgreement")), "Accounting" => array($this->getStatus(255, "https://twiki.grid.iu.edu/bin/view/Operations/ServiceLevelAgreements")), "Submission" => array($this->getStatus(336, "https://twiki.grid.iu.edu/bin/view/Operations/ServiceLevelAgreements"), $this->getStatus(308, "https://twiki.grid.iu.edu/bin/view/Operations/GlideInWMSServiceLevelAgreement")), "File Distribution" => array($this->getStatus(364, "https://twiki.grid.iu.edu/bin/view/Operations/ServiceLevelAgreements"), $this->getStatus(366, "https://twiki.grid.iu.edu/bin/view/Operations/ServiceLevelAgreements")), "User Interface" => array($this->getStatus(261, "https://twiki.grid.iu.edu/bin/view/Operations/OSGDisplayServiceLevelAgreement"), $this->getStatus(265, "https://twiki.grid.iu.edu/bin/view/Operations/GOCTicketServiceLevelAgreement"), $this->getStatus(401, "https://twiki.grid.iu.edu/bin/view/Operations/GOCTicketServiceLevelAgreement")), "Documentation" => array($this->getStatus(281, "https://twiki.grid.iu.edu/bin/view/Operations/OSGDocRepoServiceLevelAgreement"), $this->getStatus(280, "https://twiki.grid.iu.edu/bin/view/Operations/OSGWebPageServiceLevelAgreement"), $this->getStatus(334, "https://twiki.grid.iu.edu/bin/view/Operations/JIRAServiceLevelAgreement"), $this->getStatus(197, "https://twiki.grid.iu.edu/bin/view/Operations/TWikiServiceLevelAgreement")), "Best Effort" => array($this->getStatus(247, "https://twiki.grid.iu.edu/bin/view/Operations/BDIIServiceLevelAgreement"), $this->getStatus(270, "https://twiki.grid.iu.edu/bin/view/Operations/SoftwareCacheServiceLevelAgreement")));
     $this->setpagetitle(self::default_title());
 }
 public function load()
 {
     //pull sites
     $site_model = new Site();
     $sites = $site_model->get();
     $this->view->sites = $sites;
     //pull site groups
     $rgroup_model = new ResourceGroup();
     $rgroups = $rgroup_model->get();
     $this->view->rgs = array();
     $site_ids = $this->process_sitelist();
     foreach ($site_ids as $site_id) {
         $rgs = array();
         foreach ($rgroups as $rgroup) {
             //filter by gridtype
             if (isset($_REQUEST["gridtype"])) {
                 $gridtype = $rgroup->osg_grid_type_id;
                 if (!isset($_REQUEST["gridtype_" . $gridtype])) {
                     continue;
                 }
             }
             //only pass non-disable resource group
             if ($rgroup->disable == 1) {
                 continue;
             }
             if ($rgroup->site_id == $site_id) {
                 $rgs[] = $rgroup;
             }
         }
         $this->view->rgs[$site_id] = $rgs;
     }
     //pull sites (grouped by site group id)
     $rgrouped_model = new ResourceByGroupID();
     $this->view->resources_bygid = $rgrouped_model->getindex();
     //get resource status
     $model = new LatestResourceStatus();
     $this->view->resource_status = $model->getgroupby("resource_id");
     $downtime_model = new Downtime();
     $this->view->downtime = $downtime_model->getindex(array("start_time" => time(), "end_time" => time()));
     //get campus grid icons
     if (isset($_REQUEST["map_attrs_showcampusgrid"])) {
         $model = new CampusGrid();
         $this->view->campusgrids = $model->get();
     }
     $this->setpagetitle(self::default_title());
 }
 public function load()
 {
     parent::load();
     $model = new Downtime();
     $downtimes = $model->get();
     $past = array();
     $current = array();
     $future = array();
     foreach ($downtimes as $downtime) {
         $id = $downtime->id;
         if ($downtime->unix_end_time < time()) {
             if (isset($_REQUEST["downtime_attrs_showpast"])) {
                 switch ($_REQUEST["downtime_attrs_showpast"]) {
                     case "":
                         break;
                         //none..
                     //none..
                     default:
                         $days = (int) $_REQUEST["downtime_attrs_showpast"];
                         if ($downtime->unix_end_time < time() - 3600 * 24 * $days) {
                             break;
                             //too old
                         }
                     case "all":
                         $past[$id] = $downtime;
                 }
             }
         } else {
             if ($downtime->unix_start_time > time()) {
                 $future[$id] = $downtime;
             } else {
                 $current[$id] = $downtime;
             }
         }
     }
     $this->view->past_downtimes = $this->formatInfo($past);
     $this->view->current_downtimes = $this->formatInfo($current);
     $this->view->future_downtimes = $this->formatInfo($future);
     $this->setpagetitle(self::default_title());
 }
Exemple #5
0
function newDowntime($downtimeXml)
{
    $downtime = new Downtime();
    foreach ($downtimeXml->attributes() as $key => $value) {
        switch ($key) {
            case "ID":
                $promId = (int) $value;
                break;
            case "PRIMARY_KEY":
                $primaryKey = (string) $value;
                break;
            case "CLASSIFICATION":
                $classification = (string) $value;
                break;
        }
    }
    // Get the largest v4 downtime PK which is an integer appended by the string 'G0'
    // slice off the 'G0' and get the integer value.
    $v4pk = (int) substr($primaryKey, 0, strlen($primaryKey) - 2);
    if ($v4pk > $GLOBALS['largestV4DowntimePK']) {
        $GLOBALS['largestV4DowntimePK'] = $v4pk;
    }
    $downtime->setClassification($classification);
    $downtime->setDescription((string) $downtimeXml->DESCRIPTION);
    $downtime->setSeverity((string) $downtimeXml->SEVERITY);
    $startDate = new DateTime("@" . (string) $downtimeXml->START_DATE);
    $downtime->setStartDate($startDate);
    $endDate = new DateTime("@" . (string) $downtimeXml->END_DATE);
    $downtime->setEndDate($endDate);
    $insertDate = new DateTime("@" . (string) $downtimeXml->INSERT_DATE);
    $downtime->setInsertDate($insertDate);
    $downtime->setPrimaryKey($primaryKey);
    return $downtime;
}
 /**
  * Show how Bidirectional relationships must be correctly managed in 
  * userland/application code. (See Doctrine the tutorial: 
  * "Consistency of bi-directional references on the inverse side of a 
  * relation have to be managed in userland application code. Doctrine 
  * cannot magically update your collections to be consistent."). 
  */
 public function testDowntimeEndpoint_BidirectionalJoinConsistencyManagement()
 {
     print __METHOD__ . "\n";
     // create a linked entity graph as beow:
     //
     //     se        (1 service)
     //    / | \
     // el1 el2 el3   (3 endpoints)
     //    \ | /
     //     dt1       (1 downtime)
     $se = TestUtil::createSampleService('service1');
     $el1 = TestUtil::createSampleEndpointLocation();
     $el2 = TestUtil::createSampleEndpointLocation();
     $el3 = TestUtil::createSampleEndpointLocation();
     $se->addEndpointLocationDoJoin($el1);
     $se->addEndpointLocationDoJoin($el2);
     $se->addEndpointLocationDoJoin($el3);
     $dt1 = new Downtime();
     $dt1->setDescription('downtime description');
     $dt1->setSeverity("WARNING");
     $dt1->setClassification("UNSCHEDULED");
     $dt1->addEndpointLocation($el1);
     $dt1->addEndpointLocation($el2);
     $dt1->addEndpointLocation($el3);
     // persist and flush
     $this->em->persist($se);
     $this->em->persist($el1);
     $this->em->persist($el2);
     $this->em->persist($el3);
     $this->em->persist($dt1);
     $this->em->flush();
     // Now delete the relationship between dt1 and el1 + el2 using OWNING
     // SIDE ONLY; since downtime is the OWNING side we must remove el1 + el2
     // from downtime to actually delete the relationships in the DB
     // (on the subsequent flush). Since we have only removed the relationship
     // on the downtime side, our in-mem entity model is now inconsistent !
     $dt1->getEndpointLocations()->removeElement($el1);
     //$el1->getDowntimes()->removeElement($dt1);
     $dt1->getEndpointLocations()->removeElement($el2);
     //$el2->getDowntimes()->removeElement($dt1);
     $this->em->flush();
     // Entity model in DB now looks like this:
     //     se
     //    / | \
     // el1 el2 el3
     //        /
     //     dt1      (note FKs/relationships have been removed)
     // Assert that there are still three EndpointLocations and one Downtimes in the database
     $testConn = $this->getConnection();
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM EndpointLocations");
     $this->assertTrue($result->getRowCount() == 3);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes");
     $this->assertTrue($result->getRowCount() == 1);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes_EndpointLocations");
     $this->assertTrue($result->getRowCount() == 1);
     // Assert that our in-mem entity model is now inconsistent with DB
     // when VIEWED FROM THE ENDPOINT SIDE.
     $this->assertEquals(1, count($el1->getDowntimes()));
     $this->assertEquals(1, count($el2->getDowntimes()));
     $this->assertEquals(1, count($el3->getDowntimes()));
     // Assert that our in-mem entity model is consistent with DB
     // when VIEWED FROM THE DOWNTIME SIDE:
     // dt1 still has el3 linked (as expected) but not el1 or el2.
     // Note we use first() method to fetch first array collection entry!
     // (calling get(0) would not work as expected because the collection
     // is a map so array key values are preserved - el3 was added 3rd so it
     // preserves its zero-offset key value of 2).
     $this->assertEquals(1, count($dt1->getEndpointLocations()));
     $this->assertSame($el3, $dt1->getEndpointLocations()->first());
     $this->assertSame($el3, $dt1->getEndpointLocations()->get(2));
     // Next lines keep our in-mem inverse side consistent with DB. If we
     // didn't do this, then our first assertion on the following lines below
     // would fail! This shows that you have to keep your bi-directional
     // relationships consistent in userland/application code, doctrine
     // won't do this for you!
     $el1->getDowntimes()->removeElement($dt1);
     $el2->getDowntimes()->removeElement($dt1);
     // After updating the 'in-memory' entity model, check that el1 and el2
     // have no linked downtimes while el3 still has dt linked.
     // This mirrors what we have in the DB.
     $this->assertEquals(0, count($el1->getDowntimes()));
     $this->assertEquals(0, count($el2->getDowntimes()));
     $this->assertEquals(1, count($el3->getDowntimes()));
     // our collection key value is still same
     $this->assertSame($el3, $dt1->getEndpointLocations()->get(2));
 }
 private function process_resource_filter_status()
 {
     $resources_to_keep = array();
     $model = new LatestResourceStatus();
     $resource_status = $model->getgroupby("resource_id");
     //load downtime
     $downtime_model = new Downtime();
     $params = array("start_time" => time(), "end_time" => time());
     $downtimes = $downtime_model->getindex($params);
     $model = new Resource();
     $resources = $model->getindex();
     foreach ($resources as $rid => $r) {
         if (!isset($resource_status[$rid])) {
             //if status not found, then treat it as UNKNOWN
             $status_id = 4;
             //unknown
         } else {
             $rs = $resource_status[$rid];
             $status_id = $rs[0]->status_id;
         }
         //consider status to be down
         $downtime = @$downtimes[(int) $rid];
         if ($downtime !== null) {
             $status_id = 99;
         }
         if ($this->ison("status", $status_id)) {
             //if(isset($_REQUEST["status_".$status_id])) {
             if (!in_array($rid, $resources_to_keep)) {
                 $resources_to_keep[] = $rid;
             }
         }
     }
     return $resources_to_keep;
 }
         //send emails to contacts
         foreach ($organizationContacts as $contactData) {
             if (in_array($contactData->contactID, $contactIDs)) {
                 mail($email, "New Issue: {$newIssue->subjectText}", $emailMessage);
             }
         }
     }
     if (count($issueEmails) > 0) {
         //send emails to CCs
         foreach ($issueEmails as $email) {
             mail($email, "New Issue: {$newIssue->subjectText}", $emailMessage);
         }
     }
     break;
 case 'insertDowntime':
     $newDowntime = new Downtime();
     $newDowntime->entityID = $_POST['sourceOrganizationID'];
     $newDowntime->creatorID = $user->loginID;
     $newDowntime->downtimeTypeID = $_POST['downtimeType'];
     $newDowntime->issueID = $_POST['issueID'];
     $newDowntime->startDate = date('Y-m-d H:i:s', strtotime($_POST['startDate']));
     $newDowntime->endDate = date('Y-m-d H:i:s', strtotime($_POST['endDate']));
     $newDowntime->dateCreated = date('Y-m-d H:i:s');
     $newDowntime->entityTypeID = 1;
     $newDowntime->note = $_POST['note'] ? $_POST['note'] : null;
     $newDowntime->save();
     break;
 case 'submitIssueLog':
     //if this is an existing issue
     $issueLogID = $_POST['issueLogID'];
     if ($issueLogID) {
 /**
  * Test the <code>$serviceDAO->removeEndpoint($endpoint)</code> method.   
  */
 public function testServiceDAORemoveEndpoint()
 {
     print __METHOD__ . "\n";
     // create a linked entity graph as beow:
     //
     //      se -----|    (1 service)
     //     / | \    |
     //  el1 el2 el3 |    (3 endpoints)
     //  |  \ | /    |
     // dt0  dt1 ----|    (1 downtime)
     $dt1 = new Downtime();
     $dt1->setDescription('downtime description');
     $dt1->setSeverity("WARNING");
     $dt1->setClassification("UNSCHEDULED");
     $dt0 = new Downtime();
     $dt0->setDescription('downtime description');
     $dt0->setSeverity("WARNING");
     $dt0->setClassification("UNSCHEDULED");
     $se = TestUtil::createSampleService('service1');
     $el1 = TestUtil::createSampleEndpointLocation();
     $el2 = TestUtil::createSampleEndpointLocation();
     $el3 = TestUtil::createSampleEndpointLocation();
     $se->addEndpointLocationDoJoin($el1);
     $se->addEndpointLocationDoJoin($el2);
     $se->addEndpointLocationDoJoin($el3);
     //$se->_addDowntime($dt1); // we don't call this in client code !
     $dt1->addEndpointLocation($el1);
     $dt1->addEndpointLocation($el2);
     $dt1->addEndpointLocation($el3);
     $dt1->addService($se);
     $dt0->addEndpointLocation($el1);
     //$dt0->addService($se); // note we don't add this relationship for purposes of the test
     // persist and flush
     $this->em->persist($se);
     $this->em->persist($el1);
     $this->em->persist($el2);
     $this->em->persist($el3);
     $this->em->persist($dt1);
     $this->em->persist($dt0);
     $this->em->flush();
     // create DAO to test
     $serviceDao = new ServiceDAO();
     $serviceDao->setEntityManager($this->em);
     // remove first endpoint causing dt0 to be orphaned
     $serviceDao->removeEndpoint($el1);
     $this->em->flush();
     // Assert expected object graph
     //     se -----|   (1 service)
     //      | \    |
     //     el2 el3 |   (2 endpoints)
     //      | /    |
     // dt0 dt1-----|   (2 downtime)
     //
     $testConn = $this->getConnection();
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM EndpointLocations");
     $this->assertTrue($result->getRowCount() == 2);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes");
     $this->assertTrue($result->getRowCount() == 2);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes_EndpointLocations");
     $this->assertTrue($result->getRowCount() == 2);
     // Assert expected object graph in ORM Mem
     $this->assertEquals(1, count($el2->getDowntimes()));
     $this->assertEquals(1, count($el3->getDowntimes()));
     $this->assertEquals(2, count($se->getEndpointLocations()));
     $this->assertEquals(1, count($se->getDowntimes()));
     $this->assertEquals(2, count($dt1->getEndpointLocations()));
     $this->assertEquals(1, count($dt1->getServices()));
     // remove another el
     $serviceDao->removeEndpoint($el2);
     $this->em->flush();
     // Assert expected object graph in DB
     //     se -----| (1 service)
     //       \     |
     //        el3  | (1 endpoints)
     //        /    |
     // dt0 dt1-----| (2 downtime)
     //
     $testConn = $this->getConnection();
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM EndpointLocations");
     $this->assertTrue($result->getRowCount() == 1);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes");
     $this->assertTrue($result->getRowCount() == 2);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes_EndpointLocations");
     $this->assertTrue($result->getRowCount() == 1);
     // Assert expected object graph in ORM Mem
     $this->assertEquals(1, count($el3->getDowntimes()));
     $this->assertEquals(1, count($se->getEndpointLocations()));
     $this->assertEquals(1, count($se->getDowntimes()));
     $this->assertEquals(1, count($dt1->getEndpointLocations()));
     $this->assertEquals(1, count($dt1->getServices()));
     // remove another el
     $serviceDao->removeEndpoint($el3);
     $this->em->flush();
     // Assert expected object graph in DB
     //     se -----| (1 service)
     //             |
     //             | (1 endpoints)
     //             |
     // dt0 dt1-----| (2 downtime)
     //
     $testConn = $this->getConnection();
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM EndpointLocations");
     $this->assertTrue($result->getRowCount() == 0);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes");
     $this->assertTrue($result->getRowCount() == 2);
     $result = $testConn->createQueryTable('results_table', "SELECT * FROM Downtimes_EndpointLocations");
     $this->assertTrue($result->getRowCount() == 0);
     // Assert expected object graph in ORM Mem
     $this->assertEquals(0, count($se->getEndpointLocations()));
     $this->assertEquals(1, count($se->getDowntimes()));
     $this->assertEquals(0, count($dt1->getEndpointLocations()));
     $this->assertEquals(1, count($dt1->getServices()));
 }
Exemple #10
0
 /**
  * Deletes a downtime
  * @param \Downtime $dt
  * @param \User $user
  */
 public function deleteDowntime(\Downtime $dt, \User $user = null)
 {
     //Check the portal is not in read only mode, throws exception if it is
     $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
     $ses = $dt->getServices();
     $this->authorization($ses, $user);
     if ($dt->hasStarted()) {
         throw new \Exception("This downtime has already started.");
     }
     $this->em->getConnection()->beginTransaction();
     try {
         //For MEPS we need to delete from both service and enpoints
         foreach ($dt->getServices() as $se) {
             // Downtime is the owning side so remove elements from downtime.
             $dt->removeService($se);
             // unlinks on both sides
             //$dt->getServices()->removeElement($se); //unlinking
             //$se->getDowntimes()->removeElement($dt);
         }
         foreach ($dt->getEndpointLocations() as $ep) {
             // Downtime is the owning side so remove elements from downtime.
             $dt->getEndpointLocations()->removeElement($ep);
             //unlinking
             // Since Doctrine always only looks at the owning side of a
             // bidirectional association for updates, it is not necessary for
             // write operations that an inverse collection of a bidirectional
             // one-to-many or many-to-many association is updated. This
             // knowledge can often be used to improve performance by avoiding
             // the loading of the inverse collection.
             //$ep->getDowntimes()->removeElement($dt);
         }
         $this->em->remove($dt);
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
 }
    $issues = $resource->getIssues();
    $organizationArray = $resource->getOrganizationArray();
    $organizationData = $organizationArray[0];
    if ($organizationData['organizationID']) {
        $organizationID = $organizationData['organizationID'];
        $organization = new Organization(new NamedArguments(array('primaryKey' => $organizationID)));
        $orgIssues = $organization->getIssues();
        foreach ($orgIssues as $issue) {
            array_push($issues, $issue);
        }
        $organizationResourcesArray = $resource->getSiblingResourcesArray($organizationID);
    }
}
//our $organizationID could have come from the $_GET or through the resource
if ($organizationID) {
    $downtimeObj = new Downtime();
    $downtimeTypeNames = $downtimeObj->getDowntimeTypesArray();
    $defaultStart = date("Y-m-d\\TH:i");
    $defaultEnd = date("Y-m-d\\TH:i", strtotime("+1 day"));
    ?>

<form id='newDowntimeForm'>
<?php 
    if ($isOrgDowntime) {
        echo '<input type="hidden" name="sourceOrganizationID" value="' . $organizationID . '" />';
    } else {
        echo '<input type="hidden" name="sourceResourceID" value="' . $resourceID . '" />';
    }
    ?>
	<table class="thickboxTable" style="width:98%;background-image:url('images/title.gif');background-repeat:no-repeat;">
		<tr>
 public function detailAction()
 {
     if (isset($_REQUEST["resource_id"]) && isset($_REQUEST["service_id"]) && isset($_REQUEST["time"])) {
         $resource_id = (int) $_REQUEST["resource_id"];
         $service_id = (int) $_REQUEST["service_id"];
         $time = (int) $_REQUEST["time"];
         $this->view->detail_service_id = $service_id;
         $this->view->detail_time = $time;
         //get service information
         $model = new ResourceServices();
         $params = array("resource_id" => $resource_id, "service_id" => $service_id);
         $this->view->detail_service = $model->get($params);
         //get statuses at specified timestamp
         $metricdata_model = new MetricData();
         $params = array("resource_id" => $resource_id, "time" => $time);
         $latest_metrics = $metricdata_model->get($params);
         //pull metric info
         $model = new Metric();
         $this->view->metric_details = $model->getindex();
         //pull all metric for this service
         $model = new MetricService();
         $this->view->detail_critical_metrics = array();
         $this->view->detail_noncritical_metrics = array();
         foreach ($model->get(array("service_id" => $service_id)) as $metric) {
             $info = array();
             $info["metric_id"] = $metric->metric_id;
             //find the reported detail (if not, leave it empty)
             foreach ($latest_metrics as $latest_metric) {
                 if ($latest_metric->metric_id == $metric->metric_id) {
                     $info["detail_id"] = $latest_metric->id;
                     $info["detail"] = $this->fetchMetricDetail($latest_metric->id);
                     $info["status"] = Status::getStatus($latest_metric->metric_status_id);
                     $info["timestamp"] = $latest_metric->timestamp;
                     break;
                 }
             }
             if ($metric->critical == 1) {
                 $this->view->detail_critical_metrics[] = $info;
             } else {
                 $this->view->detail_noncritical_metrics[] = $info;
             }
         }
         //load service status
         $service_status_model = new ServiceStatusChange();
         $params = array();
         $params["resource_id"] = $resource_id;
         $params["service_id"] = $service_id;
         $params["start_time"] = $time;
         $params["end_time"] = $time;
         $service_statuses = $service_status_model->get($params);
         $this->view->detail_service_status = null;
         if (isset($service_statuses[0])) {
             $this->view->detail_service_status = $service_statuses[0];
         }
         //load downtime
         $downtime_model = new Downtime();
         $params = array("resource_id" => $resource_id, "start_time" => $time, "end_time" => $time);
         $downtimes = $downtime_model->get($params);
         $downtimes_forservice = $this->getDowntimesForService($downtimes, $service_id);
         if (count($downtimes_forservice) > 0) {
             $this->view->downtime = $downtimes_forservice[0];
             //grab first one for this service
         }
     }
 }
 public function loadStatusChanges()
 {
     /////////////////////////////////////////////////////////////////////////////////
     //get paramters
     if (!isset($_REQUEST["resource_id"])) {
         echo "resource_id missing";
         exit;
     }
     $dirty_resource_id = $_REQUEST["resource_id"];
     if (Zend_Validate::is($dirty_resource_id, 'Int')) {
         $resource_id = $dirty_resource_id;
     }
     list($start_time, $end_time) = getLastNDayRange(7);
     //this default shouldn't be used..
     if (isset($_REQUEST["start"]) && isset($_REQUEST["end"])) {
         $dirty_start_time = $_REQUEST["start"];
         if (Zend_Validate::is($dirty_start_time, 'Int')) {
             $start_time = $dirty_start_time;
         }
         $dirty_end_time = $_REQUEST["end"];
         if (Zend_Validate::is($dirty_end_time, 'Int')) {
             $end_time = $dirty_end_time;
         }
     }
     $service_id = null;
     if (isset($_REQUEST["service_id"])) {
         $service_id = (int) $_REQUEST["service_id"];
     }
     /////////////////////////////////////////////////////////////////////////////////
     //pull status changes
     if ($service_id === null) {
         //resource status
         $resource_statuschange_model = new ResourceStatusChange();
         $params = array();
         $params["resource_id"] = $resource_id;
         $params["start_time"] = $start_time;
         $params["end_time"] = $end_time;
         $status_changes = $resource_statuschange_model->get($params);
     } else {
         $service_statuschange_model = new ServiceStatusChange();
         $params = array();
         $params["service_id"] = $service_id;
         $params["resource_id"] = $resource_id;
         $params["start_time"] = $start_time;
         $params["end_time"] = $end_time;
         $status_changes = $service_statuschange_model->get($params);
     }
     /////////////////////////////////////////////////////////////////////////////////
     //pull downtime info
     $downtime_model = new Downtime();
     $params = array("resource_id" => $resource_id, "start_time" => $start_time, "end_time" => $end_time);
     $downtimes = $downtime_model->get($params);
     $downtimes_forservice = $this->getDowntimesForService($downtimes, $service_id);
     return array($status_changes, $start_time, $end_time, $downtimes_forservice);
 }
 public function load()
 {
     parent::load();
     $this->view->rgs = $this->rgs;
     //pull commonly needed information
     $gridtype_model = new GridTypes();
     $this->view->gridtypes = $gridtype_model->getindex();
     $model = new ResourceGroup();
     $this->view->resourcegroups = $model->getgroupby("id");
     ///////////////////////////////////////////////////////////////////////////////////////////
     //pull other optional stuff
     if (isset($_REQUEST["summary_attrs_showservice"])) {
         $servicetype_model = new Service();
         $this->view->servicetypes = $servicetype_model->getindex();
         $resourceservice_model = new ServiceByResourceID();
         $this->view->resource_services = $resourceservice_model->getindex();
         //load details (all of them for now..) and attach it to resource_services
         $detail_model = new ResourceServiceDetail();
         $resource_service_details = $detail_model->get();
         foreach ($this->view->resource_services as $rid => $services) {
             foreach ($services as $service) {
                 $service->details = array();
                 //search for details for this service
                 foreach ($resource_service_details as $detail) {
                     if ($detail->resource_id == $rid && $detail->service_id == $service->service_id) {
                         $service->details[$detail->key] = $detail->value;
                     }
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showrsvstatus"])) {
         $model = new LatestResourceStatus();
         $this->view->resource_status = $model->getgroupby("resource_id");
         $downtime_model = new Downtime();
         $this->view->downtime = $downtime_model->getindex(array("start_time" => time(), "end_time" => time()));
     }
     if (isset($_REQUEST["summary_attrs_showgipstatus"])) {
         $model = new LDIF();
         $this->view->gipstatus = $model->getValidationSummary();
     }
     if (isset($_REQUEST["summary_attrs_showvomembership"])) {
         $cache_filename = config()->vomatrix_xml_cache;
         $cache_xml = file_get_contents($cache_filename);
         $vocache = new SimpleXMLElement($cache_xml);
         $resourcegrouped = $vocache->ResourceGrouped[0];
         $this->view->vos_supported = array();
         $this->view->vos_errors = array();
         foreach ($resourcegrouped as $resource) {
             $attr = $resource->attributes();
             $resource_id = (int) $attr->id;
             $this->view->vos_supported[$resource_id] = $resource->Members[0];
             $this->view->vos_errors[$resource_id] = $resource->ErrorMessage[0];
         }
     }
     if (isset($_REQUEST["summary_attrs_showvoownership"])) {
         $model = new ResourceOwnership();
         $this->view->resource_ownerships = $model->getindex();
     }
     if (isset($_REQUEST["summary_attrs_showwlcg"])) {
         $model = new ResourceWLCG();
         $this->view->resource_wlcg = $model->getindex();
         //append bdii link
         foreach ($this->rgs as $rg_id => $rg) {
             foreach ($rg as $resource_id => $resource) {
                 //get resource group name
                 $rgroup = $this->view->resourcegroups[$rg_id][0];
                 $rgname = $rgroup->name;
                 if (isset($this->view->resource_wlcg[$resource_id][0])) {
                     $this->view->resource_wlcg[$resource_id][0]->ldap_url = "ldap://is.grid.iu.edu:2180/mds-vo-name={$rgname},o=grid";
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showenv"])) {
         $model = new ResourceEnv();
         $details = $model->getindex(array("metric_id" => 0));
         $this->view->envs = array();
         //convert to XML String to SimpleXMLElement object
         foreach ($this->rgs as $rg) {
             foreach ($rg as $resource_id => $resource) {
                 if (isset($details[$resource_id])) {
                     $rec = $details[$resource_id][0];
                     $env = null;
                     if ($rec !== null) {
                         try {
                             $env = new SimpleXMLElement($rec->xml);
                         } catch (exception $e) {
                             elog((string) $e);
                             elog($rec->xml);
                         }
                     }
                     $this->view->envs[$resource_id] = $env;
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showcontact"])) {
         $model = new ResourceContact();
         $contacts = $model->getindex();
         //group by contact_type_id
         $this->view->contacts = array();
         foreach ($this->rgs as $rg) {
             foreach ($rg as $resource_id => $resource) {
                 $types = array();
                 if (isset($contacts[$resource_id])) {
                     foreach ($contacts[$resource_id] as $contact) {
                         if (!isset($types[$contact->contact_type])) {
                             $types[$contact->contact_type] = array();
                         }
                         //group by contact name
                         $types[$contact->contact_type][] = $contact;
                     }
                     $this->view->contacts[$resource_id] = $types;
                 }
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showfqdn"])) {
         $amodel = new ResourceAlias();
         $this->view->aliases = $amodel->getindex();
     }
     if (isset($_REQUEST["summary_attrs_showhierarchy"])) {
         $this->view->hierarchy = array();
         $model = new Facilities();
         $facilities = $model->getgroupby("id", array("filter_disabled" => false));
         $model = new Site();
         $sites = $model->getgroupby("id", array("filter_disabled" => false));
         $this->view->sites = $sites;
         $model = new SupportCenters();
         $scs = $model->getgroupby("id");
         foreach ($this->rgs as $rgid => $rg) {
             $rginfo = $this->view->resourcegroups[$rgid][0];
             $siteinfo = $sites[$rginfo->site_id][0];
             $facilityinfo = $facilities[$siteinfo->facility_id][0];
             $scinfo = $scs[$siteinfo->sc_id][0];
             $this->view->hierarchy[$rgid] = array("facility" => $facilityinfo, "site" => $siteinfo, "sc" => $scinfo);
         }
     }
     if (isset($_REQUEST["summary_attrs_showticket"])) {
         $ticketmodel = new OpenTickets();
         $this->view->tickets = $ticketmodel->getGroupByRID();
     }
     $this->setpagetitle(self::default_title());
 }