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 10, 2016
1 parent 0385ea5 commit afb3a36
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 41 deletions.
128 changes: 87 additions & 41 deletions crowbar_framework/app/controllers/intelrsd_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,36 @@
# where the data model is employed.
#

class IntelRSDController < ApplicationController
class RsdController < 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 = []
# def initialize()
# @redfish_client = RedfishHelper::RedfishClient.new('localhost', '8443')
# @node_object_list = []
# end

def show
@title = "Welcome to RackScale Design"
@redfish_client = RedfishHelper::RedfishClient.new('10.160.66.119', '8443')
sys_list = get_all_systems()
p "SYSTEM LIST: #{sys_list}"
@rsd_systems = "Systems not Available"
unless sys_list.empty?
@rsd_systems = sys_list
end
end

def allocate
@redfish_client = RedfishHelper::RedfishClient.new('10.160.66.119', '8443')
all_sys_list = get_systems()
all_sys_list.each do | sys_id |
if params["#{sys_id}"] == "1"
node = get_crowbar_node_object(sys_id)
node.allocate
node.set_state("ready")
end
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,8 +86,40 @@ def make_node_object_for_system(sys_id)
nodeobject
end

def get_systems
def get_processors(sys_id)
proc_list = get_system_resource_list(sys_id, "Processors")
processors = []
proc_list.each do | proc |
proc_object = Hash.new()
p "PROCESSOR DETAIL: #{proc}"
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")
p "RESOURCE: #{@systems}"
sys_list = []

@systems["Members"].each do |member|
Expand All @@ -86,22 +140,32 @@ 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 = []
p "SYSTEM ID LIST: #{sys_list}"
sys_list.each do | sys_id |
sys_object = Hash.new()
p "READING SYSTEM ID #{sys_id}"
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")

p "SYSTEM OBJECT READ: #{system_object}"

# 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 +174,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 +196,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 +208,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 +240,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
55 changes: 55 additions & 0 deletions crowbar_framework/app/views/rsd/_chassis.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
- @chassisUnits.each do |chassis|
.panel-heading
.pull-right
= icon_tag "collapse-down"

%h2.panel-title
%a{ :href => "##{chassis.attributes["dn"].parameterize}", "data-toggle" => "collapse", "data-parent" => "#accordion" }
DN:
= chassis.attributes["dn"]

.panel-body.panel-collapse.collapse{ :id => chassis.attributes["dn"].parameterize }
- @blades.each do |blade|
- if blade.attributes["chassisId"] == chassis.attributes["id"]
.col-md-4.col-xs-6
%h3.panel-title
= check_box_tag(blade.attributes["dn"])
DN:
= blade.attributes["dn"]

%dl.dl-horizontal
%dt
= t("rsd.edit.profile")
%dd
- if blade.attributes["assignedToDn"].empty?
&mdash;
- else
= blade.attributes["assignedToDn"]
%dt
= t("rsd.edit.label")
%dd
- if blade.attributes["usrLbl"].empty?
&mdash;
- else
= blade.attributes["usrLbl"]
%dt
= t("rsd.edit.model")
%dd
= blade.attributes["model"]

%dt
= t("rsd.edit.memory")
%dd
= number_to_human_size(blade.attributes["availableMemory"].to_i * 1024 * 1024)
\/
= number_to_human_size(blade.attributes["totalMemory"].to_i * 1024 * 1024)
%dt
= t("rsd.edit.cpus")
%dd
= blade.attributes["numOfCpus"]
\/
= blade.attributes["numOfCores"]
%dt
= t("rsd.edit.interfaces")
%dd
= blade.attributes["numOfEthHostIfs"]
44 changes: 44 additions & 0 deletions crowbar_framework/app/views/rsd/_rack.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
- @rackUnits.each do |rackUnit|
.panel-heading
%h2.panel-title
= check_box_tag(rackUnit.attributes["dn"])
DN:
= rackUnit.attributes["dn"]

.panel-body
.col-md-4.col-xs-6
%dl.dl-horizontal
%dt
= t("rsd.edit.profile")
%dd
- if rackUnit.attributes["assignedToDn"].empty?
&mdash;
- else
= rackUnit.attributes["assignedToDn"]
%dt
= t("rsd.edit.label")
%dd
- if rackUnit.attributes["usrLbl"].empty?
&mdash;
- else
= rackUnit.attributes["usrLbl"]
%dt
= t("rsd.edit.model")
%dd
= rackUnit.attributes["model"]
%dt
= t("rsd.edit.memory")
%dd
= number_to_human_size(rackUnit.attributes["availableMemory"].to_i * 1024 * 1024)
\/
= number_to_human_size(rackUnit.attributes["totalMemory"].to_i * 1024 * 1024)
%dt
= t("rsd.edit.cpus")
%dd
= rackUnit.attributes["numOfCpus"]
\/
= rackUnit.attributes["numOfCores"]
%dt
= t("rsd.edit.interfaces")
%dd
= rackUnit.attributes["numOfEthHostIfs"]
48 changes: 48 additions & 0 deletions crowbar_framework/app/views/rsd/edit.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
.row
.col-xs-12
%h1.page-header
= t(".title")

.btn-group.pull-right
= link_to t(".show"), rsd_show_path, :class => "btn btn-default"

= form_tag(rsd_update_path) do
.panel.panel-default#accordion
= render "chassis"
= render "rack"

.panel-footer.text-right
- if @compute == true
%label.radio-inline
= radio_button_tag :updateAction, "compute"
= t(".compute_node")
- else
%label.radio-inline{ :title => t(".missing_profile", :profile => @compute_service_profile) }
= radio_button_tag :updateAction, "compute", false, :disabled => true
= t(".compute_node")

- if @storage == true
%label.radio-inline
= radio_button_tag :updateAction, "storage"
= t(".storage_node")
- else
%label.radio-inline{ :title => t(".missing_profile", :profile => @storage_service_profile) }
= radio_button_tag :updateAction, "storage", false, :disabled => true
= t(".storage_node")

%label.radio-inline
= radio_button_tag(:updateAction, "reboot")
= t(".reboot")

%label.radio-inline
= radio_button_tag(:updateAction, "up")
= t(".powerup")

%label.radio-inline
= radio_button_tag(:updateAction, "down")
= t(".powerdown")

&nbsp;

.btn-group
%input.btn.btn-default{ :type => "submit", :name => "submit", :value => t(".apply") }
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") }
Loading

0 comments on commit afb3a36

Please sign in to comment.