Skip to content
Merged
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
4 changes: 2 additions & 2 deletions lib/jobs/secure-erase-drive.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ function secureEraseJobFactory(
output will be:
[
{
downloadUrl: "/api/current/templates/secure_erase.py",
downloadUrl: "{{ api.templates }}/secure_erase.py?nodeId={{ task.nodeId }}",
cmd: "sudo python secure_erase.py -d '{\"diskName\": \"/dev/sda\",
\"virtualDisk\": \"/c0/v0\",\"deviceIds\": [23],
\"scsiId\": \"0:2:0:0\", \"slotIds\": [\"/e252/s5\"]}' -d...
Expand Down Expand Up @@ -408,7 +408,7 @@ function secureEraseJobFactory(
}, []);

// add script's url in the first command
this.commands[0].downloadUrl = '/api/current/templates/secure_erase.py';
this.commands[0].downloadUrl = '{{ api.templates }}/secure_erase.py?nodeId={{ task.nodeId }}';
};

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/task-data/schemas/linux-command.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"minimum": 0
},
"downloadUrl": {
"description": "Specify the download URL (relative to RackHD southbound API server) if the command needs to download some data or script from RackHD before execution",
"description": "Specify the download URL if the command needs to download some data or script before execution",
"type": "string",
"pattern": "^/[a-zA-Z0-9+-.#?=\\\/]+"
"minLength": 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest to keep the pattern and check downloadurl against a valid http URL pattern. There are talks/PRs around changing relative URI to fullpath URL and this check will help people catch errors if a legacy relative URI is used.

Ref: https://github.com/RackHD/RackHD/issues/489#issuecomment-262570418

},
"acceptedResponseCodes": {
"description": "The acceptable exit codes to mark the command success. Defaultly, exit code 0 means the command success, otherwise failure. If you want to specify other exit codes as success, write them here",
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/catalog-driveid.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
commands: [
{
command: 'sudo node get_driveid.js',
downloadUrl: '/api/current/templates/get_driveid.js'
downloadUrl: '{{ api.templates }}/get_driveid.js?nodeId={{ task.nodeId }}'
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/catalog-smart.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
commands: [
{
command: 'sudo bash get_smart.sh',
downloadUrl: '/api/current/templates/get_smart.sh'
downloadUrl: '{{ api.templates }}/get_smart.sh?nodeId={{ task.nodeId }}'
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/install-centos.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
osType: 'linux', //readonly options, should avoid change it
profile: 'install-centos.ipxe',
installScript: 'centos-ks',
installScriptUri: '{{api.templates}}/{{options.installScript}}',
installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}',

Choose a reason for hiding this comment

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

Line is too long.

hostname: 'localhost',
comport: 'ttyS0',
rackhdCallbackScript: 'centos.rackhdcallback',
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/install-coreos.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
osType: 'linux',
profile: 'install-coreos.ipxe',
installScript: 'install-coreos.sh',
installScriptUri: '{{api.templates}}/{{options.installScript}}',
installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}',

Choose a reason for hiding this comment

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

Line is too long.

comport: 'ttyS0',
hostname: 'coreos-node',
installDisk: '/dev/sda',
Expand Down
4 changes: 2 additions & 2 deletions lib/task-data/tasks/install-esx.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ module.exports = {
osType: 'esx', //readonly option, should avoid change it
profile: 'install-esx.ipxe',
installScript: 'esx-ks',
installScriptUri: '{{api.templates}}/{{options.installScript}}',
installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}',

Choose a reason for hiding this comment

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

Line is too long.

rackhdCallbackScript: 'esx.rackhdcallback',
esxBootConfigTemplate: 'esx-boot-cfg',
esxBootConfigTemplateUri: '{{api.templates}}/{{options.esxBootConfigTemplate}}',
esxBootConfigTemplateUri: '{{ api.templates }}/{{ options.esxBootConfigTemplate }}?nodeId={{ task.nodeId }}',
comport: 'com1',
comportaddress: '0x3f8', //com1=0x3f8, com2=0x2f8, com3=0x3e8, com4=0x2e8
repo: '{{file.server}}/esxi/{{options.version}}',
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/install-photon-os.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
osType: 'linux', //readonly options, should avoid change it
profile: 'install-photon-os.ipxe',
installScript: 'photon-os-ks',
installScriptUri: '{{api.templates}}/{{options.installScript}}',
installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}',

Choose a reason for hiding this comment

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

Line is too long.

hostname: 'localhost',
comport: 'ttyS0',
rackhdCallbackScript: 'photon-os.rackhdcallback',
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/install-suse.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
osType: 'linux', //readonly options, should avoid change it
profile: 'install-suse.ipxe',
installScript: 'suse-autoinst.xml',
installScriptUri: '{{api.templates}}/{{options.installScript}}',
installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}',

Choose a reason for hiding this comment

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

Line is too long.

hostname: 'localhost',
comport: 'ttyS0',
repo: '{{file.server}}/distribution/{{options.version}}/repo/oss/',
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/install-ubuntu.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
osType: 'linux', //readonly options, should avoid change it
profile: 'install-ubuntu.ipxe',
installScript: 'ubuntu-preseed',
installScriptUri: '{{api.templates}}/{{options.installScript}}',
installScriptUri: '{{ api.templates }}/{{ options.installScript }}?nodeId={{ task.nodeId }}',

Choose a reason for hiding this comment

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

Line is too long.

rackhdCallbackScript: 'ubuntu.rackhdcallback',
hostname: 'localhost',
comport: 'ttyS0',
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/rm-bmc-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
commands: [
{
command: 'sudo ./remove_bmc_credentials.sh',
downloadUrl: '/api/current/templates/remove_bmc_credentials.sh'
downloadUrl: '{{ api.templates }}/remove_bmc_credentials.sh?nodeId={{ task.nodeId }}'

Choose a reason for hiding this comment

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

Line is too long.

}
]
},
Expand Down
2 changes: 1 addition & 1 deletion lib/task-data/tasks/set-bmc-credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
commands: [
{
command: 'sudo ./set_bmc_credentials.sh',
downloadUrl: '/api/current/templates/set_bmc_credentials.sh'
downloadUrl: '{{ api.templates }}/set_bmc_credentials.sh?nodeId={{ task.nodeId }}'
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/jobs/secure-erase-drive-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe(require('path').basename(__filename), function () {
" -d \'{\"diskName\":\"/dev/sdg\",\"virtualDisk\":\"\"," +
"\"scsiId\":\"10:0:0:0\"}\'" +
" -t hdparm -o secure-erase -v lsi",
"downloadUrl": "/api/current/templates/secure_erase.py"
"downloadUrl": "{{ api.templates }}/secure_erase.py?nodeId={{ task.nodeId }}"
},
{
"cmd": "sudo python secure_erase.py -i " + taskId +
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/task-data/schemas/linux-command-schema-ut-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var canonicalCommand = {
format: 'json'
},
retries: 10,
downloadUrl: '/api/current/foo/ipmitool',
downloadUrl: 'http://10.0.0.1:8080/api/current/foo/ipmitool?nodeId=123',
timeout: 100
},
{
Expand All @@ -33,7 +33,7 @@ var negativeSetParamCommand = {
'commands': ['', null, []],
'commands[0]': ['', null],
'commands[1].acceptedResponseCodes': [[], 0, 1, -1],
'commands[1].downloadUrl': ['', 'foo', 'http://abc.com/abc'],
'commands[1].downloadUrl': [''],
'commands[1].timeout': [-1, 2.5],
'commands[1].retries': [-1, 2.5],
'commands[1].catalog.format': ['JSON', 'RAW', 'xml', 'html'] //now only support json & raw
Expand All @@ -45,7 +45,7 @@ var negativeSetParamExtra = {

var positiveSetParamCommand = {
'commands[1]': 'touch foo.txt', //allow duplicated command
'commands[1].downloadUrl': ['/foo', '/foo123/123/bar'],
'commands[1].downloadUrl': ['http://abc.com/foo', 'http://10.0.0.1:8080/foo123/123/bar?nodeId=123', 'www.abc.com/abc'],
'commands[1].timeout': [0, 1, 100000],
'commands[1].retries': [0, 1, 100000],
'commands[1].acceptedResponseCodes': [[0]],
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/utils/job-utils/command-util-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ describe('Command Util', function() {
command: 'doSomething', retries: 3, acceptedResponseCodes: [0, 127]
},
{
command: 'runSomething', downloadUrl: 'api/downloadScript'
command: 'runSomething', downloadUrl: 'http://10.0.0.1:8080/api/downloadScript?nodeId=123'
},
{
command: 'doStuff', timeout: 20 //milliseconds
Expand All @@ -373,7 +373,7 @@ describe('Command Util', function() {
retries: 3, acceptedResponseCodes: [0, 127]
});
expect(builtCommands[2]).to.deep.equal({
cmd: 'runSomething', downloadUrl: 'api/downloadScript'
cmd: 'runSomething', downloadUrl: 'http://10.0.0.1:8080/api/downloadScript?nodeId=123'
});
expect(builtCommands[3]).to.deep.equal({ cmd: 'doStuff', timeout: 20 });
});
Expand Down