Merge "Add storage options to compose menu"

This commit is contained in:
Jenkins 2016-10-17 21:26:51 +00:00 committed by Gerrit Code Review
commit 5db877eae5
3 changed files with 80 additions and 40 deletions

View File

@ -17,6 +17,7 @@ const Layout = React.createClass({
racks: [], racks: [],
systems: [], systems: [],
storage: [], storage: [],
processors: [],
nodes: [] nodes: []
}; };
}, },
@ -25,6 +26,7 @@ const Layout = React.createClass({
this.getPods(); this.getPods();
this.getRacks(); this.getRacks();
this.getSystems(); this.getSystems();
this.getProcessors();
this.getStorage(); this.getStorage();
this.getNodes(); this.getNodes();
}, },
@ -48,6 +50,9 @@ const Layout = React.createClass({
}, },
displayCompose: function() { displayCompose: function() {
this.getProcessors();
this.getStorage();
this.fillComposeForms();
this.setState({ this.setState({
homeDisplay: "none", homeDisplay: "none",
detailDisplay: "none", detailDisplay: "none",
@ -56,6 +61,43 @@ const Layout = React.createClass({
}); });
}, },
fillDropdownMenu: function(menu, itemNames, itemValues) {
var sel = document.getElementById(menu);
sel.innerHTML = '';
var opt = document.createElement('option');
opt.innerHTML = 'None';
opt.value = null;
sel.appendChild(opt);
for (var i = 0; i < itemNames.length; i++) {
opt = document.createElement('option');
opt.innerHTML = itemNames[i];
opt.value = itemValues[i];
sel.appendChild(opt);
}
},
fillComposeForms: function() {
// Fill processor dropdown menu
var processorNames = []
for (var i = 0; i < this.state.processors.length; i++) {
if (this.state.processors[i]['Model'] &&
processorNames.indexOf(this.state.processors[i]['Model']) >= 0) {
processorsNames.push(this.state.processors[i]['Model']);
}
}
this.fillDropdownMenu('procModels', processorNames, processorNames);
// Fill storage dropdown menu
var driveNames = [];
var driveValues = []
for (var i = 0; i < this.state.storage.length; i++) {
if (this.state.storage[i]['Mode'] == 'LV') {
driveNames.push(this.state.storage[i]['Name']);
driveValues.push(this.state.storage[i]['@odata.id']);
}
}
this.fillDropdownMenu('remoteDrives', driveNames, driveValues);
},
getPods: function() { getPods: function() {
util.getPods(this.setPods); util.getPods(this.setPods);
}, },
@ -80,6 +122,14 @@ const Layout = React.createClass({
this.setState({systems: systems}); this.setState({systems: systems});
}, },
getProcessors: function() {
util.getProcessors(this.state.systems, this.setProcessors);
},
setProcessors: function(processors) {
this.setState({processors: processors});
},
getStorage: function() { getStorage: function() {
util.getStorage(this.setStorage); util.getStorage(this.setStorage);
}, },

View File

@ -5,16 +5,6 @@ var util = require('../../util.js');
const ComposeDisplay = React.createClass({ const ComposeDisplay = React.createClass({
getInitialState: function() {
return {
processors: []
};
},
componentDidMount() {
this.getProcessors();
},
compose: function() { compose: function() {
var data = this.prepareRequest(); var data = this.prepareRequest();
var url = config.url + '/redfish/v1/Nodes/Actions/Allocate'; var url = config.url + '/redfish/v1/Nodes/Actions/Allocate';
@ -45,46 +35,36 @@ const ComposeDisplay = React.createClass({
}); });
}, },
getProcessors: function() {
util.getProcessors(this.props.systemList, this.setProcessors);
},
setProcessors: function(processors) {
this.setState({processors: processors});
this.fillForms();
},
fillForms: function() {
var sel = document.getElementById('procModels');
sel.innerHTML = "";
for (var i = 0; i < this.state.processors.length; i++) {
if (this.state.processors[i]['Model']) {
var opt = document.createElement('option');
opt.innerHTML = this.state.processors[i]['Model'];
opt.value = this.state.processors[i]['Model'];
sel.appendChild(opt);
}
}
},
prepareRequest: function() { prepareRequest: function() {
var name = document.getElementById('name').value; var name = document.getElementById('name').value;
var description = document.getElementById('description').value; var description = document.getElementById('description').value;
var totalMem = document.getElementById('totalMem').value; var totalMem = document.getElementById('totalMem').value;
var storageCapacity = document.getElementById('storageCapacity').value;
var iqn = document.getElementById('iqn').value;
var masterDrive = document.getElementById('remoteDrives').value;
var procModel = document.getElementById('procModels').value; var procModel = document.getElementById('procModels').value;
if (procModel == "") {
procModel = null;
}
var data = { var data = {
"Name": name, "Name": name,
"Description": description, "Description": description,
"Memory": [{ "Memory": [{
"CapacityMiB": totalMem * 1000 "CapacityMiB": totalMem * 1000
}],
"Processors": [{
"Model": procModel
}] }]
} }
if (procModel != 'null') {
data["Processors"] = [{"Model": procModel}];
}
if (iqn != 'null' && masterDrive != 'null') {
data["RemoteDrives"] = [{
"CapacityGiB": storageCapacity,
"iSCSIAddress": iqn,
"Master": {
"Type": "Snapshot",
"Resource": {
"@odata.id": masterDrive
}
}
}];
}
return JSON.stringify(data); return JSON.stringify(data);
}, },
@ -110,6 +90,18 @@ const ComposeDisplay = React.createClass({
<td align="right">System Memory GB:</td> <td align="right">System Memory GB:</td>
<td align="left"><input type="number" min="0" id="totalMem" /></td> <td align="left"><input type="number" min="0" id="totalMem" /></td>
</tr> </tr>
<tr>
<td align="right">Remote Storage Capacity GB:</td>
<td align="left"><input type="number" min="0" id="storageCapacity" /></td>
</tr>
<tr>
<td align="right">Remote storage IQN:</td>
<td align="left"><input type="text" id="iqn" /></td>
</tr>
<tr>
<td align="right">Remote storage master drive:</td>
<td align="left"><select id="remoteDrives" /></td>
</tr>
<tr> <tr>
<td align="right">Processor Model:</td> <td align="right">Processor Model:</td>
<td align="left"><select id="procModels" /></td> <td align="left"><select id="procModels" /></td>

View File

@ -39,7 +39,6 @@ const NodeList = React.createClass({
powerOn: function(nodeId) { powerOn: function(nodeId) {
var url = config.url + '/redfish/v1/Nodes/' + nodeId + '/Actions/ComposedNode.Reset' var url = config.url + '/redfish/v1/Nodes/' + nodeId + '/Actions/ComposedNode.Reset'
console.log(nodeId);
$.ajax({ $.ajax({
url: url, url: url,
type: 'POST', type: 'POST',
@ -48,7 +47,6 @@ const NodeList = React.createClass({
}, },
data: JSON.stringify({"ResetType": "On"}), data: JSON.stringify({"ResetType": "On"}),
success: function(resp) { success: function(resp) {
console.log(resp);
this.props.onUpdateNodes(); this.props.onUpdateNodes();
}.bind(this), }.bind(this),
error: function(xhr, status, err) { error: function(xhr, status, err) {