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

BD Modifications to add Storage Volume resource management #156

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

Conversation

bd-sary-alfaro
Copy link

Adding:

  • data_source_storage_volume.go
  • oneview/resource_storage_volume.go

Modifies

  • Setting values as Deprecated to avoid error on importing logical enclosure groups

if deploymentManagerSetting["deployment_cluster_uri"] != nil {
deploymentClusterUri = utils.NewNstring(deploymentManagerSetting["deployment_cluster_uri"].(string))
}
deploymentClusterUri := utils.NewNstring(deploymentManagerSetting["deployment_cluster_uri"].(string))

Choose a reason for hiding this comment

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

var deploymentClusterUri should be deploymentClusterURI

if deploymentManagerSetting["deployment_cluster_uri"] != nil {
deploymentClusterUri = utils.NewNstring(deploymentManagerSetting["deployment_cluster_uri"].(string))
}
deploymentClusterUri := utils.NewNstring(deploymentManagerSetting["deployment_cluster_uri"].(string))

Choose a reason for hiding this comment

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

var deploymentClusterUri should be deploymentClusterURI


@output.puts <<EOF
}%%
EOF

Choose a reason for hiding this comment

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

Naming/HeredocDelimiterNaming: Use meaningful heredoc delimiters.

properties.each { |x| generate_machine( x, x ) }

@output.puts <<EOF
}%%

Choose a reason for hiding this comment

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

Layout/IndentHeredoc: Use 2 spaces for indentation in a heredoc by using <<~ instead of <<.


EOF

properties.each { |x| generate_machine( x, x ) }

Choose a reason for hiding this comment

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

Layout/SpaceInsideParens: Space inside parentheses detected.

%%{
machine #{machine_name};

EOF

Choose a reason for hiding this comment

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

Naming/HeredocDelimiterNaming: Use meaningful heredoc delimiters.


%%{
machine #{machine_name};

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

desc_width -= (range_width - RANGE_WIDTH) if range_width > RANGE_WIDTH

if desc.size > desc_width
desc = desc[0..desc_width - 4] + "..."

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

desc_width = TOTAL_WIDTH - RANGE_WIDTH - 11
desc_width -= (range_width - RANGE_WIDTH) if range_width > RANGE_WIDTH

if desc.size > desc_width

Choose a reason for hiding this comment

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

Style/IfUnlessModifier: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.

#raise "Invalid encoding of range #{range}: #{codes.inspect}" unless
# is_valid? range, desc, codes

range_width = codes.map { |a| a.size }.max

Choose a reason for hiding this comment

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

Style/SymbolProc: Pass &:size as an argument to map instead of a block.


codes = (@encoding == :ucs4) ? to_ucs4(range) : to_utf8(range)

#raise "Invalid encoding of range #{range}: #{codes.inspect}" unless

Choose a reason for hiding this comment

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

Layout/LeadingCommentSpace: Missing space after #.
Layout/TrailingWhitespace: Trailing whitespace detected.

@output.puts " #{name} = "
each_alpha( @chart_url, property ) do |range, desc|

codes = (@encoding == :ucs4) ? to_ucs4(range) : to_utf8(range)

Choose a reason for hiding this comment

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

Style/TernaryParentheses: Omit parentheses for ternary conditions.

pipe = " "
@output.puts " #{name} = "
each_alpha( @chart_url, property ) do |range, desc|

Choose a reason for hiding this comment

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

Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.

def generate_machine( name, property )
pipe = " "
@output.puts " #{name} = "
each_alpha( @chart_url, property ) do |range, desc|

Choose a reason for hiding this comment

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

Layout/SpaceInsideParens: Space inside parentheses detected.

# Generate the state maching to stdout

def generate_machine( name, property )
pipe = " "

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

##
# Generate the state maching to stdout

def generate_machine( name, property )

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for generate_machine is too high. [26.87/15]
Metrics/MethodLength: Method has too many lines. [20/10]
Layout/SpaceInsideParens: Space inside parentheses detected.

range_count = range.end - range.begin + 1

sum = codes.inject(0) { |acc, elt| acc + count_codepoints(elt) }
sum == spec_count and sum == range_count

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 and.

ret.flatten!
end

def to_utf8( range )

Choose a reason for hiding this comment

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

Layout/SpaceInsideParens: Space inside parentheses detected.

###
# Don't generate last range if it is covered by first range

ret << build_range(b + "00" * left, stop) unless b == "FF"

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


###
# Don't generate last range if it is covered by first range

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

if a.hex+1 != b.hex
max = to_hex(b.hex - 1)
max = "FF" if b == "FF"
ret << "0x#{to_hex(a.hex+1)}..0x#{max} " + "0x00..0xFF " * left

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Surrounding space missing for operator +.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


if a.hex+1 != b.hex
max = to_hex(b.hex - 1)
max = "FF" if b == "FF"

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

###
# Only generate middle range if need be.

if a.hex+1 != b.hex

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Surrounding space missing for operator +.

# 0x560000 .. 0x56789A

ret = []
ret << build_range(start, a + "FF" * left)

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

# Unshared prefix, end of run

return ["0x#{a}..0x#{b} "] if left.zero?

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

def build_range( start, stop )
size = start.size/2
left = size - 1
return [""] if size < 1

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end

def build_range( start, stop )
size = start.size/2

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Surrounding space missing for operator /.

r = y << 6 | z
elsif n <= 0xefffff
x = (n >> 16) & 0x0f
y = (n >> 8) & 0x3f

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Operator >> should be surrounded by a single space.
Layout/ExtraSpacing: Unnecessary spacing detected.

to_hex(r)
end

def from_utf8_enc( n )

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for from_utf8_enc is too high. [35.57/15]
Metrics/MethodLength: Method has too many lines. [21/10]
Layout/SpaceInsideParens: Space inside parentheses detected.
Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

elsif n <= 0x10ffff
w = 0xf0 | (n >> 18)
x = 0x80 | (n >> 12) & 0x3f
y = 0x80 | (n >> 6) & 0x3f

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Operator >> should be surrounded by a single space.
Layout/ExtraSpacing: Unnecessary spacing detected.

r = y << 8 | z
elsif n <= 0xffff
x = 0xe0 | (n >> 12)
y = 0x80 | (n >> 6) & 0x3f

Choose a reason for hiding this comment

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

Layout/SpaceAroundOperators: Operator >> should be surrounded by a single space.
Layout/ExtraSpacing: Unnecessary spacing detected.


UTF8_BOUNDARIES = [0x7f, 0x7ff, 0xffff, 0x10ffff]

def to_utf8_enc( n )

Choose a reason for hiding this comment

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

Metrics/AbcSize: Assignment Branch Condition size for to_utf8_enc is too high. [40.69/15]
Metrics/MethodLength: Method has too many lines. [20/10]
Layout/SpaceInsideParens: Space inside parentheses detected.
Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.

# 0x800 - 0xffff -> 1110xxxx[4] 10yyyyyy[6] 10zzzzzz[6]
# 0x010000 - 0x10ffff -> 11110www[3] 10xxxxxx[6] 10yyyyyy[6] 10zzzzzz[6]

UTF8_BOUNDARIES = [0x7f, 0x7ff, 0xffff, 0x10ffff]

Choose a reason for hiding this comment

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

Style/MutableConstant: Freeze mutable objects assigned to constants.

# 0x00 - 0x7f -> 0zzzzzzz[7]
# 0x80 - 0x7ff -> 110yyyyy[5] 10zzzzzz[6]
# 0x800 - 0xffff -> 1110xxxx[4] 10yyyyyy[6] 10zzzzzz[6]
# 0x010000 - 0x10ffff -> 11110www[3] 10xxxxxx[6] 10yyyyyy[6] 10zzzzzz[6]

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

def to_ucs4( range )
rangestr = "0x" + to_hex(range.begin)
rangestr << "..0x" + to_hex(range.end) if range.begin != range.end
[ rangestr ]

Choose a reason for hiding this comment

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

Layout/SpaceInsideArrayLiteralBrackets: Do not use space inside array brackets.


def to_ucs4( range )
rangestr = "0x" + to_hex(range.begin)
rangestr << "..0x" + to_hex(range.end) if range.begin != range.end

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

# UCS4 is just a straight hex conversion of the unicode codepoint.

def to_ucs4( range )
rangestr = "0x" + to_hex(range.begin)

Choose a reason for hiding this comment

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

Layout/ExtraSpacing: Unnecessary spacing detected.
Layout/SpaceAroundOperators: Operator = should be surrounded by a single space.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

open( url ) do |file|
file.each_line do |line|
next if line =~ /^#/;
next if line !~ /; #{property} #/;

Choose a reason for hiding this comment

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

Style/Semicolon: Do not use semicolons to terminate expressions.

def each_alpha( url, property )
open( url ) do |file|
file.each_line do |line|
next if line =~ /^#/;

Choose a reason for hiding this comment

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

Style/Semicolon: Do not use semicolons to terminate expressions.

# range and description.

def each_alpha( url, property )
open( url ) do |file|

Choose a reason for hiding this comment

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

Security/Open: The use of Kernel#open is a serious security risk.
Layout/SpaceInsideParens: Space inside parentheses detected.

# Downloads the document at url and yields every alpha line's hex
# range and description.

def each_alpha( url, property )

Choose a reason for hiding this comment

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

Metrics/MethodLength: Method has too many lines. [14/10]
Layout/SpaceInsideParens: Space inside parentheses detected.
Layout/TrailingWhitespace: Trailing whitespace detected.

properties = o
end
opts.on("-o", "--output FILE", "output file") do |o|
@output = File.new(o, "w+")

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

opts.on("-p", "--properties x,y,z", Array, "Properties to add to machine") do |o|
properties = o
end
opts.on("-o", "--output FILE", "output file") do |o|

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

opts.on("-m", "--machine MACHINE_NAME", "Machine name") do |o|
machine_name = o
end
opts.on("-p", "--properties x,y,z", Array, "Properties to add to machine") do |o|

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [83/80]

opts.on("-u", "--url URL", "URL to process") do |o|
@chart_url = o
end
opts.on("-m", "--machine MACHINE_NAME", "Machine name") do |o|

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

exit
end
opts.on("-u", "--url URL", "URL to process") do |o|
@chart_url = o

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

puts opts
exit
end
opts.on("-u", "--url URL", "URL to process") do |o|

Choose a reason for hiding this comment

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

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

# -o, --output Write output to file
#
# Updated by: Marty Schoch <[email protected]>
#

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

@@ -0,0 +1,335 @@
#!/usr/bin/env ruby

Choose a reason for hiding this comment

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

Lint/ScriptPermission: Script file unicode2ragel.rb doesn't have execute permission.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.


@output.puts <<EOF
}%%
EOF

Choose a reason for hiding this comment

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

Naming/HeredocDelimiterNaming: Use meaningful heredoc delimiters.

properties.each { |x| generate_machine( x, x ) }

@output.puts <<EOF
}%%

Choose a reason for hiding this comment

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

Layout/IndentHeredoc: Use 2 spaces for indentation in a heredoc by using <<~ instead of <<.


EOF

properties.each { |x| generate_machine( x, x ) }

Choose a reason for hiding this comment

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

Layout/SpaceInsideParens: Space inside parentheses detected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants