id
int32
0
24.9k
repo
stringlengths
5
58
path
stringlengths
9
168
func_name
stringlengths
9
130
original_string
stringlengths
66
10.5k
language
stringclasses
1 value
code
stringlengths
66
10.5k
code_tokens
sequence
docstring
stringlengths
8
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
94
266
1,200
piotrmurach/lex
lib/lex/linter.rb
Lex.Linter.validate_tokens
def validate_tokens(lexer) if lexer.lex_tokens.empty? complain("No token list defined") end if !lexer.lex_tokens.respond_to?(:to_ary) complain("Tokens must be a list or enumerable") end terminals = [] lexer.lex_tokens.each do |token| if !identifier?(token) complain("Bad token name `#{token}`") end if terminals.include?(token) complain("Token `#{token}` already defined") end terminals << token end end
ruby
def validate_tokens(lexer) if lexer.lex_tokens.empty? complain("No token list defined") end if !lexer.lex_tokens.respond_to?(:to_ary) complain("Tokens must be a list or enumerable") end terminals = [] lexer.lex_tokens.each do |token| if !identifier?(token) complain("Bad token name `#{token}`") end if terminals.include?(token) complain("Token `#{token}` already defined") end terminals << token end end
[ "def", "validate_tokens", "(", "lexer", ")", "if", "lexer", ".", "lex_tokens", ".", "empty?", "complain", "(", "\"No token list defined\"", ")", "end", "if", "!", "lexer", ".", "lex_tokens", ".", "respond_to?", "(", ":to_ary", ")", "complain", "(", "\"Tokens must be a list or enumerable\"", ")", "end", "terminals", "=", "[", "]", "lexer", ".", "lex_tokens", ".", "each", "do", "|", "token", "|", "if", "!", "identifier?", "(", "token", ")", "complain", "(", "\"Bad token name `#{token}`\"", ")", "end", "if", "terminals", ".", "include?", "(", "token", ")", "complain", "(", "\"Token `#{token}` already defined\"", ")", "end", "terminals", "<<", "token", "end", "end" ]
Validate provided tokens @api private
[ "Validate", "provided", "tokens" ]
28460ecafb8b92cf9a31e821f9f088c8f7573665
https://github.com/piotrmurach/lex/blob/28460ecafb8b92cf9a31e821f9f088c8f7573665/lib/lex/linter.rb#L43-L61
1,201
piotrmurach/lex
lib/lex/linter.rb
Lex.Linter.validate_states
def validate_states(lexer) if !lexer.state_info.respond_to?(:each_pair) complain("States must be defined as a hash") end lexer.state_info.each do |state_name, state_type| if ![:inclusive, :exclusive].include?(state_type) complain("State type for state #{state_name}" \ " must be :inclusive or :exclusive") end if state_type == :exclusive if !lexer.state_error.key?(state_name) lexer.logger.warn("No error rule is defined " \ "for exclusive state '#{state_name}'") end if !lexer.state_ignore.key?(state_name) lexer.logger.warn("No ignore rule is defined " \ "for exclusive state '#{state_name}'") end end end end
ruby
def validate_states(lexer) if !lexer.state_info.respond_to?(:each_pair) complain("States must be defined as a hash") end lexer.state_info.each do |state_name, state_type| if ![:inclusive, :exclusive].include?(state_type) complain("State type for state #{state_name}" \ " must be :inclusive or :exclusive") end if state_type == :exclusive if !lexer.state_error.key?(state_name) lexer.logger.warn("No error rule is defined " \ "for exclusive state '#{state_name}'") end if !lexer.state_ignore.key?(state_name) lexer.logger.warn("No ignore rule is defined " \ "for exclusive state '#{state_name}'") end end end end
[ "def", "validate_states", "(", "lexer", ")", "if", "!", "lexer", ".", "state_info", ".", "respond_to?", "(", ":each_pair", ")", "complain", "(", "\"States must be defined as a hash\"", ")", "end", "lexer", ".", "state_info", ".", "each", "do", "|", "state_name", ",", "state_type", "|", "if", "!", "[", ":inclusive", ",", ":exclusive", "]", ".", "include?", "(", "state_type", ")", "complain", "(", "\"State type for state #{state_name}\"", "\" must be :inclusive or :exclusive\"", ")", "end", "if", "state_type", "==", ":exclusive", "if", "!", "lexer", ".", "state_error", ".", "key?", "(", "state_name", ")", "lexer", ".", "logger", ".", "warn", "(", "\"No error rule is defined \"", "\"for exclusive state '#{state_name}'\"", ")", "end", "if", "!", "lexer", ".", "state_ignore", ".", "key?", "(", "state_name", ")", "lexer", ".", "logger", ".", "warn", "(", "\"No ignore rule is defined \"", "\"for exclusive state '#{state_name}'\"", ")", "end", "end", "end", "end" ]
Validate provided state names @api private
[ "Validate", "provided", "state", "names" ]
28460ecafb8b92cf9a31e821f9f088c8f7573665
https://github.com/piotrmurach/lex/blob/28460ecafb8b92cf9a31e821f9f088c8f7573665/lib/lex/linter.rb#L66-L88
1,202
Wardrop/Scorched
lib/scorched/response.rb
Scorched.Response.body=
def body=(value) value = [] if !value || value == '' super(value.respond_to?(:each) ? value : [value.to_s]) end
ruby
def body=(value) value = [] if !value || value == '' super(value.respond_to?(:each) ? value : [value.to_s]) end
[ "def", "body", "=", "(", "value", ")", "value", "=", "[", "]", "if", "!", "value", "||", "value", "==", "''", "super", "(", "value", ".", "respond_to?", "(", ":each", ")", "?", "value", ":", "[", "value", ".", "to_s", "]", ")", "end" ]
Automatically wraps the assigned value in an array if it doesn't respond to ``each``. Also filters out non-true values and empty strings.
[ "Automatically", "wraps", "the", "assigned", "value", "in", "an", "array", "if", "it", "doesn", "t", "respond", "to", "each", ".", "Also", "filters", "out", "non", "-", "true", "values", "and", "empty", "strings", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/response.rb#L17-L20
1,203
Wardrop/Scorched
lib/scorched/response.rb
Scorched.Response.finish
def finish(*args, &block) self['Content-Type'] ||= 'text/html;charset=utf-8' @block = block if block if [204, 205, 304].include?(status.to_i) header.delete "Content-Type" header.delete "Content-Length" close [status.to_i, header, []] else [status.to_i, header, body] end end
ruby
def finish(*args, &block) self['Content-Type'] ||= 'text/html;charset=utf-8' @block = block if block if [204, 205, 304].include?(status.to_i) header.delete "Content-Type" header.delete "Content-Length" close [status.to_i, header, []] else [status.to_i, header, body] end end
[ "def", "finish", "(", "*", "args", ",", "&", "block", ")", "self", "[", "'Content-Type'", "]", "||=", "'text/html;charset=utf-8'", "@block", "=", "block", "if", "block", "if", "[", "204", ",", "205", ",", "304", "]", ".", "include?", "(", "status", ".", "to_i", ")", "header", ".", "delete", "\"Content-Type\"", "header", ".", "delete", "\"Content-Length\"", "close", "[", "status", ".", "to_i", ",", "header", ",", "[", "]", "]", "else", "[", "status", ".", "to_i", ",", "header", ",", "body", "]", "end", "end" ]
Override finish to avoid using BodyProxy
[ "Override", "finish", "to", "avoid", "using", "BodyProxy" ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/response.rb#L23-L34
1,204
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.try_matches
def try_matches eligable_matches.each do |match,idx| request.breadcrumb << match catch(:pass) { dispatch(match) return true } request.breadcrumb.pop # Current match passed, so pop the breadcrumb before the next iteration. end response.status = (!matches.empty? && eligable_matches.empty?) ? 403 : 404 end
ruby
def try_matches eligable_matches.each do |match,idx| request.breadcrumb << match catch(:pass) { dispatch(match) return true } request.breadcrumb.pop # Current match passed, so pop the breadcrumb before the next iteration. end response.status = (!matches.empty? && eligable_matches.empty?) ? 403 : 404 end
[ "def", "try_matches", "eligable_matches", ".", "each", "do", "|", "match", ",", "idx", "|", "request", ".", "breadcrumb", "<<", "match", "catch", "(", ":pass", ")", "{", "dispatch", "(", "match", ")", "return", "true", "}", "request", ".", "breadcrumb", ".", "pop", "# Current match passed, so pop the breadcrumb before the next iteration.", "end", "response", ".", "status", "=", "(", "!", "matches", ".", "empty?", "&&", "eligable_matches", ".", "empty?", ")", "?", "403", ":", "404", "end" ]
Tries to dispatch to each eligable match. If the first match _passes_, tries the second match and so on. If there are no eligable matches, or all eligable matches pass, an appropriate 4xx response status is set.
[ "Tries", "to", "dispatch", "to", "each", "eligable", "match", ".", "If", "the", "first", "match", "_passes_", "tries", "the", "second", "match", "and", "so", "on", ".", "If", "there", "are", "no", "eligable", "matches", "or", "all", "eligable", "matches", "pass", "an", "appropriate", "4xx", "response", "status", "is", "set", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L315-L325
1,205
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.dispatch
def dispatch(match) @_dispatched = true target = match.mapping[:target] response.merge! begin if Proc === target instance_exec(&target) else target.call(env.merge( 'SCRIPT_NAME' => request.matched_path.chomp('/'), 'PATH_INFO' => request.unmatched_path[match.path.chomp('/').length..-1] )) end end end
ruby
def dispatch(match) @_dispatched = true target = match.mapping[:target] response.merge! begin if Proc === target instance_exec(&target) else target.call(env.merge( 'SCRIPT_NAME' => request.matched_path.chomp('/'), 'PATH_INFO' => request.unmatched_path[match.path.chomp('/').length..-1] )) end end end
[ "def", "dispatch", "(", "match", ")", "@_dispatched", "=", "true", "target", "=", "match", ".", "mapping", "[", ":target", "]", "response", ".", "merge!", "begin", "if", "Proc", "===", "target", "instance_exec", "(", "target", ")", "else", "target", ".", "call", "(", "env", ".", "merge", "(", "'SCRIPT_NAME'", "=>", "request", ".", "matched_path", ".", "chomp", "(", "'/'", ")", ",", "'PATH_INFO'", "=>", "request", ".", "unmatched_path", "[", "match", ".", "path", ".", "chomp", "(", "'/'", ")", ".", "length", "..", "-", "1", "]", ")", ")", "end", "end", "end" ]
Dispatches the request to the matched target. Overriding this method provides the opportunity for one to have more control over how mapping targets are invoked.
[ "Dispatches", "the", "request", "to", "the", "matched", "target", ".", "Overriding", "this", "method", "provides", "the", "opportunity", "for", "one", "to", "have", "more", "control", "over", "how", "mapping", "targets", "are", "invoked", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L329-L342
1,206
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.matches
def matches @_matches ||= begin to_match = request.unmatched_path to_match = to_match.chomp('/') if config[:strip_trailing_slash] == :ignore && to_match =~ %r{./$} mappings.map { |mapping| mapping[:pattern].match(to_match) do |match_data| if match_data.pre_match == '' if match_data.names.empty? captures = match_data.captures else captures = Hash[match_data.names.map {|v| v.to_sym}.zip(match_data.captures)] captures.each do |k,v| captures[k] = symbol_matchers[k][1].call(v) if Array === symbol_matchers[k] end end Match.new(mapping, captures, match_data.to_s, check_for_failed_condition(mapping[:conditions])) end end }.compact end end
ruby
def matches @_matches ||= begin to_match = request.unmatched_path to_match = to_match.chomp('/') if config[:strip_trailing_slash] == :ignore && to_match =~ %r{./$} mappings.map { |mapping| mapping[:pattern].match(to_match) do |match_data| if match_data.pre_match == '' if match_data.names.empty? captures = match_data.captures else captures = Hash[match_data.names.map {|v| v.to_sym}.zip(match_data.captures)] captures.each do |k,v| captures[k] = symbol_matchers[k][1].call(v) if Array === symbol_matchers[k] end end Match.new(mapping, captures, match_data.to_s, check_for_failed_condition(mapping[:conditions])) end end }.compact end end
[ "def", "matches", "@_matches", "||=", "begin", "to_match", "=", "request", ".", "unmatched_path", "to_match", "=", "to_match", ".", "chomp", "(", "'/'", ")", "if", "config", "[", ":strip_trailing_slash", "]", "==", ":ignore", "&&", "to_match", "=~", "%r{", "}", "mappings", ".", "map", "{", "|", "mapping", "|", "mapping", "[", ":pattern", "]", ".", "match", "(", "to_match", ")", "do", "|", "match_data", "|", "if", "match_data", ".", "pre_match", "==", "''", "if", "match_data", ".", "names", ".", "empty?", "captures", "=", "match_data", ".", "captures", "else", "captures", "=", "Hash", "[", "match_data", ".", "names", ".", "map", "{", "|", "v", "|", "v", ".", "to_sym", "}", ".", "zip", "(", "match_data", ".", "captures", ")", "]", "captures", ".", "each", "do", "|", "k", ",", "v", "|", "captures", "[", "k", "]", "=", "symbol_matchers", "[", "k", "]", "[", "1", "]", ".", "call", "(", "v", ")", "if", "Array", "===", "symbol_matchers", "[", "k", "]", "end", "end", "Match", ".", "new", "(", "mapping", ",", "captures", ",", "match_data", ".", "to_s", ",", "check_for_failed_condition", "(", "mapping", "[", ":conditions", "]", ")", ")", "end", "end", "}", ".", "compact", "end", "end" ]
Finds mappings that match the unmatched portion of the request path, returning an array of `Match` objects, or an empty array if no matches were found. The `:eligable` attribute of the `Match` object indicates whether the conditions for that mapping passed. The result is cached for the life time of the controller instance, for the sake of effecient recalling.
[ "Finds", "mappings", "that", "match", "the", "unmatched", "portion", "of", "the", "request", "path", "returning", "an", "array", "of", "Match", "objects", "or", "an", "empty", "array", "if", "no", "matches", "were", "found", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L349-L369
1,207
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.eligable_matches
def eligable_matches @_eligable_matches ||= begin matches.select { |m| m.failed_condition.nil? }.each_with_index.sort_by do |m,idx| priority = m.mapping[:priority] || 0 media_type_rank = [*m.mapping[:conditions][:media_type]].map { |type| env['scorched.accept'][:accept].rank(type, true) }.max || 0 order = -idx [priority, media_type_rank, order] end.reverse end end
ruby
def eligable_matches @_eligable_matches ||= begin matches.select { |m| m.failed_condition.nil? }.each_with_index.sort_by do |m,idx| priority = m.mapping[:priority] || 0 media_type_rank = [*m.mapping[:conditions][:media_type]].map { |type| env['scorched.accept'][:accept].rank(type, true) }.max || 0 order = -idx [priority, media_type_rank, order] end.reverse end end
[ "def", "eligable_matches", "@_eligable_matches", "||=", "begin", "matches", ".", "select", "{", "|", "m", "|", "m", ".", "failed_condition", ".", "nil?", "}", ".", "each_with_index", ".", "sort_by", "do", "|", "m", ",", "idx", "|", "priority", "=", "m", ".", "mapping", "[", ":priority", "]", "||", "0", "media_type_rank", "=", "[", "m", ".", "mapping", "[", ":conditions", "]", "[", ":media_type", "]", "]", ".", "map", "{", "|", "type", "|", "env", "[", "'scorched.accept'", "]", "[", ":accept", "]", ".", "rank", "(", "type", ",", "true", ")", "}", ".", "max", "||", "0", "order", "=", "-", "idx", "[", "priority", ",", "media_type_rank", ",", "order", "]", "end", ".", "reverse", "end", "end" ]
Returns an ordered list of eligable matches. Orders matches based on media_type, ensuring priority and definition order are respected appropriately. Sorts by mapping priority first, media type appropriateness second, and definition order third.
[ "Returns", "an", "ordered", "list", "of", "eligable", "matches", ".", "Orders", "matches", "based", "on", "media_type", "ensuring", "priority", "and", "definition", "order", "are", "respected", "appropriately", ".", "Sorts", "by", "mapping", "priority", "first", "media", "type", "appropriateness", "second", "and", "definition", "order", "third", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L374-L385
1,208
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.check_for_failed_condition
def check_for_failed_condition(conds) failed = (conds || []).find { |c, v| !check_condition?(c, v) } if failed failed[0] = failed[0][0..-2].to_sym if failed[0][-1] == '!' end failed end
ruby
def check_for_failed_condition(conds) failed = (conds || []).find { |c, v| !check_condition?(c, v) } if failed failed[0] = failed[0][0..-2].to_sym if failed[0][-1] == '!' end failed end
[ "def", "check_for_failed_condition", "(", "conds", ")", "failed", "=", "(", "conds", "||", "[", "]", ")", ".", "find", "{", "|", "c", ",", "v", "|", "!", "check_condition?", "(", "c", ",", "v", ")", "}", "if", "failed", "failed", "[", "0", "]", "=", "failed", "[", "0", "]", "[", "0", "..", "-", "2", "]", ".", "to_sym", "if", "failed", "[", "0", "]", "[", "-", "1", "]", "==", "'!'", "end", "failed", "end" ]
Tests the given conditions, returning the name of the first failed condition, or nil otherwise.
[ "Tests", "the", "given", "conditions", "returning", "the", "name", "of", "the", "first", "failed", "condition", "or", "nil", "otherwise", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L388-L394
1,209
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.check_condition?
def check_condition?(c, v) c = c[0..-2].to_sym if invert = (c[-1] == '!') raise Error, "The condition `#{c}` either does not exist, or is not an instance of Proc" unless Proc === self.conditions[c] retval = instance_exec(v, &self.conditions[c]) invert ? !retval : !!retval end
ruby
def check_condition?(c, v) c = c[0..-2].to_sym if invert = (c[-1] == '!') raise Error, "The condition `#{c}` either does not exist, or is not an instance of Proc" unless Proc === self.conditions[c] retval = instance_exec(v, &self.conditions[c]) invert ? !retval : !!retval end
[ "def", "check_condition?", "(", "c", ",", "v", ")", "c", "=", "c", "[", "0", "..", "-", "2", "]", ".", "to_sym", "if", "invert", "=", "(", "c", "[", "-", "1", "]", "==", "'!'", ")", "raise", "Error", ",", "\"The condition `#{c}` either does not exist, or is not an instance of Proc\"", "unless", "Proc", "===", "self", ".", "conditions", "[", "c", "]", "retval", "=", "instance_exec", "(", "v", ",", "self", ".", "conditions", "[", "c", "]", ")", "invert", "?", "!", "retval", ":", "!", "!", "retval", "end" ]
Test the given condition, returning true if the condition passes, or false otherwise.
[ "Test", "the", "given", "condition", "returning", "true", "if", "the", "condition", "passes", "or", "false", "otherwise", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L397-L402
1,210
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.redirect
def redirect(url, status: (env['HTTP_VERSION'] == 'HTTP/1.1') ? 303 : 302, halt: true) response['Location'] = absolute(url) response.status = status self.halt if halt end
ruby
def redirect(url, status: (env['HTTP_VERSION'] == 'HTTP/1.1') ? 303 : 302, halt: true) response['Location'] = absolute(url) response.status = status self.halt if halt end
[ "def", "redirect", "(", "url", ",", "status", ":", "(", "env", "[", "'HTTP_VERSION'", "]", "==", "'HTTP/1.1'", ")", "?", "303", ":", "302", ",", "halt", ":", "true", ")", "response", "[", "'Location'", "]", "=", "absolute", "(", "url", ")", "response", ".", "status", "=", "status", "self", ".", "halt", "if", "halt", "end" ]
Redirects to the specified path or URL. An optional HTTP status is also accepted.
[ "Redirects", "to", "the", "specified", "path", "or", "URL", ".", "An", "optional", "HTTP", "status", "is", "also", "accepted", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L405-L409
1,211
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.flash
def flash(key = :flash) raise Error, "Flash session data cannot be used without a valid Rack session" unless session flash_hash = env['scorched.flash'] ||= {} flash_hash[key] ||= {} session[key] ||= {} unless session[key].methods(false).include? :[]= session[key].define_singleton_method(:[]=) do |k, v| flash_hash[key][k] = v end end session[key] end
ruby
def flash(key = :flash) raise Error, "Flash session data cannot be used without a valid Rack session" unless session flash_hash = env['scorched.flash'] ||= {} flash_hash[key] ||= {} session[key] ||= {} unless session[key].methods(false).include? :[]= session[key].define_singleton_method(:[]=) do |k, v| flash_hash[key][k] = v end end session[key] end
[ "def", "flash", "(", "key", "=", ":flash", ")", "raise", "Error", ",", "\"Flash session data cannot be used without a valid Rack session\"", "unless", "session", "flash_hash", "=", "env", "[", "'scorched.flash'", "]", "||=", "{", "}", "flash_hash", "[", "key", "]", "||=", "{", "}", "session", "[", "key", "]", "||=", "{", "}", "unless", "session", "[", "key", "]", ".", "methods", "(", "false", ")", ".", "include?", ":[]=", "session", "[", "key", "]", ".", "define_singleton_method", "(", ":[]=", ")", "do", "|", "k", ",", "v", "|", "flash_hash", "[", "key", "]", "[", "k", "]", "=", "v", "end", "end", "session", "[", "key", "]", "end" ]
Flash session storage helper. Stores session data until the next time this method is called with the same arguments, at which point it's reset. The typical use case is to provide feedback to the user on the previous action they performed.
[ "Flash", "session", "storage", "helper", ".", "Stores", "session", "data", "until", "the", "next", "time", "this", "method", "is", "called", "with", "the", "same", "arguments", "at", "which", "point", "it", "s", "reset", ".", "The", "typical", "use", "case", "is", "to", "provide", "feedback", "to", "the", "user", "on", "the", "previous", "action", "they", "performed", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L440-L451
1,212
Wardrop/Scorched
lib/scorched/controller.rb
Scorched.Controller.run_filters
def run_filters(type) halted = false tracker = env['scorched.executed_filters'] ||= {before: Set.new, after: Set.new} filters[type].reject { |f| tracker[type].include?(f) }.each do |f| unless check_for_failed_condition(f[:conditions]) || (halted && !f[:force]) tracker[type] << f halted = true unless run_filter(f) end end !halted end
ruby
def run_filters(type) halted = false tracker = env['scorched.executed_filters'] ||= {before: Set.new, after: Set.new} filters[type].reject { |f| tracker[type].include?(f) }.each do |f| unless check_for_failed_condition(f[:conditions]) || (halted && !f[:force]) tracker[type] << f halted = true unless run_filter(f) end end !halted end
[ "def", "run_filters", "(", "type", ")", "halted", "=", "false", "tracker", "=", "env", "[", "'scorched.executed_filters'", "]", "||=", "{", "before", ":", "Set", ".", "new", ",", "after", ":", "Set", ".", "new", "}", "filters", "[", "type", "]", ".", "reject", "{", "|", "f", "|", "tracker", "[", "type", "]", ".", "include?", "(", "f", ")", "}", ".", "each", "do", "|", "f", "|", "unless", "check_for_failed_condition", "(", "f", "[", ":conditions", "]", ")", "||", "(", "halted", "&&", "!", "f", "[", ":force", "]", ")", "tracker", "[", "type", "]", "<<", "f", "halted", "=", "true", "unless", "run_filter", "(", "f", ")", "end", "end", "!", "halted", "end" ]
Returns false if any of the filters halted the request. True otherwise.
[ "Returns", "false", "if", "any", "of", "the", "filters", "halted", "the", "request", ".", "True", "otherwise", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/controller.rb#L598-L608
1,213
Wardrop/Scorched
lib/scorched/request.rb
Scorched.Request.unescaped_path
def unescaped_path path_info.split(/(%25|%2F)/i).each_slice(2).map { |v, m| URI.unescape(v) << (m || '') }.join('') end
ruby
def unescaped_path path_info.split(/(%25|%2F)/i).each_slice(2).map { |v, m| URI.unescape(v) << (m || '') }.join('') end
[ "def", "unescaped_path", "path_info", ".", "split", "(", "/", "/i", ")", ".", "each_slice", "(", "2", ")", ".", "map", "{", "|", "v", ",", "m", "|", "URI", ".", "unescape", "(", "v", ")", "<<", "(", "m", "||", "''", ")", "}", ".", "join", "(", "''", ")", "end" ]
The unescaped URL, excluding the escaped forward-slash and percent. The resulting string will always be safe to unescape again in situations where the forward-slash or percent are expected and valid characters.
[ "The", "unescaped", "URL", "excluding", "the", "escaped", "forward", "-", "slash", "and", "percent", ".", "The", "resulting", "string", "will", "always", "be", "safe", "to", "unescape", "again", "in", "situations", "where", "the", "forward", "-", "slash", "or", "percent", "are", "expected", "and", "valid", "characters", "." ]
0833a6f9ed9ff42976577e5bbe5f23b7323eacb5
https://github.com/Wardrop/Scorched/blob/0833a6f9ed9ff42976577e5bbe5f23b7323eacb5/lib/scorched/request.rb#L35-L37
1,214
softlayer/softlayer-ruby
lib/softlayer/Server.rb
SoftLayer.Server.reboot!
def reboot!(reboot_technique = :default_reboot) case reboot_technique when :default_reboot self.service.rebootDefault when :os_reboot self.service.rebootSoft when :power_cycle self.service.rebootHard else raise ArgumentError, "Unrecognized reboot technique in SoftLayer::Server#reboot!}" end end
ruby
def reboot!(reboot_technique = :default_reboot) case reboot_technique when :default_reboot self.service.rebootDefault when :os_reboot self.service.rebootSoft when :power_cycle self.service.rebootHard else raise ArgumentError, "Unrecognized reboot technique in SoftLayer::Server#reboot!}" end end
[ "def", "reboot!", "(", "reboot_technique", "=", ":default_reboot", ")", "case", "reboot_technique", "when", ":default_reboot", "self", ".", "service", ".", "rebootDefault", "when", ":os_reboot", "self", ".", "service", ".", "rebootSoft", "when", ":power_cycle", "self", ".", "service", ".", "rebootHard", "else", "raise", "ArgumentError", ",", "\"Unrecognized reboot technique in SoftLayer::Server#reboot!}\"", "end", "end" ]
Construct a server from the given client using the network data found in +network_hash+ Most users should not have to call this method directly. Instead you should access the servers property of an Account object, or use methods like BareMetalServer#find_servers or VirtualServer#find_servers Reboot the server. This action is taken immediately. Servers can be rebooted in three different ways: :default_reboot - (Try soft, then hard) Attempts to reboot a server using the :os_reboot technique then, if that is not successful, tries the :power_cycle method :os_reboot - (aka. soft reboot) instructs the server's host operating system to reboot :power_cycle - (aka. hard reboot) The actual (for hardware) or metaphorical (for virtual servers) equivalent to pulling the plug on the server then plugging it back in.
[ "Construct", "a", "server", "from", "the", "given", "client", "using", "the", "network", "data", "found", "in", "+", "network_hash", "+" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Server.rb#L174-L185
1,215
softlayer/softlayer-ruby
lib/softlayer/Server.rb
SoftLayer.Server.notes=
def notes=(new_notes) raise ArgumentError, "The new notes cannot be nil" unless new_notes edit_template = { "notes" => new_notes } self.service.editObject(edit_template) self.refresh_details() end
ruby
def notes=(new_notes) raise ArgumentError, "The new notes cannot be nil" unless new_notes edit_template = { "notes" => new_notes } self.service.editObject(edit_template) self.refresh_details() end
[ "def", "notes", "=", "(", "new_notes", ")", "raise", "ArgumentError", ",", "\"The new notes cannot be nil\"", "unless", "new_notes", "edit_template", "=", "{", "\"notes\"", "=>", "new_notes", "}", "self", ".", "service", ".", "editObject", "(", "edit_template", ")", "self", ".", "refresh_details", "(", ")", "end" ]
Change the notes of the server raises ArgumentError if you pass nil as the notes
[ "Change", "the", "notes", "of", "the", "server", "raises", "ArgumentError", "if", "you", "pass", "nil", "as", "the", "notes" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Server.rb#L205-L214
1,216
softlayer/softlayer-ruby
lib/softlayer/Server.rb
SoftLayer.Server.set_hostname!
def set_hostname!(new_hostname) raise ArgumentError, "The new hostname cannot be nil" unless new_hostname raise ArgumentError, "The new hostname cannot be empty" if new_hostname.empty? edit_template = { "hostname" => new_hostname } self.service.editObject(edit_template) self.refresh_details() end
ruby
def set_hostname!(new_hostname) raise ArgumentError, "The new hostname cannot be nil" unless new_hostname raise ArgumentError, "The new hostname cannot be empty" if new_hostname.empty? edit_template = { "hostname" => new_hostname } self.service.editObject(edit_template) self.refresh_details() end
[ "def", "set_hostname!", "(", "new_hostname", ")", "raise", "ArgumentError", ",", "\"The new hostname cannot be nil\"", "unless", "new_hostname", "raise", "ArgumentError", ",", "\"The new hostname cannot be empty\"", "if", "new_hostname", ".", "empty?", "edit_template", "=", "{", "\"hostname\"", "=>", "new_hostname", "}", "self", ".", "service", ".", "editObject", "(", "edit_template", ")", "self", ".", "refresh_details", "(", ")", "end" ]
Change the hostname of this server Raises an ArgumentError if the new hostname is nil or empty
[ "Change", "the", "hostname", "of", "this", "server", "Raises", "an", "ArgumentError", "if", "the", "new", "hostname", "is", "nil", "or", "empty" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Server.rb#L229-L239
1,217
softlayer/softlayer-ruby
lib/softlayer/Server.rb
SoftLayer.Server.set_domain!
def set_domain!(new_domain) raise ArgumentError, "The new hostname cannot be nil" unless new_domain raise ArgumentError, "The new hostname cannot be empty" if new_domain.empty? edit_template = { "domain" => new_domain } self.service.editObject(edit_template) self.refresh_details() end
ruby
def set_domain!(new_domain) raise ArgumentError, "The new hostname cannot be nil" unless new_domain raise ArgumentError, "The new hostname cannot be empty" if new_domain.empty? edit_template = { "domain" => new_domain } self.service.editObject(edit_template) self.refresh_details() end
[ "def", "set_domain!", "(", "new_domain", ")", "raise", "ArgumentError", ",", "\"The new hostname cannot be nil\"", "unless", "new_domain", "raise", "ArgumentError", ",", "\"The new hostname cannot be empty\"", "if", "new_domain", ".", "empty?", "edit_template", "=", "{", "\"domain\"", "=>", "new_domain", "}", "self", ".", "service", ".", "editObject", "(", "edit_template", ")", "self", ".", "refresh_details", "(", ")", "end" ]
Change the domain of this server Raises an ArgumentError if the new domain is nil or empty no further validation is done on the domain name
[ "Change", "the", "domain", "of", "this", "server" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Server.rb#L247-L257
1,218
softlayer/softlayer-ruby
lib/softlayer/Server.rb
SoftLayer.Server.change_port_speed
def change_port_speed(new_speed, public = true) if public self.service.setPublicNetworkInterfaceSpeed(new_speed) else self.service.setPrivateNetworkInterfaceSpeed(new_speed) end self.refresh_details() self end
ruby
def change_port_speed(new_speed, public = true) if public self.service.setPublicNetworkInterfaceSpeed(new_speed) else self.service.setPrivateNetworkInterfaceSpeed(new_speed) end self.refresh_details() self end
[ "def", "change_port_speed", "(", "new_speed", ",", "public", "=", "true", ")", "if", "public", "self", ".", "service", ".", "setPublicNetworkInterfaceSpeed", "(", "new_speed", ")", "else", "self", ".", "service", ".", "setPrivateNetworkInterfaceSpeed", "(", "new_speed", ")", "end", "self", ".", "refresh_details", "(", ")", "self", "end" ]
Change the current port speed of the server +new_speed+ is expressed Mbps and should be 0, 10, 100, or 1000. Ports have a maximum speed that will limit the actual speed set on the port. Set +public+ to +false+ in order to change the speed of the private network interface.
[ "Change", "the", "current", "port", "speed", "of", "the", "server" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Server.rb#L278-L287
1,219
softlayer/softlayer-ruby
lib/softlayer/Server.rb
SoftLayer.Server.reload_os!
def reload_os!(token = '', provisioning_script_uri = nil, ssh_keys = nil) configuration = {} configuration['customProvisionScriptUri'] = provisioning_script_uri if provisioning_script_uri configuration['sshKeyIds'] = ssh_keys if ssh_keys self.service.reloadOperatingSystem(token, configuration) end
ruby
def reload_os!(token = '', provisioning_script_uri = nil, ssh_keys = nil) configuration = {} configuration['customProvisionScriptUri'] = provisioning_script_uri if provisioning_script_uri configuration['sshKeyIds'] = ssh_keys if ssh_keys self.service.reloadOperatingSystem(token, configuration) end
[ "def", "reload_os!", "(", "token", "=", "''", ",", "provisioning_script_uri", "=", "nil", ",", "ssh_keys", "=", "nil", ")", "configuration", "=", "{", "}", "configuration", "[", "'customProvisionScriptUri'", "]", "=", "provisioning_script_uri", "if", "provisioning_script_uri", "configuration", "[", "'sshKeyIds'", "]", "=", "ssh_keys", "if", "ssh_keys", "self", ".", "service", ".", "reloadOperatingSystem", "(", "token", ",", "configuration", ")", "end" ]
Begins an OS reload on this server. The OS reload can wipe out the data on your server so this method uses a confirmation mechanism built into the underlying SoftLayer API. If you call this method once without a token, it will not actually start the reload. Instead it will return a token to you. That token is good for 10 minutes. If you call this method again and pass that token **then** the OS reload will actually begin. If you wish to force the OS Reload and bypass the token safety mechanism pass the token 'FORCE' as the first parameter. If you do so the reload will proceed immediately.
[ "Begins", "an", "OS", "reload", "on", "this", "server", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Server.rb#L303-L310
1,220
drone/drone-ruby
lib/drone/plugin.rb
Drone.Plugin.parse
def parse self.result ||= Payload.new.tap do |payload| PayloadRepresenter.new( payload ).from_json( input ) end rescue MultiJson::ParseError raise InvalidJsonError end
ruby
def parse self.result ||= Payload.new.tap do |payload| PayloadRepresenter.new( payload ).from_json( input ) end rescue MultiJson::ParseError raise InvalidJsonError end
[ "def", "parse", "self", ".", "result", "||=", "Payload", ".", "new", ".", "tap", "do", "|", "payload", "|", "PayloadRepresenter", ".", "new", "(", "payload", ")", ".", "from_json", "(", "input", ")", "end", "rescue", "MultiJson", "::", "ParseError", "raise", "InvalidJsonError", "end" ]
Initialize the plugin parser @param input [String] the JSON as a string to parse @return [Drone::Plugin] the instance of that class Parse the provided payload @return [Drone::Payload] the parsed payload within model @raise [Drone::InvalidJsonError] if the provided JSON is invalid
[ "Initialize", "the", "plugin", "parser" ]
4b95286c45a9c44f2e38c393b804f753fb286b50
https://github.com/drone/drone-ruby/blob/4b95286c45a9c44f2e38c393b804f753fb286b50/lib/drone/plugin.rb#L43-L53
1,221
softlayer/softlayer-ruby
lib/softlayer/APIParameterFilter.rb
SoftLayer.APIParameterFilter.object_filter
def object_filter(filter) raise ArgumentError, "object_filter expects an instance of SoftLayer::ObjectFilter" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter) # we create a new object in case the user wants to store off the # filter chain and reuse it later APIParameterFilter.new(self.target, @parameters.merge({:object_filter => filter})); end
ruby
def object_filter(filter) raise ArgumentError, "object_filter expects an instance of SoftLayer::ObjectFilter" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter) # we create a new object in case the user wants to store off the # filter chain and reuse it later APIParameterFilter.new(self.target, @parameters.merge({:object_filter => filter})); end
[ "def", "object_filter", "(", "filter", ")", "raise", "ArgumentError", ",", "\"object_filter expects an instance of SoftLayer::ObjectFilter\"", "if", "filter", ".", "nil?", "||", "!", "filter", ".", "kind_of?", "(", "SoftLayer", "::", "ObjectFilter", ")", "# we create a new object in case the user wants to store off the", "# filter chain and reuse it later", "APIParameterFilter", ".", "new", "(", "self", ".", "target", ",", "@parameters", ".", "merge", "(", "{", ":object_filter", "=>", "filter", "}", ")", ")", ";", "end" ]
Adds an object_filter to the result. An Object Filter allows you to specify criteria which are used to filter the results returned by the server.
[ "Adds", "an", "object_filter", "to", "the", "result", ".", "An", "Object", "Filter", "allows", "you", "to", "specify", "criteria", "which", "are", "used", "to", "filter", "the", "results", "returned", "by", "the", "server", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/APIParameterFilter.rb#L114-L120
1,222
softlayer/softlayer-ruby
lib/softlayer/VirtualServerUpgradeOrder.rb
SoftLayer.VirtualServerUpgradeOrder.verify
def verify() if has_order_items? order_template = order_object order_template = yield order_object if block_given? @virtual_server.softlayer_client[:Product_Order].verifyOrder(order_template) end end
ruby
def verify() if has_order_items? order_template = order_object order_template = yield order_object if block_given? @virtual_server.softlayer_client[:Product_Order].verifyOrder(order_template) end end
[ "def", "verify", "(", ")", "if", "has_order_items?", "order_template", "=", "order_object", "order_template", "=", "yield", "order_object", "if", "block_given?", "@virtual_server", ".", "softlayer_client", "[", ":Product_Order", "]", ".", "verifyOrder", "(", "order_template", ")", "end", "end" ]
Create an upgrade order for the virtual server provided. Sends the order represented by this object to SoftLayer for validation. If a block is passed to verify, the code will send the order template being constructed to the block before the order is actually sent for validation.
[ "Create", "an", "upgrade", "order", "for", "the", "virtual", "server", "provided", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServerUpgradeOrder.rb#L52-L58
1,223
softlayer/softlayer-ruby
lib/softlayer/VirtualServerUpgradeOrder.rb
SoftLayer.VirtualServerUpgradeOrder.place_order!
def place_order!() if has_order_items? order_template = order_object order_template = yield order_object if block_given? @virtual_server.softlayer_client[:Product_Order].placeOrder(order_template) end end
ruby
def place_order!() if has_order_items? order_template = order_object order_template = yield order_object if block_given? @virtual_server.softlayer_client[:Product_Order].placeOrder(order_template) end end
[ "def", "place_order!", "(", ")", "if", "has_order_items?", "order_template", "=", "order_object", "order_template", "=", "yield", "order_object", "if", "block_given?", "@virtual_server", ".", "softlayer_client", "[", ":Product_Order", "]", ".", "placeOrder", "(", "order_template", ")", "end", "end" ]
Places the order represented by this object. This is likely to involve a change to the charges on an account. If a block is passed to this routine, the code will send the order template being constructed to that block before the order is sent
[ "Places", "the", "order", "represented", "by", "this", "object", ".", "This", "is", "likely", "to", "involve", "a", "change", "to", "the", "charges", "on", "an", "account", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServerUpgradeOrder.rb#L67-L74
1,224
softlayer/softlayer-ruby
lib/softlayer/VirtualServerUpgradeOrder.rb
SoftLayer.VirtualServerUpgradeOrder._item_prices_in_category
def _item_prices_in_category(which_category) @virtual_server.upgrade_options.select { |item_price| item_price['categories'].find { |category| category['categoryCode'] == which_category } } end
ruby
def _item_prices_in_category(which_category) @virtual_server.upgrade_options.select { |item_price| item_price['categories'].find { |category| category['categoryCode'] == which_category } } end
[ "def", "_item_prices_in_category", "(", "which_category", ")", "@virtual_server", ".", "upgrade_options", ".", "select", "{", "|", "item_price", "|", "item_price", "[", "'categories'", "]", ".", "find", "{", "|", "category", "|", "category", "[", "'categoryCode'", "]", "==", "which_category", "}", "}", "end" ]
Returns a list of the update item prices, in the given category, for the server
[ "Returns", "a", "list", "of", "the", "update", "item", "prices", "in", "the", "given", "category", "for", "the", "server" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServerUpgradeOrder.rb#L106-L108
1,225
softlayer/softlayer-ruby
lib/softlayer/VirtualServerUpgradeOrder.rb
SoftLayer.VirtualServerUpgradeOrder._item_price_with_capacity
def _item_price_with_capacity(which_category, capacity) _item_prices_in_category(which_category).find { |item_price| item_price['item']['capacity'].to_i == capacity} end
ruby
def _item_price_with_capacity(which_category, capacity) _item_prices_in_category(which_category).find { |item_price| item_price['item']['capacity'].to_i == capacity} end
[ "def", "_item_price_with_capacity", "(", "which_category", ",", "capacity", ")", "_item_prices_in_category", "(", "which_category", ")", ".", "find", "{", "|", "item_price", "|", "item_price", "[", "'item'", "]", "[", "'capacity'", "]", ".", "to_i", "==", "capacity", "}", "end" ]
Searches through the upgrade items prices known to this server for the one that is in a particular category and whose capacity matches the value given. Returns the item_price or nil
[ "Searches", "through", "the", "upgrade", "items", "prices", "known", "to", "this", "server", "for", "the", "one", "that", "is", "in", "a", "particular", "category", "and", "whose", "capacity", "matches", "the", "value", "given", ".", "Returns", "the", "item_price", "or", "nil" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServerUpgradeOrder.rb#L114-L116
1,226
softlayer/softlayer-ruby
lib/softlayer/VirtualServerUpgradeOrder.rb
SoftLayer.VirtualServerUpgradeOrder.order_object
def order_object prices = [] cores_price_item = @cores ? _item_price_with_capacity("guest_core", @cores) : nil ram_price_item = @ram ? _item_price_with_capacity("ram", @ram) : nil max_port_speed_price_item = @max_port_speed ? _item_price_with_capacity("port_speed", @max_port_speed) : nil prices << { "id" => cores_price_item['id'] } if cores_price_item prices << { "id" => ram_price_item['id'] } if ram_price_item prices << { "id" => max_port_speed_price_item['id'] } if max_port_speed_price_item # put together an order upgrade_order = { 'complexType' => 'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade', 'virtualGuests' => [{'id' => @virtual_server.id }], 'properties' => [{'name' => 'MAINTENANCE_WINDOW', 'value' => @upgrade_at ? @upgrade_at.iso8601 : Time.now.iso8601}], 'prices' => prices } end
ruby
def order_object prices = [] cores_price_item = @cores ? _item_price_with_capacity("guest_core", @cores) : nil ram_price_item = @ram ? _item_price_with_capacity("ram", @ram) : nil max_port_speed_price_item = @max_port_speed ? _item_price_with_capacity("port_speed", @max_port_speed) : nil prices << { "id" => cores_price_item['id'] } if cores_price_item prices << { "id" => ram_price_item['id'] } if ram_price_item prices << { "id" => max_port_speed_price_item['id'] } if max_port_speed_price_item # put together an order upgrade_order = { 'complexType' => 'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade', 'virtualGuests' => [{'id' => @virtual_server.id }], 'properties' => [{'name' => 'MAINTENANCE_WINDOW', 'value' => @upgrade_at ? @upgrade_at.iso8601 : Time.now.iso8601}], 'prices' => prices } end
[ "def", "order_object", "prices", "=", "[", "]", "cores_price_item", "=", "@cores", "?", "_item_price_with_capacity", "(", "\"guest_core\"", ",", "@cores", ")", ":", "nil", "ram_price_item", "=", "@ram", "?", "_item_price_with_capacity", "(", "\"ram\"", ",", "@ram", ")", ":", "nil", "max_port_speed_price_item", "=", "@max_port_speed", "?", "_item_price_with_capacity", "(", "\"port_speed\"", ",", "@max_port_speed", ")", ":", "nil", "prices", "<<", "{", "\"id\"", "=>", "cores_price_item", "[", "'id'", "]", "}", "if", "cores_price_item", "prices", "<<", "{", "\"id\"", "=>", "ram_price_item", "[", "'id'", "]", "}", "if", "ram_price_item", "prices", "<<", "{", "\"id\"", "=>", "max_port_speed_price_item", "[", "'id'", "]", "}", "if", "max_port_speed_price_item", "# put together an order", "upgrade_order", "=", "{", "'complexType'", "=>", "'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade'", ",", "'virtualGuests'", "=>", "[", "{", "'id'", "=>", "@virtual_server", ".", "id", "}", "]", ",", "'properties'", "=>", "[", "{", "'name'", "=>", "'MAINTENANCE_WINDOW'", ",", "'value'", "=>", "@upgrade_at", "?", "@upgrade_at", ".", "iso8601", ":", "Time", ".", "now", ".", "iso8601", "}", "]", ",", "'prices'", "=>", "prices", "}", "end" ]
construct an order object
[ "construct", "an", "order", "object" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServerUpgradeOrder.rb#L121-L139
1,227
softlayer/softlayer-ruby
lib/softlayer/NetworkStorage.rb
SoftLayer.NetworkStorage.assign_credential
def assign_credential(username) raise ArgumentError, "The username cannot be nil" unless username raise ArgumentError, "The username cannot be empty" if username.empty? self.service.assignCredential(username.to_s) @credentials = nil end
ruby
def assign_credential(username) raise ArgumentError, "The username cannot be nil" unless username raise ArgumentError, "The username cannot be empty" if username.empty? self.service.assignCredential(username.to_s) @credentials = nil end
[ "def", "assign_credential", "(", "username", ")", "raise", "ArgumentError", ",", "\"The username cannot be nil\"", "unless", "username", "raise", "ArgumentError", ",", "\"The username cannot be empty\"", "if", "username", ".", "empty?", "self", ".", "service", ".", "assignCredential", "(", "username", ".", "to_s", ")", "@credentials", "=", "nil", "end" ]
Assign an existing network storage credential specified by the username to the network storage instance
[ "Assign", "an", "existing", "network", "storage", "credential", "specified", "by", "the", "username", "to", "the", "network", "storage", "instance" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/NetworkStorage.rb#L141-L148
1,228
softlayer/softlayer-ruby
lib/softlayer/NetworkStorage.rb
SoftLayer.NetworkStorage.password=
def password=(password) raise ArgumentError, "The new password cannot be nil" unless password raise ArgumentError, "The new password cannot be empty" if password.empty? self.service.editObject({ "password" => password.to_s }) self.refresh_details() end
ruby
def password=(password) raise ArgumentError, "The new password cannot be nil" unless password raise ArgumentError, "The new password cannot be empty" if password.empty? self.service.editObject({ "password" => password.to_s }) self.refresh_details() end
[ "def", "password", "=", "(", "password", ")", "raise", "ArgumentError", ",", "\"The new password cannot be nil\"", "unless", "password", "raise", "ArgumentError", ",", "\"The new password cannot be empty\"", "if", "password", ".", "empty?", "self", ".", "service", ".", "editObject", "(", "{", "\"password\"", "=>", "password", ".", "to_s", "}", ")", "self", ".", "refresh_details", "(", ")", "end" ]
Updates the password for the network storage instance.
[ "Updates", "the", "password", "for", "the", "network", "storage", "instance", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/NetworkStorage.rb#L168-L174
1,229
softlayer/softlayer-ruby
lib/softlayer/NetworkStorage.rb
SoftLayer.NetworkStorage.remove_credential
def remove_credential(username) raise ArgumentError, "The username cannot be nil" unless username raise ArgumentError, "The username cannot be empty" if username.empty? self.service.removeCredential(username.to_s) @credentials = nil end
ruby
def remove_credential(username) raise ArgumentError, "The username cannot be nil" unless username raise ArgumentError, "The username cannot be empty" if username.empty? self.service.removeCredential(username.to_s) @credentials = nil end
[ "def", "remove_credential", "(", "username", ")", "raise", "ArgumentError", ",", "\"The username cannot be nil\"", "unless", "username", "raise", "ArgumentError", ",", "\"The username cannot be empty\"", "if", "username", ".", "empty?", "self", ".", "service", ".", "removeCredential", "(", "username", ".", "to_s", ")", "@credentials", "=", "nil", "end" ]
Remove an existing network storage credential specified by the username from the network storage instance
[ "Remove", "an", "existing", "network", "storage", "credential", "specified", "by", "the", "username", "from", "the", "network", "storage", "instance" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/NetworkStorage.rb#L179-L186
1,230
softlayer/softlayer-ruby
lib/softlayer/NetworkStorage.rb
SoftLayer.NetworkStorage.softlayer_properties
def softlayer_properties(object_mask = nil) my_service = self.service if(object_mask) my_service = my_service.object_mask(object_mask) else my_service = my_service.object_mask(self.class.default_object_mask) end my_service.getObject() end
ruby
def softlayer_properties(object_mask = nil) my_service = self.service if(object_mask) my_service = my_service.object_mask(object_mask) else my_service = my_service.object_mask(self.class.default_object_mask) end my_service.getObject() end
[ "def", "softlayer_properties", "(", "object_mask", "=", "nil", ")", "my_service", "=", "self", ".", "service", "if", "(", "object_mask", ")", "my_service", "=", "my_service", ".", "object_mask", "(", "object_mask", ")", "else", "my_service", "=", "my_service", ".", "object_mask", "(", "self", ".", "class", ".", "default_object_mask", ")", "end", "my_service", ".", "getObject", "(", ")", "end" ]
Make an API request to SoftLayer and return the latest properties hash for this object.
[ "Make", "an", "API", "request", "to", "SoftLayer", "and", "return", "the", "latest", "properties", "hash", "for", "this", "object", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/NetworkStorage.rb#L310-L320
1,231
softlayer/softlayer-ruby
lib/softlayer/NetworkStorage.rb
SoftLayer.NetworkStorage.update_credential_password
def update_credential_password(username, password) raise ArgumentError, "The new password cannot be nil" unless password raise ArgumentError, "The new username cannot be nil" unless username raise ArgumentError, "The new password cannot be empty" if password.empty? raise ArgumentError, "The new username cannot be empty" if username.empty? self.service.editCredential(username.to_s, password.to_s) @credentials = nil end
ruby
def update_credential_password(username, password) raise ArgumentError, "The new password cannot be nil" unless password raise ArgumentError, "The new username cannot be nil" unless username raise ArgumentError, "The new password cannot be empty" if password.empty? raise ArgumentError, "The new username cannot be empty" if username.empty? self.service.editCredential(username.to_s, password.to_s) @credentials = nil end
[ "def", "update_credential_password", "(", "username", ",", "password", ")", "raise", "ArgumentError", ",", "\"The new password cannot be nil\"", "unless", "password", "raise", "ArgumentError", ",", "\"The new username cannot be nil\"", "unless", "username", "raise", "ArgumentError", ",", "\"The new password cannot be empty\"", "if", "password", ".", "empty?", "raise", "ArgumentError", ",", "\"The new username cannot be empty\"", "if", "username", ".", "empty?", "self", ".", "service", ".", "editCredential", "(", "username", ".", "to_s", ",", "password", ".", "to_s", ")", "@credentials", "=", "nil", "end" ]
Updates the password for the network storage credential of the username specified.
[ "Updates", "the", "password", "for", "the", "network", "storage", "credential", "of", "the", "username", "specified", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/NetworkStorage.rb#L325-L334
1,232
softlayer/softlayer-ruby
lib/softlayer/ProductPackage.rb
SoftLayer.ProductPackage.items_with_description
def items_with_description(expected_description) filter = ObjectFilter.new { |filter| filter.accept("items.description").when_it is(expected_description) } items_data = self.service.object_filter(filter).getItems() items_data.collect do |item_data| first_price = item_data['prices'][0] ProductConfigurationOption.new(item_data, first_price) end end
ruby
def items_with_description(expected_description) filter = ObjectFilter.new { |filter| filter.accept("items.description").when_it is(expected_description) } items_data = self.service.object_filter(filter).getItems() items_data.collect do |item_data| first_price = item_data['prices'][0] ProductConfigurationOption.new(item_data, first_price) end end
[ "def", "items_with_description", "(", "expected_description", ")", "filter", "=", "ObjectFilter", ".", "new", "{", "|", "filter", "|", "filter", ".", "accept", "(", "\"items.description\"", ")", ".", "when_it", "is", "(", "expected_description", ")", "}", "items_data", "=", "self", ".", "service", ".", "object_filter", "(", "filter", ")", ".", "getItems", "(", ")", "items_data", ".", "collect", "do", "|", "item_data", "|", "first_price", "=", "item_data", "[", "'prices'", "]", "[", "0", "]", "ProductConfigurationOption", ".", "new", "(", "item_data", ",", "first_price", ")", "end", "end" ]
Returns the package items with the given description Currently this is returning the low-level hash representation directly from the Network API
[ "Returns", "the", "package", "items", "with", "the", "given", "description", "Currently", "this", "is", "returning", "the", "low", "-", "level", "hash", "representation", "directly", "from", "the", "Network", "API" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/ProductPackage.rb#L143-L151
1,233
softlayer/softlayer-ruby
lib/softlayer/ImageTemplate.rb
SoftLayer.ImageTemplate.available_datacenters
def available_datacenters datacenters_data = self.service.getStorageLocations() datacenters_data.collect { |datacenter_data| SoftLayer::Datacenter.datacenter_named(datacenter_data['name']) } end
ruby
def available_datacenters datacenters_data = self.service.getStorageLocations() datacenters_data.collect { |datacenter_data| SoftLayer::Datacenter.datacenter_named(datacenter_data['name']) } end
[ "def", "available_datacenters", "datacenters_data", "=", "self", ".", "service", ".", "getStorageLocations", "(", ")", "datacenters_data", ".", "collect", "{", "|", "datacenter_data", "|", "SoftLayer", "::", "Datacenter", ".", "datacenter_named", "(", "datacenter_data", "[", "'name'", "]", ")", "}", "end" ]
Returns an array of the datacenters that this image can be stored in. This is the set of datacenters that you may choose from, when putting together a list you will send to the datacenters= setter.
[ "Returns", "an", "array", "of", "the", "datacenters", "that", "this", "image", "can", "be", "stored", "in", ".", "This", "is", "the", "set", "of", "datacenters", "that", "you", "may", "choose", "from", "when", "putting", "together", "a", "list", "you", "will", "send", "to", "the", "datacenters", "=", "setter", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/ImageTemplate.rb#L110-L113
1,234
softlayer/softlayer-ruby
lib/softlayer/ImageTemplate.rb
SoftLayer.ImageTemplate.shared_with_accounts=
def shared_with_accounts= (account_id_list) already_sharing_with = self.shared_with_accounts accounts_to_add = account_id_list.select { |account_id| !already_sharing_with.include?(account_id) } # Note, using the network API, it is possible to "unshare" an image template # with the account that owns it, however, this leads to a rather odd state # where the image has allocated resources (that the account may be charged for) # but no way to delete those resources. For that reason this model # always includes the account ID that owns the image in the list of # accounts the image will be shared with. my_account_id = self['accountId'] accounts_to_add.push(my_account_id) if !already_sharing_with.include?(my_account_id) && !accounts_to_add.include?(my_account_id) accounts_to_remove = already_sharing_with.select { |account_id| (account_id != my_account_id) && !account_id_list.include?(account_id) } accounts_to_add.each {|account_id| self.service.permitSharingAccess account_id } accounts_to_remove.each {|account_id| self.service.denySharingAccess account_id } end
ruby
def shared_with_accounts= (account_id_list) already_sharing_with = self.shared_with_accounts accounts_to_add = account_id_list.select { |account_id| !already_sharing_with.include?(account_id) } # Note, using the network API, it is possible to "unshare" an image template # with the account that owns it, however, this leads to a rather odd state # where the image has allocated resources (that the account may be charged for) # but no way to delete those resources. For that reason this model # always includes the account ID that owns the image in the list of # accounts the image will be shared with. my_account_id = self['accountId'] accounts_to_add.push(my_account_id) if !already_sharing_with.include?(my_account_id) && !accounts_to_add.include?(my_account_id) accounts_to_remove = already_sharing_with.select { |account_id| (account_id != my_account_id) && !account_id_list.include?(account_id) } accounts_to_add.each {|account_id| self.service.permitSharingAccess account_id } accounts_to_remove.each {|account_id| self.service.denySharingAccess account_id } end
[ "def", "shared_with_accounts", "=", "(", "account_id_list", ")", "already_sharing_with", "=", "self", ".", "shared_with_accounts", "accounts_to_add", "=", "account_id_list", ".", "select", "{", "|", "account_id", "|", "!", "already_sharing_with", ".", "include?", "(", "account_id", ")", "}", "# Note, using the network API, it is possible to \"unshare\" an image template", "# with the account that owns it, however, this leads to a rather odd state", "# where the image has allocated resources (that the account may be charged for)", "# but no way to delete those resources. For that reason this model", "# always includes the account ID that owns the image in the list of", "# accounts the image will be shared with.", "my_account_id", "=", "self", "[", "'accountId'", "]", "accounts_to_add", ".", "push", "(", "my_account_id", ")", "if", "!", "already_sharing_with", ".", "include?", "(", "my_account_id", ")", "&&", "!", "accounts_to_add", ".", "include?", "(", "my_account_id", ")", "accounts_to_remove", "=", "already_sharing_with", ".", "select", "{", "|", "account_id", "|", "(", "account_id", "!=", "my_account_id", ")", "&&", "!", "account_id_list", ".", "include?", "(", "account_id", ")", "}", "accounts_to_add", ".", "each", "{", "|", "account_id", "|", "self", ".", "service", ".", "permitSharingAccess", "account_id", "}", "accounts_to_remove", ".", "each", "{", "|", "account_id", "|", "self", ".", "service", ".", "denySharingAccess", "account_id", "}", "end" ]
Change the set of accounts that this image is shared with. The parameter is an array of account ID's. Note that this routine will "unshare" with any accounts not included in the list passed in so the list should be comprehensive
[ "Change", "the", "set", "of", "accounts", "that", "this", "image", "is", "shared", "with", ".", "The", "parameter", "is", "an", "array", "of", "account", "ID", "s", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/ImageTemplate.rb#L132-L150
1,235
softlayer/softlayer-ruby
lib/softlayer/ImageTemplate.rb
SoftLayer.ImageTemplate.wait_until_ready
def wait_until_ready(max_trials, seconds_between_tries = 2) # pessimistically assume the server is not ready num_trials = 0 begin self.refresh_details() parent_ready = !(has_sl_property? :transactionId) || (self[:transactionId] == "") children_ready = (nil == self['children'].find { |child| child['transactionId'] != "" }) ready = parent_ready && children_ready yield ready if block_given? num_trials = num_trials + 1 sleep(seconds_between_tries) if !ready && (num_trials <= max_trials) end until ready || (num_trials >= max_trials) ready end
ruby
def wait_until_ready(max_trials, seconds_between_tries = 2) # pessimistically assume the server is not ready num_trials = 0 begin self.refresh_details() parent_ready = !(has_sl_property? :transactionId) || (self[:transactionId] == "") children_ready = (nil == self['children'].find { |child| child['transactionId'] != "" }) ready = parent_ready && children_ready yield ready if block_given? num_trials = num_trials + 1 sleep(seconds_between_tries) if !ready && (num_trials <= max_trials) end until ready || (num_trials >= max_trials) ready end
[ "def", "wait_until_ready", "(", "max_trials", ",", "seconds_between_tries", "=", "2", ")", "# pessimistically assume the server is not ready", "num_trials", "=", "0", "begin", "self", ".", "refresh_details", "(", ")", "parent_ready", "=", "!", "(", "has_sl_property?", ":transactionId", ")", "||", "(", "self", "[", ":transactionId", "]", "==", "\"\"", ")", "children_ready", "=", "(", "nil", "==", "self", "[", "'children'", "]", ".", "find", "{", "|", "child", "|", "child", "[", "'transactionId'", "]", "!=", "\"\"", "}", ")", "ready", "=", "parent_ready", "&&", "children_ready", "yield", "ready", "if", "block_given?", "num_trials", "=", "num_trials", "+", "1", "sleep", "(", "seconds_between_tries", ")", "if", "!", "ready", "&&", "(", "num_trials", "<=", "max_trials", ")", "end", "until", "ready", "||", "(", "num_trials", ">=", "max_trials", ")", "ready", "end" ]
Repeatedly poll the network API until transactions related to this image template are finished A template is not 'ready' until all the transactions on the template itself, and all its children are complete. At each trial, the routine will yield to a block if one is given The block is passed one parameter, a boolean flag indicating whether or not the image template is 'ready'.
[ "Repeatedly", "poll", "the", "network", "API", "until", "transactions", "related", "to", "this", "image", "template", "are", "finished" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/ImageTemplate.rb#L175-L192
1,236
softlayer/softlayer-ruby
lib/softlayer/ServerFirewallOrder.rb
SoftLayer.ServerFirewallOrder.verify
def verify() order_template = firewall_order_template order_template = yield order_template if block_given? server.softlayer_client[:Product_Order].verifyOrder(order_template) end
ruby
def verify() order_template = firewall_order_template order_template = yield order_template if block_given? server.softlayer_client[:Product_Order].verifyOrder(order_template) end
[ "def", "verify", "(", ")", "order_template", "=", "firewall_order_template", "order_template", "=", "yield", "order_template", "if", "block_given?", "server", ".", "softlayer_client", "[", ":Product_Order", "]", ".", "verifyOrder", "(", "order_template", ")", "end" ]
Create a new order for the given server Calls the SoftLayer API to verify that the template provided by this order is valid This routine will return the order template generated by the API or will throw an exception This routine will not actually create a Bare Metal Instance and will not affect billing. If you provide a block, it will receive the order template as a parameter and the block may make changes to the template before it is submitted.
[ "Create", "a", "new", "order", "for", "the", "given", "server" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/ServerFirewallOrder.rb#L31-L36
1,237
softlayer/softlayer-ruby
lib/softlayer/VLANFirewall.rb
SoftLayer.VLANFirewall.cancel!
def cancel!(notes = nil) user = self.softlayer_client[:Account].object_mask("mask[id,account.id]").getCurrentUser notes = "Cancelled by a call to #{__method__} in the softlayer_api gem" if notes == nil || notes == "" cancellation_request = { 'accountId' => user['account']['id'], 'userId' => user['id'], 'items' => [ { 'billingItemId' => self['networkVlanFirewall']['billingItem']['id'], 'immediateCancellationFlag' => true } ], 'notes' => notes } self.softlayer_client[:Billing_Item_Cancellation_Request].createObject(cancellation_request) end
ruby
def cancel!(notes = nil) user = self.softlayer_client[:Account].object_mask("mask[id,account.id]").getCurrentUser notes = "Cancelled by a call to #{__method__} in the softlayer_api gem" if notes == nil || notes == "" cancellation_request = { 'accountId' => user['account']['id'], 'userId' => user['id'], 'items' => [ { 'billingItemId' => self['networkVlanFirewall']['billingItem']['id'], 'immediateCancellationFlag' => true } ], 'notes' => notes } self.softlayer_client[:Billing_Item_Cancellation_Request].createObject(cancellation_request) end
[ "def", "cancel!", "(", "notes", "=", "nil", ")", "user", "=", "self", ".", "softlayer_client", "[", ":Account", "]", ".", "object_mask", "(", "\"mask[id,account.id]\"", ")", ".", "getCurrentUser", "notes", "=", "\"Cancelled by a call to #{__method__} in the softlayer_api gem\"", "if", "notes", "==", "nil", "||", "notes", "==", "\"\"", "cancellation_request", "=", "{", "'accountId'", "=>", "user", "[", "'account'", "]", "[", "'id'", "]", ",", "'userId'", "=>", "user", "[", "'id'", "]", ",", "'items'", "=>", "[", "{", "'billingItemId'", "=>", "self", "[", "'networkVlanFirewall'", "]", "[", "'billingItem'", "]", "[", "'id'", "]", ",", "'immediateCancellationFlag'", "=>", "true", "}", "]", ",", "'notes'", "=>", "notes", "}", "self", ".", "softlayer_client", "[", ":Billing_Item_Cancellation_Request", "]", ".", "createObject", "(", "cancellation_request", ")", "end" ]
Cancel the firewall This method cancels the firewall and releases its resources. The cancellation is processed immediately! Call this method with careful deliberation! Notes is a string that describes the reason for the cancellation. If empty or nil, a default string will be added.
[ "Cancel", "the", "firewall" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VLANFirewall.rb#L123-L138
1,238
softlayer/softlayer-ruby
lib/softlayer/VLANFirewall.rb
SoftLayer.VLANFirewall.change_rules_bypass!
def change_rules_bypass!(bypass_symbol) change_object = { "firewallContextAccessControlListId" => rules_ACL_id(), "rules" => self.rules } case bypass_symbol when :apply_firewall_rules change_object['bypassFlag'] = false self.softlayer_client[:Network_Firewall_Update_Request].createObject(change_object) when :bypass_firewall_rules change_object['bypassFlag'] = true self.softlayer_client[:Network_Firewall_Update_Request].createObject(change_object) else raise ArgumentError, "An invalid parameter was sent to #{__method__}. It accepts :apply_firewall_rules and :bypass_firewall_rules" end end
ruby
def change_rules_bypass!(bypass_symbol) change_object = { "firewallContextAccessControlListId" => rules_ACL_id(), "rules" => self.rules } case bypass_symbol when :apply_firewall_rules change_object['bypassFlag'] = false self.softlayer_client[:Network_Firewall_Update_Request].createObject(change_object) when :bypass_firewall_rules change_object['bypassFlag'] = true self.softlayer_client[:Network_Firewall_Update_Request].createObject(change_object) else raise ArgumentError, "An invalid parameter was sent to #{__method__}. It accepts :apply_firewall_rules and :bypass_firewall_rules" end end
[ "def", "change_rules_bypass!", "(", "bypass_symbol", ")", "change_object", "=", "{", "\"firewallContextAccessControlListId\"", "=>", "rules_ACL_id", "(", ")", ",", "\"rules\"", "=>", "self", ".", "rules", "}", "case", "bypass_symbol", "when", ":apply_firewall_rules", "change_object", "[", "'bypassFlag'", "]", "=", "false", "self", ".", "softlayer_client", "[", ":Network_Firewall_Update_Request", "]", ".", "createObject", "(", "change_object", ")", "when", ":bypass_firewall_rules", "change_object", "[", "'bypassFlag'", "]", "=", "true", "self", ".", "softlayer_client", "[", ":Network_Firewall_Update_Request", "]", ".", "createObject", "(", "change_object", ")", "else", "raise", "ArgumentError", ",", "\"An invalid parameter was sent to #{__method__}. It accepts :apply_firewall_rules and :bypass_firewall_rules\"", "end", "end" ]
This method asks the firewall to ignore its rule set and pass all traffic through the firewall. Compare the behavior of this routine with change_routing_bypass! It is important to note that changing the bypass to :bypass_firewall_rules removes ALL the protection offered by the firewall. This routine should be used with extreme discretion. Note that this routine queues a rule change and rule changes may take time to process. The change will probably not take effect immediately. The two symbols accepted as arguments by this routine are: :apply_firewall_rules - The rules of the firewall are applied to traffic. This is the default operating mode of the firewall :bypass_firewall_rules - The rules of the firewall are ignored. In this configuration the firewall provides no protection.
[ "This", "method", "asks", "the", "firewall", "to", "ignore", "its", "rule", "set", "and", "pass", "all", "traffic", "through", "the", "firewall", ".", "Compare", "the", "behavior", "of", "this", "routine", "with", "change_routing_bypass!" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VLANFirewall.rb#L187-L203
1,239
softlayer/softlayer-ruby
lib/softlayer/VLANFirewall.rb
SoftLayer.VLANFirewall.change_routing_bypass!
def change_routing_bypass!(routing_symbol) vlan_firewall_id = self['networkVlanFirewall']['id'] raise "Could not identify the device for a VLAN firewall" if !vlan_firewall_id case routing_symbol when :route_through_firewall self.softlayer_client[:Network_Vlan_Firewall].object_with_id(vlan_firewall_id).updateRouteBypass(false) when :route_around_firewall self.softlayer_client[:Network_Vlan_Firewall].object_with_id(vlan_firewall_id).updateRouteBypass(true) else raise ArgumentError, "An invalid parameter was sent to #{__method__}. It accepts :route_through_firewall and :route_around_firewall" end end
ruby
def change_routing_bypass!(routing_symbol) vlan_firewall_id = self['networkVlanFirewall']['id'] raise "Could not identify the device for a VLAN firewall" if !vlan_firewall_id case routing_symbol when :route_through_firewall self.softlayer_client[:Network_Vlan_Firewall].object_with_id(vlan_firewall_id).updateRouteBypass(false) when :route_around_firewall self.softlayer_client[:Network_Vlan_Firewall].object_with_id(vlan_firewall_id).updateRouteBypass(true) else raise ArgumentError, "An invalid parameter was sent to #{__method__}. It accepts :route_through_firewall and :route_around_firewall" end end
[ "def", "change_routing_bypass!", "(", "routing_symbol", ")", "vlan_firewall_id", "=", "self", "[", "'networkVlanFirewall'", "]", "[", "'id'", "]", "raise", "\"Could not identify the device for a VLAN firewall\"", "if", "!", "vlan_firewall_id", "case", "routing_symbol", "when", ":route_through_firewall", "self", ".", "softlayer_client", "[", ":Network_Vlan_Firewall", "]", ".", "object_with_id", "(", "vlan_firewall_id", ")", ".", "updateRouteBypass", "(", "false", ")", "when", ":route_around_firewall", "self", ".", "softlayer_client", "[", ":Network_Vlan_Firewall", "]", ".", "object_with_id", "(", "vlan_firewall_id", ")", ".", "updateRouteBypass", "(", "true", ")", "else", "raise", "ArgumentError", ",", "\"An invalid parameter was sent to #{__method__}. It accepts :route_through_firewall and :route_around_firewall\"", "end", "end" ]
This method allows you to route traffic around the firewall and directly to the servers it protects. Compare the behavior of this routine with change_rules_bypass! It is important to note that changing the routing to :route_around_firewall removes ALL the protection offered by the firewall. This routine should be used with extreme discretion. Note that this routine constructs a transaction. The Routing change may not happen immediately. The two symbols accepted as arguments by the routine are: :route_through_firewall - Network traffic is sent through the firewall to the servers in the VLAN segment it protects. This is the usual operating mode of the firewall. :route_around_firewall - Network traffic will be sent directly to the servers in the VLAN segment protected by this firewall. This means that the firewall will *NOT* be protecting those servers.
[ "This", "method", "allows", "you", "to", "route", "traffic", "around", "the", "firewall", "and", "directly", "to", "the", "servers", "it", "protects", ".", "Compare", "the", "behavior", "of", "this", "routine", "with", "change_rules_bypass!" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VLANFirewall.rb#L221-L234
1,240
softlayer/softlayer-ruby
lib/softlayer/VLANFirewall.rb
SoftLayer.VLANFirewall.rules_ACL_id
def rules_ACL_id outside_interface_data = self['firewallInterfaces'].find { |interface_data| interface_data['name'] == 'outside' } incoming_ACL = outside_interface_data['firewallContextAccessControlLists'].find { |firewallACL_data| firewallACL_data['direction'] == 'in' } if outside_interface_data if incoming_ACL return incoming_ACL['id'] else return nil end end
ruby
def rules_ACL_id outside_interface_data = self['firewallInterfaces'].find { |interface_data| interface_data['name'] == 'outside' } incoming_ACL = outside_interface_data['firewallContextAccessControlLists'].find { |firewallACL_data| firewallACL_data['direction'] == 'in' } if outside_interface_data if incoming_ACL return incoming_ACL['id'] else return nil end end
[ "def", "rules_ACL_id", "outside_interface_data", "=", "self", "[", "'firewallInterfaces'", "]", ".", "find", "{", "|", "interface_data", "|", "interface_data", "[", "'name'", "]", "==", "'outside'", "}", "incoming_ACL", "=", "outside_interface_data", "[", "'firewallContextAccessControlLists'", "]", ".", "find", "{", "|", "firewallACL_data", "|", "firewallACL_data", "[", "'direction'", "]", "==", "'in'", "}", "if", "outside_interface_data", "if", "incoming_ACL", "return", "incoming_ACL", "[", "'id'", "]", "else", "return", "nil", "end", "end" ]
Searches the set of access control lists for the firewall device in order to locate the one that sits on the "outside" side of the network and handles 'in'coming traffic.
[ "Searches", "the", "set", "of", "access", "control", "lists", "for", "the", "firewall", "device", "in", "order", "to", "locate", "the", "one", "that", "sits", "on", "the", "outside", "side", "of", "the", "network", "and", "handles", "in", "coming", "traffic", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VLANFirewall.rb#L277-L286
1,241
softlayer/softlayer-ruby
lib/softlayer/VirtualServerOrder.rb
SoftLayer.VirtualServerOrder.place_order!
def place_order!() order_template = virtual_guest_template order_template = yield order_template if block_given? virtual_server_hash = @softlayer_client[:Virtual_Guest].createObject(order_template) SoftLayer::VirtualServer.server_with_id(virtual_server_hash['id'], :client => @softlayer_client) if virtual_server_hash end
ruby
def place_order!() order_template = virtual_guest_template order_template = yield order_template if block_given? virtual_server_hash = @softlayer_client[:Virtual_Guest].createObject(order_template) SoftLayer::VirtualServer.server_with_id(virtual_server_hash['id'], :client => @softlayer_client) if virtual_server_hash end
[ "def", "place_order!", "(", ")", "order_template", "=", "virtual_guest_template", "order_template", "=", "yield", "order_template", "if", "block_given?", "virtual_server_hash", "=", "@softlayer_client", "[", ":Virtual_Guest", "]", ".", "createObject", "(", "order_template", ")", "SoftLayer", "::", "VirtualServer", ".", "server_with_id", "(", "virtual_server_hash", "[", "'id'", "]", ",", ":client", "=>", "@softlayer_client", ")", "if", "virtual_server_hash", "end" ]
Calls the SoftLayer API to place an order for a new virtual server based on the template in this order. If this succeeds then you will be billed for the new Virtual Server. If you provide a block, it will receive the order template as a parameter and should return an order template, **carefully** modified, that will be sent to create the server
[ "Calls", "the", "SoftLayer", "API", "to", "place", "an", "order", "for", "a", "new", "virtual", "server", "based", "on", "the", "template", "in", "this", "order", ".", "If", "this", "succeeds", "then", "you", "will", "be", "billed", "for", "the", "new", "Virtual", "Server", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServerOrder.rb#L141-L147
1,242
softlayer/softlayer-ruby
lib/softlayer/Software.rb
SoftLayer.Software.delete_user_password!
def delete_user_password!(username) user_password = self.passwords.select { |sw_pw| sw_pw.username == username.to_s } unless user_password.empty? softlayer_client[:Software_Component_Password].object_with_id(user_password.first['id']).deleteObject @passwords = nil end end
ruby
def delete_user_password!(username) user_password = self.passwords.select { |sw_pw| sw_pw.username == username.to_s } unless user_password.empty? softlayer_client[:Software_Component_Password].object_with_id(user_password.first['id']).deleteObject @passwords = nil end end
[ "def", "delete_user_password!", "(", "username", ")", "user_password", "=", "self", ".", "passwords", ".", "select", "{", "|", "sw_pw", "|", "sw_pw", ".", "username", "==", "username", ".", "to_s", "}", "unless", "user_password", ".", "empty?", "softlayer_client", "[", ":Software_Component_Password", "]", ".", "object_with_id", "(", "user_password", ".", "first", "[", "'id'", "]", ")", ".", "deleteObject", "@passwords", "=", "nil", "end", "end" ]
Deletes specified username password from current software instance This is a final action and cannot be undone. the transaction will proceed immediately. Call it with extreme care!
[ "Deletes", "specified", "username", "password", "from", "current", "software", "instance" ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Software.rb#L109-L116
1,243
hanneskaeufler/danger-todoist
lib/todoist/plugin.rb
Danger.DangerTodoist.print_todos_table
def print_todos_table find_todos if @todos.nil? return if @todos.empty? markdown("#### Todos left in files") @todos .group_by(&:file) .each { |file, todos| print_todos_per_file(file, todos) } end
ruby
def print_todos_table find_todos if @todos.nil? return if @todos.empty? markdown("#### Todos left in files") @todos .group_by(&:file) .each { |file, todos| print_todos_per_file(file, todos) } end
[ "def", "print_todos_table", "find_todos", "if", "@todos", ".", "nil?", "return", "if", "@todos", ".", "empty?", "markdown", "(", "\"#### Todos left in files\"", ")", "@todos", ".", "group_by", "(", ":file", ")", ".", "each", "{", "|", "file", ",", "todos", "|", "print_todos_per_file", "(", "file", ",", "todos", ")", "}", "end" ]
Adds a list of offending files to the danger comment @return [void]
[ "Adds", "a", "list", "of", "offending", "files", "to", "the", "danger", "comment" ]
6f2075fc6a1ca1426b473885f90f7234c4ed0ce7
https://github.com/hanneskaeufler/danger-todoist/blob/6f2075fc6a1ca1426b473885f90f7234c4ed0ce7/lib/todoist/plugin.rb#L72-L81
1,244
softlayer/softlayer-ruby
lib/softlayer/VirtualServerOrder_Package.rb
SoftLayer.VirtualServerOrder_Package.virtual_server_order
def virtual_server_order product_order = { 'packageId' => @package.id, 'useHourlyPricing' => !!@hourly, 'virtualGuests' => [{ 'domain' => @domain, 'hostname' => @hostname }] } #Note that the use of image_template and SoftLayer::ProductPackage os/guest_diskX configuration category #item prices is mutually exclusive. product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template product_order['location'] = @datacenter.id if @datacenter product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI product_order['provisionScripts'] = [@provision_script_uri.to_s] if @provision_script_uri product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids product_order['virtualGuests'][0]['userData'] = @user_metadata if @user_metadata product_order['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id product_order['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id product_order['prices'] = @configuration_options.collect do |key, value| if value.respond_to?(:price_id) price_id = value.price_id else price_id = value.to_i end { 'id' => price_id } end product_order end
ruby
def virtual_server_order product_order = { 'packageId' => @package.id, 'useHourlyPricing' => !!@hourly, 'virtualGuests' => [{ 'domain' => @domain, 'hostname' => @hostname }] } #Note that the use of image_template and SoftLayer::ProductPackage os/guest_diskX configuration category #item prices is mutually exclusive. product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template product_order['location'] = @datacenter.id if @datacenter product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI product_order['provisionScripts'] = [@provision_script_uri.to_s] if @provision_script_uri product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids product_order['virtualGuests'][0]['userData'] = @user_metadata if @user_metadata product_order['primaryNetworkComponent'] = { "networkVlan" => { "id" => @public_vlan_id.to_i } } if @public_vlan_id product_order['primaryBackendNetworkComponent'] = { "networkVlan" => {"id" => @private_vlan_id.to_i } } if @private_vlan_id product_order['prices'] = @configuration_options.collect do |key, value| if value.respond_to?(:price_id) price_id = value.price_id else price_id = value.to_i end { 'id' => price_id } end product_order end
[ "def", "virtual_server_order", "product_order", "=", "{", "'packageId'", "=>", "@package", ".", "id", ",", "'useHourlyPricing'", "=>", "!", "!", "@hourly", ",", "'virtualGuests'", "=>", "[", "{", "'domain'", "=>", "@domain", ",", "'hostname'", "=>", "@hostname", "}", "]", "}", "#Note that the use of image_template and SoftLayer::ProductPackage os/guest_diskX configuration category", "#item prices is mutually exclusive.", "product_order", "[", "'imageTemplateGlobalIdentifier'", "]", "=", "@image_template", ".", "global_id", "if", "@image_template", "product_order", "[", "'location'", "]", "=", "@datacenter", ".", "id", "if", "@datacenter", "product_order", "[", "'provisionScripts'", "]", "=", "[", "@provision_script_URI", ".", "to_s", "]", "if", "@provision_script_URI", "product_order", "[", "'provisionScripts'", "]", "=", "[", "@provision_script_uri", ".", "to_s", "]", "if", "@provision_script_uri", "product_order", "[", "'sshKeys'", "]", "=", "[", "{", "'sshKeyIds'", "=>", "@ssh_key_ids", "}", "]", "if", "@ssh_key_ids", "product_order", "[", "'virtualGuests'", "]", "[", "0", "]", "[", "'userData'", "]", "=", "@user_metadata", "if", "@user_metadata", "product_order", "[", "'primaryNetworkComponent'", "]", "=", "{", "\"networkVlan\"", "=>", "{", "\"id\"", "=>", "@public_vlan_id", ".", "to_i", "}", "}", "if", "@public_vlan_id", "product_order", "[", "'primaryBackendNetworkComponent'", "]", "=", "{", "\"networkVlan\"", "=>", "{", "\"id\"", "=>", "@private_vlan_id", ".", "to_i", "}", "}", "if", "@private_vlan_id", "product_order", "[", "'prices'", "]", "=", "@configuration_options", ".", "collect", "do", "|", "key", ",", "value", "|", "if", "value", ".", "respond_to?", "(", ":price_id", ")", "price_id", "=", "value", ".", "price_id", "else", "price_id", "=", "value", ".", "to_i", "end", "{", "'id'", "=>", "price_id", "}", "end", "product_order", "end" ]
Construct and return a hash representing a +SoftLayer_Container_Product_Order_Virtual_Guest+ based on the configuration options given.
[ "Construct", "and", "return", "a", "hash", "representing", "a", "+", "SoftLayer_Container_Product_Order_Virtual_Guest", "+", "based", "on", "the", "configuration", "options", "given", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServerOrder_Package.rb#L145-L177
1,245
softlayer/softlayer-ruby
lib/softlayer/VirtualServer.rb
SoftLayer.VirtualServer.capture_image
def capture_image(image_name, include_attached_storage = false, image_notes = '') image_notes = '' if !image_notes image_name = 'Captured Image' if !image_name disk_filter = lambda { |disk| disk['device'] == '0' } disk_filter = lambda { |disk| disk['device'] != '1' } if include_attached_storage disks = self.blockDevices.select(&disk_filter) self.service.createArchiveTransaction(image_name, disks, image_notes) if disks && !disks.empty? image_templates = SoftLayer::ImageTemplate.find_private_templates(:name => image_name) image_templates[0] if !image_templates.empty? end
ruby
def capture_image(image_name, include_attached_storage = false, image_notes = '') image_notes = '' if !image_notes image_name = 'Captured Image' if !image_name disk_filter = lambda { |disk| disk['device'] == '0' } disk_filter = lambda { |disk| disk['device'] != '1' } if include_attached_storage disks = self.blockDevices.select(&disk_filter) self.service.createArchiveTransaction(image_name, disks, image_notes) if disks && !disks.empty? image_templates = SoftLayer::ImageTemplate.find_private_templates(:name => image_name) image_templates[0] if !image_templates.empty? end
[ "def", "capture_image", "(", "image_name", ",", "include_attached_storage", "=", "false", ",", "image_notes", "=", "''", ")", "image_notes", "=", "''", "if", "!", "image_notes", "image_name", "=", "'Captured Image'", "if", "!", "image_name", "disk_filter", "=", "lambda", "{", "|", "disk", "|", "disk", "[", "'device'", "]", "==", "'0'", "}", "disk_filter", "=", "lambda", "{", "|", "disk", "|", "disk", "[", "'device'", "]", "!=", "'1'", "}", "if", "include_attached_storage", "disks", "=", "self", ".", "blockDevices", ".", "select", "(", "disk_filter", ")", "self", ".", "service", ".", "createArchiveTransaction", "(", "image_name", ",", "disks", ",", "image_notes", ")", "if", "disks", "&&", "!", "disks", ".", "empty?", "image_templates", "=", "SoftLayer", "::", "ImageTemplate", ".", "find_private_templates", "(", ":name", "=>", "image_name", ")", "image_templates", "[", "0", "]", "if", "!", "image_templates", ".", "empty?", "end" ]
Capture a disk image of this virtual server for use with other servers. image_name will become the name of the image in the portal. If include_attached_storage is true, the images of attached storage will be included as well. The image_notes should be a string and will be added to the image as notes. The routine returns the instance of SoftLayer::ImageTemplate that is created. That image template will probably not be available immediately, however. You may use the wait_until_ready routine of SoftLayer::ImageTemplate to wait on it.
[ "Capture", "a", "disk", "image", "of", "this", "virtual", "server", "for", "use", "with", "other", "servers", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServer.rb#L132-L145
1,246
softlayer/softlayer-ruby
lib/softlayer/VirtualServer.rb
SoftLayer.VirtualServer.wait_until_ready
def wait_until_ready(max_trials, wait_for_transactions = false, seconds_between_tries = 2) # pessimistically assume the server is not ready num_trials = 0 begin self.refresh_details() has_os_reload = has_sl_property? :lastOperatingSystemReload has_active_transaction = has_sl_property? :activeTransaction reloading_os = has_active_transaction && has_os_reload && (self.last_operating_system_reload['id'] == self.active_transaction['id']) provisioned = has_sl_property?(:provisionDate) && ! self['provisionDate'].empty? # a server is ready when it is provisioned, not reloading the OS # (and if wait_for_transactions is true, when there are no active transactions). ready = provisioned && !reloading_os && (!wait_for_transactions || !has_active_transaction) num_trials = num_trials + 1 yield ready if block_given? sleep(seconds_between_tries) if !ready && (num_trials <= max_trials) end until ready || (num_trials >= max_trials) ready end
ruby
def wait_until_ready(max_trials, wait_for_transactions = false, seconds_between_tries = 2) # pessimistically assume the server is not ready num_trials = 0 begin self.refresh_details() has_os_reload = has_sl_property? :lastOperatingSystemReload has_active_transaction = has_sl_property? :activeTransaction reloading_os = has_active_transaction && has_os_reload && (self.last_operating_system_reload['id'] == self.active_transaction['id']) provisioned = has_sl_property?(:provisionDate) && ! self['provisionDate'].empty? # a server is ready when it is provisioned, not reloading the OS # (and if wait_for_transactions is true, when there are no active transactions). ready = provisioned && !reloading_os && (!wait_for_transactions || !has_active_transaction) num_trials = num_trials + 1 yield ready if block_given? sleep(seconds_between_tries) if !ready && (num_trials <= max_trials) end until ready || (num_trials >= max_trials) ready end
[ "def", "wait_until_ready", "(", "max_trials", ",", "wait_for_transactions", "=", "false", ",", "seconds_between_tries", "=", "2", ")", "# pessimistically assume the server is not ready", "num_trials", "=", "0", "begin", "self", ".", "refresh_details", "(", ")", "has_os_reload", "=", "has_sl_property?", ":lastOperatingSystemReload", "has_active_transaction", "=", "has_sl_property?", ":activeTransaction", "reloading_os", "=", "has_active_transaction", "&&", "has_os_reload", "&&", "(", "self", ".", "last_operating_system_reload", "[", "'id'", "]", "==", "self", ".", "active_transaction", "[", "'id'", "]", ")", "provisioned", "=", "has_sl_property?", "(", ":provisionDate", ")", "&&", "!", "self", "[", "'provisionDate'", "]", ".", "empty?", "# a server is ready when it is provisioned, not reloading the OS", "# (and if wait_for_transactions is true, when there are no active transactions).", "ready", "=", "provisioned", "&&", "!", "reloading_os", "&&", "(", "!", "wait_for_transactions", "||", "!", "has_active_transaction", ")", "num_trials", "=", "num_trials", "+", "1", "yield", "ready", "if", "block_given?", "sleep", "(", "seconds_between_tries", ")", "if", "!", "ready", "&&", "(", "num_trials", "<=", "max_trials", ")", "end", "until", "ready", "||", "(", "num_trials", ">=", "max_trials", ")", "ready", "end" ]
Repeatedly polls the API to find out if this server is 'ready'. The server is ready when it is provisioned and any operating system reloads have completed. If wait_for_transactions is true, then the routine will poll until all transactions (not just an OS Reload) have completed on the server. max_trials is the maximum number of times the routine will poll the API seconds_between_tries is the polling interval (in seconds) The routine returns true if the server was found to be ready. If max_trials is exceeded and the server is still not ready, the routine returns false If a block is passed to this routine it will be called on each trial with a boolean argument representing whether or not the server is ready Calling this routine will (in essence) block the thread on which the request is made.
[ "Repeatedly", "polls", "the", "API", "to", "find", "out", "if", "this", "server", "is", "ready", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/VirtualServer.rb#L166-L190
1,247
softlayer/softlayer-ruby
lib/softlayer/Account.rb
SoftLayer.Account.find_vlan_with_number
def find_vlan_with_number(vlan_number) filter = SoftLayer::ObjectFilter.new() { |filter| filter.accept('networkVlans.vlanNumber').when_it is vlan_number } vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans return vlan_data end
ruby
def find_vlan_with_number(vlan_number) filter = SoftLayer::ObjectFilter.new() { |filter| filter.accept('networkVlans.vlanNumber').when_it is vlan_number } vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans return vlan_data end
[ "def", "find_vlan_with_number", "(", "vlan_number", ")", "filter", "=", "SoftLayer", "::", "ObjectFilter", ".", "new", "(", ")", "{", "|", "filter", "|", "filter", ".", "accept", "(", "'networkVlans.vlanNumber'", ")", ".", "when_it", "is", "vlan_number", "}", "vlan_data", "=", "self", ".", "service", ".", "object_mask", "(", "\"mask[id,vlanNumber,primaryRouter,networkSpace]\"", ")", ".", "object_filter", "(", "filter", ")", ".", "getNetworkVlans", "return", "vlan_data", "end" ]
Searches the account's list of VLANs for the ones with the given vlan number. This may return multiple results because a VLAN can span different routers and you will get a separate segment for each router. The IDs of the different segments can be helpful for ordering firewalls.
[ "Searches", "the", "account", "s", "list", "of", "VLANs", "for", "the", "ones", "with", "the", "given", "vlan", "number", ".", "This", "may", "return", "multiple", "results", "because", "a", "VLAN", "can", "span", "different", "routers", "and", "you", "will", "get", "a", "separate", "segment", "for", "each", "router", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Account.rb#L267-L274
1,248
softlayer/softlayer-ruby
lib/softlayer/Client.rb
SoftLayer.Client.service_named
def service_named(service_name, service_options = {}) raise ArgumentError,"Please provide a service name" if service_name.nil? || service_name.empty? # Strip whitespace from service_name and ensure that it starts with "SoftLayer_". # If it does not, then add the prefix. full_name = service_name.to_s.strip if not full_name =~ /\ASoftLayer_/ full_name = "SoftLayer_#{service_name}" end # if we've already created this service, just return it # otherwise create a new service service_key = full_name.to_sym if [email protected]_key?(service_key) @services[service_key] = SoftLayer::Service.new(full_name, {:client => self}.merge(service_options)) end @services[service_key] end
ruby
def service_named(service_name, service_options = {}) raise ArgumentError,"Please provide a service name" if service_name.nil? || service_name.empty? # Strip whitespace from service_name and ensure that it starts with "SoftLayer_". # If it does not, then add the prefix. full_name = service_name.to_s.strip if not full_name =~ /\ASoftLayer_/ full_name = "SoftLayer_#{service_name}" end # if we've already created this service, just return it # otherwise create a new service service_key = full_name.to_sym if [email protected]_key?(service_key) @services[service_key] = SoftLayer::Service.new(full_name, {:client => self}.merge(service_options)) end @services[service_key] end
[ "def", "service_named", "(", "service_name", ",", "service_options", "=", "{", "}", ")", "raise", "ArgumentError", ",", "\"Please provide a service name\"", "if", "service_name", ".", "nil?", "||", "service_name", ".", "empty?", "# Strip whitespace from service_name and ensure that it starts with \"SoftLayer_\".", "# If it does not, then add the prefix.", "full_name", "=", "service_name", ".", "to_s", ".", "strip", "if", "not", "full_name", "=~", "/", "\\A", "/", "full_name", "=", "\"SoftLayer_#{service_name}\"", "end", "# if we've already created this service, just return it", "# otherwise create a new service", "service_key", "=", "full_name", ".", "to_sym", "if", "!", "@services", ".", "has_key?", "(", "service_key", ")", "@services", "[", "service_key", "]", "=", "SoftLayer", "::", "Service", ".", "new", "(", "full_name", ",", "{", ":client", "=>", "self", "}", ".", "merge", "(", "service_options", ")", ")", "end", "@services", "[", "service_key", "]", "end" ]
Returns a service with the given name. If a service has already been created by this client that same service will be returned each time it is called for by name. Otherwise the system will try to construct a new service object and return that. If the service has to be created then the service_options will be passed along to the creative function. However, when returning a previously created Service, the service_options will be ignored. If the service_name provided does not start with 'SoftLayer_' that prefix will be added
[ "Returns", "a", "service", "with", "the", "given", "name", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Client.rb#L170-L188
1,249
softlayer/softlayer-ruby
lib/softlayer/Service.rb
SoftLayer.Service.call_softlayer_api_with_params
def call_softlayer_api_with_params(method_name, parameters, args) additional_headers = {}; # The client knows about authentication, so ask him for the auth headers authentication_headers = self.client.authentication_headers additional_headers.merge!(authentication_headers) if parameters && parameters.server_object_filter additional_headers.merge!("#{@service_name}ObjectFilter" => parameters.server_object_filter) end # Object masks go into the headers too. if parameters && parameters.server_object_mask object_mask = parameters.server_object_mask additional_headers.merge!("SoftLayer_ObjectMask" => { "mask" => object_mask }) unless object_mask.empty? end # Result limits go into the headers if (parameters && parameters.server_result_limit) additional_headers.merge!("resultLimit" => { "limit" => parameters.server_result_limit, "offset" => (parameters.server_result_offset || 0) }) end # Add an object id to the headers. if parameters && parameters.server_object_id additional_headers.merge!("#{@service_name}InitParameters" => { "id" => parameters.server_object_id }) end # This is a workaround for a potential problem that arises from mis-using the # API. If you call SoftLayer_Virtual_Guest and you call the getObject method # but pass a virtual guest as a parameter, what happens is the getObject method # is called through an HTTP POST verb and the API creates a new VirtualServer that # is a copy of the one you passed in. # # The counter-intuitive creation of a new Virtual Server is unexpected and, even worse, # is something you can be billed for. To prevent that, we ignore the request # body on a "getObject" call and print out a warning. if (method_name == :getObject) && (nil != args) && (!args.empty?) then $stderr.puts "Warning - The getObject method takes no parameters. The parameters you have provided will be ignored." args = nil end # Collect all the different header pieces into a single hash that # will become the first argument to the call. call_headers = { "headers" => additional_headers } begin call_value = xmlrpc_client.call(method_name.to_s, call_headers, *args) rescue XMLRPC::FaultException => e puts "A XMLRPC Fault was returned #{e}" if $DEBUG raise end return call_value end
ruby
def call_softlayer_api_with_params(method_name, parameters, args) additional_headers = {}; # The client knows about authentication, so ask him for the auth headers authentication_headers = self.client.authentication_headers additional_headers.merge!(authentication_headers) if parameters && parameters.server_object_filter additional_headers.merge!("#{@service_name}ObjectFilter" => parameters.server_object_filter) end # Object masks go into the headers too. if parameters && parameters.server_object_mask object_mask = parameters.server_object_mask additional_headers.merge!("SoftLayer_ObjectMask" => { "mask" => object_mask }) unless object_mask.empty? end # Result limits go into the headers if (parameters && parameters.server_result_limit) additional_headers.merge!("resultLimit" => { "limit" => parameters.server_result_limit, "offset" => (parameters.server_result_offset || 0) }) end # Add an object id to the headers. if parameters && parameters.server_object_id additional_headers.merge!("#{@service_name}InitParameters" => { "id" => parameters.server_object_id }) end # This is a workaround for a potential problem that arises from mis-using the # API. If you call SoftLayer_Virtual_Guest and you call the getObject method # but pass a virtual guest as a parameter, what happens is the getObject method # is called through an HTTP POST verb and the API creates a new VirtualServer that # is a copy of the one you passed in. # # The counter-intuitive creation of a new Virtual Server is unexpected and, even worse, # is something you can be billed for. To prevent that, we ignore the request # body on a "getObject" call and print out a warning. if (method_name == :getObject) && (nil != args) && (!args.empty?) then $stderr.puts "Warning - The getObject method takes no parameters. The parameters you have provided will be ignored." args = nil end # Collect all the different header pieces into a single hash that # will become the first argument to the call. call_headers = { "headers" => additional_headers } begin call_value = xmlrpc_client.call(method_name.to_s, call_headers, *args) rescue XMLRPC::FaultException => e puts "A XMLRPC Fault was returned #{e}" if $DEBUG raise end return call_value end
[ "def", "call_softlayer_api_with_params", "(", "method_name", ",", "parameters", ",", "args", ")", "additional_headers", "=", "{", "}", ";", "# The client knows about authentication, so ask him for the auth headers", "authentication_headers", "=", "self", ".", "client", ".", "authentication_headers", "additional_headers", ".", "merge!", "(", "authentication_headers", ")", "if", "parameters", "&&", "parameters", ".", "server_object_filter", "additional_headers", ".", "merge!", "(", "\"#{@service_name}ObjectFilter\"", "=>", "parameters", ".", "server_object_filter", ")", "end", "# Object masks go into the headers too.", "if", "parameters", "&&", "parameters", ".", "server_object_mask", "object_mask", "=", "parameters", ".", "server_object_mask", "additional_headers", ".", "merge!", "(", "\"SoftLayer_ObjectMask\"", "=>", "{", "\"mask\"", "=>", "object_mask", "}", ")", "unless", "object_mask", ".", "empty?", "end", "# Result limits go into the headers", "if", "(", "parameters", "&&", "parameters", ".", "server_result_limit", ")", "additional_headers", ".", "merge!", "(", "\"resultLimit\"", "=>", "{", "\"limit\"", "=>", "parameters", ".", "server_result_limit", ",", "\"offset\"", "=>", "(", "parameters", ".", "server_result_offset", "||", "0", ")", "}", ")", "end", "# Add an object id to the headers.", "if", "parameters", "&&", "parameters", ".", "server_object_id", "additional_headers", ".", "merge!", "(", "\"#{@service_name}InitParameters\"", "=>", "{", "\"id\"", "=>", "parameters", ".", "server_object_id", "}", ")", "end", "# This is a workaround for a potential problem that arises from mis-using the", "# API. If you call SoftLayer_Virtual_Guest and you call the getObject method", "# but pass a virtual guest as a parameter, what happens is the getObject method", "# is called through an HTTP POST verb and the API creates a new VirtualServer that", "# is a copy of the one you passed in.", "#", "# The counter-intuitive creation of a new Virtual Server is unexpected and, even worse,", "# is something you can be billed for. To prevent that, we ignore the request", "# body on a \"getObject\" call and print out a warning.", "if", "(", "method_name", "==", ":getObject", ")", "&&", "(", "nil", "!=", "args", ")", "&&", "(", "!", "args", ".", "empty?", ")", "then", "$stderr", ".", "puts", "\"Warning - The getObject method takes no parameters. The parameters you have provided will be ignored.\"", "args", "=", "nil", "end", "# Collect all the different header pieces into a single hash that", "# will become the first argument to the call.", "call_headers", "=", "{", "\"headers\"", "=>", "additional_headers", "}", "begin", "call_value", "=", "xmlrpc_client", ".", "call", "(", "method_name", ".", "to_s", ",", "call_headers", ",", "args", ")", "rescue", "XMLRPC", "::", "FaultException", "=>", "e", "puts", "\"A XMLRPC Fault was returned #{e}\"", "if", "$DEBUG", "raise", "end", "return", "call_value", "end" ]
Issue an HTTP request to call the given method from the SoftLayer API with the parameters and arguments given. Parameters are information _about_ the call, the object mask or the particular object in the SoftLayer API you are calling. Arguments are the arguments to the SoftLayer method that you wish to invoke. This is intended to be used in the internal processing of method_missing and need not be called directly.
[ "Issue", "an", "HTTP", "request", "to", "call", "the", "given", "method", "from", "the", "SoftLayer", "API", "with", "the", "parameters", "and", "arguments", "given", "." ]
48d7e0e36a3b02d832e7e303a513020a8fbde93b
https://github.com/softlayer/softlayer-ruby/blob/48d7e0e36a3b02d832e7e303a513020a8fbde93b/lib/softlayer/Service.rb#L221-L276
1,250
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/bios_helper.rb
ILO_SDK.BiosHelper.set_bios_settings
def set_bios_settings(options, system_id = 1) r = response_handler(rest_patch("/redfish/v1/Systems/#{system_id}/bios/Settings/", body: options)) @logger.warn(r) if r['error'] true end
ruby
def set_bios_settings(options, system_id = 1) r = response_handler(rest_patch("/redfish/v1/Systems/#{system_id}/bios/Settings/", body: options)) @logger.warn(r) if r['error'] true end
[ "def", "set_bios_settings", "(", "options", ",", "system_id", "=", "1", ")", "r", "=", "response_handler", "(", "rest_patch", "(", "\"/redfish/v1/Systems/#{system_id}/bios/Settings/\"", ",", "body", ":", "options", ")", ")", "@logger", ".", "warn", "(", "r", ")", "if", "r", "[", "'error'", "]", "true", "end" ]
Set BIOS settings @param options [Hash] Hash of options to set @param system_id [Integer, String] ID of the system @raise [RuntimeError] if the request failed @return true
[ "Set", "BIOS", "settings" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L28-L32
1,251
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/bios_helper.rb
ILO_SDK.BiosHelper.set_uefi_shell_startup
def set_uefi_shell_startup(uefi_shell_startup, uefi_shell_startup_location, uefi_shell_startup_url) new_action = { 'UefiShellStartup' => uefi_shell_startup, 'UefiShellStartupLocation' => uefi_shell_startup_location, 'UefiShellStartupUrl' => uefi_shell_startup_url } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
ruby
def set_uefi_shell_startup(uefi_shell_startup, uefi_shell_startup_location, uefi_shell_startup_url) new_action = { 'UefiShellStartup' => uefi_shell_startup, 'UefiShellStartupLocation' => uefi_shell_startup_location, 'UefiShellStartupUrl' => uefi_shell_startup_url } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
[ "def", "set_uefi_shell_startup", "(", "uefi_shell_startup", ",", "uefi_shell_startup_location", ",", "uefi_shell_startup_url", ")", "new_action", "=", "{", "'UefiShellStartup'", "=>", "uefi_shell_startup", ",", "'UefiShellStartupLocation'", "=>", "uefi_shell_startup_location", ",", "'UefiShellStartupUrl'", "=>", "uefi_shell_startup_url", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/bios/Settings/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the UEFI shell start up @param uefi_shell_startup [String, Symbol] @param uefi_shell_startup_location [String, Symbol] @param uefi_shell_startup_url [String, Symbol] @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "UEFI", "shell", "start", "up" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L71-L80
1,252
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/bios_helper.rb
ILO_SDK.BiosHelper.get_bios_dhcp
def get_bios_dhcp response = rest_get('/redfish/v1/Systems/1/bios/Settings/') bios = response_handler(response) { 'Dhcpv4' => bios['Dhcpv4'], 'Ipv4Address' => bios['Ipv4Address'], 'Ipv4Gateway' => bios['Ipv4Gateway'], 'Ipv4PrimaryDNS' => bios['Ipv4PrimaryDNS'], 'Ipv4SecondaryDNS' => bios['Ipv4SecondaryDNS'], 'Ipv4SubnetMask' => bios['Ipv4SubnetMask'] } end
ruby
def get_bios_dhcp response = rest_get('/redfish/v1/Systems/1/bios/Settings/') bios = response_handler(response) { 'Dhcpv4' => bios['Dhcpv4'], 'Ipv4Address' => bios['Ipv4Address'], 'Ipv4Gateway' => bios['Ipv4Gateway'], 'Ipv4PrimaryDNS' => bios['Ipv4PrimaryDNS'], 'Ipv4SecondaryDNS' => bios['Ipv4SecondaryDNS'], 'Ipv4SubnetMask' => bios['Ipv4SubnetMask'] } end
[ "def", "get_bios_dhcp", "response", "=", "rest_get", "(", "'/redfish/v1/Systems/1/bios/Settings/'", ")", "bios", "=", "response_handler", "(", "response", ")", "{", "'Dhcpv4'", "=>", "bios", "[", "'Dhcpv4'", "]", ",", "'Ipv4Address'", "=>", "bios", "[", "'Ipv4Address'", "]", ",", "'Ipv4Gateway'", "=>", "bios", "[", "'Ipv4Gateway'", "]", ",", "'Ipv4PrimaryDNS'", "=>", "bios", "[", "'Ipv4PrimaryDNS'", "]", ",", "'Ipv4SecondaryDNS'", "=>", "bios", "[", "'Ipv4SecondaryDNS'", "]", ",", "'Ipv4SubnetMask'", "=>", "bios", "[", "'Ipv4SubnetMask'", "]", "}", "end" ]
Get the BIOS DHCP @raise [RuntimeError] if the request failed @return [String] bios_dhcp
[ "Get", "the", "BIOS", "DHCP" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L85-L96
1,253
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/bios_helper.rb
ILO_SDK.BiosHelper.set_bios_dhcp
def set_bios_dhcp(dhcpv4, ipv4_address = '', ipv4_gateway = '', ipv4_primary_dns = '', ipv4_secondary_dns = '', ipv4_subnet_mask = '') new_action = { 'Dhcpv4' => dhcpv4, 'Ipv4Address' => ipv4_address, 'Ipv4Gateway' => ipv4_gateway, 'Ipv4PrimaryDNS' => ipv4_primary_dns, 'Ipv4SecondaryDNS' => ipv4_secondary_dns, 'Ipv4SubnetMask' => ipv4_subnet_mask } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
ruby
def set_bios_dhcp(dhcpv4, ipv4_address = '', ipv4_gateway = '', ipv4_primary_dns = '', ipv4_secondary_dns = '', ipv4_subnet_mask = '') new_action = { 'Dhcpv4' => dhcpv4, 'Ipv4Address' => ipv4_address, 'Ipv4Gateway' => ipv4_gateway, 'Ipv4PrimaryDNS' => ipv4_primary_dns, 'Ipv4SecondaryDNS' => ipv4_secondary_dns, 'Ipv4SubnetMask' => ipv4_subnet_mask } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
[ "def", "set_bios_dhcp", "(", "dhcpv4", ",", "ipv4_address", "=", "''", ",", "ipv4_gateway", "=", "''", ",", "ipv4_primary_dns", "=", "''", ",", "ipv4_secondary_dns", "=", "''", ",", "ipv4_subnet_mask", "=", "''", ")", "new_action", "=", "{", "'Dhcpv4'", "=>", "dhcpv4", ",", "'Ipv4Address'", "=>", "ipv4_address", ",", "'Ipv4Gateway'", "=>", "ipv4_gateway", ",", "'Ipv4PrimaryDNS'", "=>", "ipv4_primary_dns", ",", "'Ipv4SecondaryDNS'", "=>", "ipv4_secondary_dns", ",", "'Ipv4SubnetMask'", "=>", "ipv4_subnet_mask", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/bios/Settings/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the BIOS DHCP @param dhcpv4 [String, Symbol] @param ipv4_address [String, Symbol] @param ipv4_gateway [String, Symbol] @param ipv4_primary_dns [String, Symbol] @param ipv4_secondary_dns [String, Symbol] @param ipv4_subnet_mask [String, Symbol] @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "BIOS", "DHCP" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L107-L119
1,254
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/bios_helper.rb
ILO_SDK.BiosHelper.set_url_boot_file
def set_url_boot_file(url_boot_file) new_action = { 'UrlBootFile' => url_boot_file } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
ruby
def set_url_boot_file(url_boot_file) new_action = { 'UrlBootFile' => url_boot_file } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
[ "def", "set_url_boot_file", "(", "url_boot_file", ")", "new_action", "=", "{", "'UrlBootFile'", "=>", "url_boot_file", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/bios/Settings/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the URL boot file @param url_boot_file [String, Symbol] @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "URL", "boot", "file" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L133-L138
1,255
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/bios_helper.rb
ILO_SDK.BiosHelper.set_bios_service
def set_bios_service(name, email) new_action = { 'ServiceName' => name, 'ServiceEmail' => email } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
ruby
def set_bios_service(name, email) new_action = { 'ServiceName' => name, 'ServiceEmail' => email } response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action) response_handler(response) true end
[ "def", "set_bios_service", "(", "name", ",", "email", ")", "new_action", "=", "{", "'ServiceName'", "=>", "name", ",", "'ServiceEmail'", "=>", "email", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/bios/Settings/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the BIOS service @param name [String, Symbol] @param email [String, Symbol] @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "BIOS", "service" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/bios_helper.rb#L157-L165
1,256
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/log_entry_helper.rb
ILO_SDK.LogEntryHelper.clear_logs
def clear_logs(log_type) new_action = { 'Action' => 'ClearLog' } response = rest_post(uri_for_log_type(log_type), body: new_action) response_handler(response) true end
ruby
def clear_logs(log_type) new_action = { 'Action' => 'ClearLog' } response = rest_post(uri_for_log_type(log_type), body: new_action) response_handler(response) true end
[ "def", "clear_logs", "(", "log_type", ")", "new_action", "=", "{", "'Action'", "=>", "'ClearLog'", "}", "response", "=", "rest_post", "(", "uri_for_log_type", "(", "log_type", ")", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Clear the specified logs @param [String, Symbol] log_type @raise [RuntimeError] if the request failed @return true
[ "Clear", "the", "specified", "logs" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/log_entry_helper.rb#L34-L39
1,257
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/log_entry_helper.rb
ILO_SDK.LogEntryHelper.get_logs
def get_logs(severity_level, duration, log_type) response = rest_get("#{uri_for_log_type(log_type)}Entries/") entries = response_handler(response)['Items'] start_time = Time.now.utc - (duration * 3600) if severity_level.nil? entries.select { |e| Time.parse(e['Created']) > start_time } else entries.select { |e| severity_level.to_s.casecmp(e['Severity']) == 0 && Time.parse(e['Created']) > start_time } end end
ruby
def get_logs(severity_level, duration, log_type) response = rest_get("#{uri_for_log_type(log_type)}Entries/") entries = response_handler(response)['Items'] start_time = Time.now.utc - (duration * 3600) if severity_level.nil? entries.select { |e| Time.parse(e['Created']) > start_time } else entries.select { |e| severity_level.to_s.casecmp(e['Severity']) == 0 && Time.parse(e['Created']) > start_time } end end
[ "def", "get_logs", "(", "severity_level", ",", "duration", ",", "log_type", ")", "response", "=", "rest_get", "(", "\"#{uri_for_log_type(log_type)}Entries/\"", ")", "entries", "=", "response_handler", "(", "response", ")", "[", "'Items'", "]", "start_time", "=", "Time", ".", "now", ".", "utc", "-", "(", "duration", "*", "3600", ")", "if", "severity_level", ".", "nil?", "entries", ".", "select", "{", "|", "e", "|", "Time", ".", "parse", "(", "e", "[", "'Created'", "]", ")", ">", "start_time", "}", "else", "entries", ".", "select", "{", "|", "e", "|", "severity_level", ".", "to_s", ".", "casecmp", "(", "e", "[", "'Severity'", "]", ")", "==", "0", "&&", "Time", ".", "parse", "(", "e", "[", "'Created'", "]", ")", ">", "start_time", "}", "end", "end" ]
Get the specified logs @param [String, Symbol, NilClass] severity_level Set to nil to get all logs @param [String, Symbol] duration Up to this many hours ago @param [String, Symbol] log_type IEL or IML @raise [RuntimeError] if the request failed @return [Array] log entries
[ "Get", "the", "specified", "logs" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/log_entry_helper.rb#L56-L65
1,258
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/computer_details_helper.rb
ILO_SDK.ComputerDetailsHelper.get_computer_details
def get_computer_details general_computer_details = get_general_computer_details computer_network_details = get_computer_network_details array_controller_details = get_array_controller_details general_computer_details.merge(computer_network_details).merge(array_controller_details) end
ruby
def get_computer_details general_computer_details = get_general_computer_details computer_network_details = get_computer_network_details array_controller_details = get_array_controller_details general_computer_details.merge(computer_network_details).merge(array_controller_details) end
[ "def", "get_computer_details", "general_computer_details", "=", "get_general_computer_details", "computer_network_details", "=", "get_computer_network_details", "array_controller_details", "=", "get_array_controller_details", "general_computer_details", ".", "merge", "(", "computer_network_details", ")", ".", "merge", "(", "array_controller_details", ")", "end" ]
Get all of the computer details @raise [RuntimeError] if the request failed @return [Hash] computer_details
[ "Get", "all", "of", "the", "computer", "details" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_details_helper.rb#L18-L23
1,259
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/computer_details_helper.rb
ILO_SDK.ComputerDetailsHelper.get_general_computer_details
def get_general_computer_details response = rest_get('/redfish/v1/Systems/1/') details = response_handler(response) { 'GeneralDetails' => { 'manufacturer' => details['Manufacturer'], 'model' => details['Model'], 'AssetTag' => details['AssetTag'], 'bios_version' => details['Bios']['Current']['VersionString'], 'memory' => details['Memory']['TotalSystemMemoryGB'].to_s + ' GB', 'processors' => details['Processors']['Count'].to_s + ' x ' + details['Processors']['ProcessorFamily'].to_s } } end
ruby
def get_general_computer_details response = rest_get('/redfish/v1/Systems/1/') details = response_handler(response) { 'GeneralDetails' => { 'manufacturer' => details['Manufacturer'], 'model' => details['Model'], 'AssetTag' => details['AssetTag'], 'bios_version' => details['Bios']['Current']['VersionString'], 'memory' => details['Memory']['TotalSystemMemoryGB'].to_s + ' GB', 'processors' => details['Processors']['Count'].to_s + ' x ' + details['Processors']['ProcessorFamily'].to_s } } end
[ "def", "get_general_computer_details", "response", "=", "rest_get", "(", "'/redfish/v1/Systems/1/'", ")", "details", "=", "response_handler", "(", "response", ")", "{", "'GeneralDetails'", "=>", "{", "'manufacturer'", "=>", "details", "[", "'Manufacturer'", "]", ",", "'model'", "=>", "details", "[", "'Model'", "]", ",", "'AssetTag'", "=>", "details", "[", "'AssetTag'", "]", ",", "'bios_version'", "=>", "details", "[", "'Bios'", "]", "[", "'Current'", "]", "[", "'VersionString'", "]", ",", "'memory'", "=>", "details", "[", "'Memory'", "]", "[", "'TotalSystemMemoryGB'", "]", ".", "to_s", "+", "' GB'", ",", "'processors'", "=>", "details", "[", "'Processors'", "]", "[", "'Count'", "]", ".", "to_s", "+", "' x '", "+", "details", "[", "'Processors'", "]", "[", "'ProcessorFamily'", "]", ".", "to_s", "}", "}", "end" ]
Get the general computer details @raise [RuntimeError] if the request failed @return [Fixnum] general_computer_details
[ "Get", "the", "general", "computer", "details" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_details_helper.rb#L28-L41
1,260
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/computer_details_helper.rb
ILO_SDK.ComputerDetailsHelper.get_computer_network_details
def get_computer_network_details network_adapters = [] response = rest_get('/redfish/v1/Systems/1/NetworkAdapters/') networks = response_handler(response)['links']['Member'] networks.each do |network| response = rest_get(network['href']) detail = response_handler(response) physical_ports = [] detail['PhysicalPorts'].each do |port| n = { 'Name' => port['Name'], 'StructuredName' => port['Oem']['Hp']['StructuredName'], 'MacAddress' => port['MacAddress'], 'State' => port['Status']['State'] } physical_ports.push(n) end nets = { 'Name' => detail['Name'], 'StructuredName' => detail['StructuredName'], 'PartNumber' => detail['PartNumber'], 'State' => detail['Status']['State'], 'Health' => detail['Status']['Health'], 'PhysicalPorts' => physical_ports } network_adapters.push(nets) end { 'NetworkAdapters' => network_adapters } end
ruby
def get_computer_network_details network_adapters = [] response = rest_get('/redfish/v1/Systems/1/NetworkAdapters/') networks = response_handler(response)['links']['Member'] networks.each do |network| response = rest_get(network['href']) detail = response_handler(response) physical_ports = [] detail['PhysicalPorts'].each do |port| n = { 'Name' => port['Name'], 'StructuredName' => port['Oem']['Hp']['StructuredName'], 'MacAddress' => port['MacAddress'], 'State' => port['Status']['State'] } physical_ports.push(n) end nets = { 'Name' => detail['Name'], 'StructuredName' => detail['StructuredName'], 'PartNumber' => detail['PartNumber'], 'State' => detail['Status']['State'], 'Health' => detail['Status']['Health'], 'PhysicalPorts' => physical_ports } network_adapters.push(nets) end { 'NetworkAdapters' => network_adapters } end
[ "def", "get_computer_network_details", "network_adapters", "=", "[", "]", "response", "=", "rest_get", "(", "'/redfish/v1/Systems/1/NetworkAdapters/'", ")", "networks", "=", "response_handler", "(", "response", ")", "[", "'links'", "]", "[", "'Member'", "]", "networks", ".", "each", "do", "|", "network", "|", "response", "=", "rest_get", "(", "network", "[", "'href'", "]", ")", "detail", "=", "response_handler", "(", "response", ")", "physical_ports", "=", "[", "]", "detail", "[", "'PhysicalPorts'", "]", ".", "each", "do", "|", "port", "|", "n", "=", "{", "'Name'", "=>", "port", "[", "'Name'", "]", ",", "'StructuredName'", "=>", "port", "[", "'Oem'", "]", "[", "'Hp'", "]", "[", "'StructuredName'", "]", ",", "'MacAddress'", "=>", "port", "[", "'MacAddress'", "]", ",", "'State'", "=>", "port", "[", "'Status'", "]", "[", "'State'", "]", "}", "physical_ports", ".", "push", "(", "n", ")", "end", "nets", "=", "{", "'Name'", "=>", "detail", "[", "'Name'", "]", ",", "'StructuredName'", "=>", "detail", "[", "'StructuredName'", "]", ",", "'PartNumber'", "=>", "detail", "[", "'PartNumber'", "]", ",", "'State'", "=>", "detail", "[", "'Status'", "]", "[", "'State'", "]", ",", "'Health'", "=>", "detail", "[", "'Status'", "]", "[", "'Health'", "]", ",", "'PhysicalPorts'", "=>", "physical_ports", "}", "network_adapters", ".", "push", "(", "nets", ")", "end", "{", "'NetworkAdapters'", "=>", "network_adapters", "}", "end" ]
Get the computer network details @raise [RuntimeError] if the request failed @return [Hash] computer_network_details
[ "Get", "the", "computer", "network", "details" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_details_helper.rb#L46-L76
1,261
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/firmware_update.rb
ILO_SDK.FirmwareUpdateHelper.set_fw_upgrade
def set_fw_upgrade(uri, tpm_override_flag = true) new_action = { 'Action' => 'InstallFromURI', 'FirmwareURI' => uri, 'TPMOverrideFlag' => tpm_override_flag } response = rest_post('/redfish/v1/Managers/1/UpdateService/', body: new_action) response_handler(response) true end
ruby
def set_fw_upgrade(uri, tpm_override_flag = true) new_action = { 'Action' => 'InstallFromURI', 'FirmwareURI' => uri, 'TPMOverrideFlag' => tpm_override_flag } response = rest_post('/redfish/v1/Managers/1/UpdateService/', body: new_action) response_handler(response) true end
[ "def", "set_fw_upgrade", "(", "uri", ",", "tpm_override_flag", "=", "true", ")", "new_action", "=", "{", "'Action'", "=>", "'InstallFromURI'", ",", "'FirmwareURI'", "=>", "uri", ",", "'TPMOverrideFlag'", "=>", "tpm_override_flag", "}", "response", "=", "rest_post", "(", "'/redfish/v1/Managers/1/UpdateService/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the Firmware Upgrade @param [String, Symbol] uri @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "Firmware", "Upgrade" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/firmware_update.rb#L27-L32
1,262
petebrowne/sprockets-helpers
lib/sprockets/helpers.rb
Sprockets.Helpers.asset_path
def asset_path(source, options = {}) uri = URI.parse(source) return source if uri.absolute? options[:prefix] = Sprockets::Helpers.prefix unless options[:prefix] if Helpers.debug || options[:debug] options[:manifest] = false options[:digest] = false options[:asset_host] = false end source_ext = File.extname(source) if options[:ext] && source_ext != ".#{options[:ext]}" uri.path << ".#{options[:ext]}" end path = find_asset_path(uri, source, options) if options[:expand] && path.respond_to?(:to_a) path.to_a else path.to_s end end
ruby
def asset_path(source, options = {}) uri = URI.parse(source) return source if uri.absolute? options[:prefix] = Sprockets::Helpers.prefix unless options[:prefix] if Helpers.debug || options[:debug] options[:manifest] = false options[:digest] = false options[:asset_host] = false end source_ext = File.extname(source) if options[:ext] && source_ext != ".#{options[:ext]}" uri.path << ".#{options[:ext]}" end path = find_asset_path(uri, source, options) if options[:expand] && path.respond_to?(:to_a) path.to_a else path.to_s end end
[ "def", "asset_path", "(", "source", ",", "options", "=", "{", "}", ")", "uri", "=", "URI", ".", "parse", "(", "source", ")", "return", "source", "if", "uri", ".", "absolute?", "options", "[", ":prefix", "]", "=", "Sprockets", "::", "Helpers", ".", "prefix", "unless", "options", "[", ":prefix", "]", "if", "Helpers", ".", "debug", "||", "options", "[", ":debug", "]", "options", "[", ":manifest", "]", "=", "false", "options", "[", ":digest", "]", "=", "false", "options", "[", ":asset_host", "]", "=", "false", "end", "source_ext", "=", "File", ".", "extname", "(", "source", ")", "if", "options", "[", ":ext", "]", "&&", "source_ext", "!=", "\".#{options[:ext]}\"", "uri", ".", "path", "<<", "\".#{options[:ext]}\"", "end", "path", "=", "find_asset_path", "(", "uri", ",", "source", ",", "options", ")", "if", "options", "[", ":expand", "]", "&&", "path", ".", "respond_to?", "(", ":to_a", ")", "path", ".", "to_a", "else", "path", ".", "to_s", "end", "end" ]
Returns the path to an asset either in the Sprockets environment or the public directory. External URIs are untouched. ==== Options * <tt>:ext</tt> - The extension to append if the source does not have one. * <tt>:dir</tt> - The directory to prepend if the file is in the public directory. * <tt>:digest</tt> - Wether or not use the digest paths for assets. Set Sprockets::Helpers.digest for global configuration. * <tt>:prefix</tt> - Use a custom prefix for the Sprockets environment. Set Sprockets::Helpers.prefix for global configuration. * <tt>:body</tt> - Adds a ?body=1 flag that tells Sprockets to return only the body of the asset. ==== Examples For files within Sprockets: asset_path 'xmlhr.js' # => '/assets/xmlhr.js' asset_path 'xmlhr', :ext => 'js' # => '/assets/xmlhr.js' asset_path 'xmlhr.js', :digest => true # => '/assets/xmlhr-27a8f1f96afd8d4c67a59eb9447f45bd.js' asset_path 'xmlhr.js', :prefix => '/themes' # => '/themes/xmlhr.js' For files outside of Sprockets: asset_path 'xmlhr' # => '/xmlhr' asset_path 'xmlhr', :ext => 'js' # => '/xmlhr.js' asset_path 'dir/xmlhr.js', :dir => 'javascripts' # => '/javascripts/dir/xmlhr.js' asset_path '/dir/xmlhr.js', :dir => 'javascripts' # => '/dir/xmlhr.js' asset_path 'http://www.example.com/js/xmlhr' # => 'http://www.example.com/js/xmlhr' asset_path 'http://www.example.com/js/xmlhr.js' # => 'http://www.example.com/js/xmlhr.js'
[ "Returns", "the", "path", "to", "an", "asset", "either", "in", "the", "Sprockets", "environment", "or", "the", "public", "directory", ".", "External", "URIs", "are", "untouched", "." ]
e3b952a392345432046ef7016bf60c502eb370ae
https://github.com/petebrowne/sprockets-helpers/blob/e3b952a392345432046ef7016bf60c502eb370ae/lib/sprockets/helpers.rb#L127-L151
1,263
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/chassis_helper.rb
ILO_SDK.ChassisHelper.get_power_metrics
def get_power_metrics chassis = rest_get('/redfish/v1/Chassis/') chassis_uri = response_handler(chassis)['links']['Member'][0]['href'] power_metrics_uri = response_handler(rest_get(chassis_uri))['links']['PowerMetrics']['href'] response = rest_get(power_metrics_uri) metrics = response_handler(response) power_supplies = [] metrics['PowerSupplies'].each do |ps| power_supply = { 'LineInputVoltage' => ps['LineInputVoltage'], 'LineInputVoltageType' => ps['LineInputVoltageType'], 'PowerCapacityWatts' => ps['PowerCapacityWatts'], 'PowerSupplyType' => ps['PowerSupplyType'], 'Health' => ps['Status']['Health'], 'State' => ps['Status']['State'] } power_supplies.push(power_supply) end { @host => { 'PowerCapacityWatts' => metrics['PowerCapacityWatts'], 'PowerConsumedWatts' => metrics['PowerConsumedWatts'], 'PowerSupplies' => power_supplies } } end
ruby
def get_power_metrics chassis = rest_get('/redfish/v1/Chassis/') chassis_uri = response_handler(chassis)['links']['Member'][0]['href'] power_metrics_uri = response_handler(rest_get(chassis_uri))['links']['PowerMetrics']['href'] response = rest_get(power_metrics_uri) metrics = response_handler(response) power_supplies = [] metrics['PowerSupplies'].each do |ps| power_supply = { 'LineInputVoltage' => ps['LineInputVoltage'], 'LineInputVoltageType' => ps['LineInputVoltageType'], 'PowerCapacityWatts' => ps['PowerCapacityWatts'], 'PowerSupplyType' => ps['PowerSupplyType'], 'Health' => ps['Status']['Health'], 'State' => ps['Status']['State'] } power_supplies.push(power_supply) end { @host => { 'PowerCapacityWatts' => metrics['PowerCapacityWatts'], 'PowerConsumedWatts' => metrics['PowerConsumedWatts'], 'PowerSupplies' => power_supplies } } end
[ "def", "get_power_metrics", "chassis", "=", "rest_get", "(", "'/redfish/v1/Chassis/'", ")", "chassis_uri", "=", "response_handler", "(", "chassis", ")", "[", "'links'", "]", "[", "'Member'", "]", "[", "0", "]", "[", "'href'", "]", "power_metrics_uri", "=", "response_handler", "(", "rest_get", "(", "chassis_uri", ")", ")", "[", "'links'", "]", "[", "'PowerMetrics'", "]", "[", "'href'", "]", "response", "=", "rest_get", "(", "power_metrics_uri", ")", "metrics", "=", "response_handler", "(", "response", ")", "power_supplies", "=", "[", "]", "metrics", "[", "'PowerSupplies'", "]", ".", "each", "do", "|", "ps", "|", "power_supply", "=", "{", "'LineInputVoltage'", "=>", "ps", "[", "'LineInputVoltage'", "]", ",", "'LineInputVoltageType'", "=>", "ps", "[", "'LineInputVoltageType'", "]", ",", "'PowerCapacityWatts'", "=>", "ps", "[", "'PowerCapacityWatts'", "]", ",", "'PowerSupplyType'", "=>", "ps", "[", "'PowerSupplyType'", "]", ",", "'Health'", "=>", "ps", "[", "'Status'", "]", "[", "'Health'", "]", ",", "'State'", "=>", "ps", "[", "'Status'", "]", "[", "'State'", "]", "}", "power_supplies", ".", "push", "(", "power_supply", ")", "end", "{", "@host", "=>", "{", "'PowerCapacityWatts'", "=>", "metrics", "[", "'PowerCapacityWatts'", "]", ",", "'PowerConsumedWatts'", "=>", "metrics", "[", "'PowerConsumedWatts'", "]", ",", "'PowerSupplies'", "=>", "power_supplies", "}", "}", "end" ]
Get the power metrics @raise [RuntimeError] if the request failed @return [Hash] power_metrics
[ "Get", "the", "power", "metrics" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/chassis_helper.rb#L18-L43
1,264
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/chassis_helper.rb
ILO_SDK.ChassisHelper.get_thermal_metrics
def get_thermal_metrics chassis = rest_get('/redfish/v1/Chassis/') chassis_uri = response_handler(chassis)['links']['Member'][0]['href'] thermal_metrics_uri = response_handler(rest_get(chassis_uri))['links']['ThermalMetrics']['href'] response = rest_get(thermal_metrics_uri) temperatures = response_handler(response)['Temperatures'] temp_details = [] temperatures.each do |temp| temp_detail = { 'PhysicalContext' => temp['PhysicalContext'], 'Name' => temp['Name'], 'CurrentReading' => temp['ReadingCelsius'], 'CriticalThreshold' => temp['LowerThresholdCritical'], 'Health' => temp['Status']['Health'], 'State' => temp['Status']['State'] } temp_details.push(temp_detail) end { @host => temp_details } end
ruby
def get_thermal_metrics chassis = rest_get('/redfish/v1/Chassis/') chassis_uri = response_handler(chassis)['links']['Member'][0]['href'] thermal_metrics_uri = response_handler(rest_get(chassis_uri))['links']['ThermalMetrics']['href'] response = rest_get(thermal_metrics_uri) temperatures = response_handler(response)['Temperatures'] temp_details = [] temperatures.each do |temp| temp_detail = { 'PhysicalContext' => temp['PhysicalContext'], 'Name' => temp['Name'], 'CurrentReading' => temp['ReadingCelsius'], 'CriticalThreshold' => temp['LowerThresholdCritical'], 'Health' => temp['Status']['Health'], 'State' => temp['Status']['State'] } temp_details.push(temp_detail) end { @host => temp_details } end
[ "def", "get_thermal_metrics", "chassis", "=", "rest_get", "(", "'/redfish/v1/Chassis/'", ")", "chassis_uri", "=", "response_handler", "(", "chassis", ")", "[", "'links'", "]", "[", "'Member'", "]", "[", "0", "]", "[", "'href'", "]", "thermal_metrics_uri", "=", "response_handler", "(", "rest_get", "(", "chassis_uri", ")", ")", "[", "'links'", "]", "[", "'ThermalMetrics'", "]", "[", "'href'", "]", "response", "=", "rest_get", "(", "thermal_metrics_uri", ")", "temperatures", "=", "response_handler", "(", "response", ")", "[", "'Temperatures'", "]", "temp_details", "=", "[", "]", "temperatures", ".", "each", "do", "|", "temp", "|", "temp_detail", "=", "{", "'PhysicalContext'", "=>", "temp", "[", "'PhysicalContext'", "]", ",", "'Name'", "=>", "temp", "[", "'Name'", "]", ",", "'CurrentReading'", "=>", "temp", "[", "'ReadingCelsius'", "]", ",", "'CriticalThreshold'", "=>", "temp", "[", "'LowerThresholdCritical'", "]", ",", "'Health'", "=>", "temp", "[", "'Status'", "]", "[", "'Health'", "]", ",", "'State'", "=>", "temp", "[", "'Status'", "]", "[", "'State'", "]", "}", "temp_details", ".", "push", "(", "temp_detail", ")", "end", "{", "@host", "=>", "temp_details", "}", "end" ]
Get the thermal metrics @raise [RuntimeError] if the request failed @return [Hash] thermal_metrics
[ "Get", "the", "thermal", "metrics" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/chassis_helper.rb#L48-L67
1,265
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/date_time_helper.rb
ILO_SDK.DateTimeHelper.set_time_zone
def set_time_zone(time_zone) time_response = rest_get('/redfish/v1/Managers/1/DateTime/') new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone } new_action = { 'TimeZone' => { 'Index' => new_time_zone[0]['Index'] } } response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action) response_handler(response) true end
ruby
def set_time_zone(time_zone) time_response = rest_get('/redfish/v1/Managers/1/DateTime/') new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone } new_action = { 'TimeZone' => { 'Index' => new_time_zone[0]['Index'] } } response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action) response_handler(response) true end
[ "def", "set_time_zone", "(", "time_zone", ")", "time_response", "=", "rest_get", "(", "'/redfish/v1/Managers/1/DateTime/'", ")", "new_time_zone", "=", "response_handler", "(", "time_response", ")", "[", "'TimeZoneList'", "]", ".", "select", "{", "|", "timezone", "|", "timezone", "[", "'Name'", "]", "==", "time_zone", "}", "new_action", "=", "{", "'TimeZone'", "=>", "{", "'Index'", "=>", "new_time_zone", "[", "0", "]", "[", "'Index'", "]", "}", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Managers/1/DateTime/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the Time Zone @param [Fixnum] time_zone @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "Time", "Zone" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/date_time_helper.rb#L27-L34
1,266
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/date_time_helper.rb
ILO_SDK.DateTimeHelper.set_ntp
def set_ntp(use_ntp) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } } response = rest_patch('/redfish/v1/Managers/1/EthernetInterfaces/1/', body: new_action) response_handler(response) true end
ruby
def set_ntp(use_ntp) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } } response = rest_patch('/redfish/v1/Managers/1/EthernetInterfaces/1/', body: new_action) response_handler(response) true end
[ "def", "set_ntp", "(", "use_ntp", ")", "new_action", "=", "{", "'Oem'", "=>", "{", "'Hp'", "=>", "{", "'DHCPv4'", "=>", "{", "'UseNTPServers'", "=>", "use_ntp", "}", "}", "}", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Managers/1/EthernetInterfaces/1/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set whether or not ntp servers are being used @param [TrueClass, FalseClass] use_ntp @raise [RuntimeError] if the request failed @return true
[ "Set", "whether", "or", "not", "ntp", "servers", "are", "being", "used" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/date_time_helper.rb#L48-L53
1,267
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/date_time_helper.rb
ILO_SDK.DateTimeHelper.set_ntp_servers
def set_ntp_servers(ntp_servers) new_action = { 'StaticNTPServers' => ntp_servers } response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action) response_handler(response) true end
ruby
def set_ntp_servers(ntp_servers) new_action = { 'StaticNTPServers' => ntp_servers } response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action) response_handler(response) true end
[ "def", "set_ntp_servers", "(", "ntp_servers", ")", "new_action", "=", "{", "'StaticNTPServers'", "=>", "ntp_servers", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Managers/1/DateTime/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the NTP Servers @param [Fixnum] ntp_servers @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "NTP", "Servers" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/date_time_helper.rb#L67-L72
1,268
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/cli.rb
ILO_SDK.Cli.output
def output(data = {}, indent = 0) case @options['format'] when 'json' puts JSON.pretty_generate(data) when 'yaml' puts data.to_yaml else # rubocop:disable Metrics/BlockNesting if data.class == Hash data.each do |k, v| if v.class == Hash || v.class == Array puts "#{' ' * indent}#{k.nil? ? 'nil' : k}:" output(v, indent + 2) else puts "#{' ' * indent}#{k.nil? ? 'nil' : k}: #{v.nil? ? 'nil' : v}" end end elsif data.class == Array data.each do |d| if d.class == Hash || d.class == Array output(d, indent + 2) else puts "#{' ' * indent}#{d.nil? ? 'nil' : d}" end end puts "\nTotal: #{data.size}" if indent < 1 else puts "#{' ' * indent}#{data.nil? ? 'nil' : data}" end # rubocop:enable Metrics/BlockNesting end end
ruby
def output(data = {}, indent = 0) case @options['format'] when 'json' puts JSON.pretty_generate(data) when 'yaml' puts data.to_yaml else # rubocop:disable Metrics/BlockNesting if data.class == Hash data.each do |k, v| if v.class == Hash || v.class == Array puts "#{' ' * indent}#{k.nil? ? 'nil' : k}:" output(v, indent + 2) else puts "#{' ' * indent}#{k.nil? ? 'nil' : k}: #{v.nil? ? 'nil' : v}" end end elsif data.class == Array data.each do |d| if d.class == Hash || d.class == Array output(d, indent + 2) else puts "#{' ' * indent}#{d.nil? ? 'nil' : d}" end end puts "\nTotal: #{data.size}" if indent < 1 else puts "#{' ' * indent}#{data.nil? ? 'nil' : data}" end # rubocop:enable Metrics/BlockNesting end end
[ "def", "output", "(", "data", "=", "{", "}", ",", "indent", "=", "0", ")", "case", "@options", "[", "'format'", "]", "when", "'json'", "puts", "JSON", ".", "pretty_generate", "(", "data", ")", "when", "'yaml'", "puts", "data", ".", "to_yaml", "else", "# rubocop:disable Metrics/BlockNesting", "if", "data", ".", "class", "==", "Hash", "data", ".", "each", "do", "|", "k", ",", "v", "|", "if", "v", ".", "class", "==", "Hash", "||", "v", ".", "class", "==", "Array", "puts", "\"#{' ' * indent}#{k.nil? ? 'nil' : k}:\"", "output", "(", "v", ",", "indent", "+", "2", ")", "else", "puts", "\"#{' ' * indent}#{k.nil? ? 'nil' : k}: #{v.nil? ? 'nil' : v}\"", "end", "end", "elsif", "data", ".", "class", "==", "Array", "data", ".", "each", "do", "|", "d", "|", "if", "d", ".", "class", "==", "Hash", "||", "d", ".", "class", "==", "Array", "output", "(", "d", ",", "indent", "+", "2", ")", "else", "puts", "\"#{' ' * indent}#{d.nil? ? 'nil' : d}\"", "end", "end", "puts", "\"\\nTotal: #{data.size}\"", "if", "indent", "<", "1", "else", "puts", "\"#{' ' * indent}#{data.nil? ? 'nil' : data}\"", "end", "# rubocop:enable Metrics/BlockNesting", "end", "end" ]
Print output in a given format.
[ "Print", "output", "in", "a", "given", "format", "." ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/cli.rb#L223-L254
1,269
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/boot_settings_helper.rb
ILO_SDK.BootSettingsHelper.set_boot_order
def set_boot_order(boot_order) new_action = { 'PersistentBootConfigOrder' => boot_order } response = rest_patch('/redfish/v1/systems/1/bios/Boot/Settings/', body: new_action) response_handler(response) true end
ruby
def set_boot_order(boot_order) new_action = { 'PersistentBootConfigOrder' => boot_order } response = rest_patch('/redfish/v1/systems/1/bios/Boot/Settings/', body: new_action) response_handler(response) true end
[ "def", "set_boot_order", "(", "boot_order", ")", "new_action", "=", "{", "'PersistentBootConfigOrder'", "=>", "boot_order", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/systems/1/bios/Boot/Settings/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the boot order @param [Fixnum] boot_order @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "boot", "order" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/boot_settings_helper.rb#L45-L50
1,270
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/boot_settings_helper.rb
ILO_SDK.BootSettingsHelper.set_temporary_boot_order
def set_temporary_boot_order(boot_target) response = rest_get('/redfish/v1/Systems/1/') boottargets = response_handler(response)['Boot']['BootSourceOverrideSupported'] unless boottargets.include? boot_target raise "BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values are: #{boottargets}" end new_action = { 'Boot' => { 'BootSourceOverrideTarget' => boot_target } } response = rest_patch('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
ruby
def set_temporary_boot_order(boot_target) response = rest_get('/redfish/v1/Systems/1/') boottargets = response_handler(response)['Boot']['BootSourceOverrideSupported'] unless boottargets.include? boot_target raise "BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values are: #{boottargets}" end new_action = { 'Boot' => { 'BootSourceOverrideTarget' => boot_target } } response = rest_patch('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
[ "def", "set_temporary_boot_order", "(", "boot_target", ")", "response", "=", "rest_get", "(", "'/redfish/v1/Systems/1/'", ")", "boottargets", "=", "response_handler", "(", "response", ")", "[", "'Boot'", "]", "[", "'BootSourceOverrideSupported'", "]", "unless", "boottargets", ".", "include?", "boot_target", "raise", "\"BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values are: #{boottargets}\"", "end", "new_action", "=", "{", "'Boot'", "=>", "{", "'BootSourceOverrideTarget'", "=>", "boot_target", "}", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the temporary boot order @param [Fixnum] boot_target @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "temporary", "boot", "order" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/boot_settings_helper.rb#L64-L74
1,271
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/service_root_helper.rb
ILO_SDK.ServiceRootHelper.get_schema
def get_schema(schema_prefix) response = rest_get('/redfish/v1/Schemas/') schemas = response_handler(response)['Items'] schema = schemas.select { |s| s['Schema'].start_with?(schema_prefix) } raise "NO schema found with this schema prefix : #{schema_prefix}" if schema.empty? info = [] schema.each do |sc| response = rest_get(sc['Location'][0]['Uri']['extref']) schema_store = response_handler(response) info.push(schema_store) end info end
ruby
def get_schema(schema_prefix) response = rest_get('/redfish/v1/Schemas/') schemas = response_handler(response)['Items'] schema = schemas.select { |s| s['Schema'].start_with?(schema_prefix) } raise "NO schema found with this schema prefix : #{schema_prefix}" if schema.empty? info = [] schema.each do |sc| response = rest_get(sc['Location'][0]['Uri']['extref']) schema_store = response_handler(response) info.push(schema_store) end info end
[ "def", "get_schema", "(", "schema_prefix", ")", "response", "=", "rest_get", "(", "'/redfish/v1/Schemas/'", ")", "schemas", "=", "response_handler", "(", "response", ")", "[", "'Items'", "]", "schema", "=", "schemas", ".", "select", "{", "|", "s", "|", "s", "[", "'Schema'", "]", ".", "start_with?", "(", "schema_prefix", ")", "}", "raise", "\"NO schema found with this schema prefix : #{schema_prefix}\"", "if", "schema", ".", "empty?", "info", "=", "[", "]", "schema", ".", "each", "do", "|", "sc", "|", "response", "=", "rest_get", "(", "sc", "[", "'Location'", "]", "[", "0", "]", "[", "'Uri'", "]", "[", "'extref'", "]", ")", "schema_store", "=", "response_handler", "(", "response", ")", "info", ".", "push", "(", "schema_store", ")", "end", "info", "end" ]
Get the schema information with given prefix @param [String, Symbol] schema_prefix @raise [RuntimeError] if the request failed @return [Array] schema
[ "Get", "the", "schema", "information", "with", "given", "prefix" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/service_root_helper.rb#L19-L31
1,272
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/service_root_helper.rb
ILO_SDK.ServiceRootHelper.get_registry
def get_registry(registry_prefix) response = rest_get('/redfish/v1/Registries/') registries = response_handler(response)['Items'] registry = registries.select { |reg| reg['Schema'].start_with?(registry_prefix) } info = [] registry.each do |reg| response = rest_get(reg['Location'][0]['Uri']['extref']) registry_store = response_handler(response) info.push(registry_store) end info end
ruby
def get_registry(registry_prefix) response = rest_get('/redfish/v1/Registries/') registries = response_handler(response)['Items'] registry = registries.select { |reg| reg['Schema'].start_with?(registry_prefix) } info = [] registry.each do |reg| response = rest_get(reg['Location'][0]['Uri']['extref']) registry_store = response_handler(response) info.push(registry_store) end info end
[ "def", "get_registry", "(", "registry_prefix", ")", "response", "=", "rest_get", "(", "'/redfish/v1/Registries/'", ")", "registries", "=", "response_handler", "(", "response", ")", "[", "'Items'", "]", "registry", "=", "registries", ".", "select", "{", "|", "reg", "|", "reg", "[", "'Schema'", "]", ".", "start_with?", "(", "registry_prefix", ")", "}", "info", "=", "[", "]", "registry", ".", "each", "do", "|", "reg", "|", "response", "=", "rest_get", "(", "reg", "[", "'Location'", "]", "[", "0", "]", "[", "'Uri'", "]", "[", "'extref'", "]", ")", "registry_store", "=", "response_handler", "(", "response", ")", "info", ".", "push", "(", "registry_store", ")", "end", "info", "end" ]
Get the Registry with given registry_prefix @param [String, Symbol] registry_prefix @raise [RuntimeError] if the request failed @return [Array] registry
[ "Get", "the", "Registry", "with", "given", "registry_prefix" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/service_root_helper.rb#L37-L48
1,273
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/manager_network_protocol_helper.rb
ILO_SDK.ManagerNetworkProtocolHelper.set_timeout
def set_timeout(timeout) new_action = { 'SessionTimeoutMinutes' => timeout } response = rest_patch('/redfish/v1/Managers/1/NetworkService/', body: new_action) response_handler(response) true end
ruby
def set_timeout(timeout) new_action = { 'SessionTimeoutMinutes' => timeout } response = rest_patch('/redfish/v1/Managers/1/NetworkService/', body: new_action) response_handler(response) true end
[ "def", "set_timeout", "(", "timeout", ")", "new_action", "=", "{", "'SessionTimeoutMinutes'", "=>", "timeout", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Managers/1/NetworkService/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the Session Timeout Minutes @param [Fixnum] timeout @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "Session", "Timeout", "Minutes" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/manager_network_protocol_helper.rb#L27-L32
1,274
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/ethernet_interface_helper.rb
ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dhcp
def set_ilo_ipv4_dhcp(manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => true, 'UseDNSServers' => true, 'UseDomainName' => true, 'UseGateway' => true, 'UseNTPServers' => true, 'UseStaticRoutes' => true, 'UseWINSServers' => true } } } } response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
ruby
def set_ilo_ipv4_dhcp(manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => true, 'UseDNSServers' => true, 'UseDomainName' => true, 'UseGateway' => true, 'UseNTPServers' => true, 'UseStaticRoutes' => true, 'UseWINSServers' => true } } } } response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
[ "def", "set_ilo_ipv4_dhcp", "(", "manager_id", ":", "1", ",", "ethernet_interface", ":", "1", ")", "new_action", "=", "{", "'Oem'", "=>", "{", "'Hp'", "=>", "{", "'DHCPv4'", "=>", "{", "'Enabled'", "=>", "true", ",", "'UseDNSServers'", "=>", "true", ",", "'UseDomainName'", "=>", "true", ",", "'UseGateway'", "=>", "true", ",", "'UseNTPServers'", "=>", "true", ",", "'UseStaticRoutes'", "=>", "true", ",", "'UseWINSServers'", "=>", "true", "}", "}", "}", "}", "response", "=", "rest_patch", "(", "\"/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/\"", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set EthernetInterface to obtain IPv4 settings from DHCP @param manager_id [Integer, String] ID of the Manager @param ethernet_interface [Integer, String] ID of the EthernetInterface @raise [RuntimeError] if the request failed @return true
[ "Set", "EthernetInterface", "to", "obtain", "IPv4", "settings", "from", "DHCP" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L29-L48
1,275
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/ethernet_interface_helper.rb
ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_static
def set_ilo_ipv4_static(ip:, netmask:, gateway: '0.0.0.0', manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } }, 'IPv4Addresses' => [ 'Address' => ip, 'SubnetMask' => netmask, 'Gateway' => gateway ] } response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
ruby
def set_ilo_ipv4_static(ip:, netmask:, gateway: '0.0.0.0', manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } }, 'IPv4Addresses' => [ 'Address' => ip, 'SubnetMask' => netmask, 'Gateway' => gateway ] } response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
[ "def", "set_ilo_ipv4_static", "(", "ip", ":", ",", "netmask", ":", ",", "gateway", ":", "'0.0.0.0'", ",", "manager_id", ":", "1", ",", "ethernet_interface", ":", "1", ")", "new_action", "=", "{", "'Oem'", "=>", "{", "'Hp'", "=>", "{", "'DHCPv4'", "=>", "{", "'Enabled'", "=>", "false", "}", "}", "}", ",", "'IPv4Addresses'", "=>", "[", "'Address'", "=>", "ip", ",", "'SubnetMask'", "=>", "netmask", ",", "'Gateway'", "=>", "gateway", "]", "}", "response", "=", "rest_patch", "(", "\"/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/\"", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set EthernetInterface to static IPv4 address @param ip [String] IPv4 address @param netmask [String] IPv4 subnet mask @param gateway [String] IPv4 default gateway @param manager_id [Integer, String] ID of the Manager @param ethernet_interface [Integer, String] ID of the EthernetInterface @raise [RuntimeError] if the request failed @return true
[ "Set", "EthernetInterface", "to", "static", "IPv4", "address" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L58-L68
1,276
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/ethernet_interface_helper.rb
ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dns_servers
def set_ilo_ipv4_dns_servers(dns_servers:, manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseDNSServers' => false }, 'IPv4' => { 'DNSServers' => dns_servers } } } } response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
ruby
def set_ilo_ipv4_dns_servers(dns_servers:, manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseDNSServers' => false }, 'IPv4' => { 'DNSServers' => dns_servers } } } } response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
[ "def", "set_ilo_ipv4_dns_servers", "(", "dns_servers", ":", ",", "manager_id", ":", "1", ",", "ethernet_interface", ":", "1", ")", "new_action", "=", "{", "'Oem'", "=>", "{", "'Hp'", "=>", "{", "'DHCPv4'", "=>", "{", "'UseDNSServers'", "=>", "false", "}", ",", "'IPv4'", "=>", "{", "'DNSServers'", "=>", "dns_servers", "}", "}", "}", "}", "response", "=", "rest_patch", "(", "\"/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/\"", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set EthernetInterface DNS servers @param dns_servers [Array] list of DNS servers @param manager_id [Integer, String] ID of the Manager @param ethernet_interface [Integer, String] ID of the EthernetInterface @raise [RuntimeError] if the request failed @return true
[ "Set", "EthernetInterface", "DNS", "servers" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L76-L88
1,277
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/ethernet_interface_helper.rb
ILO_SDK.EthernetInterfaceHelper.set_ilo_hostname
def set_ilo_hostname(hostname:, domain_name: nil, manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } } new_action['Oem']['Hp'].merge!('DHCPv4' => {}, 'DHCPv6' => {}) if domain_name new_action['Oem']['Hp']['DHCPv4']['UseDomainName'] = false if domain_name new_action['Oem']['Hp']['DHCPv6']['UseDomainName'] = false if domain_name new_action['Oem']['Hp']['DomainName'] = domain_name if domain_name response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
ruby
def set_ilo_hostname(hostname:, domain_name: nil, manager_id: 1, ethernet_interface: 1) new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } } new_action['Oem']['Hp'].merge!('DHCPv4' => {}, 'DHCPv6' => {}) if domain_name new_action['Oem']['Hp']['DHCPv4']['UseDomainName'] = false if domain_name new_action['Oem']['Hp']['DHCPv6']['UseDomainName'] = false if domain_name new_action['Oem']['Hp']['DomainName'] = domain_name if domain_name response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action) response_handler(response) true end
[ "def", "set_ilo_hostname", "(", "hostname", ":", ",", "domain_name", ":", "nil", ",", "manager_id", ":", "1", ",", "ethernet_interface", ":", "1", ")", "new_action", "=", "{", "'Oem'", "=>", "{", "'Hp'", "=>", "{", "'HostName'", "=>", "hostname", "}", "}", "}", "new_action", "[", "'Oem'", "]", "[", "'Hp'", "]", ".", "merge!", "(", "'DHCPv4'", "=>", "{", "}", ",", "'DHCPv6'", "=>", "{", "}", ")", "if", "domain_name", "new_action", "[", "'Oem'", "]", "[", "'Hp'", "]", "[", "'DHCPv4'", "]", "[", "'UseDomainName'", "]", "=", "false", "if", "domain_name", "new_action", "[", "'Oem'", "]", "[", "'Hp'", "]", "[", "'DHCPv6'", "]", "[", "'UseDomainName'", "]", "=", "false", "if", "domain_name", "new_action", "[", "'Oem'", "]", "[", "'Hp'", "]", "[", "'DomainName'", "]", "=", "domain_name", "if", "domain_name", "response", "=", "rest_patch", "(", "\"/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/\"", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set iLO hostname and domain name @param hostname [String] iLO hostname @param domain_name [String] iLO domain name @param manager_id [Integer, String] ID of the Manager @param ethernet_interface [Integer, String] ID of the EthernetInterface @raise [RuntimeError] if the request failed @return true
[ "Set", "iLO", "hostname", "and", "domain", "name" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/ethernet_interface_helper.rb#L97-L106
1,278
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/rest.rb
ILO_SDK.Rest.rest_api
def rest_api(type, path, options = {}) raise InvalidRequest, 'Must specify path' unless path raise InvalidRequest, 'Must specify type' unless type @logger.debug "Making :#{type} rest call to #{@host}#{path}" uri = URI.parse(URI.escape("#{@host}#{path}")) http = @disable_proxy ? Net::HTTP.new(uri.host, uri.port, nil, nil) : Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_enabled request = build_request(type, uri, options) response = http.request(request) @logger.debug " Response: Code=#{response.code}. Headers=#{response.to_hash}\n Body=#{response.body}" response rescue OpenSSL::SSL::SSLError => e msg = 'SSL verification failed for the request. Please either:' msg += "\n 1. Install the necessary certificate(s) into your cert store" msg += ". Using cert store: #{ENV['SSL_CERT_FILE']}" if ENV['SSL_CERT_FILE'] msg += "\n 2. Set the :ssl_enabled option to false for your iLO client (not recommended)" @logger.error msg raise e rescue SocketError => e e.message.prepend("Failed to connect to iLO host #{@host}!\n") raise e end
ruby
def rest_api(type, path, options = {}) raise InvalidRequest, 'Must specify path' unless path raise InvalidRequest, 'Must specify type' unless type @logger.debug "Making :#{type} rest call to #{@host}#{path}" uri = URI.parse(URI.escape("#{@host}#{path}")) http = @disable_proxy ? Net::HTTP.new(uri.host, uri.port, nil, nil) : Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if uri.scheme == 'https' http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_enabled request = build_request(type, uri, options) response = http.request(request) @logger.debug " Response: Code=#{response.code}. Headers=#{response.to_hash}\n Body=#{response.body}" response rescue OpenSSL::SSL::SSLError => e msg = 'SSL verification failed for the request. Please either:' msg += "\n 1. Install the necessary certificate(s) into your cert store" msg += ". Using cert store: #{ENV['SSL_CERT_FILE']}" if ENV['SSL_CERT_FILE'] msg += "\n 2. Set the :ssl_enabled option to false for your iLO client (not recommended)" @logger.error msg raise e rescue SocketError => e e.message.prepend("Failed to connect to iLO host #{@host}!\n") raise e end
[ "def", "rest_api", "(", "type", ",", "path", ",", "options", "=", "{", "}", ")", "raise", "InvalidRequest", ",", "'Must specify path'", "unless", "path", "raise", "InvalidRequest", ",", "'Must specify type'", "unless", "type", "@logger", ".", "debug", "\"Making :#{type} rest call to #{@host}#{path}\"", "uri", "=", "URI", ".", "parse", "(", "URI", ".", "escape", "(", "\"#{@host}#{path}\"", ")", ")", "http", "=", "@disable_proxy", "?", "Net", "::", "HTTP", ".", "new", "(", "uri", ".", "host", ",", "uri", ".", "port", ",", "nil", ",", "nil", ")", ":", "Net", "::", "HTTP", ".", "new", "(", "uri", ".", "host", ",", "uri", ".", "port", ")", "http", ".", "use_ssl", "=", "true", "if", "uri", ".", "scheme", "==", "'https'", "http", ".", "verify_mode", "=", "OpenSSL", "::", "SSL", "::", "VERIFY_NONE", "unless", "@ssl_enabled", "request", "=", "build_request", "(", "type", ",", "uri", ",", "options", ")", "response", "=", "http", ".", "request", "(", "request", ")", "@logger", ".", "debug", "\" Response: Code=#{response.code}. Headers=#{response.to_hash}\\n Body=#{response.body}\"", "response", "rescue", "OpenSSL", "::", "SSL", "::", "SSLError", "=>", "e", "msg", "=", "'SSL verification failed for the request. Please either:'", "msg", "+=", "\"\\n 1. Install the necessary certificate(s) into your cert store\"", "msg", "+=", "\". Using cert store: #{ENV['SSL_CERT_FILE']}\"", "if", "ENV", "[", "'SSL_CERT_FILE'", "]", "msg", "+=", "\"\\n 2. Set the :ssl_enabled option to false for your iLO client (not recommended)\"", "@logger", ".", "error", "msg", "raise", "e", "rescue", "SocketError", "=>", "e", "e", ".", "message", ".", "prepend", "(", "\"Failed to connect to iLO host #{@host}!\\n\"", ")", "raise", "e", "end" ]
Make a restful API request to the iLO @param [Symbol] type the rest method/type Options are :get, :post, :put, :patch, and :delete @param [String] path the path for the request. Usually starts with "/rest/" @param [Hash] options the options for the request @option options [String] :body Hash to be converted into json and set as the request body @option options [String] :Content-Type ('application/json') Set to nil or :none to have this option removed @raise [InvalidRequest] if the request is invalid @raise [SocketError] if a connection could not be made @raise [OpenSSL::SSL::SSLError] if SSL validation of the iLO's certificate failed @return [NetHTTPResponse] The response object
[ "Make", "a", "restful", "API", "request", "to", "the", "iLO" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/rest.rb#L30-L54
1,279
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/rest.rb
ILO_SDK.Rest.response_handler
def response_handler(response) case response.code.to_i when RESPONSE_CODE_OK # Synchronous read/query begin return JSON.parse(response.body) rescue JSON::ParserError => e @logger.warn "Failed to parse JSON response. #{e}" return response.body end when RESPONSE_CODE_CREATED # Synchronous add return JSON.parse(response.body) when RESPONSE_CODE_ACCEPTED # Asynchronous add, update or delete return JSON.parse(response.body) # TODO: Remove when tested # TODO: Make this actually wait for the task # @logger.debug "Waiting for task: #{response.header['location']}" # task = wait_for(response.header['location']) # return true unless task['associatedResource'] && task['associatedResource']['resourceUri'] # resource_data = rest_get(task['associatedResource']['resourceUri']) # return JSON.parse(resource_data.body) when RESPONSE_CODE_NO_CONTENT # Synchronous delete return {} when RESPONSE_CODE_BAD_REQUEST raise BadRequest, "400 BAD REQUEST #{response.body}" when RESPONSE_CODE_UNAUTHORIZED raise Unauthorized, "401 UNAUTHORIZED #{response.body}" when RESPONSE_CODE_NOT_FOUND raise NotFound, "404 NOT FOUND #{response.body}" else raise RequestError, "#{response.code} #{response.body}" end end
ruby
def response_handler(response) case response.code.to_i when RESPONSE_CODE_OK # Synchronous read/query begin return JSON.parse(response.body) rescue JSON::ParserError => e @logger.warn "Failed to parse JSON response. #{e}" return response.body end when RESPONSE_CODE_CREATED # Synchronous add return JSON.parse(response.body) when RESPONSE_CODE_ACCEPTED # Asynchronous add, update or delete return JSON.parse(response.body) # TODO: Remove when tested # TODO: Make this actually wait for the task # @logger.debug "Waiting for task: #{response.header['location']}" # task = wait_for(response.header['location']) # return true unless task['associatedResource'] && task['associatedResource']['resourceUri'] # resource_data = rest_get(task['associatedResource']['resourceUri']) # return JSON.parse(resource_data.body) when RESPONSE_CODE_NO_CONTENT # Synchronous delete return {} when RESPONSE_CODE_BAD_REQUEST raise BadRequest, "400 BAD REQUEST #{response.body}" when RESPONSE_CODE_UNAUTHORIZED raise Unauthorized, "401 UNAUTHORIZED #{response.body}" when RESPONSE_CODE_NOT_FOUND raise NotFound, "404 NOT FOUND #{response.body}" else raise RequestError, "#{response.code} #{response.body}" end end
[ "def", "response_handler", "(", "response", ")", "case", "response", ".", "code", ".", "to_i", "when", "RESPONSE_CODE_OK", "# Synchronous read/query", "begin", "return", "JSON", ".", "parse", "(", "response", ".", "body", ")", "rescue", "JSON", "::", "ParserError", "=>", "e", "@logger", ".", "warn", "\"Failed to parse JSON response. #{e}\"", "return", "response", ".", "body", "end", "when", "RESPONSE_CODE_CREATED", "# Synchronous add", "return", "JSON", ".", "parse", "(", "response", ".", "body", ")", "when", "RESPONSE_CODE_ACCEPTED", "# Asynchronous add, update or delete", "return", "JSON", ".", "parse", "(", "response", ".", "body", ")", "# TODO: Remove when tested", "# TODO: Make this actually wait for the task", "# @logger.debug \"Waiting for task: #{response.header['location']}\"", "# task = wait_for(response.header['location'])", "# return true unless task['associatedResource'] && task['associatedResource']['resourceUri']", "# resource_data = rest_get(task['associatedResource']['resourceUri'])", "# return JSON.parse(resource_data.body)", "when", "RESPONSE_CODE_NO_CONTENT", "# Synchronous delete", "return", "{", "}", "when", "RESPONSE_CODE_BAD_REQUEST", "raise", "BadRequest", ",", "\"400 BAD REQUEST #{response.body}\"", "when", "RESPONSE_CODE_UNAUTHORIZED", "raise", "Unauthorized", ",", "\"401 UNAUTHORIZED #{response.body}\"", "when", "RESPONSE_CODE_NOT_FOUND", "raise", "NotFound", ",", "\"404 NOT FOUND #{response.body}\"", "else", "raise", "RequestError", ",", "\"#{response.code} #{response.body}\"", "end", "end" ]
Handle the response for rest call. If an asynchronous task was started, this waits for it to complete. @param [HTTPResponse] HTTP response @raise [ILO_SDK::BadRequest] if the request failed with a 400 status @raise [ILO_SDK::Unauthorized] if the request failed with a 401 status @raise [ILO_SDK::NotFound] if the request failed with a 404 status @raise [ILO_SDK::RequestError] if the request failed with any other status @return [Hash] The parsed JSON body
[ "Handle", "the", "response", "for", "rest", "call", ".", "If", "an", "asynchronous", "task", "was", "started", "this", "waits", "for", "it", "to", "complete", "." ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/rest.rb#L102-L132
1,280
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/manager_account_helper.rb
ILO_SDK.ManagerAccountHelper.get_account_privileges
def get_account_privileges(username) response = rest_get('/redfish/v1/AccountService/Accounts/') accounts = response_handler(response)['Items'] accounts.each do |account| if account['Oem']['Hp']['LoginName'] == username return account['Oem']['Hp']['Privileges'] end end end
ruby
def get_account_privileges(username) response = rest_get('/redfish/v1/AccountService/Accounts/') accounts = response_handler(response)['Items'] accounts.each do |account| if account['Oem']['Hp']['LoginName'] == username return account['Oem']['Hp']['Privileges'] end end end
[ "def", "get_account_privileges", "(", "username", ")", "response", "=", "rest_get", "(", "'/redfish/v1/AccountService/Accounts/'", ")", "accounts", "=", "response_handler", "(", "response", ")", "[", "'Items'", "]", "accounts", ".", "each", "do", "|", "account", "|", "if", "account", "[", "'Oem'", "]", "[", "'Hp'", "]", "[", "'LoginName'", "]", "==", "username", "return", "account", "[", "'Oem'", "]", "[", "'Hp'", "]", "[", "'Privileges'", "]", "end", "end", "end" ]
Get the Privileges for a user @param [String, Symbol] username @raise [RuntimeError] if the request failed @return [Hash] privileges
[ "Get", "the", "Privileges", "for", "a", "user" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/manager_account_helper.rb#L19-L27
1,281
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/manager_account_helper.rb
ILO_SDK.ManagerAccountHelper.set_account_privileges
def set_account_privileges(username, privileges) response = rest_get('/redfish/v1/AccountService/Accounts/') accounts = response_handler(response)['Items'] id = '0' accounts.each do |account| if account['Oem']['Hp']['LoginName'] == username id = account['Id'] break end end new_action = { 'Oem' => { 'Hp' => { 'Privileges' => privileges } } } response = rest_patch("/redfish/v1/AccountService/Accounts/#{id}/", body: new_action) response_handler(response) true end
ruby
def set_account_privileges(username, privileges) response = rest_get('/redfish/v1/AccountService/Accounts/') accounts = response_handler(response)['Items'] id = '0' accounts.each do |account| if account['Oem']['Hp']['LoginName'] == username id = account['Id'] break end end new_action = { 'Oem' => { 'Hp' => { 'Privileges' => privileges } } } response = rest_patch("/redfish/v1/AccountService/Accounts/#{id}/", body: new_action) response_handler(response) true end
[ "def", "set_account_privileges", "(", "username", ",", "privileges", ")", "response", "=", "rest_get", "(", "'/redfish/v1/AccountService/Accounts/'", ")", "accounts", "=", "response_handler", "(", "response", ")", "[", "'Items'", "]", "id", "=", "'0'", "accounts", ".", "each", "do", "|", "account", "|", "if", "account", "[", "'Oem'", "]", "[", "'Hp'", "]", "[", "'LoginName'", "]", "==", "username", "id", "=", "account", "[", "'Id'", "]", "break", "end", "end", "new_action", "=", "{", "'Oem'", "=>", "{", "'Hp'", "=>", "{", "'Privileges'", "=>", "privileges", "}", "}", "}", "response", "=", "rest_patch", "(", "\"/redfish/v1/AccountService/Accounts/#{id}/\"", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the privileges for a user @param [TrueClass, FalseClass] username @param [Hash] privileges @option privileges [TrueClass, FalseClass] :LoginPriv @option privileges [TrueClass, FalseClass] :RemoteConsolePriv @option privileges [TrueClass, FalseClass] :UserConfigPriv @option privileges [TrueClass, FalseClass] :VirtualMediaPriv @option privileges [TrueClass, FalseClass] :VirtualPowerAndResetPriv @option privileges [TrueClass, FalseClass] :iLOConfigPriv @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "privileges", "for", "a", "user" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/manager_account_helper.rb#L40-L60
1,282
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/https_cert_helper.rb
ILO_SDK.HttpsCertHelper.get_certificate
def get_certificate uri = URI.parse(URI.escape(@host)) options = { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE } Net::HTTP.start(uri.host, uri.port, options) do |http| http.peer_cert end end
ruby
def get_certificate uri = URI.parse(URI.escape(@host)) options = { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE } Net::HTTP.start(uri.host, uri.port, options) do |http| http.peer_cert end end
[ "def", "get_certificate", "uri", "=", "URI", ".", "parse", "(", "URI", ".", "escape", "(", "@host", ")", ")", "options", "=", "{", "use_ssl", ":", "true", ",", "verify_mode", ":", "OpenSSL", "::", "SSL", "::", "VERIFY_NONE", "}", "Net", "::", "HTTP", ".", "start", "(", "uri", ".", "host", ",", "uri", ".", "port", ",", "options", ")", "do", "|", "http", "|", "http", ".", "peer_cert", "end", "end" ]
Get the SSL Certificate @raise [RuntimeError] if the request failed @return [OpenSSL::X509::Certificate] x509_certificate rubocop:disable Style/SymbolProc
[ "Get", "the", "SSL", "Certificate" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/https_cert_helper.rb#L19-L25
1,283
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/https_cert_helper.rb
ILO_SDK.HttpsCertHelper.generate_csr
def generate_csr(country, state, city, org_name, org_unit, common_name) new_action = { 'Action' => 'GenerateCSR', 'Country' => country, 'State' => state, 'City' => city, 'OrgName' => org_name, 'OrgUnit' => org_unit, 'CommonName' => common_name } response = rest_post('/redfish/v1/Managers/1/SecurityService/HttpsCert/', body: new_action) response_handler(response) true end
ruby
def generate_csr(country, state, city, org_name, org_unit, common_name) new_action = { 'Action' => 'GenerateCSR', 'Country' => country, 'State' => state, 'City' => city, 'OrgName' => org_name, 'OrgUnit' => org_unit, 'CommonName' => common_name } response = rest_post('/redfish/v1/Managers/1/SecurityService/HttpsCert/', body: new_action) response_handler(response) true end
[ "def", "generate_csr", "(", "country", ",", "state", ",", "city", ",", "org_name", ",", "org_unit", ",", "common_name", ")", "new_action", "=", "{", "'Action'", "=>", "'GenerateCSR'", ",", "'Country'", "=>", "country", ",", "'State'", "=>", "state", ",", "'City'", "=>", "city", ",", "'OrgName'", "=>", "org_name", ",", "'OrgUnit'", "=>", "org_unit", ",", "'CommonName'", "=>", "common_name", "}", "response", "=", "rest_post", "(", "'/redfish/v1/Managers/1/SecurityService/HttpsCert/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Generate a Certificate Signing Request @param [String] country @param [String] state @param [String] city @param [String] orgName @param [String] orgUnit @param [String] commonName @raise [RuntimeError] if the request failed @return true
[ "Generate", "a", "Certificate", "Signing", "Request" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/https_cert_helper.rb#L51-L64
1,284
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/secure_boot_helper.rb
ILO_SDK.SecureBootHelper.set_uefi_secure_boot
def set_uefi_secure_boot(secure_boot_enable) new_action = { 'SecureBootEnable' => secure_boot_enable } response = rest_patch('/redfish/v1/Systems/1/SecureBoot/', body: new_action) response_handler(response) true end
ruby
def set_uefi_secure_boot(secure_boot_enable) new_action = { 'SecureBootEnable' => secure_boot_enable } response = rest_patch('/redfish/v1/Systems/1/SecureBoot/', body: new_action) response_handler(response) true end
[ "def", "set_uefi_secure_boot", "(", "secure_boot_enable", ")", "new_action", "=", "{", "'SecureBootEnable'", "=>", "secure_boot_enable", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/SecureBoot/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the UEFI secure boot true or false @param [Boolean] secure_boot_enable @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "UEFI", "secure", "boot", "true", "or", "false" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/secure_boot_helper.rb#L27-L32
1,285
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/power_helper.rb
ILO_SDK.PowerHelper.set_power_state
def set_power_state(state) new_action = { 'Action' => 'Reset', 'ResetType' => state } response = rest_post('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
ruby
def set_power_state(state) new_action = { 'Action' => 'Reset', 'ResetType' => state } response = rest_post('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
[ "def", "set_power_state", "(", "state", ")", "new_action", "=", "{", "'Action'", "=>", "'Reset'", ",", "'ResetType'", "=>", "state", "}", "response", "=", "rest_post", "(", "'/redfish/v1/Systems/1/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the Power State @param [String, Symbol] state @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "Power", "State" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/power_helper.rb#L27-L32
1,286
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/snmp_service_helper.rb
ILO_SDK.SNMPServiceHelper.set_snmp
def set_snmp(snmp_mode, snmp_alerts) new_action = { 'Mode' => snmp_mode, 'AlertsEnabled' => snmp_alerts } response = rest_patch('/redfish/v1/Managers/1/SnmpService/', body: new_action) response_handler(response) true end
ruby
def set_snmp(snmp_mode, snmp_alerts) new_action = { 'Mode' => snmp_mode, 'AlertsEnabled' => snmp_alerts } response = rest_patch('/redfish/v1/Managers/1/SnmpService/', body: new_action) response_handler(response) true end
[ "def", "set_snmp", "(", "snmp_mode", ",", "snmp_alerts", ")", "new_action", "=", "{", "'Mode'", "=>", "snmp_mode", ",", "'AlertsEnabled'", "=>", "snmp_alerts", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Managers/1/SnmpService/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the SNMP Mode and Alerts Enabled value @param [String, Symbol] snmp_mode @param [Boolean] snmp_alerts @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "SNMP", "Mode", "and", "Alerts", "Enabled", "value" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/snmp_service_helper.rb#L36-L41
1,287
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/virtual_media_helper.rb
ILO_SDK.VirtualMediaHelper.get_virtual_media
def get_virtual_media response = rest_get('/redfish/v1/Managers/1/VirtualMedia/') media = {} response_handler(response)['links']['Member'].each do |vm| response = rest_get(vm['href']) virtual_media = response_handler(response) media[virtual_media['Id']] = { 'Image' => virtual_media['Image'], 'MediaTypes' => virtual_media['MediaTypes'] } end media end
ruby
def get_virtual_media response = rest_get('/redfish/v1/Managers/1/VirtualMedia/') media = {} response_handler(response)['links']['Member'].each do |vm| response = rest_get(vm['href']) virtual_media = response_handler(response) media[virtual_media['Id']] = { 'Image' => virtual_media['Image'], 'MediaTypes' => virtual_media['MediaTypes'] } end media end
[ "def", "get_virtual_media", "response", "=", "rest_get", "(", "'/redfish/v1/Managers/1/VirtualMedia/'", ")", "media", "=", "{", "}", "response_handler", "(", "response", ")", "[", "'links'", "]", "[", "'Member'", "]", ".", "each", "do", "|", "vm", "|", "response", "=", "rest_get", "(", "vm", "[", "'href'", "]", ")", "virtual_media", "=", "response_handler", "(", "response", ")", "media", "[", "virtual_media", "[", "'Id'", "]", "]", "=", "{", "'Image'", "=>", "virtual_media", "[", "'Image'", "]", ",", "'MediaTypes'", "=>", "virtual_media", "[", "'MediaTypes'", "]", "}", "end", "media", "end" ]
Get the Virtual Media Information @raise [RuntimeError] if the request failed @return [String] virtual_media
[ "Get", "the", "Virtual", "Media", "Information" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/virtual_media_helper.rb#L18-L30
1,288
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/virtual_media_helper.rb
ILO_SDK.VirtualMediaHelper.insert_virtual_media
def insert_virtual_media(id, image) new_action = { 'Action' => 'InsertVirtualMedia', 'Target' => '/Oem/Hp', 'Image' => image } response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action) response_handler(response) true end
ruby
def insert_virtual_media(id, image) new_action = { 'Action' => 'InsertVirtualMedia', 'Target' => '/Oem/Hp', 'Image' => image } response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action) response_handler(response) true end
[ "def", "insert_virtual_media", "(", "id", ",", "image", ")", "new_action", "=", "{", "'Action'", "=>", "'InsertVirtualMedia'", ",", "'Target'", "=>", "'/Oem/Hp'", ",", "'Image'", "=>", "image", "}", "response", "=", "rest_post", "(", "\"/redfish/v1/Managers/1/VirtualMedia/#{id}/\"", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Insert Virtual Media @param [String, Symbol] id @param [String, Symbol] image @return true
[ "Insert", "Virtual", "Media" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/virtual_media_helper.rb#L44-L53
1,289
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/virtual_media_helper.rb
ILO_SDK.VirtualMediaHelper.eject_virtual_media
def eject_virtual_media(id) new_action = { 'Action' => 'EjectVirtualMedia', 'Target' => '/Oem/Hp' } response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action) response_handler(response) true end
ruby
def eject_virtual_media(id) new_action = { 'Action' => 'EjectVirtualMedia', 'Target' => '/Oem/Hp' } response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action) response_handler(response) true end
[ "def", "eject_virtual_media", "(", "id", ")", "new_action", "=", "{", "'Action'", "=>", "'EjectVirtualMedia'", ",", "'Target'", "=>", "'/Oem/Hp'", "}", "response", "=", "rest_post", "(", "\"/redfish/v1/Managers/1/VirtualMedia/#{id}/\"", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Eject Virtual Media @param [String, Symbol] id @return true
[ "Eject", "Virtual", "Media" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/virtual_media_helper.rb#L58-L66
1,290
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/computer_system_helper.rb
ILO_SDK.ComputerSystemHelper.set_asset_tag
def set_asset_tag(asset_tag) @logger.warn '[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.' new_action = { 'AssetTag' => asset_tag } response = rest_patch('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
ruby
def set_asset_tag(asset_tag) @logger.warn '[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.' new_action = { 'AssetTag' => asset_tag } response = rest_patch('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
[ "def", "set_asset_tag", "(", "asset_tag", ")", "@logger", ".", "warn", "'[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.'", "new_action", "=", "{", "'AssetTag'", "=>", "asset_tag", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the Asset Tag @deprecated Use {#set_system_settings} instead @param asset_tag [String, Symbol] @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "Asset", "Tag" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_system_helper.rb#L48-L54
1,291
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/computer_system_helper.rb
ILO_SDK.ComputerSystemHelper.set_indicator_led
def set_indicator_led(state) @logger.warn '[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.' new_action = { 'IndicatorLED' => state } response = rest_patch('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
ruby
def set_indicator_led(state) @logger.warn '[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.' new_action = { 'IndicatorLED' => state } response = rest_patch('/redfish/v1/Systems/1/', body: new_action) response_handler(response) true end
[ "def", "set_indicator_led", "(", "state", ")", "@logger", ".", "warn", "'[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.'", "new_action", "=", "{", "'IndicatorLED'", "=>", "state", "}", "response", "=", "rest_patch", "(", "'/redfish/v1/Systems/1/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Set the UID indicator LED @deprecated Use {#set_system_settings} instead @param state [String, Symbol] @raise [RuntimeError] if the request failed @return true
[ "Set", "the", "UID", "indicator", "LED" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/computer_system_helper.rb#L71-L77
1,292
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/account_service_helper.rb
ILO_SDK.AccountServiceHelper.userhref
def userhref(uri, username) response = rest_get(uri) items = response_handler(response)['Items'] items.each do |it| return it['links']['self']['href'] if it['UserName'] == username end end
ruby
def userhref(uri, username) response = rest_get(uri) items = response_handler(response)['Items'] items.each do |it| return it['links']['self']['href'] if it['UserName'] == username end end
[ "def", "userhref", "(", "uri", ",", "username", ")", "response", "=", "rest_get", "(", "uri", ")", "items", "=", "response_handler", "(", "response", ")", "[", "'Items'", "]", "items", ".", "each", "do", "|", "it", "|", "return", "it", "[", "'links'", "]", "[", "'self'", "]", "[", "'href'", "]", "if", "it", "[", "'UserName'", "]", "==", "username", "end", "end" ]
Get the HREF for a user with a specific username @param [String, Symbol] uri @param [String, Symbol] username @raise [RuntimeError] if the request failed @return [String] userhref
[ "Get", "the", "HREF", "for", "a", "user", "with", "a", "specific", "username" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L20-L26
1,293
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/account_service_helper.rb
ILO_SDK.AccountServiceHelper.create_user
def create_user(username, password) new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' => { 'LoginName' => username } } } response = rest_post('/redfish/v1/AccountService/Accounts/', body: new_action) response_handler(response) true end
ruby
def create_user(username, password) new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' => { 'LoginName' => username } } } response = rest_post('/redfish/v1/AccountService/Accounts/', body: new_action) response_handler(response) true end
[ "def", "create_user", "(", "username", ",", "password", ")", "new_action", "=", "{", "'UserName'", "=>", "username", ",", "'Password'", "=>", "password", ",", "'Oem'", "=>", "{", "'Hp'", "=>", "{", "'LoginName'", "=>", "username", "}", "}", "}", "response", "=", "rest_post", "(", "'/redfish/v1/AccountService/Accounts/'", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Create a user @param [String, Symbol] username @param [String, Symbol] password @raise [RuntimeError] if the request failed @return true
[ "Create", "a", "user" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L41-L46
1,294
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/account_service_helper.rb
ILO_SDK.AccountServiceHelper.change_password
def change_password(username, password) new_action = { 'Password' => password } userhref = userhref('/redfish/v1/AccountService/Accounts/', username) response = rest_patch(userhref, body: new_action) response_handler(response) true end
ruby
def change_password(username, password) new_action = { 'Password' => password } userhref = userhref('/redfish/v1/AccountService/Accounts/', username) response = rest_patch(userhref, body: new_action) response_handler(response) true end
[ "def", "change_password", "(", "username", ",", "password", ")", "new_action", "=", "{", "'Password'", "=>", "password", "}", "userhref", "=", "userhref", "(", "'/redfish/v1/AccountService/Accounts/'", ",", "username", ")", "response", "=", "rest_patch", "(", "userhref", ",", "body", ":", "new_action", ")", "response_handler", "(", "response", ")", "true", "end" ]
Change the password for a user @param [String, Symbol] username @param [String, Symbol] password @raise [RuntimeError] if the request failed @return true
[ "Change", "the", "password", "for", "a", "user" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L53-L59
1,295
HewlettPackard/ilo-sdk-ruby
lib/ilo-sdk/helpers/account_service_helper.rb
ILO_SDK.AccountServiceHelper.delete_user
def delete_user(username) userhref = userhref('/redfish/v1/AccountService/Accounts/', username) response = rest_delete(userhref) response_handler(response) true end
ruby
def delete_user(username) userhref = userhref('/redfish/v1/AccountService/Accounts/', username) response = rest_delete(userhref) response_handler(response) true end
[ "def", "delete_user", "(", "username", ")", "userhref", "=", "userhref", "(", "'/redfish/v1/AccountService/Accounts/'", ",", "username", ")", "response", "=", "rest_delete", "(", "userhref", ")", "response_handler", "(", "response", ")", "true", "end" ]
Delete a specific user @param [String, Symbol] username @raise [RuntimeError] if the request failed @return true
[ "Delete", "a", "specific", "user" ]
ac171cd75d070ccf64017d43777ded40a5f018f9
https://github.com/HewlettPackard/ilo-sdk-ruby/blob/ac171cd75d070ccf64017d43777ded40a5f018f9/lib/ilo-sdk/helpers/account_service_helper.rb#L65-L70
1,296
nledez/proxmox
lib/proxmox.rb
Proxmox.Proxmox.templates
def templates data = http_action_get "nodes/#{@node}/storage/local/content" template_list = {} data.each do |ve| name = ve['volid'].gsub(%r{local:vztmpl\/(.*).tar.gz}, '\1') template_list[name] = ve end template_list end
ruby
def templates data = http_action_get "nodes/#{@node}/storage/local/content" template_list = {} data.each do |ve| name = ve['volid'].gsub(%r{local:vztmpl\/(.*).tar.gz}, '\1') template_list[name] = ve end template_list end
[ "def", "templates", "data", "=", "http_action_get", "\"nodes/#{@node}/storage/local/content\"", "template_list", "=", "{", "}", "data", ".", "each", "do", "|", "ve", "|", "name", "=", "ve", "[", "'volid'", "]", ".", "gsub", "(", "%r{", "\\/", "}", ",", "'\\1'", ")", "template_list", "[", "name", "]", "=", "ve", "end", "template_list", "end" ]
Get template list :call-seq: templates -> Hash Return a Hash of all templates Example: templates Example return: { 'ubuntu-10.04-standard_10.04-4_i386' => { 'format' => 'tgz', 'content' => 'vztmpl', 'volid' => 'local:vztmpl/ubuntu-10.04-standard_10.04-4_i386.tar.gz', 'size' => 142126884 }, 'ubuntu-12.04-standard_12.04-1_i386' => { 'format' => 'tgz', 'content' => 'vztmpl', 'volid' => 'local:vztmpl/ubuntu-12.04-standard_12.04-1_i386.tar.gz', 'size' => 130040792 } }
[ "Get", "template", "list" ]
cc679cc69deb78b20f88074b235e172869070a0d
https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L108-L116
1,297
nledez/proxmox
lib/proxmox.rb
Proxmox.Proxmox.openvz_get
def openvz_get data = http_action_get "nodes/#{@node}/openvz" ve_list = {} data.each do |ve| ve_list[ve['vmid']] = ve end ve_list end
ruby
def openvz_get data = http_action_get "nodes/#{@node}/openvz" ve_list = {} data.each do |ve| ve_list[ve['vmid']] = ve end ve_list end
[ "def", "openvz_get", "data", "=", "http_action_get", "\"nodes/#{@node}/openvz\"", "ve_list", "=", "{", "}", "data", ".", "each", "do", "|", "ve", "|", "ve_list", "[", "ve", "[", "'vmid'", "]", "]", "=", "ve", "end", "ve_list", "end" ]
Get CT list :call-seq: openvz_get -> Hash Return a Hash of all openvz container Example: openvz_get Example return: { '101' => { 'maxswap' => 536870912, 'disk' => 405168128, 'ip' => '192.168.1.5', 'status' => 'running', 'netout' => 272, 'maxdisk' => 4294967296, 'maxmem' => 536870912, 'uptime' => 3068073, 'swap' => 0, 'vmid' => '101', 'nproc' => '10', 'diskread' => 0, 'cpu' => 0.00031670581100007, 'netin' => 0, 'name' => 'test2.domain.com', 'failcnt' => 0, 'diskwrite' => 0, 'mem' => 22487040, 'type' => 'openvz', 'cpus' => 1 }, [...] }
[ "Get", "CT", "list" ]
cc679cc69deb78b20f88074b235e172869070a0d
https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L155-L162
1,298
nledez/proxmox
lib/proxmox.rb
Proxmox.Proxmox.openvz_post
def openvz_post(ostemplate, vmid, config = {}) config['vmid'] = vmid config['ostemplate'] = "local%3Avztmpl%2F#{ostemplate}.tar.gz" vm_definition = config.to_a.map { |v| v.join '=' }.join '&' http_action_post("nodes/#{@node}/openvz", vm_definition) end
ruby
def openvz_post(ostemplate, vmid, config = {}) config['vmid'] = vmid config['ostemplate'] = "local%3Avztmpl%2F#{ostemplate}.tar.gz" vm_definition = config.to_a.map { |v| v.join '=' }.join '&' http_action_post("nodes/#{@node}/openvz", vm_definition) end
[ "def", "openvz_post", "(", "ostemplate", ",", "vmid", ",", "config", "=", "{", "}", ")", "config", "[", "'vmid'", "]", "=", "vmid", "config", "[", "'ostemplate'", "]", "=", "\"local%3Avztmpl%2F#{ostemplate}.tar.gz\"", "vm_definition", "=", "config", ".", "to_a", ".", "map", "{", "|", "v", "|", "v", ".", "join", "'='", "}", ".", "join", "'&'", "http_action_post", "(", "\"nodes/#{@node}/openvz\"", ",", "vm_definition", ")", "end" ]
Create CT container :call-seq: openvz_post(ostemplate, vmid) -> String openvz_post(ostemplate, vmid, options) -> String Return a String as task ID Examples: openvz_post('ubuntu-10.04-standard_10.04-4_i386', 200) openvz_post('ubuntu-10.04-standard_10.04-4_i386', 200, {'hostname' => 'test.test.com', 'password' => 'testt' }) Example return: UPID:localhost:000BC66A:1279E395:521EFC4E:vzcreate:200:root@pam:
[ "Create", "CT", "container" ]
cc679cc69deb78b20f88074b235e172869070a0d
https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L181-L187
1,299
nledez/proxmox
lib/proxmox.rb
Proxmox.Proxmox.create_ticket
def create_ticket post_param = { username: @username, realm: @realm, password: @password } @site['access/ticket'].post post_param do |response, _request, _result, &_block| if response.code == 200 extract_ticket response else @connection_status = 'error' end end end
ruby
def create_ticket post_param = { username: @username, realm: @realm, password: @password } @site['access/ticket'].post post_param do |response, _request, _result, &_block| if response.code == 200 extract_ticket response else @connection_status = 'error' end end end
[ "def", "create_ticket", "post_param", "=", "{", "username", ":", "@username", ",", "realm", ":", "@realm", ",", "password", ":", "@password", "}", "@site", "[", "'access/ticket'", "]", ".", "post", "post_param", "do", "|", "response", ",", "_request", ",", "_result", ",", "&", "_block", "|", "if", "response", ".", "code", "==", "200", "extract_ticket", "response", "else", "@connection_status", "=", "'error'", "end", "end", "end" ]
Methods manages auth
[ "Methods", "manages", "auth" ]
cc679cc69deb78b20f88074b235e172869070a0d
https://github.com/nledez/proxmox/blob/cc679cc69deb78b20f88074b235e172869070a0d/lib/proxmox.rb#L340-L349