Skip to content

Commit f19f2ec

Browse files
committed
UI for node allocation from Intel Rackscale systems
- Lists available systems from Rackscale Simulator - Allows selection of specific systems for allocation - Creates a node object and allocates the same as a crowbar node - Also refined the controller to obtain system-specific info - UI contains only a list of check-boxes and one Allocate button
1 parent 3ffdbf2 commit f19f2ec

File tree

6 files changed

+172
-42
lines changed

6 files changed

+172
-42
lines changed

crowbar_framework/app/controllers/intelrsd_controller.rb

Lines changed: 79 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,33 @@
3232
# where the data model is employed.
3333
#
3434

35-
class IntelRSDController < ApplicationController
36-
attr_reader :logger, :insecure
37-
38-
def initialize
39-
host = ENV["CROWBAR_REDFISH_HOST"] || "localhost"
40-
port = ENV["CROWBAR_REDFISH_PORT"] || "8443"
41-
@redfish_client = RedfishHelper::RedfishClient.new(host, port)
42-
@node_object_list = []
35+
class RsdController < ApplicationController
36+
attr_reader :redfish_client, :logger
37+
38+
# Client setup for the class
39+
host = ENV["CROWBAR_REDFISH_HOST"] || "localhost"
40+
port = ENV["CROWBAR_REDFISH_PORT"] || "8443"
41+
@redfish_client = RedfishHelper::RedfishClient.new(host, port)
42+
43+
def show
44+
@title = "Welcome to RackScale Design"
45+
sys_list = get_all_systems
46+
@rsd_systems = "Systems not Available"
47+
unless sys_list.empty?
48+
@rsd_systems = sys_list
49+
end
50+
end
51+
52+
def allocate
53+
all_sys_list = get_systems
54+
all_sys_list.each do |sys_id|
55+
if params[sys_id.to_s] == "1"
56+
node = get_crowbar_node_object(sys_id)
57+
node.allocate
58+
node.set_state("ready")
59+
end
60+
end
61+
redirect_to rsd_show_path, notice: "Selected nodes allocated as compute nodes"
4362
end
4463

4564
def get_system_resource_list(sys_id, resource)
@@ -64,6 +83,36 @@ def make_node_object_for_system(sys_id)
6483
nodeobject
6584
end
6685

86+
def get_processors(sys_id)
87+
proc_list = get_system_resource_list(sys_id, "Processors")
88+
processors = []
89+
proc_list.each do |proc|
90+
proc_object = Hash.new
91+
proc_object["Model"] = proc["Model"]
92+
proc_object["Manufacturer"] = proc["Manufacturer"]
93+
proc_object["Architecture"] = proc["Architecture"]
94+
proc_object["TotalCores"] = proc["TotalCores"]
95+
proc_object["TotalThreads"] = proc["TotalThreads"]
96+
processors.push(proc_object)
97+
end
98+
processors
99+
end
100+
101+
def get_memory(sys_id)
102+
mem_list = get_system_resource_list(sys_id, "Memory")
103+
memories = []
104+
mem_list.each do |mem|
105+
mem_object = Hash.new
106+
mem_object["MemoryType"] = mem["MemoryType"]
107+
mem_object["CapacityMB"] = mem["CapacityMiB"]
108+
mem_object["Speed"] = mem["OperatingSpeedMHz"]
109+
mem_object["Size"] = mem["SizeMiB"]
110+
mem_object["Health"] = mem["Health"]
111+
memories.push(mem_object)
112+
end
113+
memories
114+
end
115+
67116
def get_systems
68117
@systems = @redfish_client.get_resource("Systems")
69118
sys_list = []
@@ -86,22 +135,28 @@ def get_system_data(sys_id)
86135
system_data
87136
end
88137

89-
def get_rsd_nodes
90-
system_list = get_systems
91-
system_list.each do |system|
92-
node_object = make_node_object_for_system(system)
93-
@node_object_list.push(node_object)
138+
def get_all_systems
139+
sys_list = get_systems
140+
all_systems = []
141+
sys_list.each do |sys_id|
142+
sys_object = Hash.new
143+
sys_object["SystemId"] = sys_id
144+
sys_object["Processors"] = get_processors(sys_id)
145+
sys_object["Memory"] = get_memory(sys_id)
146+
all_systems.push(sys_object)
94147
end
95-
@node_object_list
148+
all_systems
96149
end
97150

98151
def get_crowbar_node_object(sys_id)
99152
system_object = get_system_data(sys_id)
100153
node_name_prefix = "d"
101-
node_name_prefix = "IRSD" if system_object["Oem"].key?("Intel_RackScale")
154+
node_name_prefix = "IRSD-" if system_object["Oem"].key?("Intel_RackScale")
102155

156+
# Pickin up the first IP address. This may not be always the correct address.
157+
# It must be revisited when testing with Rackscale hardware.
103158
eth_interface = system_object["EthernetInterfaces"].first
104-
node_name = node_name_prefix + eth_interface["MACAddress"].tr(":", "-")
159+
node_name = node_name_prefix + eth_interface["MACAddress"].tr(":", "-") + "-#{sys_id}"
105160

106161
node = NodeObject.create_new "#{node_name}.#{Crowbar::Settings.domain}".downcase
107162

@@ -110,15 +165,16 @@ def get_crowbar_node_object(sys_id)
110165
node.set["rackscale"] = true
111166
# track the rackscale id for this node
112167
node.set["rackscale_id"] = sys_id
113-
node.set["target_cpu"] = ""
168+
node.set["target_cpu"] = "x86_64"
114169
node.set["target_vendor"] = "suse"
115-
node.set["host_cpu"] = ""
170+
node.set["host_cpu"] = system_object["ProcessorSummary"]["Model"]
116171
node.set["host_vendor"] = "suse"
117172
node.set["kernel"] = "" # Kernel modules and configurations
118173
node.set["counters"] = "" # various network interfaces and other counters
119174
node.set["hostname"] = node_name
120175
node.set["fqdn"] = "#{node_name}.#{Crowbar::Settings.domain}"
121176
node.set["domain"] = Crowbar::Settings.domain
177+
122178
ipaddress_data = eth_interface["IPv4Addresses"].first
123179
node.set["ipaddress"] = ipaddress_data["Address"]
124180
node.set["macaddress"] = eth_interface["MACAddress"]
@@ -131,7 +187,7 @@ def get_crowbar_node_object(sys_id)
131187
node.set["roles"] = []
132188
["deployer-config-default", "network-config-default", "dns-config-default",
133189
"logging-config-default", "ntp-config-default",
134-
"provisioner-base", "provisioner-config-default"].each do |role_name|
190+
"provisioner-base", "provisioner-config-default", "nova-compute"].each do |role_name|
135191
node["roles"] << role_name
136192
end
137193

@@ -143,25 +199,15 @@ def get_crowbar_node_object(sys_id)
143199
node.set["virtualization"]["role"] = "guest"
144200
node.set["platform"] = "suse"
145201
node.set["platform_version"] = "12.1"
146-
node.set["dmi"]["bios"]["all_records"] = ""
147-
node.set["dmi"]["bios"]["vendor"] = ""
148202
node.set["dmi"]["bios"]["version"] = system_object["BiosVersion"]
149-
node.set["dmi"]["bios"]["release_date"] = ""
150-
node.set["dmi"]["bios"]["address"] = ""
151-
node.set["dmi"]["bios"]["runtime_size"] = ""
152-
node.set["dmi"]["bios"]["rom_size"] = ""
153-
node.set["dmi"]["bios"]["bios_revision"] = ""
154203
node.set["dmi"]["system"]["product_name"] = system_object["Model"]
155-
node.set["dmi"]["system"]["manufacturer"] = ""
156-
node.set["dmi"]["system"]["serial_number"] = "Not Specified"
157-
node.set["dmi"]["system"]["uuid"] = ""
204+
node.set["dmi"]["system"]["manufacturer"] = system_object["Manufacturer"]
205+
node.set["dmi"]["system"]["serial_number"] = system_object["SerialNumber"]
206+
node.set["dmi"]["system"]["uuid"] = system_object["UUID"]
158207
node.set["dmi"]["system"]["wake_up_type"] = "Power Switch"
159208
node.set["dmi"]["system"]["sku_number"] = "Not Specified"
160209
node.set["dmi"]["system"]["family"] = "Not Specified"
161210
node.set["dmi"]["chassis"]["serial_number"] = system_object["SerialNumber"]
162-
node.set["dmi"]["chassis"]["all_records"] = ""
163-
node.set["dmi"]["chassis"]["manufacturer"] = ""
164-
node.set["dmi"]["chassis"]["all_records"] = ""
165211
node.set["dmi"]["chassis"]["boot_up_state"] = "Safe"
166212
node.set["dmi"]["chassis"]["power_supply_state"] = "Safe"
167213
# this is needed so its counted properly for the UI
@@ -185,15 +231,6 @@ def get_crowbar_node_object(sys_id)
185231

186232
node.set["filesystem"]["sysfs"] = ""
187233
node.save
188-
node.allocate
189-
node.set_state("ready")
234+
node
190235
end
191236
end
192-
193-
# run it on a thread to not block the UI at the start
194-
Thread.new do
195-
rsd_controller = IntelRSDController.new
196-
node_list = rsd_controller.get_systems
197-
first_node = node_list.first
198-
rsd_controller.get_crowbar_node_object(first_node)
199-
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.row
2+
.col-xs-12
3+
%h1.page-header
4+
= t(".title")
5+
6+
.row
7+
.col-xs-12
8+
.panel.panel-default
9+
.panel-body
10+
.alert.alert-info
11+
= t(".rsd_header")
12+
13+
= form_for :node, :url => rsd_allocate_path, :html => { :role => "form" } do |f|
14+
= hidden_field_tag "return", @allocated
15+
.panel.panel-default#accordion
16+
%h2
17+
= t(".sys_header")
18+
.panel-panel-body
19+
%table.table.table-hover.table-middle{ :style => "border: 1px; width: 100%" }
20+
%thead
21+
%tr
22+
%th
23+
= t(".rsd_selection")
24+
%th
25+
= t(".system_id")
26+
%tbody
27+
- @rsd_systems.each do |rsd_system|
28+
%tr
29+
%td= check_box_tag "#{rsd_system['SystemId']}"
30+
%td= link_to("System-#{rsd_system['SystemId']}")
31+
.btn-group.pull-right
32+
%input.btn.btn-default{ :type => "submit", :name => "allocate", :value => t(".allocate_switch") }
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Copyright 2016, SUSE LINUX GmbH
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
en:
18+
nav:
19+
utils:
20+
rsd: 'Intel RackScale'
21+
rsd:
22+
show:
23+
title: 'Intel Rackscale'
24+
rsd_header: 'Lists Systems available from Intel RackScale server by talking to the Redfish APIs'
25+
man_header: 'Managers'
26+
sys_header: 'Systems'
27+
sw_header: 'Switches'
28+
ch_header: 'Chassis'
29+
allocate_switch: 'Allocate'
30+
rsd_selection: 'Selection'
31+
system_id: 'System ID'
32+
barclamp:
33+
rsd:
34+
login:
35+
provide_creds: 'Please provide Rackscale login credentials.'
36+
please_login: 'No active Rackscale session; please login.'

crowbar_framework/config/navigation.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
level2.item :repositories, t("nav.utils.repositories"), repositories_path
4040
level2.item :backup, t("nav.utils.backup"), backups_path
4141
level2.item :logs, t("nav.utils.logs"), utils_path
42+
level2.item :rsd, t("nav.utils.rsd"), rsd_show_path
4243
end
4344
end
4445
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#
2+
# Copyright 2016, SUSE LINUX GmbH
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
get 'rsd/show' => 'rsd#show', as: 'rsd_show'
18+
post 'rsd/allocate' => 'rsd#allocate', as: 'rsd_allocate'

intelrsd.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@ crowbar:
2929
run_order: 112
3030
chef_order: 112
3131
proposal_schema_version: 3
32+
33+
nav:
34+
utils:
35+
rsd:
36+
order: 91
37+
route: 'rsd_edit_path'

0 commit comments

Comments
 (0)