Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sas2ircu and sas3ircu support #595

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/jobs/linux-catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ function catalogJobFactory(
*/
CatalogJob.prototype._run = function() {
var self = this;
this._subscribeRequestProperties(function() {
return self.options;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use linux command job for template rendering, and don't need to modify the basic catalog job here which might bring side effect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once upon a time, my raid card could not get catalog info successfully, a certain RackHd developer told me to modify these code. I could not find slack Threads for this.If it is not a bug, I think here code is useless.


this._subscribeRequestCommands(function() {
logger.debug("Received command request from node. Sending commands.", {
Expand Down
9 changes: 9 additions & 0 deletions lib/task-data/schemas/catalog-sas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"copyright": "Copyright 2016, EMC, Inc.",
"properties": {
"adapter": {
"$ref": "flash-megaraid.json#/definitions/Adapter"
}
},
"required": ["adapter"]
}
5 changes: 5 additions & 0 deletions lib/task-data/schemas/create-megaraid.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
"type": "string",
"minLength": 1
},
"Script": {
"description": "The script name",
"type": "string",
"minLength": 0
},
"RaidOption": {
"description": "The RAID options",
"properties": {
Expand Down
22 changes: 22 additions & 0 deletions lib/task-data/tasks/catalog-sasraid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2015, EMC, Inc.

'use strict';

module.exports = {
friendlyName: 'Catalog sasraid',
injectableName: 'Task.Catalog.sasraid',
implementsTask: 'Task.Base.Linux.Catalog',
optionsSchema: 'catalog-sas.json',
options: {
adapter: '0',
commands: [
'sudo python /opt/sas_info.py /opt/sas2ircu',
'sudo python /opt/sas_info.py /opt/sas3ircu'
]
},
properties: {
catalog: {
type: 'sasraid'
}
}
};
4 changes: 2 additions & 2 deletions lib/task-data/tasks/megaraid-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ module.exports = {
controller: '{{ context.controller }}',
commands: [
{
command: 'sudo ./megaraid-config.sh',
downloadUrl: '{{ api.templates }}/megaraid-config.sh?nodeId={{ task.nodeId }}'
command: 'sudo ./{{ options.script }}',
downloadUrl: '{{ api.templates }}/{{ options.script }}?nodeId={{ task.nodeId }}'
}
]
},
Expand Down
36 changes: 36 additions & 0 deletions lib/utils/job-utils/command-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function commandParserFactory(Logger, Promise, _) {
perccliDriveInfo = 'sudo /opt/MegaRAID/perccli/perccli64 /c0 /eall /sall show all J',
perccliVirtualDiskInfo = 'sudo /opt/MegaRAID/perccli/perccli64 /c0 /vall show all J',
perccliVersionInfo = 'sudo /opt/MegaRAID/perccli/perccli64 -v',
sas2ircuInfo = 'sudo python /opt/sas_info.py /opt/sas2ircu',
sas3ircuInfo = 'sudo python /opt/sas_info.py /opt/sas2ircu',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the key word is sas3ircu

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, my carelessness .

mpt2fusionAdapterInfo = 'sudo /opt/mpt/mpt2fusion/sas2flash -s -list',
mellanoxInfo = 'sudo mlxfwmanager --query-xml',
lshw = 'sudo lshw -json',
Expand Down Expand Up @@ -729,6 +731,38 @@ function commandParserFactory(Logger, Promise, _) {
};


CommandParser.prototype[sas2ircuInfo] = function(data) {
if (data.error) {
return Promise.resolve({ source: 'megaraid-controllers', error: data.error });
}
try {
var store = true;
var parsed = JSON.parse(data.stdout);
if (parsed.Controllers[0]['Command Status'].Status === 'Failure') {
store = false;
}
return Promise.resolve({ data: parsed, source: 'megaraid-controllers', store: store });
} catch (e) {
return Promise.resolve({ source: 'megaraid-controllers', error: e });
}
};

CommandParser.prototype[sas3ircuInfo] = function(data) {
if (data.error) {
return Promise.resolve({ source: 'megaraid-controllers', error: data.error });
}
try {
var store = true;
var parsed = JSON.parse(data.stdout);
if (parsed.Controllers[0]['Command Status'].Status === 'Failure') {
store = false;
}
return Promise.resolve({ data: parsed, source: 'megaraid-controllers', store: store });
} catch (e) {
return Promise.resolve({ source: 'megaraid-controllers', error: e });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the source here still "megaraid-controllers"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not very familiar with sas2008/sas3008 raid card series, if these cards are mega series?
For convenience, I just put these catalogs to "megaraid-controllers",and my python "/opt/sas_info.py" code stdout is also in "megaraid-controllers" json format.
If these cards not mega series, I think it is better renew a catalog for it.

}
};

CommandParser.prototype[megaraidVirtualDiskInfo] = function(data) {
if (data.error) {
return Promise.resolve({ source: 'megaraid-virtual-disks', error: data.error });
Expand Down Expand Up @@ -809,6 +843,8 @@ function commandParserFactory(Logger, Promise, _) {
CommandParser.prototype[perccliVirtualDiskInfo] =
CommandParser.prototype[megaraidVirtualDiskInfo];
CommandParser.prototype[perccliAdapterInfo] = CommandParser.prototype[megaraidAdapterInfo];
CommandParser.prototype[sas2ircuInfo] = CommandParser.prototype[sas2ircuInfo];
CommandParser.prototype[sas3ircuInfo] = CommandParser.prototype[sas3ircuInfo];
CommandParser.prototype[perccliControllerCount] =
CommandParser.prototype[megaraidControllerCount];
CommandParser.prototype[mpt2fusionAdapterInfo] = function(data) {
Expand Down