diff --git a/classes/OpenXdmod/Migration/Version800To810/ConfigFilesMigration.php b/classes/OpenXdmod/Migration/Version800To810/ConfigFilesMigration.php index 64959adf52..d3d2d26705 100644 --- a/classes/OpenXdmod/Migration/Version800To810/ConfigFilesMigration.php +++ b/classes/OpenXdmod/Migration/Version800To810/ConfigFilesMigration.php @@ -17,10 +17,13 @@ class ConfigFilesMigration extends AbstractConfigFilesMigration private $cloudRolesFilePath; + private $templateCloudRolesFile; + public function __construct($currentVersion, $newVersion) { - $this->cloudRolesFilePath = CONFIG_DIR."/roles.d/cloud.json"; - parent::__construct($currentVersion, $newVersion); + $this->templateCloudRolesFile = DATA_DIR . '/templates/roles.d/cloud.json'; + $this->cloudRolesFilePath = CONFIG_DIR . '/roles.d/cloud.json'; + parent::__construct($currentVersion, $newVersion); } /** @@ -29,7 +32,7 @@ public function __construct($currentVersion, $newVersion) public function execute() { if (file_exists($this->cloudRolesFilePath)) { - $this->addCloudRolesGroupBy(); + $this->addtoCloudRoles(); } $this->assertPortalSettingsIsWritable(); @@ -42,13 +45,14 @@ public function execute() /** * Adds new group bys to roles.d/cloud.json */ - public function addCloudRolesGroupBy() + public function addtoCloudRoles() { // Json::loadFile throws an exception if the file is completely empty or if there some other // problem loading the file. If those exceptions are thrown catch them so the rest of the // migration script can continue to run try{ $cloudRolesFile = Json::loadFile($this->cloudRolesFilePath); + $templateCloudRoles = Json::loadFile($this->templateCloudRolesFile); } catch(Exception $e){ return false; @@ -58,6 +62,9 @@ public function addCloudRolesGroupBy() foreach($cloudRolesFile['+roles'] as $key => $unused) { $cloudRolesFile['+roles'][$key]['+query_descripters'][] = array('realm' => 'Cloud', 'group_by' => 'person'); $cloudRolesFile['+roles'][$key]['+query_descripters'][] = array('realm' => 'Cloud', 'group_by' => 'username'); + if ($key === '+default') { + $cloudRolesFile['+roles'][$key]['+summary_charts'] = $templateCloudRoles['+roles'][$key]['+summary_charts']; + } } // An exception can be thrown if there is a problem writing the file. Catch and log the issue diff --git a/classes/OpenXdmod/Setup/ResourcesSetup.php b/classes/OpenXdmod/Setup/ResourcesSetup.php index e278fd62af..807b63de79 100644 --- a/classes/OpenXdmod/Setup/ResourcesSetup.php +++ b/classes/OpenXdmod/Setup/ResourcesSetup.php @@ -6,6 +6,8 @@ namespace OpenXdmod\Setup; +use \CCR\Json; + /** * Resources setup. */ @@ -195,8 +197,8 @@ private function rolesFileMatches($realm) return false; } - return file_get_contents(TEMPLATE_DIR . '/roles.d/' . $realm . '.json') - === file_get_contents($rolesFile); + return JSON::loadFile(TEMPLATE_DIR . '/roles.d/' . $realm . '.json', false) + === JSON::loadFile($rolesFile, false); } /** diff --git a/configuration/roles.d/cloud.json b/configuration/roles.d/cloud.json deleted file mode 100644 index fa35af3740..0000000000 --- a/configuration/roles.d/cloud.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "+roles": { - "+default": { - "+query_descripters": [{ - "realm": "Cloud", - "group_by": "none" - }, - { - "realm": "Cloud", - "group_by": "project" - }, - { - "realm": "Cloud", - "group_by": "configuration" - }, - { - "realm": "Cloud", - "group_by": "resource" - }, - { - "realm": "Cloud", - "group_by": "vm_size" - }, - { - "realm": "Cloud", - "group_by": "vm_size_memory" - }, - { - "realm": "Cloud", - "group_by": "submission_venue" - }, - { - "realm": "Cloud", - "group_by": "person" - }, - { - "realm": "Cloud", - "group_by": "username" - } - ] - }, - "+pub": { - "+query_descripters": [{ - "realm": "Cloud", - "group_by": "none" - }, - { - "realm": "Cloud", - "group_by": "project" - }, - { - "realm": "Cloud", - "group_by": "configuration" - }, - { - "realm": "Cloud", - "group_by": "resource" - }, - { - "realm": "Cloud", - "group_by": "vm_size" - }, - { - "realm": "Cloud", - "group_by": "vm_size_memory" - }, - { - "realm": "Cloud", - "group_by": "submission_venue" - }, - { - "realm": "Cloud", - "group_by": "person" - }, - { - "realm": "Cloud", - "group_by": "username" - } - ] - } - } -} diff --git a/templates/roles.d/cloud.json b/templates/roles.d/cloud.json index 4b39efc87c..a7692bad93 100644 --- a/templates/roles.d/cloud.json +++ b/templates/roles.d/cloud.json @@ -42,13 +42,13 @@ "data_series": { "data": [{ "combine_type": "stack", - "display_type": "column", + "display_type": "area", "filters": { "data": [], "total": 0 }, - "group_by": "project", - "has_std_err": true, + "group_by": "resource", + "has_std_err": false, "ignore_global": false, "log_scale": false, "long_legend": true, @@ -69,20 +69,20 @@ "limit": 10, "show_filters": true, "start": 0, - "timeseries": false, - "title": "Cloud - Total CPU Hours by Project" + "timeseries": true, + "title": "Cloud - Total CPU Hours by Resource" }, { "data_series": { "data": [{ "combine_type": "stack", - "display_type": "column", + "display_type": "area", "filters": { "data": [], "total": 0 }, "group_by": "project", - "has_std_err": true, + "has_std_err": false, "ignore_global": false, "log_scale": false, "long_legend": true, @@ -103,7 +103,7 @@ "limit": 10, "show_filters": true, "start": 0, - "timeseries": false, + "timeseries": true, "title": "Cloud - Number of Sessions Started by Project" } ] @@ -134,16 +134,16 @@ "group_by": "vm_size_memory" }, { - "realm": "Cloud", - "group_by": "submission_venue" + "realm": "Cloud", + "group_by": "submission_venue" }, { - "realm": "Cloud", - "group_by": "person" + "realm": "Cloud", + "group_by": "person" }, { - "realm": "Cloud", - "group_by": "username" + "realm": "Cloud", + "group_by": "username" } ] }