Skip to content

Commit

Permalink
Cloud updates (#11)
Browse files Browse the repository at this point in the history
Cloud updates
  • Loading branch information
plessbd authored May 16, 2019
2 parents 88ff63e + dea4885 commit 11d1c40
Show file tree
Hide file tree
Showing 13 changed files with 931 additions and 21 deletions.
7 changes: 4 additions & 3 deletions build.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "xdmod-federated",
"version": "8.1.0",
"version": "8.1.2",
"release": "0.1",
"prerelease": "beta1.20190122",
"files": {
"include_paths": [
],
Expand All @@ -21,7 +20,9 @@
},
"file_maps": {
"data": [
"classes"
"classes",
"patches",
{ "templates": "templates/federated" }
],
"bin": [
"bin/"
Expand Down
41 changes: 30 additions & 11 deletions classes/OpenXdmod/Setup/FederatedSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,44 @@ class FederatedSetup extends SubMenuSetupItem
public function __construct(Console $console)
{
parent::__construct($console);
$this->genMenu();
}

$items = array(
public function genMenu(){
$settings = $this->loadIniConfig('portal_settings', 'federated');
$hubItems = array(
new MenuItem(
'1',
'2',
'List current instances',
new ListFederatedInstancesSetup($console, $this)
new ListFederatedInstancesSetup($this->console, $this)
),
new MenuItem(
'2',
'3',
'Add new instance',
new AddFederatedInstanceSetup($console, $this)
),
new AddFederatedInstanceSetup($this->console, $this)
)
);
$items = array(
new MenuItem(
'r',
'Return to main menu',
new SubMenuQuitSetup($console, $this)
'1',
'Set Federation Role',
new SetFederatedRole($this->console, $this)
),
);

$this->menu = new Menu($items, $console, 'Federated module setup');
if($settings['federated_role'] === "hub"){
$items = array_merge($items, $hubItems);
}
$items = array_merge(
$items,
array(
new MenuItem(
'r',
'Return to main menu',
new SubMenuQuitSetup($this->console, $this)
),
)
);
$this->menu = new Menu($items, $this->console, 'Federated module setup');
}

/**
Expand All @@ -72,6 +90,7 @@ public function handle()
$this->quit = false;

while (!$this->quit) {
$this->genMenu();
$this->menu->display();
}
}
Expand Down
80 changes: 80 additions & 0 deletions classes/OpenXdmod/Setup/SetFederatedRole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php
namespace OpenXdmod\Setup;

use DateTime;
use CCR\Log;
use ETL\Utilities;
/**
* Federation Instance setup.
*/
class SetFederatedRole extends SetupItem
{

/**
* Main federation setup
*
* @var FederatedSetup
*/
protected $parent;

/**
* @inheritdoc
*/
public function __construct(Console $console, FederatedSetup $parent)
{
parent::__construct($console);
$this->parent = $parent;
}

/**
* @inheritdoc
*/
public function handle()
{
$settings = $this->loadIniConfig('portal_settings', 'federated');
$this->console->displaySectionHeader('Set Federation Role');
$this->console->displayBlankLine();
$role = strtolower(
$this->console->prompt(
'Is this a federation `hub` or `instance`?',
$settings['federated_role']
)
);
if($role !== $settings['federated_role'])
{
switch($role){
case 'instance':
$url = $this->console->prompt('What is the url for the hub?', $settings['federated_huburl']);
if (empty($url)) {
$this->console->displayMessage("Error, instance URL is required!");
}
else{
if($settings['federated_role'] === 'hub'){
$this->patchOpenXdmod(true);
}
$settings['federated_role'] = 'instance';
$settings['federated_huburl'] = $url;
$this->saveIniConfig($settings, 'portal_settings', 'federated');
}
break;
case 'hub':
$settings['federated_role'] = 'hub';
$this->saveIniConfig($settings, 'portal_settings', 'federated');
$this->patchOpenXdmod();
break;
default:
$this->console->displayMessage("Error, no role specified!");
$this->console->prompt('Press ENTER to continue.');
}
}
}
function patchOpenXdmod($reverse = false){
$directionOption = '--forward';
$patchPath = DATA_DIR . '/patches/federated/';
if($reverse){
$directionOption = '--reverse';
}
$this->executeCommand('patch --quiet ' . $directionOption . ' -up1 --directory=/usr/share/xdmod/ < ' . $patchPath . 'usr-share-xdmod.diff');
$this->executeCommand('patch --quiet ' . $directionOption . ' -up2 --directory=/etc/xdmod/ < ' . $patchPath . 'configuration.diff');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"instance_id": "scif.instance_id",
"account_id": "scif.account_id",
"provider_identifier": "COALESCE(scif.provider_identifier, 'unknown')",
"person_id": "upf.id"
"person_id": "COALESCE(upf.id, -1)"
},

"joins": [
Expand All @@ -30,7 +30,8 @@
"schema": "${UTILITY_SCHEMA}",
"name": "person",
"alias": "upf",
"on": "upf.person_origin_id = scif.person_id AND upf.organization_id = drf.organization_id"
"on": "upf.person_origin_id = scif.person_id AND upf.organization_id = drf.organization_id",
"type": "LEFT"
}
],
"groupby": [
Expand Down
4 changes: 4 additions & 0 deletions configuration/portal_settings.d/federated.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[federated]
version = "8.1.2"
role =
huburl =
1 change: 1 addition & 0 deletions docs/federated-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ su - tungsten -c '/opt/continuent/software/tungsten-replicator-5.0.1/tools/tpm c
```

```bash
su - tungsten -c '/opt/continuent/software/tungsten-replicator-5.0.1/tools/tpm update'
su - tungsten -c '/opt/continuent/software/tungsten-replicator-5.0.1/tools/tpm update xdmodfederation'
```

Expand Down
10 changes: 10 additions & 0 deletions patches/federated/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
When running a federation HUB you will need the following changes made to the OpenXDMoD code.
**NOTE** This is done automatically as part of `xdmod-setup` when setting the federation type to `hub`

patch -up1 --directory=/usr/share/xdmod/ < patches/cloud/usr-share-xdmod.diff
patch -up2 --directory=/etc/xdmod/ < patches/cloud/configuration.diff

If you have no jobs data use the following as well to remove Jobs related information.

patch -up1 --directory=/usr/share/xdmod/ < patches/cloud/nojobs-usr-share-xdmod.diff
patch -up2 --directory=/etc/xdmod/ < patches/cloud/nojobs-configuration.diff
148 changes: 148 additions & 0 deletions patches/federated/configuration.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
diff --git a/configuration/etl/etl_action_defs.d/cloud_common/cloud_metrics_aggregation.json b/configuration/etl/etl_action_defs.d/cloud_common/cloud_metrics_aggregation.json
index f2fc4bd5..de5b4f7f 100644
--- a/configuration/etl/etl_action_defs.d/cloud_common/cloud_metrics_aggregation.json
+++ b/configuration/etl/etl_action_defs.d/cloud_common/cloud_metrics_aggregation.json
@@ -27,7 +27,8 @@
"year": "${:YEAR_VALUE}",
"${AGGREGATION_UNIT}": "${:PERIOD_VALUE}",
"host_resource_id": "sr.resource_id",
- "account_id": "instance.account_id",
+ "#": "THE FOLLOWING HAS BEEN CHANGED BY THE FEDERATION MODULE",
+ "account_id": "ca.primaryid",
"person_id": "sr.person_id",
"systemaccount_id": "sr.systemaccount_id",
"processorbucket_id": "(SELECT id FROM ${SOURCE_SCHEMA}.processor_buckets pb WHERE sr.num_cores BETWEEN pb.min_processors AND pb.max_processors)",
@@ -71,6 +72,13 @@
"schema": "${UTILITY_SCHEMA}",
"alias": "task_resource",
"on": "task_resource.id = sr.resource_id"
+ },
+ {
+ "#": "THE FOLLOWING IS ADDED BY THE FEDERATION MODULE",
+ "name":"account",
+ "alias":"ca",
+ "schema": "${SOURCE_SCHEMA}",
+ "on": "ca.resource_id = instance.resource_id AND ca.account_id = instance.account_id"
}
],
"where": [
diff --git a/configuration/etl/etl_action_defs.d/cloud_common/session_records.json b/configuration/etl/etl_action_defs.d/cloud_common/session_records.json
index 1ce31ca7..63f12522 100644
--- a/configuration/etl/etl_action_defs.d/cloud_common/session_records.json
+++ b/configuration/etl/etl_action_defs.d/cloud_common/session_records.json
@@ -11,7 +11,8 @@
"end_event_type_id": "e.end_event_id",
"resource_id": "it.resource_id",
"instance_type": "itt.instance_type",
- "instance_type_id": "itt.instance_type_id",
+ "#": "THE FOLLOWING WAS MODIFIFED BY THE FEDERATION MODULE",
+ "instance_type_id": "itt.primaryid",
"num_cores": "itt.num_cores",
"memory_mb": "itt.memory_mb",
"disk_gb": "itt.disk_gb",
diff --git a/configuration/etl/etl_tables.d/cloud_common/account.json b/configuration/etl/etl_tables.d/cloud_common/account.json
index b89f3f44..0d18fe83 100644
--- a/configuration/etl/etl_tables.d/cloud_common/account.json
+++ b/configuration/etl/etl_tables.d/cloud_common/account.json
@@ -14,7 +14,7 @@
"name": "account_id",
"type": "int(11)",
"nullable": false,
- "extra": "auto_increment",
+ "#": "Auto-increment REMOVED FROM THIS COLUMN BY THE FEDERATION",
"comment": "Unknown = 1"
},
{
@@ -29,9 +29,17 @@
"nullable": true,
"default": null,
"comment": "What to show the user"
+ },
+ {
+ "#": "THIS HAS BEEN ADDED BY THE FEDERATION",
+ "name": "primaryid",
+ "type": "bigint(20) unsigned",
+ "nullable": false,
+ "extra": "auto_increment",
+ "comment": "Added by federation"
}
],
-
+ "#": "THE FOLLOWING IS NOT VALID ON A FEDERATION HUB",
"#": "Note that the primary key is (resource, account) rather than account_id so we can",
"#": "take advantage of ON DUPLICATE KEY UPDATE to update existing entries and still use",
"#": "auto_increment for new entries.",
@@ -45,15 +53,16 @@

"indexes": [
{
+ "#": "THE FOLLOWING HAS BEEN CHANGED BY THE FEDERATION MODULE",
"name": "PRIMARY",
"columns": [
- "resource_id",
- "provider_account"
+ "primaryid"
],
"is_unique": true
},
{
- "name": "autoincrement_key",
+ "#": "THE FOLLOWING HAS BEEN CHANGED BY THE FEDERATION MODULE",
+ "name": "uniq",
"columns": [
"resource_id",
"account_id"
diff --git a/configuration/etl/etl_tables.d/cloud_common/instance_type.json b/configuration/etl/etl_tables.d/cloud_common/instance_type.json
index f7d4e39e..0f769bbf 100644
--- a/configuration/etl/etl_tables.d/cloud_common/instance_type.json
+++ b/configuration/etl/etl_tables.d/cloud_common/instance_type.json
@@ -16,7 +16,7 @@
"name": "instance_type_id",
"type": "int(11)",
"nullable": false,
- "extra": "auto_increment",
+ "#": "Auto-increment REMOVED FROM THIS COLUMN BY THE FEDERATION",
"comment": "Auto-increment relative to resource_id. Unknown = 1"
},
{
@@ -69,7 +69,15 @@
"nullable": true,
"default": null,
"comment": "End time for this configuration as a unix timestamp to the microsecond., NULL if it is still in effect."
- }
+ },
+ {
+ "#": "THIS HAS BEEN ADDED BY THE FEDERATION",
+ "name": "primaryid",
+ "type": "bigint(20) unsigned",
+ "nullable": false,
+ "extra": "auto_increment",
+ "comment": "Added by federation"
+ }
],

"#": "Note that the primary key is (resource, instance_type, num_cores, memory_mb, disk_gb)",
@@ -78,7 +86,14 @@

"indexes": [
{
- "name": "PRIMARY",
+ "#": "THE FOLLOWING HAS BEEN ADDED BY THE FEDERATION MODULE",
+ "name": "PRIMARY",
+ "columns": [
+ "primaryid"
+ ]
+ },{
+ "#": "THE FOLLOWING HAS BEEN CHANGED BY THE FEDERATION MODULE",
+ "name": "uniq",
"columns": [
"resource_id",
"instance_type",
@@ -89,6 +104,7 @@
"is_unique": true
},
{
+ "#": "THE FOLLOWING IS NOT VALID ON A FEDERATION HUB",
"#": "For MyISAM tables, you can specify AUTO_INCREMENT on a secondary column in a",
"#": "multiple-column index. In this case, the generated value for the AUTO_INCREMENT column",
"#": "is calculated as MAX(auto_increment_column) + 1 WHERE prefix=given-prefix. This is",
Loading

0 comments on commit 11d1c40

Please sign in to comment.