Skip to content

Commit

Permalink
Fix ipmi-user-list catalog data
Browse files Browse the repository at this point in the history
Code that parsed `sudo ipmitool -c user list N` assumed there
would be a header row printed and built the user hash keys from
the first line. However `ipmitool user list` only prints the
headers when invoked without `-c` which puts it into CSV output
mode. When invoked with `-c` there is no header line and the
first user was getting eaten up and treated as the header.

Example ipmitool output:

    monorail@monorail-micro:~$ sudo ipmitool user list 1
    ID  Name             Callin  Link Auth  IPMI Msg   Channel Priv Limit
    2   root             true    true       true       ADMINISTRATOR
    monorail@monorail-micro:~$ sudo ipmitool user -c list 1
    2,root,true,true,true,ADMINISTRATOR

This fix hard-codes the header values as the header that is
printed when invoked without `-c` looks nigh-impossible to
parse. The previous code was also eating the first user because
that line was taken as the header line.
  • Loading branch information
gavin-scott committed Mar 17, 2018
1 parent 0df7a66 commit 78f7cd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/utils/job-utils/command-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function commandParserFactory(Logger, Promise, _) {
}
});
var parsed = {},
header = lines.shift().split(','),
header = ['ID', 'Name', 'Callin', 'Link Auth', 'IPMI Msg', 'Channel Priv Limit'],
columns = _.map(lines, function (line) {
return line.split(',');
});
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/utils/job-utils/command-parser-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -847,14 +847,14 @@ describe("Task Parser", function () {
expect(result.data[1].Name).to.equal('');
expect(result.data[1].Callin).to.equal('true');
expect(result.data[1]['Link Auth']).to.equal('false');
expect(result.data[1]['IPMI Msg Channel']).to.equal('true');
expect(result.data[1]['Priv Limit']).to.equal('ADMINISTRATOR');
expect(result.data[1]['IPMI Msg']).to.equal('true');
expect(result.data[1]['Channel Priv Limit']).to.equal('ADMINISTRATOR');
expect(result.data[2].ID).to.equal('2');
expect(result.data[2].Name).to.equal('root');
expect(result.data[2].Callin).to.equal('false');
expect(result.data[2]['Link Auth']).to.equal('true');
expect(result.data[2]['IPMI Msg Channel']).to.equal('true');
expect(result.data[2]['Priv Limit']).to.equal('ADMINISTRATOR');
expect(result.data[2]['IPMI Msg']).to.equal('true');
expect(result.data[2]['Channel Priv Limit']).to.equal('ADMINISTRATOR');
});
});

Expand Down
5 changes: 3 additions & 2 deletions spec/lib/utils/job-utils/stdout-helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright 2015 - 2018, EMC, Inc.

module.exports.amiOutput = '+---------------------------------------------------------------------------+\n' +
'| *** ******** ****** ******* ******** |\n' +
'| ********* ******* ******** ********** **** *** ****** ********* |\n' +
Expand Down Expand Up @@ -3477,8 +3479,7 @@ module.exports.ipmiSelOutput = '1,05/27/2014,21:20:43,Event Logging Disabled #0x
'8,05/27/2014,21:23:25,Power Unit #0x02,Non-Redundant: Sufficient from Redundant,Asserted';


module.exports.ipmiUserListOutput = 'ID,Name,Callin,Link Auth,IPMI Msg Channel,Priv Limit\n' +
'1,,true,false,true,ADMINISTRATOR\n' +
module.exports.ipmiUserListOutput = '1,,true,false,true,ADMINISTRATOR\n' +
'2,root,false,true,true,ADMINISTRATOR\n';

module.exports.ipmiUserSummaryOutput = 'Maximum IDs : 15\n' +
Expand Down

0 comments on commit 78f7cd6

Please sign in to comment.