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

RAC-6214 : add dell wsman delete volume #558

Merged
merged 3 commits into from
Nov 21, 2017

Conversation

yaolingling
Copy link
Contributor

Background

Replace RACADM based RAID operation feature implementation with WSMAN API. This pr is used for deleting volume operation.

Details

To solve this problem, a new graph is created which contains four tasks. The first task is used to getComponent xml file. The second task is used to update the xml file for deleting volume. The third task is used to delete volume. The last task is used to update mongodb. Details in https://rackhd.atlassian.net/browse/RAC-6214

Reviewers
@nortonluo @lanchongyizu @AlaricChan

Logger,
Promise
){
var logger = Logger.initialize(Smb2ClientFactory);

Choose a reason for hiding this comment

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

'logger' is defined but never used.

});
XMLSerializer = XmlDOM.XMLSerializer;
serializer = new XMLSerializer();
};

Choose a reason for hiding this comment

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

Unnecessary semicolon.

}).then(function(){
self._done();
}).catch(function(err){
logger.error('Error occurs', error);

Choose a reason for hiding this comment

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

'error' is not defined.

return smb2Client.writeFile(fileName, doc);
}).then(function(){
self._done();
}).catch(function(err){

Choose a reason for hiding this comment

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

'err' is defined but never used.

}
}
}
for(var i = 0; i < deleteIndex.length; i++){

Choose a reason for hiding this comment

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

'i' is already defined.
Unexpected use of '++'.

var components = doc.getElementsByTagName('Component');
var deleteIndex = [];

for(var i = 0; i < components.length; i++){

Choose a reason for hiding this comment

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

Unexpected use of '++'.

"description": "Specify if SSL certificate is enabled",
"type": "boolean"
},
"_taskTimeout": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an options for all tasks and it has been covered in common-task-options (https://github.com/RackHD/on-tasks/blob/master/lib/task-data/schemas/common-task-options.json#L22), so you don't need to describe it again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will remove "_taskTimeout"

"$ref": "#/definitions/shutdownType"
}
},
"required": ["volumeId"]
Copy link
Contributor

Choose a reason for hiding this comment

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

if shutdownType is optional, you'd better tell its default value in its description.

Copy link
Contributor

Choose a reason for hiding this comment

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

And there is difference between "setting a default value in task definition" and "describe it as optional in task schema". If the job needs this option for execution, then the option has to be required no matter you set a default value in task definition or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add description for default value.

implementsTask: "Task.Base.Dell.Wsman.getComponent",
optionsSchema: 'dell-wsman-delete-volume.json',
options: {
volumeId: "",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please confirm, is the empty volumeId valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The volumeId check will be added.

'validator'
));

function DellWsmanRAIDFactory(
Copy link
Contributor

Choose a reason for hiding this comment

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

why no _run callback?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_run callback is defined in it's parent class

}

Smb2Client.prototype.readFile = function(fileName){
logger.info("Smb2Client readFile function, fileName:" + fileName);
Copy link
Contributor

Choose a reason for hiding this comment

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

use logger.debug seems to be more reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

}
};
WsmanTool.prototype.clientRequest.resolves(response);
expect(job.doRAIDoperation(obms)).to.be.fulfilled;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is a promise it has to be returned, otherwise this test case is always success no matter the promise is fufilled or rejected.

validator.isIP.returns(false);
expect(function(){
job.doRAIDoperation(obms);
}).to.throw('Invalid ServerIP');
Copy link
Contributor

Choose a reason for hiding this comment

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

throw only works for sync function. For async function, use something like `return expect(...).to.be.rejected;'

configuration.get.returns(configFile);
expect(function(){
job._run();
}).to.not.throw('Dell SCP web service is not defined in smiConfig.json.');
Copy link
Contributor

Choose a reason for hiding this comment

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

throw cannot be used for async function, it has been explained above.


WsmanGetComponentJob.prototype.getComponent = function(obm) {
if (!validator.isIP(obm.config.host)) {
throw new Error('Invalid ServerIP');
Copy link
Contributor

Choose a reason for hiding this comment

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

if you design the function to return a promise, then you'd better also wrap the error in promise, you will find it will become easier to write unit-test.

var componentNames = "";
if(self.options.volumeId !== undefined){
componentNames = self.options.volumeId.split(':')[1];
}else if(self.options.drives !== undefined){
Copy link
Contributor

Choose a reason for hiding this comment

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

The task schema misses the description for the option drives.
Meanwhile, look like this is a typo drives ==> 'drivers'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spelling error. It should be drivers. The option isn't used in delete volume. It will be defined in other feature, such as "add volume"


module.exports = {
friendlyName: 'Dell Wsman GetComponent Base Task',
injectableName: 'Task.Base.Dell.Wsman.GetXml',
Copy link
Member

Choose a reason for hiding this comment

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

Duplicated file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's deleted

@anhou anhou merged commit beee4d5 into RackHD:master Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
7 participants