Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/xdmod9.0' into admindash
Browse files Browse the repository at this point in the history
  • Loading branch information
jpwhite4 committed Jul 21, 2020
2 parents 1dc9426 + 1428cb3 commit af61045
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 21 deletions.
5 changes: 5 additions & 0 deletions configuration/etl/etl.d/cloud_ingest_resource_specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
}
}
},
{
"name": "CloudResourceSpecsStaging",
"class": "DatabaseIngestor",
"definition_file": "cloud_common/staging_resource_specifications.json"
},
{
"name": "CloudResourceSpecsAddEndDay",
"namespace": "ETL\\Maintenance",
Expand Down
1 change: 1 addition & 0 deletions configuration/etl/etl.d/xdmod-migration-8_5_1-9_0_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"cloud_common/session_records.json",
"cloud_common/event.json",
"cloud_common/raw_resource_specs.json",
"cloud_common/staging_resource_specifications.json",
"cloud_common/cloud_resource_specs.json",
"cloud_common/account.json",
"cloud_common/instance_type.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
"hostname": "r1.hostname",
"vcpus": "IF(r1.memory_mb = -1 AND r1.vcpus = -1, r2.vcpus, r1.vcpus)",
"memory_mb": "IF(r1.memory_mb = -1 AND r1.vcpus = -1, r2.memory_mb, r1.memory_mb)",
"start_date_ts": "UNIX_TIMESTAMP(IF(r1.memory_mb = -1 AND r1.vcpus = -1, r2.fact_date, r1.fact_date))",
"end_date_ts": "UNIX_TIMESTAMP(CASE WHEN MIN(r2.fact_date) IS NOT NULL AND (r1.memory_mb != -1 AND r1.vcpus != -1) THEN MIN(r2.fact_date) - INTERVAL 1 DAY WHEN r1.memory_mb = -1 AND r1.vcpus = -1 AND (SELECT MAX(fact_date) FROM modw_cloud.raw_resource_specs) != MAX(r2.fact_date) THEN MAX(r1.fact_date) - INTERVAL 1 DAY ELSE CURDATE() END)",
"start_day_id": "IF(r1.memory_mb = -1 AND r1.vcpus = -1, YEAR(r2.fact_date) * 100000 + DAYOFYEAR(r2.fact_date), YEAR(r1.fact_date) * 100000 + DAYOFYEAR(r1.fact_date))",
"end_day_id": "CASE WHEN MIN(r2.fact_date) IS NOT NULL AND (r1.memory_mb != -1 AND r1.vcpus != -1) THEN YEAR(MIN(r2.fact_date) - INTERVAL 1 DAY) * 100000 + DAYOFYEAR(MIN(r2.fact_date) - INTERVAL 1 DAY) WHEN r1.memory_mb = -1 AND r1.vcpus = -1 AND (SELECT MAX(fact_date) FROM modw_cloud.raw_resource_specs) != MAX(r2.fact_date) THEN YEAR(MAX(r1.fact_date) - INTERVAL 1 DAY) * 100000 + DAYOFYEAR(MAX(r1.fact_date) - INTERVAL 1 DAY) ELSE YEAR(CURDATE()) * 100000 + DAYOFYEAR(CURDATE()) END"
"start_date_ts": "UNIX_TIMESTAMP(IF(r1.memory_mb = -1 AND r1.vcpus = -1, MIN(r2.fact_date), MIN(r1.fact_date)))",
"end_date_ts": "UNIX_TIMESTAMP(CASE WHEN MIN(r2.fact_date) IS NOT NULL AND (r1.memory_mb != -1 AND r1.vcpus != -1) THEN MIN(r2.fact_date) - INTERVAL 1 DAY WHEN r1.memory_mb = -1 AND r1.vcpus = -1 AND (SELECT MAX(fact_date) FROM modw_cloud.staging_resource_specifications) != MAX(r2.fact_date) THEN MAX(r1.fact_date) - INTERVAL 1 DAY ELSE CURDATE() END)",
"start_day_id": "IF(r1.memory_mb = -1 AND r1.vcpus = -1, YEAR(MIN(r2.fact_date)) * 100000 + DAYOFYEAR(MIN(r2.fact_date)), YEAR(MIN(r1.fact_date)) * 100000 + DAYOFYEAR(MIN(r1.fact_date)))",
"end_day_id": "CASE WHEN MIN(r2.fact_date) IS NOT NULL AND (r1.memory_mb != -1 AND r1.vcpus != -1) THEN YEAR(MIN(r2.fact_date) - INTERVAL 1 DAY) * 100000 + DAYOFYEAR(MIN(r2.fact_date) - INTERVAL 1 DAY) WHEN r1.memory_mb = -1 AND r1.vcpus = -1 AND (SELECT MAX(fact_date) FROM modw_cloud.staging_resource_specifications) != MAX(r2.fact_date) THEN YEAR(MAX(r1.fact_date) - INTERVAL 1 DAY) * 100000 + DAYOFYEAR(MAX(r1.fact_date) - INTERVAL 1 DAY) ELSE YEAR(CURDATE()) * 100000 + DAYOFYEAR(CURDATE()) END"
},
"joins": [{
"name": "raw_resource_specs",
"name": "staging_resource_specifications",
"schema": "${SOURCE_SCHEMA}",
"alias": "r1"
},
{
"name": "raw_resource_specs",
"name": "staging_resource_specifications",
"schema": "${SOURCE_SCHEMA}",
"alias": "r2",
"type": "LEFT",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"#": "@@session.time_zone is used instead of using the time zone listed in resources.json to keep consistency",
"#": "with how time zone conversion works for other places in the cloud realm",
"table_definition": {
"$ref": "${table_definition_dir}/cloud_common/staging_resource_specifications.json#/table_definition"
},
"source_query": {
"records": {
"resource_id": "raw.resource_id",
"hostname": "raw.hostname",
"vcpus": "raw.vcpus",
"memory_mb": "raw.memory_mb",
"fact_date": "DATE(CONVERT_TZ(raw.fact_date, '+00:00', @@session.time_zone))"
},
"joins": [{
"name": "raw_resource_specs",
"schema": "${SOURCE_SCHEMA}",
"alias": "raw"
}]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- This sql statement inserts -1 values for the memory_mb and vcpus for a day that a compute node has been
-- removed from the most recently ingested resource specifications file. The -1 helps when setting start and
-- end times of a cpu and memory configuration for a compute node.
INSERT INTO modw_cloud.raw_resource_specs (hostname, resource_id, memory_mb, vcpus, fact_date) SELECT
INSERT INTO modw_cloud.staging_resource_specifications (hostname, resource_id, memory_mb, vcpus, fact_date) SELECT
rs.hostname,
rs.resource_id,
rs.memory_mb,
Expand All @@ -20,29 +20,29 @@ FROM
rs.resource_id,
rs2.hostname
FROM
modw_cloud.raw_resource_specs AS rs
modw_cloud.staging_resource_specifications AS rs
LEFT JOIN
(SELECT r.resource_id, r.hostname, r.fact_date FROM modw_cloud.raw_resource_specs AS r GROUP BY r.resource_id, r.hostname) AS rs2 ON rs.resource_id = rs2.resource_id
(SELECT r.resource_id, r.hostname, r.fact_date FROM modw_cloud.staging_resource_specifications AS r GROUP BY r.resource_id, r.hostname) AS rs2 ON rs.resource_id = rs2.resource_id
GROUP BY
rs.resource_id,
rs.fact_date,
rs2.hostname
HAVING
MIN(rs2.fact_date) <= rs.fact_date) AS rss1
LEFT JOIN
`modw_cloud`.`raw_resource_specs` AS rss2
`modw_cloud`.`staging_resource_specifications` AS rss2
ON
rss1.resource_id = rss2.resource_id AND rss1.fact_date = rss2.fact_date AND rss1.hostname = rss2.hostname
WHERE
rss2.memory_mb IS NULL AND rss2.vcpus IS NULL
GROUP BY
rss1.resource_id, rss1.hostname, rss1.fact_date) as rs
LEFT JOIN
(SELECT MAX(r.fact_date) AS fact_date, r.hostname, r.resource_id FROM modw_cloud.raw_resource_specs AS r GROUP BY r.resource_id, r.hostname) AS r1
(SELECT MAX(r.fact_date) AS fact_date, r.hostname, r.resource_id FROM modw_cloud.staging_resource_specifications AS r GROUP BY r.resource_id, r.hostname) AS r1
ON
rs.resource_id = r1.resource_id and rs.hostname = r1.hostname
LEFT JOIN
`modw_cloud`.`raw_resource_specs` AS rs2
`modw_cloud`.`staging_resource_specifications` AS rs2
ON
r1.resource_id = rs2.resource_id AND r1.hostname = rs2.hostname AND r1.fact_date = rs2.fact_date AND rs2.memory_mb != -1 AND rs2.vcpus != -1
WHERE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
{
"name": "fact_date",
"type": "date",
"type": "datetime",
"nullable": false
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"#": "Record types are global to all cloud resources",

"table_definition": {
"name": "staging_resource_specifications",
"engine": "MyISAM",
"comment": "Record type: accounting, administrative, derived, etc.",
"columns": [
{
"name": "hostname",
"type": "varchar(225)",
"nullable": false
},
{
"name": "resource_id",
"type": "int(11)",
"nullable": false,
"comment": "Unknown = -1 for global dimensions"
},
{
"name": "memory_mb",
"type": "int(11)",
"nullable": false,
"comment": "Amount of memory available on the associated node."
},
{
"name": "vcpus",
"type": "int(5)",
"nullable": false,
"default": null,
"comment": "Number of vcpus available on the associated node."
},
{
"name": "fact_date",
"type": "date",
"nullable": false
}
],
"indexes": [
{
"name": "PRIMARY",
"columns": [
"resource_id",
"hostname",
"memory_mb",
"vcpus",
"fact_date"
],
"is_unique": true
}
]
}
}
3 changes: 3 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ The default is that resources are assumed to not allow node sharing. If
the SUPReMM module is in use and a resource does allow node sharing then
this should be set to `true`.

For cloud resources the timezone is not used and times are converted to
the local timezone that the server is in.

```json
[
{
Expand Down
33 changes: 25 additions & 8 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,29 @@ function isReferrer($referrer)
<link rel="stylesheet" type="text/css" href="gui/css/LoginPrompt.css"/>
<?php endif; ?>

<?php
$realms = array_reduce(Realms::getRealms(), function ($carry, Realm $item) {
$carry [] = $item->getName();
return $carry;
}, array());
?>

<script type='text/javascript'>

<?php
$realms = array_reduce(Realms::getRealms(), function ($carry, Realm $item) {
$carry [] = $item->getName();
return $carry;
}, array());

if (count($realms) === 0) {
$code = <<<JS
Ext.onReady(function() {
Ext.MessageBox.alert(
'Invalid State Detected',
'This Open XDMoD installation is in an invalid state.<br/><br/>' +
'Before Open XDMoD can be utilized you must run ingestion at least once.<br/><br/>' +
'If ingestion has already been run then make sure that you have run the acl-config CLI application and that it has completed successfully.<br/><br/>' +
'<b>NOTE: Open XDMoD will not function correctly until this problem has been resolved.</b>'
);
});
JS;
print $code;
}

print "CCR.xdmod.publicUser = " . json_encode(!$userLoggedIn) . ";\n";

$tech_support_recipient = xd_utilities\getConfiguration('general', 'tech_support_recipient');
Expand Down Expand Up @@ -281,7 +294,11 @@ function ($item) {

print "CCR.xdmod.ui.rawDataAllowedRealms = " . json_encode($rawDataRealms) . ";\n";

print "CCR.xdmod.ui.disabledMenus = " . json_encode(Acls::getDisabledMenus($user, $realms)) . ";\n";
try {
print "CCR.xdmod.ui.disabledMenus = " . json_encode(Acls::getDisabledMenus($user, $realms)) . ";\n";
} catch (Exception $e) {
print "CCR.xdmod.ui.disabledMenus = [];\n";
}

if ($userLoggedIn) {
print "CCR.xdmod.ui.allRoles = " . json_encode($user->enumAllAvailableRoles()) . "\n";
Expand Down

0 comments on commit af61045

Please sign in to comment.