diff --git a/valence/ui/src/js/components/Layout.js b/valence/ui/src/js/components/Layout.js index f605b05..a705532 100644 --- a/valence/ui/src/js/components/Layout.js +++ b/valence/ui/src/js/components/Layout.js @@ -17,6 +17,7 @@ const Layout = React.createClass({ racks: [], systems: [], storage: [], + processors: [], nodes: [] }; }, @@ -25,6 +26,7 @@ const Layout = React.createClass({ this.getPods(); this.getRacks(); this.getSystems(); + this.getProcessors(); this.getStorage(); this.getNodes(); }, @@ -48,6 +50,9 @@ const Layout = React.createClass({ }, displayCompose: function() { + this.getProcessors(); + this.getStorage(); + this.fillComposeForms(); this.setState({ homeDisplay: "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() { util.getPods(this.setPods); }, @@ -80,6 +122,14 @@ const Layout = React.createClass({ this.setState({systems: systems}); }, + getProcessors: function() { + util.getProcessors(this.state.systems, this.setProcessors); + }, + + setProcessors: function(processors) { + this.setState({processors: processors}); + }, + getStorage: function() { util.getStorage(this.setStorage); }, diff --git a/valence/ui/src/js/components/home/ComposeDisplay.js b/valence/ui/src/js/components/home/ComposeDisplay.js index 68d46cb..32230dc 100644 --- a/valence/ui/src/js/components/home/ComposeDisplay.js +++ b/valence/ui/src/js/components/home/ComposeDisplay.js @@ -5,16 +5,6 @@ var util = require('../../util.js'); const ComposeDisplay = React.createClass({ - getInitialState: function() { - return { - processors: [] - }; - }, - - componentDidMount() { - this.getProcessors(); - }, - compose: function() { var data = this.prepareRequest(); 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() { var name = document.getElementById('name').value; var description = document.getElementById('description').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; - if (procModel == "") { - procModel = null; - } var data = { "Name": name, "Description": description, "Memory": [{ "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); }, @@ -110,6 +90,18 @@ const ComposeDisplay = React.createClass({