From 4831fc79a9c3ab4a4e4d081ed496c4def05c6ff3 Mon Sep 17 00:00:00 2001 From: Nate Potter Date: Wed, 12 Oct 2016 14:00:22 -0700 Subject: [PATCH] Add storage options to compose menu This commit adds options in the compose menu to specify required storage capacity, an iqn (perhaps this could be randomized) and a master drive, all of which are required when sectioning off new storage for a composed node. Change-Id: Idc605d165ce6028252049681bd5bbde8abe8853e Partial-bug: #1630811 --- valence/ui/src/js/components/Layout.js | 50 ++++++++++++++ .../src/js/components/home/ComposeDisplay.js | 68 ++++++++----------- valence/ui/src/js/components/home/NodeList.js | 2 - 3 files changed, 80 insertions(+), 40 deletions(-) diff --git a/valence/ui/src/js/components/Layout.js b/valence/ui/src/js/components/Layout.js index 4d5807c..ae42efc 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 3c9e6d6..0eddaba 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'; @@ -38,46 +28,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); }, @@ -103,6 +83,18 @@ const ComposeDisplay = React.createClass({ System Memory GB: + + Remote Storage Capacity GB: + + + + Remote storage IQN: + + + + Remote storage master drive: + diff --git a/valence/ui/src/js/components/home/NodeList.js b/valence/ui/src/js/components/home/NodeList.js index f030db5..5663c2f 100644 --- a/valence/ui/src/js/components/home/NodeList.js +++ b/valence/ui/src/js/components/home/NodeList.js @@ -39,7 +39,6 @@ const NodeList = React.createClass({ powerOn: function(nodeId) { var url = config.url + '/redfish/v1/Nodes/' + nodeId + '/Actions/ComposedNode.Reset' - console.log(nodeId); $.ajax({ url: url, type: 'POST', @@ -48,7 +47,6 @@ const NodeList = React.createClass({ }, data: JSON.stringify({"ResetType": "On"}), success: function(resp) { - console.log(resp); this.props.onUpdateNodes(); }.bind(this), error: function(xhr, status, err) {