Skip to content

Commit

Permalink
UI for node allocation from Intel Rackscale systems
Browse files Browse the repository at this point in the history
  - 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
  • Loading branch information
mmnelemane committed Oct 19, 2016
1 parent 3ffdbf2 commit 8e9db87
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 42 deletions.
120 changes: 78 additions & 42 deletions crowbar_framework/app/controllers/intelrsd_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,32 @@
# where the data model is employed.
#

class IntelRSDController < ApplicationController
attr_reader :logger, :insecure

def initialize
host = ENV["CROWBAR_REDFISH_HOST"] || "localhost"
port = ENV["CROWBAR_REDFISH_PORT"] || "8443"
@redfish_client = RedfishHelper::RedfishClient.new(host, port)
@node_object_list = []
class RsdController < ApplicationController
attr_reader :redfish_client, :logger

# Client setup for the class
host = ENV["CROWBAR_REDFISH_HOST"] || "localhost"
port = ENV["CROWBAR_REDFISH_PORT"] || "8443"
@redfish_client = RedfishHelper::RedfishClient.new(host, port)

def show
@title = "Welcome to RackScale Design"
sys_list = get_all_systems
@rsd_systems = "Systems not Available"
unless sys_list.empty?
@rsd_systems = sys_list
end
end

def allocate
all_sys_list = get_systems
all_sys_list.each do |sys_id|
next unless params[sys_id.to_s] == "1"
node = get_crowbar_node_object(sys_id)
node.allocate
node.set_state("ready")
end
redirect_to rsd_show_path, notice: "Selected nodes allocated as compute nodes"
end

def get_system_resource_list(sys_id, resource)
Expand All @@ -64,6 +82,36 @@ def make_node_object_for_system(sys_id)
nodeobject
end

def get_processors(sys_id)
proc_list = get_system_resource_list(sys_id, "Processors")
processors = []
proc_list.each do |proc|
proc_object = Hash.new
proc_object["Model"] = proc["Model"]
proc_object["Manufacturer"] = proc["Manufacturer"]
proc_object["Architecture"] = proc["Architecture"]
proc_object["TotalCores"] = proc["TotalCores"]
proc_object["TotalThreads"] = proc["TotalThreads"]
processors.push(proc_object)
end
processors
end

def get_memory(sys_id)
mem_list = get_system_resource_list(sys_id, "Memory")
memories = []
mem_list.each do |mem|
mem_object = Hash.new
mem_object["MemoryType"] = mem["MemoryType"]
mem_object["CapacityMB"] = mem["CapacityMiB"]
mem_object["Speed"] = mem["OperatingSpeedMHz"]
mem_object["Size"] = mem["SizeMiB"]
mem_object["Health"] = mem["Health"]
memories.push(mem_object)
end
memories
end

def get_systems
@systems = @redfish_client.get_resource("Systems")
sys_list = []
Expand All @@ -86,22 +134,28 @@ def get_system_data(sys_id)
system_data
end

def get_rsd_nodes
system_list = get_systems
system_list.each do |system|
node_object = make_node_object_for_system(system)
@node_object_list.push(node_object)
def get_all_systems
sys_list = get_systems
all_systems = []
sys_list.each do |sys_id|
sys_object = Hash.new
sys_object["SystemId"] = sys_id
sys_object["Processors"] = get_processors(sys_id)
sys_object["Memory"] = get_memory(sys_id)
all_systems.push(sys_object)
end
@node_object_list
all_systems
end

def get_crowbar_node_object(sys_id)
system_object = get_system_data(sys_id)
node_name_prefix = "d"
node_name_prefix = "IRSD" if system_object["Oem"].key?("Intel_RackScale")
node_name_prefix = "IRSD-" if system_object["Oem"].key?("Intel_RackScale")

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

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

Expand All @@ -110,15 +164,16 @@ def get_crowbar_node_object(sys_id)
node.set["rackscale"] = true
# track the rackscale id for this node
node.set["rackscale_id"] = sys_id
node.set["target_cpu"] = ""
node.set["target_cpu"] = "x86_64"
node.set["target_vendor"] = "suse"
node.set["host_cpu"] = ""
node.set["host_cpu"] = system_object["ProcessorSummary"]["Model"]
node.set["host_vendor"] = "suse"
node.set["kernel"] = "" # Kernel modules and configurations
node.set["counters"] = "" # various network interfaces and other counters
node.set["hostname"] = node_name
node.set["fqdn"] = "#{node_name}.#{Crowbar::Settings.domain}"
node.set["domain"] = Crowbar::Settings.domain

ipaddress_data = eth_interface["IPv4Addresses"].first
node.set["ipaddress"] = ipaddress_data["Address"]
node.set["macaddress"] = eth_interface["MACAddress"]
Expand All @@ -131,7 +186,7 @@ def get_crowbar_node_object(sys_id)
node.set["roles"] = []
["deployer-config-default", "network-config-default", "dns-config-default",
"logging-config-default", "ntp-config-default",
"provisioner-base", "provisioner-config-default"].each do |role_name|
"provisioner-base", "provisioner-config-default", "nova-compute"].each do |role_name|
node["roles"] << role_name
end

Expand All @@ -143,25 +198,15 @@ def get_crowbar_node_object(sys_id)
node.set["virtualization"]["role"] = "guest"
node.set["platform"] = "suse"
node.set["platform_version"] = "12.1"
node.set["dmi"]["bios"]["all_records"] = ""
node.set["dmi"]["bios"]["vendor"] = ""
node.set["dmi"]["bios"]["version"] = system_object["BiosVersion"]
node.set["dmi"]["bios"]["release_date"] = ""
node.set["dmi"]["bios"]["address"] = ""
node.set["dmi"]["bios"]["runtime_size"] = ""
node.set["dmi"]["bios"]["rom_size"] = ""
node.set["dmi"]["bios"]["bios_revision"] = ""
node.set["dmi"]["system"]["product_name"] = system_object["Model"]
node.set["dmi"]["system"]["manufacturer"] = ""
node.set["dmi"]["system"]["serial_number"] = "Not Specified"
node.set["dmi"]["system"]["uuid"] = ""
node.set["dmi"]["system"]["manufacturer"] = system_object["Manufacturer"]
node.set["dmi"]["system"]["serial_number"] = system_object["SerialNumber"]
node.set["dmi"]["system"]["uuid"] = system_object["UUID"]
node.set["dmi"]["system"]["wake_up_type"] = "Power Switch"
node.set["dmi"]["system"]["sku_number"] = "Not Specified"
node.set["dmi"]["system"]["family"] = "Not Specified"
node.set["dmi"]["chassis"]["serial_number"] = system_object["SerialNumber"]
node.set["dmi"]["chassis"]["all_records"] = ""
node.set["dmi"]["chassis"]["manufacturer"] = ""
node.set["dmi"]["chassis"]["all_records"] = ""
node.set["dmi"]["chassis"]["boot_up_state"] = "Safe"
node.set["dmi"]["chassis"]["power_supply_state"] = "Safe"
# this is needed so its counted properly for the UI
Expand All @@ -185,15 +230,6 @@ def get_crowbar_node_object(sys_id)

node.set["filesystem"]["sysfs"] = ""
node.save
node.allocate
node.set_state("ready")
node
end
end

# run it on a thread to not block the UI at the start
Thread.new do
rsd_controller = IntelRSDController.new
node_list = rsd_controller.get_systems
first_node = node_list.first
rsd_controller.get_crowbar_node_object(first_node)
end
32 changes: 32 additions & 0 deletions crowbar_framework/app/views/rsd/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.row
.col-xs-12
%h1.page-header
= t(".title")

.row
.col-xs-12
.panel.panel-default
.panel-body
.alert.alert-info
= t(".rsd_header")

= form_for :node, :url => rsd_allocate_path, :html => { :role => "form" } do |f|
= hidden_field_tag "return", @allocated
.panel.panel-default#accordion
%h2
= t(".sys_header")
.panel-panel-body
%table.table.table-hover.table-middle{ :style => "border: 1px; width: 100%" }
%thead
%tr
%th
= t(".rsd_selection")
%th
= t(".system_id")
%tbody
- @rsd_systems.each do |rsd_system|
%tr
%td= check_box_tag "#{rsd_system['SystemId']}"
%td= link_to("System-#{rsd_system['SystemId']}")
.btn-group.pull-right
%input.btn.btn-default{ :type => "submit", :name => "allocate", :value => t(".allocate_switch") }
36 changes: 36 additions & 0 deletions crowbar_framework/config/locales/intel_rsd/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#
# Copyright 2016, SUSE LINUX GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

en:
nav:
utils:
rsd: 'Intel RackScale'
rsd:
show:
title: 'Intel Rackscale'
rsd_header: 'Lists Systems available from Intel RackScale server by talking to the Redfish APIs'
man_header: 'Managers'
sys_header: 'Systems'
sw_header: 'Switches'
ch_header: 'Chassis'
allocate_switch: 'Allocate'
rsd_selection: 'Selection'
system_id: 'System ID'
barclamp:
rsd:
login:
provide_creds: 'Please provide Rackscale login credentials.'
please_login: 'No active Rackscale session; please login.'
1 change: 1 addition & 0 deletions crowbar_framework/config/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
level2.item :repositories, t("nav.utils.repositories"), repositories_path
level2.item :backup, t("nav.utils.backup"), backups_path
level2.item :logs, t("nav.utils.logs"), utils_path
level2.item :rsd, t("nav.utils.rsd"), rsd_show_path
end
end
end
18 changes: 18 additions & 0 deletions crowbar_framework/config/routes.d/intel-rsd.routes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2016, SUSE LINUX GmbH
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

get 'rsd/show' => 'rsd#show', as: 'rsd_show'
post 'rsd/allocate' => 'rsd#allocate', as: 'rsd_allocate'
6 changes: 6 additions & 0 deletions intelrsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,9 @@ crowbar:
run_order: 112
chef_order: 112
proposal_schema_version: 3

nav:
utils:
rsd:
order: 91
route: 'rsd_edit_path'

0 comments on commit 8e9db87

Please sign in to comment.