Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI and controller to interact with Rackscale simulator APIs. #711

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mmnelemane
Copy link
Contributor

@mmnelemane mmnelemane commented Oct 10, 2016

Provides a basic UI interface for RackScale systems:

  • Lists all the available Systems with their System IDs as a table of check-boxes
  • The UI allows the user to select one or more systems in the list for allocation
  • Clicking on the Allocate button creates a basic node object based on the data obtained through Redfish APIs from the RackScale simulator
  • The Nodes/Dashboard screen displays the list of allocated nodes and some basic info on the node.

NOTE: The UI need not be final and only done for easier test and a basic demo.

Here are a few sample screen-shot.
screenshot_20161010_110908
screenshot_20161010_111006
screenshot_20161010_111030

This PR depends on #693

Copy link
Member

@Itxaka Itxaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!


def show
@title = "Welcome to RackScale Design"
@redfish_client = RedfishHelper::RedfishClient.new('10.160.66.119', '8443')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can initialise the client as part of the class so we dont have to create a client per method?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, missing getting the host+port from env variables.

@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}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails.logger instead of p?

# consider some better cache/expiration strategy.
if @@domain.nil?
dns_proposal = Proposal.where(barclamp: "dns", name: "default").first
@@domain = dns_proposal[:attributes][:dns][:domain] unless dns_proposal.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)

# consider some better cache/expiration strategy.
if @@domain.nil?
dns_proposal = Proposal.where(barclamp: "dns", name: "default").first
@@domain = dns_proposal[:attributes][:dns][:domain] unless dns_proposal.nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)


module Crowbar
class Settings
@@domain = nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)


module Crowbar
class Settings
@@domain = nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/ClassVars: Replace class var @@Domain with a class instance var. (https://github.com/bbatsov/ruby-style-guide#no-class-vars)

end
JSON.load(network_proposal[3])
else
JSON.load(json_path.read)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)

end
JSON.load(network_proposal[3])
else
JSON.load(json_path.read)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)

network_proposal = proposals["proposals"]["records"].detect do |p|
p[1] == "network" && p[2] == "default"
end
JSON.load(network_proposal[3])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)

network_proposal = proposals["proposals"]["records"].detect do |p|
p[1] == "network" && p[2] == "default"
end
JSON.load(network_proposal[3])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security/JSONLoad: Prefer JSON.parse over JSON.load. (http://ruby-doc.org/stdlib-2.3.0/libdoc/json/rdoc/JSON.html#method-i-load)

return "Windows Server 2012" if target_platform == "windows-6.2"
return "Hyper-V Server 2012 R2" if target_platform == "hyperv-6.3"
return "Hyper-V Server 2012" if target_platform == "hyperv-6.2"
return target_platform

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)

return "Windows Server 2012" if target_platform == "windows-6.2"
return "Hyper-V Server 2012 R2" if target_platform == "hyperv-6.3"
return "Hyper-V Server 2012" if target_platform == "hyperv-6.2"
return target_platform

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)

)
end

it "checks for node repositories" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [32/25]

)
end

it "checks for node repositories" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [32/25]

require "spec_helper"

describe Api::UpgradeController, type: :request do
context "with a successful upgrade API request" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [158/25]

require "spec_helper"

describe Api::UpgradeController, type: :request do
context "with a successful upgrade API request" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [158/25]

@@ -0,0 +1,186 @@
require "spec_helper"

describe Api::UpgradeController, type: :request do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [160/25]

@@ -0,0 +1,186 @@
require "spec_helper"

describe Api::UpgradeController, type: :request do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [160/25]

@@ -0,0 +1,36 @@
require "spec_helper"

describe Api::ErrorsController, type: :request do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [26/25]

@@ -0,0 +1,36 @@
require "spec_helper"

describe Api::ErrorsController, type: :request do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [26/25]

require "spec_helper"

describe Api::CrowbarController, type: :request do
context "with a successful crowbar API request" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [66/25]

require "spec_helper"

describe Api::CrowbarController, type: :request do
context "with a successful crowbar API request" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [66/25]

@@ -0,0 +1,79 @@
require "spec_helper"

describe Api::CrowbarController, type: :request do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [68/25]

options[:show] << :bios unless options[:bios].empty?

options = { raid: {}, bios: {}, show: [] }
unless proposals[0]["attributes"].nil? or proposals[0]["attributes"]["crowbar"].nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/AndOr: Use || instead of or. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)

options = { raid: {}, bios: {}, show: [] }

proposals = Proposal.where(barclamp: "crowbar")
raise "Can't find any crowbar proposal" if proposals.nil? or proposals[0].nil?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/AndOr: Use || instead of or. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)

if @@domain.nil?
dns_proposal = Proposal.where(barclamp: "dns", name: "default").first
@@domain = dns_proposal[:attributes][:dns][:domain] unless dns_proposal.nil?
end

if @@domain.nil?
return `dnsdomainname`.strip
return %x{dnsdomainname}.strip

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/CommandLiteral: Use backticks around command string. (https://github.com/bbatsov/ruby-style-guide#percent-x)

@@domain = nil

class << self
def domain
# FIXME: We are using a global here to avoid lookups. We need to
# consider some better cache/expiration strategy.
# NOTE: We are using a global here to avoid lookups. We need to consider some better cache/expiration strategy

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [119/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)

@@ -16,51 +16,39 @@

module Crowbar
class Settings

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/EmptyLinesAroundClassBody: Extra empty line detected at class body beginning.

end
# Install route from each barclamp
Rails.root.join("config", "routes.d").children.each do |routes|
eval(routes.read, binding) if routes.extname == ".routes"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/Eval: The use of eval is a serious security risk.

end
end
# Install route from each barclamp
Rails.root.join("config", "routes.d").children.each do |routes|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/MultilineIfModifier: Favor a normal if-statement over a modifier clause in a multiline statement. (https://github.com/bbatsov/ruby-style-guide#no-multiline-if-modifiers)

else
next unless ip_addr.ipv4?
addresses.push address if ip_addr.ipv4?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/IfInsideElse: Convert if nested inside else to elsif.

# end
#unless ipv6_configured || ipv6_addrs.empty?
# return false
#end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)

# unless ipv6_configured || ipv6_addrs.empty?
# return false
# end
#unless ipv6_configured || ipv6_addrs.empty?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)

@@ -1579,7 +1633,7 @@ def process_raid_boot
return true
end

false
return false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)

@@ -1562,7 +1616,7 @@ def process_raid_member(device, attributes)
end
end

false
return false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)

@@ -1544,7 +1598,7 @@ def process_raid_device(device, attributes)
end
end

false
return false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantReturn: Redundant return detected. (https://github.com/bbatsov/ruby-style-guide#no-explicit-return)

Rails.logger.warn "Alias #{value}.#{domain} FQDN not saved because it exceeded the 63 character length limit or it's length (#{value.length}) will cause the total DNS max of 255 to be exeeded."
raise "#{I18n.t("too_long_dns_alias", scope: "model.node")}: #{value}.#{domain}"
raise "#{I18n.t('too_long_dns_alias', scope: 'model.node')}: #{value}.#{domain}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiteralsInInterpolation: Prefer double-quoted strings inside interpolations. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylestringliteralsininterpolation)

end

# commit current proposal (with the crowbar-upgrade role still assigned to nodes),
# so the recipe is executed when nodes have 'ready' state
proposal_commit("default", false, false)
self.proposal_commit("default", false, false)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/RedundantSelf: Redundant self detected. (https://github.com/bbatsov/ruby-style-guide#no-self-unless-required)

node["crowbar_wall"]["crowbar_upgrade_step"] = "revert_to_ready"
node.save
node.set_state("ready")
if node.state == "crowbar_upgrade"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/Next: Use next to skip iteration. (https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals)

if ssh_status[0] != 200
save_error_state("Failed to reboot the machine. Could not ssh.")
# Join the cluster: start pacemaker and run selected recipes
script = "/usr/sbin/crowbar-post-upgrade.sh"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint/UnreachableCode: Unreachable code detected.

mmnelemane and others added 4 commits December 19, 2016 17:33
  - 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
…ocalhost and default port

On node creation:
 - set the proper node+domain for the node object
 - set the node name to the short name
 - set the fqdn and domain name to the proper ones
 - set the uptime to avoid failure on node details UI
 - set the roles to just names so they are linked to the barclamps
 - set the product name, serial number so they are shown properly in the UI
 - set the disk key for removable so disks are shown properly on the UI
 - count all the memory and aggregate it to be shown on the UI
 - count the processors with an 0 index so they can be shown in the UI
 - allocate the node
 - set the node to ready status

All the node creation changes also fix the node not being shown properly when going to the details
as well as crowbar crashing when moving the node to a different group
 - Store 2 more items in the NodeObject to identify and track the rackscale instances
 - Rewrite the rest-client queries to protect and log http exceptions
 - Create several Power management shortcuts for the RedFish client
 - Create a handler for redfish commands
 - On power management actions, check for rackscale and execute the actions via rest calls
@port = @rsd_server_port
Rails.logger.warn "RackScale Server: #{@host}, Port: #{@port}"
#@redfish_client = RedfishHelper::RedfishClient.new(host, port)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/TrailingWhitespace: Trailing whitespace detected. (https://github.com/bbatsov/ruby-style-guide#no-trailing-whitespace)

@host = @rsd_rest_server
@port = @rsd_server_port
Rails.logger.warn "RackScale Server: #{@host}, Port: #{@port}"
#@redfish_client = RedfishHelper::RedfishClient.new(host, port)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)

 - Added text boxes to edit PSME server IP and port.
@mmnelemane mmnelemane changed the title [NotForMerge]UI to Allocate nodes from Rackscale systems UI and controller to interact with Rackscale simulator APIs. Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

5 participants