Skip to content

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

Open
mmnelemane wants to merge 5 commits intocrowbar:masterfrom
mmnelemane:rsd_integration
Open

UI and controller to interact with Rackscale simulator APIs.#711
mmnelemane wants to merge 5 commits intocrowbar:masterfrom
mmnelemane:rsd_integration

Conversation

@mmnelemane
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?

@mmnelemane mmnelemane force-pushed the rsd_integration branch 4 times, most recently from f19f2ec to 8e9db87 Compare October 19, 2016 09:39
# 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?
Copy link
Copy Markdown

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?
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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])
Copy link
Copy Markdown

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])
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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?
Copy link
Copy Markdown

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?
Copy link
Copy Markdown

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?
return `dnsdomainname`.strip
return %x{dnsdomainname}.strip
Copy link
Copy Markdown

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)

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
Copy link
Copy Markdown

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)


module Crowbar
class Settings

Copy link
Copy Markdown

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.

Comment thread crowbar_framework/config/routes.rb Outdated
end
# Install route from each barclamp
Rails.root.join("config", "routes.d").children.each do |routes|
eval(routes.read, binding) if routes.extname == ".routes"
Copy link
Copy Markdown

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.

Comment thread crowbar_framework/config/routes.rb Outdated
end
end
# Install route from each barclamp
Rails.root.join("config", "routes.d").children.each do |routes|
Copy link
Copy Markdown

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)

addresses.push address if ip_addr.ipv6?
else
next unless ip_addr.ipv4?
addresses.push address if ip_addr.ipv4?
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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?
Copy link
Copy Markdown

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)

end

false
return false
Copy link
Copy Markdown

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

false
return false
Copy link
Copy Markdown

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

false
return false
Copy link
Copy Markdown

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)

if value.length>63 || value.length+domain.length>254
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}"
Copy link
Copy Markdown

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)

# 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)
Copy link
Copy Markdown

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"
Copy link
Copy Markdown

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"
Copy link
Copy Markdown

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
Copy link
Copy Markdown

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)
Copy link
Copy Markdown

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