Skip to content

Commit

Permalink
Novice User Interface - Center Report Card (#63)
Browse files Browse the repository at this point in the history
* Added CenterReportCardPortlet and required infrastructure

Added a new Portlet, the Center Report Card Portlet, for the Novice User view.
This portlet displays App Kernel run information ( Failed, Under Performing, In
Control, and Over Performing ) for a given time period. If the user clicks on
one of the presented rows, they will be taken to the `App Kernels-> Performance
Map` tab. It's duration toolbar will be updated to match the start / end date
the portlet is using and the row that corresponds to the resource / app kernel
the user clicked on will be selected.

- To support this new feature, the `Performance Map` was moved from the Internal
Dashboard to be a new sub tab of `App Kernels`.
- A new function, `getPerformanceMapRaw`, was added to
`AppKernelControllerProvider`.
- `AppKernels.js` was modified so that it knows how to activate a sub tab, if one
is provided.
- A number of masking / unmasking calls were added so that the user is kept in
the loop as to when XDMoD is busy retrieving data.

* Updating build files

Just updating the build files so that they're included in the rpm.

* Updated to remove XSEDE dependency

The `Compliance` class is located in the `XSEDE` module but is utilized here in
the `AppKernels` module. I believe we want users to be able to utilize the
`AppKernels` module without having `XSEDE` installed, so this should help us
achieve that goal.

* Reformatted per eslint feedback

* Adding a CSS file to this modules assets

We were already including the `ColumnHeaderGroup.js` file here, now we also
include `ColumnHeaderGroup.css`.

* Added documentation to .travis file.

Just documenting the previously added line.

* Updates to allow additional filtering of app kernel data

Added the ability for the the AppKernel Performance Map to be filtered by a set
of authorized resources or the set of resources associated with a User's
organization.

* Removed userOrganization and cleaned up resource_ids

* Updates to the `getRawPerformanceMap` function

- Added some additional documentation / throws clause to reflect requiring the
  user calling this endpoint to have either the Center Director or Center Staff
  acl.
- Updated the function to require the authenticated user making the request to
  have the Center Director or Center Staff acl.
- Replaced the use of `MetricExplorer::getDimensionValues` with
  `XDUser::getResources` per research / discussion w/ @jpwhite4.

* Updating the authorization method for `getRawPerformanceMap`

We require that either Center Director's *or* Center Staff be allowed to utilize
this endpoint. The original `authorize($request, $requirements)` function call
instead ensures that the user have *all* of the acls supplied.

* Update authorization logic & resource parameter

- authorization logic update: derrrrr.... I r know logics.
- `resource` param for `PerformanceMap`: needed to massage the form it was
  provided to `PerformanceMap`.

* Fixing path to ColumnHeaderGroup.css

* Pinning dist so that php 5.4 will work

* eslint fix

* asfjlk

* Added documentation & formatted some sql

* Standardizing authorization logic

We have the same logic in `XDUser::getResources` just updating so that they're
the same.
  • Loading branch information
ryanrath authored Jul 15, 2019
1 parent c1cb1eb commit d1f7dfc
Show file tree
Hide file tree
Showing 18 changed files with 2,264 additions and 1,754 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ sudo: false

# Specify the build matrix
language: php
dist: trusty
php:
- '5.4'
- '7.0'
Expand All @@ -28,5 +29,8 @@ before_install: git clone --depth=1 --branch="v1" https://github.com/ubccr/xdmod
# Delegate the installation step to the shared Travis installation script
install: .qa/travis/install.sh

# Need to make sure that the style config files are in place before the build step.
before_script: .qa/style/install.sh ./

# Delegate the build step to the shared Travis build script
script: .qa/travis/build.sh
3 changes: 2 additions & 1 deletion build.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"configuration/rest.d": "rest.d",
"configuration/assets.d": "assets.d",
"configuration/modules.d/appkernels.json": "modules.d/appkernels.json",
"configuration/linker.d/appkernels.json": "linker.d/appkernels.json"
"configuration/linker.d/appkernels.json": "linker.d/appkernels.json",
"configuration/roles.d/appkernels-center_report_card.json": "roles.d/appkernels-center_report_card.json"
},
"etc/crond": {
"configuration/cron.conf": "xdmod-appkernels"
Expand Down
108 changes: 98 additions & 10 deletions classes/AppKernel/AppKernelDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public function __construct(\Log $logger = NULL, $configSection = NULL)
: $configSection);

$this->db = DB::factory($configSection);
$this->modwDB = DB::factory('database');
$this->logger = $logger !== NULL ? $logger : \Log::singleton('null');
} // __construct()

Expand Down Expand Up @@ -401,18 +402,12 @@ public function getResources($start_date = NULL, $end_date = NULL, array $pu_cou
$access_to_some_resource=true;

//get all associated organization
$organizations=array();
if(in_array("cd",$roles))
$organizations=array_merge($organizations,$user->getOrganizationCollection("cd"));
if(in_array("cs",$roles))
$organizations=array_merge($organizations,$user->getOrganizationCollection("cs"));

$organizations[]=$user->getPrimaryOrganization();
$organizations[]=$user->getActiveOrganization();
$organizations = array(
$user->getOrganizationID()
);

#get resource_id for all associated resources
$c=new \Compliance();
$rr=$c->getResourceListing(date_format(date_sub(date_create(), date_interval_create_from_date_string("90 days")),'Y-m-d'),date_format(date_create(),'Y-m-d'));
$rr=$this->getResourceListing(date_format(date_sub(date_create(), date_interval_create_from_date_string("90 days")),'Y-m-d'),date_format(date_create(),'Y-m-d'));

$organizations_resources_id=array();
foreach($rr as $r){
Expand All @@ -436,6 +431,99 @@ public function getResources($start_date = NULL, $end_date = NULL, array $pu_cou
return $resources;
} // getResources()

/**
* This function has been lifted from the XSEDE Modules Compliance class so that AppKernels can
* be used by Open Source Users. Retrieves a list of resources filtered by the optionally provided
* `$start_date` and `$end_date`
*
* @param string|null $start_date
* @param string|null $end_date
* @return mixed
*/
public function getResourceListing($start_date = null, $end_date = null) {

// Order by descending end_date and processors

$ts = "";

// Resources which have no end date are considered still active so use the max date
// possible. Resources are sorted in order of decreasing end date so this will keep active
// resources at the top of the list.

$m = "CASE WHEN rf.end_date IS NULL THEN '9999-12-31' ELSE rf.end_date END";

$query_params = array();

if (isset($start_date) && isset($end_date)) {

/*
Account for ALL resources (in other words, an overlap between the supplied timeframe and the resource timeframe)
S(t) E(t)
|----------------------------|
|------------------------|
S(r) E(r)
(t): Supplied timeframe
(r): A resource
Overlap exists when S(r) <= E(t) AND E(r) >= S(t)
*/

$ts .= " AND rf.start_date <= :ts_start_date_lte AND ($m) >= :ts_end_date_gte";

$query_params[':ts_start_date_lte'] = $end_date;
$query_params[':ts_end_date_gte'] = $start_date;

}

$query = "
SELECT
rf.code,
rf.organization_id,
rf.id,
rt.description,
rt.abbrev,
CASE
WHEN rf.end_date IS NULL THEN 'N/A'
ELSE DATE_FORMAT(rf.end_date, '%Y-%m-%d')
END AS official_end_date,
$m AS resource_end_date,
DATE_FORMAT(rf.start_date, '%Y-%m-%d') AS resource_start_date,
CASE
WHEN rs.processors IS NULL THEN 0
ELSE rs.processors
END AS processors
FROM
modw.resourcefact AS rf,
modw.resourcespecs rs,
modw.resourcetype AS rt
WHERE
rf.id = rs.resource_id
AND rf.resourcetype_id = rt.id
AND rt.abbrev IN ('HPC', 'HTC', 'DIC', 'Vis', 'Disk', 'Cloud')
AND rf.code NOT LIKE 'TG%'
$ts
AND UNIX_TIMESTAMP(:start_date_lte) >= rs.start_date_ts
AND (
rs.end_date_ts IS NULL
OR UNIX_TIMESTAMP(:end_date_gte) <= rs.end_date_ts
)
ORDER BY
rs.processors DESC,
resource_end_date DESC,
rf.code DESC"
;

$query_params[':start_date_lte'] = $end_date;
$query_params[':end_date_gte'] = $end_date;

return $this->modwDB->query($query, $query_params);
}//getResourceListing

// --------------------------------------------------------------------------------

public function getProcessingUnits($start_date = NULL, $end_date = NULL, array $resource_ids = array(), array $metrics = array())
Expand Down
Loading

0 comments on commit d1f7dfc

Please sign in to comment.