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 list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
20,300 | poise/poise | lib/poise/utils.rb | Poise.Utils.check_block_arity! | def check_block_arity!(block, args)
# Convert the block to a lambda-style proc. You can't make this shit up.
obj = Object.new
obj.define_singleton_method(:block, &block)
block = obj.method(:block).to_proc
# Check
required_args = block.arity < 0 ? ~block.arity : block.arity
if ... | ruby | def check_block_arity!(block, args)
# Convert the block to a lambda-style proc. You can't make this shit up.
obj = Object.new
obj.define_singleton_method(:block, &block)
block = obj.method(:block).to_proc
# Check
required_args = block.arity < 0 ? ~block.arity : block.arity
if ... | [
"def",
"check_block_arity!",
"(",
"block",
",",
"args",
")",
"# Convert the block to a lambda-style proc. You can't make this shit up.",
"obj",
"=",
"Object",
".",
"new",
"obj",
".",
"define_singleton_method",
"(",
":block",
",",
"block",
")",
"block",
"=",
"obj",
"."... | Check that the given arguments match the given block. This is needed
because Ruby will nil-pad mismatched argspecs on blocks rather than error.
@since 2.3.0
@param block [Proc] Block to check.
@param args [Array<Object>] Arguments to check.
@return [void] | [
"Check",
"that",
"the",
"given",
"arguments",
"match",
"the",
"given",
"block",
".",
"This",
"is",
"needed",
"because",
"Ruby",
"will",
"nil",
"-",
"pad",
"mismatched",
"argspecs",
"on",
"blocks",
"rather",
"than",
"error",
"."
] | 07c33d4f844cf6e97cf349a12f06448d0db9a8d2 | https://github.com/poise/poise/blob/07c33d4f844cf6e97cf349a12f06448d0db9a8d2/lib/poise/utils.rb#L168-L178 |
20,301 | kontena/kong-client-ruby | lib/kong/consumer.rb | Kong.Consumer.oauth_apps | def oauth_apps
apps = []
response = client.get("#{@api_end_point}#{self.id}/oauth2") rescue nil
if response
response['data'].each do |attributes|
apps << Kong::OAuthApp.new(attributes)
end
end
apps
end | ruby | def oauth_apps
apps = []
response = client.get("#{@api_end_point}#{self.id}/oauth2") rescue nil
if response
response['data'].each do |attributes|
apps << Kong::OAuthApp.new(attributes)
end
end
apps
end | [
"def",
"oauth_apps",
"apps",
"=",
"[",
"]",
"response",
"=",
"client",
".",
"get",
"(",
"\"#{@api_end_point}#{self.id}/oauth2\"",
")",
"rescue",
"nil",
"if",
"response",
"response",
"[",
"'data'",
"]",
".",
"each",
"do",
"|",
"attributes",
"|",
"apps",
"<<",... | List OAuth applications
@return [Array<Kong::OAuthApp>] | [
"List",
"OAuth",
"applications"
] | 028c8913388f46c7b3a41984f36687d147f74442 | https://github.com/kontena/kong-client-ruby/blob/028c8913388f46c7b3a41984f36687d147f74442/lib/kong/consumer.rb#L25-L34 |
20,302 | cisco/cisco-network-node-utils | lib/cisco_node_utils/bgp_af.rb | Cisco.RouterBgpAF.dampening_half_time | def dampening_half_time
return nil if dampening.nil? || dampening_routemap_configured?
if dampening.is_a?(Array) && !dampening.empty?
dampening[0].to_i
else
default_dampening_half_time
end
end | ruby | def dampening_half_time
return nil if dampening.nil? || dampening_routemap_configured?
if dampening.is_a?(Array) && !dampening.empty?
dampening[0].to_i
else
default_dampening_half_time
end
end | [
"def",
"dampening_half_time",
"return",
"nil",
"if",
"dampening",
".",
"nil?",
"||",
"dampening_routemap_configured?",
"if",
"dampening",
".",
"is_a?",
"(",
"Array",
")",
"&&",
"!",
"dampening",
".",
"empty?",
"dampening",
"[",
"0",
"]",
".",
"to_i",
"else",
... | For all of the following dampening getters, half_time, reuse_time,
suppress_time, and max_suppress_time, return nil if dampening
is not configured, but also return nil if a dampening routemap
is configured because they are mutually exclusive. | [
"For",
"all",
"of",
"the",
"following",
"dampening",
"getters",
"half_time",
"reuse_time",
"suppress_time",
"and",
"max_suppress_time",
"return",
"nil",
"if",
"dampening",
"is",
"not",
"configured",
"but",
"also",
"return",
"nil",
"if",
"a",
"dampening",
"routemap... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/bgp_af.rb#L229-L236 |
20,303 | cisco/cisco-network-node-utils | lib/cisco_node_utils/bgp_af.rb | Cisco.RouterBgpAF.method_missing | def method_missing(*args)
name = args[0].to_s
if args.length == 1 # Getter
if name =~ /^default_(.*)$/
config_get_default('bgp_af', Regexp.last_match(1))
else
config_get('bgp_af', name, @get_args)
end
elsif args.length == 2 && name =~ /^(.*)=$/ # Setter
... | ruby | def method_missing(*args)
name = args[0].to_s
if args.length == 1 # Getter
if name =~ /^default_(.*)$/
config_get_default('bgp_af', Regexp.last_match(1))
else
config_get('bgp_af', name, @get_args)
end
elsif args.length == 2 && name =~ /^(.*)=$/ # Setter
... | [
"def",
"method_missing",
"(",
"*",
"args",
")",
"name",
"=",
"args",
"[",
"0",
"]",
".",
"to_s",
"if",
"args",
".",
"length",
"==",
"1",
"# Getter",
"if",
"name",
"=~",
"/",
"/",
"config_get_default",
"(",
"'bgp_af'",
",",
"Regexp",
".",
"last_match",
... | Universal Getter, Default Getter, and Setter | [
"Universal",
"Getter",
"Default",
"Getter",
"and",
"Setter"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/bgp_af.rb#L508-L522 |
20,304 | cisco/cisco-network-node-utils | lib/cisco_node_utils/bgp_af.rb | Cisco.RouterBgpAF.respond_to? | def respond_to?(method_sym, _include_private=false)
name = method_sym.to_s
key = :getter?
if name =~ /^(.*)=$/
name = Regexp.last_match(1)
# Use table_map_set() to set these properties
return false if name == 'table_map' || name == 'table_map_filter'
key = :setter?
... | ruby | def respond_to?(method_sym, _include_private=false)
name = method_sym.to_s
key = :getter?
if name =~ /^(.*)=$/
name = Regexp.last_match(1)
# Use table_map_set() to set these properties
return false if name == 'table_map' || name == 'table_map_filter'
key = :setter?
... | [
"def",
"respond_to?",
"(",
"method_sym",
",",
"_include_private",
"=",
"false",
")",
"name",
"=",
"method_sym",
".",
"to_s",
"key",
"=",
":getter?",
"if",
"name",
"=~",
"/",
"/",
"name",
"=",
"Regexp",
".",
"last_match",
"(",
"1",
")",
"# Use table_map_set... | Is the given name available in the YAML? | [
"Is",
"the",
"given",
"name",
"available",
"in",
"the",
"YAML?"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/bgp_af.rb#L525-L543 |
20,305 | cisco/cisco-network-node-utils | lib/cisco_node_utils/ace.rb | Cisco.Ace.ace_get | def ace_get
str = config_get('acl', 'ace', @get_args)
return nil if str.nil?
remark = Regexp.new('(?<seqno>\d+) remark (?<remark>.*)').match(str)
return remark unless remark.nil?
# specialized icmp protocol handling
return icmp_ace_get(str) if str.include?('icmp')
# rubocop:... | ruby | def ace_get
str = config_get('acl', 'ace', @get_args)
return nil if str.nil?
remark = Regexp.new('(?<seqno>\d+) remark (?<remark>.*)').match(str)
return remark unless remark.nil?
# specialized icmp protocol handling
return icmp_ace_get(str) if str.include?('icmp')
# rubocop:... | [
"def",
"ace_get",
"str",
"=",
"config_get",
"(",
"'acl'",
",",
"'ace'",
",",
"@get_args",
")",
"return",
"nil",
"if",
"str",
".",
"nil?",
"remark",
"=",
"Regexp",
".",
"new",
"(",
"'(?<seqno>\\d+) remark (?<remark>.*)'",
")",
".",
"match",
"(",
"str",
")",... | common ace getter | [
"common",
"ace",
"getter"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/ace.rb#L70-L100 |
20,306 | cisco/cisco-network-node-utils | lib/cisco_node_utils/ace.rb | Cisco.Ace.icmp_ace_get | def icmp_ace_get(str)
# rubocop:disable Metrics/LineLength
# fragments is nvgen at a different location than all other
# proto_option so get rid of it so as not to mess up other fields
str.sub!('fragments ', '')
regexp = Regexp.new('(?<seqno>\d+) (?<action>\S+)'\
' *(?<pro... | ruby | def icmp_ace_get(str)
# rubocop:disable Metrics/LineLength
# fragments is nvgen at a different location than all other
# proto_option so get rid of it so as not to mess up other fields
str.sub!('fragments ', '')
regexp = Regexp.new('(?<seqno>\d+) (?<action>\S+)'\
' *(?<pro... | [
"def",
"icmp_ace_get",
"(",
"str",
")",
"# rubocop:disable Metrics/LineLength",
"# fragments is nvgen at a different location than all other",
"# proto_option so get rid of it so as not to mess up other fields",
"str",
".",
"sub!",
"(",
"'fragments '",
",",
"''",
")",
"regexp",
"="... | icmp ace getter | [
"icmp",
"ace",
"getter"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/ace.rb#L103-L154 |
20,307 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface.rb | Cisco.Interface.hsrp_delay_minimum= | def hsrp_delay_minimum=(val)
Feature.hsrp_enable if val
config_set('interface', 'hsrp_delay', name: @name,
minimum: 'minimum', min: val, reload: '', rel: '')
end | ruby | def hsrp_delay_minimum=(val)
Feature.hsrp_enable if val
config_set('interface', 'hsrp_delay', name: @name,
minimum: 'minimum', min: val, reload: '', rel: '')
end | [
"def",
"hsrp_delay_minimum",
"=",
"(",
"val",
")",
"Feature",
".",
"hsrp_enable",
"if",
"val",
"config_set",
"(",
"'interface'",
",",
"'hsrp_delay'",
",",
"name",
":",
"@name",
",",
"minimum",
":",
"'minimum'",
",",
"min",
":",
"val",
",",
"reload",
":",
... | hsrp delay minimum and reload are in the same CLI
but both can be set independent of each other | [
"hsrp",
"delay",
"minimum",
"and",
"reload",
"are",
"in",
"the",
"same",
"CLI",
"but",
"both",
"can",
"be",
"set",
"independent",
"of",
"each",
"other"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface.rb#L337-L341 |
20,308 | cisco/cisco-network-node-utils | lib/cisco_node_utils/stp_global.rb | Cisco.StpGlobal.bd_total_range_with_vlans | def bd_total_range_with_vlans
hash = Vlan.vlans
arr = []
hash.keys.each do |id|
arr << id.to_i
end
Utils.array_to_str(arr)
ret_arr = []
ret_arr << Utils.array_to_str(arr)
end | ruby | def bd_total_range_with_vlans
hash = Vlan.vlans
arr = []
hash.keys.each do |id|
arr << id.to_i
end
Utils.array_to_str(arr)
ret_arr = []
ret_arr << Utils.array_to_str(arr)
end | [
"def",
"bd_total_range_with_vlans",
"hash",
"=",
"Vlan",
".",
"vlans",
"arr",
"=",
"[",
"]",
"hash",
".",
"keys",
".",
"each",
"do",
"|",
"id",
"|",
"arr",
"<<",
"id",
".",
"to_i",
"end",
"Utils",
".",
"array_to_str",
"(",
"arr",
")",
"ret_arr",
"=",... | bridge-domain and vlans are mutually exclusive
so when there are vlans, we need to remove them
from the bd range while restting | [
"bridge",
"-",
"domain",
"and",
"vlans",
"are",
"mutually",
"exclusive",
"so",
"when",
"there",
"are",
"vlans",
"we",
"need",
"to",
"remove",
"them",
"from",
"the",
"bd",
"range",
"while",
"restting"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/stp_global.rb#L652-L661 |
20,309 | cisco/cisco-network-node-utils | lib/cisco_node_utils/itd_device_group_node.rb | Cisco.ItdDeviceGroupNode.hs_weight | def hs_weight(hs, wt)
if hs != hot_standby && hot_standby == default_hot_standby
self.lweight = wt unless weight == wt
self.lhot_standby = hs
elsif hs != hot_standby && hot_standby != default_hot_standby
self.lhot_standby = hs
self.lweight = wt unless weight == wt
elsif... | ruby | def hs_weight(hs, wt)
if hs != hot_standby && hot_standby == default_hot_standby
self.lweight = wt unless weight == wt
self.lhot_standby = hs
elsif hs != hot_standby && hot_standby != default_hot_standby
self.lhot_standby = hs
self.lweight = wt unless weight == wt
elsif... | [
"def",
"hs_weight",
"(",
"hs",
",",
"wt",
")",
"if",
"hs",
"!=",
"hot_standby",
"&&",
"hot_standby",
"==",
"default_hot_standby",
"self",
".",
"lweight",
"=",
"wt",
"unless",
"weight",
"==",
"wt",
"self",
".",
"lhot_standby",
"=",
"hs",
"elsif",
"hs",
"!... | Call this for setting hot_standby and weight together because
the CLI is pretty weird and it accepts these params in a very
particular way and they cannot even be reset unless proper
order is followed | [
"Call",
"this",
"for",
"setting",
"hot_standby",
"and",
"weight",
"together",
"because",
"the",
"CLI",
"is",
"pretty",
"weird",
"and",
"it",
"accepts",
"these",
"params",
"in",
"a",
"very",
"particular",
"way",
"and",
"they",
"cannot",
"even",
"be",
"reset",... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/itd_device_group_node.rb#L125-L138 |
20,310 | cisco/cisco-network-node-utils | lib/cisco_node_utils/bridge_domain_vni.rb | Cisco.BridgeDomainVNI.curr_bd_vni_hash | def curr_bd_vni_hash
final_bd_vni = {}
curr_vni = config_get('bridge_domain_vni', 'member_vni')
curr_bd_vni = config_get('bridge_domain_vni', 'member_vni_bd')
return final_bd_vni if curr_vni.empty? || curr_bd_vni.empty?
curr_vni_list = BridgeDomainVNI.string_to_array(curr_vni)
curr_... | ruby | def curr_bd_vni_hash
final_bd_vni = {}
curr_vni = config_get('bridge_domain_vni', 'member_vni')
curr_bd_vni = config_get('bridge_domain_vni', 'member_vni_bd')
return final_bd_vni if curr_vni.empty? || curr_bd_vni.empty?
curr_vni_list = BridgeDomainVNI.string_to_array(curr_vni)
curr_... | [
"def",
"curr_bd_vni_hash",
"final_bd_vni",
"=",
"{",
"}",
"curr_vni",
"=",
"config_get",
"(",
"'bridge_domain_vni'",
",",
"'member_vni'",
")",
"curr_bd_vni",
"=",
"config_get",
"(",
"'bridge_domain_vni'",
",",
"'member_vni_bd'",
")",
"return",
"final_bd_vni",
"if",
... | Example clis;
system bridge-domain 101-200
bridge-domain 101-200
bridge-domain 101-110,120,141-145,180
member vni 6001-6011,5041-5044,8000,9000
config_get('bridge_domain_vni', 'member_vni')
will get the current member vni in this case
6001-6011,5041-5044,8000,9000
config_get('bridge_domain_vni', 'member_vni... | [
"Example",
"clis",
";",
"system",
"bridge",
"-",
"domain",
"101",
"-",
"200",
"bridge",
"-",
"domain",
"101",
"-",
"200",
"bridge",
"-",
"domain",
"101",
"-",
"110",
"120",
"141",
"-",
"145",
"180",
"member",
"vni",
"6001",
"-",
"6011",
"5041",
"-",
... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/bridge_domain_vni.rb#L88-L102 |
20,311 | cisco/cisco-network-node-utils | lib/cisco_node_utils/node.rb | Cisco.Node.massage_structured | def massage_structured(get_args, ref)
# Nothing to do unless nxapi_structured.
return [get_args, ref] unless
ref.hash['get_data_format'] == :nxapi_structured
# The CmdRef object will contain a get_value Array with 2 values.
# The first value is the key to identify the correct row in the... | ruby | def massage_structured(get_args, ref)
# Nothing to do unless nxapi_structured.
return [get_args, ref] unless
ref.hash['get_data_format'] == :nxapi_structured
# The CmdRef object will contain a get_value Array with 2 values.
# The first value is the key to identify the correct row in the... | [
"def",
"massage_structured",
"(",
"get_args",
",",
"ref",
")",
"# Nothing to do unless nxapi_structured.",
"return",
"[",
"get_args",
",",
"ref",
"]",
"unless",
"ref",
".",
"hash",
"[",
"'get_data_format'",
"]",
"==",
":nxapi_structured",
"# The CmdRef object will conta... | The yaml file may specifiy an Array as the get_value to drill down into
nxapi_structured table output. The table may contain multiple rows but
only one of the rows has the interesting data. | [
"The",
"yaml",
"file",
"may",
"specifiy",
"an",
"Array",
"as",
"the",
"get_value",
"to",
"drill",
"down",
"into",
"nxapi_structured",
"table",
"output",
".",
"The",
"table",
"may",
"contain",
"multiple",
"rows",
"but",
"only",
"one",
"of",
"the",
"rows",
"... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/node.rb#L70-L95 |
20,312 | cisco/cisco-network-node-utils | lib/cisco_node_utils/node.rb | Cisco.Node.massage | def massage(value, ref)
Cisco::Logger.debug "Massaging '#{value}' (#{value.inspect})"
value = drill_down_structured(value, ref)
if value.is_a?(Array) && !ref.multiple
fail "Expected zero/one value but got '#{value}'" if value.length > 1
value = value[0]
end
if (value.nil? |... | ruby | def massage(value, ref)
Cisco::Logger.debug "Massaging '#{value}' (#{value.inspect})"
value = drill_down_structured(value, ref)
if value.is_a?(Array) && !ref.multiple
fail "Expected zero/one value but got '#{value}'" if value.length > 1
value = value[0]
end
if (value.nil? |... | [
"def",
"massage",
"(",
"value",
",",
"ref",
")",
"Cisco",
"::",
"Logger",
".",
"debug",
"\"Massaging '#{value}' (#{value.inspect})\"",
"value",
"=",
"drill_down_structured",
"(",
"value",
",",
"ref",
")",
"if",
"value",
".",
"is_a?",
"(",
"Array",
")",
"&&",
... | Attempt to massage the given value into the format specified by the
given CmdRef object. | [
"Attempt",
"to",
"massage",
"the",
"given",
"value",
"into",
"the",
"format",
"specified",
"by",
"the",
"given",
"CmdRef",
"object",
"."
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/node.rb#L140-L160 |
20,313 | cisco/cisco-network-node-utils | lib/cisco_node_utils/command_reference.rb | Cisco.CommandReference.lookup | def lookup(feature, name)
value = @hash[feature]
value = value[name] if value.is_a? Hash
fail IndexError, "No CmdRef defined for #{feature}, #{name}" if value.nil?
value
end | ruby | def lookup(feature, name)
value = @hash[feature]
value = value[name] if value.is_a? Hash
fail IndexError, "No CmdRef defined for #{feature}, #{name}" if value.nil?
value
end | [
"def",
"lookup",
"(",
"feature",
",",
"name",
")",
"value",
"=",
"@hash",
"[",
"feature",
"]",
"value",
"=",
"value",
"[",
"name",
"]",
"if",
"value",
".",
"is_a?",
"Hash",
"fail",
"IndexError",
",",
"\"No CmdRef defined for #{feature}, #{name}\"",
"if",
"va... | Get the command reference | [
"Get",
"the",
"command",
"reference"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/command_reference.rb#L424-L429 |
20,314 | cisco/cisco-network-node-utils | lib/cisco_node_utils/command_reference.rb | Cisco.CommandReference.validate_yaml | def validate_yaml(node, filename, depth=0, parents=nil)
return unless node && (mapping?(node) || node.children)
# Psych wraps everything in a Document instance, which we ignore.
unless node.class.ancestors.any? { |name| /Document/ =~ name.to_s }
depth += 1
end
debug "Validating #{n... | ruby | def validate_yaml(node, filename, depth=0, parents=nil)
return unless node && (mapping?(node) || node.children)
# Psych wraps everything in a Document instance, which we ignore.
unless node.class.ancestors.any? { |name| /Document/ =~ name.to_s }
depth += 1
end
debug "Validating #{n... | [
"def",
"validate_yaml",
"(",
"node",
",",
"filename",
",",
"depth",
"=",
"0",
",",
"parents",
"=",
"nil",
")",
"return",
"unless",
"node",
"&&",
"(",
"mapping?",
"(",
"node",
")",
"||",
"node",
".",
"children",
")",
"# Psych wraps everything in a Document in... | Validate the YAML node tree before converting it into Ruby
data structures.
@raise RuntimeError if the node tree is not valid by our constraints.
@param node Node to be validated, then recurse to its children.
@param filename File that YAML was parsed from, for messages
@param depth Depth into the node tree
@pa... | [
"Validate",
"the",
"YAML",
"node",
"tree",
"before",
"converting",
"it",
"into",
"Ruby",
"data",
"structures",
"."
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/command_reference.rb#L621-L684 |
20,315 | cisco/cisco-network-node-utils | lib/cisco_node_utils/command_reference.rb | Cisco.CommandReference.load_yaml | def load_yaml(yaml_file)
fail "File #{yaml_file} doesn't exist." unless File.exist?(yaml_file)
# Parse YAML file into a tree of nodes
# Psych::SyntaxError doesn't inherit from StandardError in some versions,
# so we want to explicitly catch it if using Psych.
rescue_errors = [::StandardErr... | ruby | def load_yaml(yaml_file)
fail "File #{yaml_file} doesn't exist." unless File.exist?(yaml_file)
# Parse YAML file into a tree of nodes
# Psych::SyntaxError doesn't inherit from StandardError in some versions,
# so we want to explicitly catch it if using Psych.
rescue_errors = [::StandardErr... | [
"def",
"load_yaml",
"(",
"yaml_file",
")",
"fail",
"\"File #{yaml_file} doesn't exist.\"",
"unless",
"File",
".",
"exist?",
"(",
"yaml_file",
")",
"# Parse YAML file into a tree of nodes",
"# Psych::SyntaxError doesn't inherit from StandardError in some versions,",
"# so we want to e... | Read in yaml file.
The expectation is that a file corresponds to a feature | [
"Read",
"in",
"yaml",
"file",
".",
"The",
"expectation",
"is",
"that",
"a",
"file",
"corresponds",
"to",
"a",
"feature"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/command_reference.rb#L689-L707 |
20,316 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface_ospf.rb | Cisco.InterfaceOspf.message_digest_key_set | def message_digest_key_set(keyid, algtype, enctype, enc)
current_keyid = message_digest_key_id
if keyid == default_message_digest_key_id && current_keyid != keyid
config_set('interface_ospf', 'message_digest_key_set',
@interface.name, 'no', current_keyid,
'', ''... | ruby | def message_digest_key_set(keyid, algtype, enctype, enc)
current_keyid = message_digest_key_id
if keyid == default_message_digest_key_id && current_keyid != keyid
config_set('interface_ospf', 'message_digest_key_set',
@interface.name, 'no', current_keyid,
'', ''... | [
"def",
"message_digest_key_set",
"(",
"keyid",
",",
"algtype",
",",
"enctype",
",",
"enc",
")",
"current_keyid",
"=",
"message_digest_key_id",
"if",
"keyid",
"==",
"default_message_digest_key_id",
"&&",
"current_keyid",
"!=",
"keyid",
"config_set",
"(",
"'interface_os... | interface %s
%s ip ospf message-digest-key %d %s %d %s | [
"interface",
"%s",
"%s",
"ip",
"ospf",
"message",
"-",
"digest",
"-",
"key",
"%d",
"%s",
"%d",
"%s"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface_ospf.rb#L160-L173 |
20,317 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface_ospf.rb | Cisco.InterfaceOspf.bfd | def bfd
val = config_get('interface_ospf', 'bfd', @interface.name)
return if val.nil?
val.include?('disable') ? false : true
end | ruby | def bfd
val = config_get('interface_ospf', 'bfd', @interface.name)
return if val.nil?
val.include?('disable') ? false : true
end | [
"def",
"bfd",
"val",
"=",
"config_get",
"(",
"'interface_ospf'",
",",
"'bfd'",
",",
"@interface",
".",
"name",
")",
"return",
"if",
"val",
".",
"nil?",
"val",
".",
"include?",
"(",
"'disable'",
")",
"?",
"false",
":",
"true",
"end"
] | CLI can be either of the following or none
ip ospf bfd
ip ospf bfd disable | [
"CLI",
"can",
"be",
"either",
"of",
"the",
"following",
"or",
"none",
"ip",
"ospf",
"bfd",
"ip",
"ospf",
"bfd",
"disable"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface_ospf.rb#L226-L230 |
20,318 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface_ospf.rb | Cisco.InterfaceOspf.bfd= | def bfd=(val)
return if val == bfd
Feature.bfd_enable
state = (val == default_bfd) ? 'no' : ''
disable = val ? '' : 'disable'
config_set('interface_ospf', 'bfd', @interface.name,
state, disable)
end | ruby | def bfd=(val)
return if val == bfd
Feature.bfd_enable
state = (val == default_bfd) ? 'no' : ''
disable = val ? '' : 'disable'
config_set('interface_ospf', 'bfd', @interface.name,
state, disable)
end | [
"def",
"bfd",
"=",
"(",
"val",
")",
"return",
"if",
"val",
"==",
"bfd",
"Feature",
".",
"bfd_enable",
"state",
"=",
"(",
"val",
"==",
"default_bfd",
")",
"?",
"'no'",
":",
"''",
"disable",
"=",
"val",
"?",
"''",
":",
"'disable'",
"config_set",
"(",
... | interface %s
%s ip ospf bfd %s | [
"interface",
"%s",
"%s",
"ip",
"ospf",
"bfd",
"%s"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface_ospf.rb#L234-L241 |
20,319 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface_ospf.rb | Cisco.InterfaceOspf.network_type= | def network_type=(type)
no_cmd = (type == default_network_type) ? 'no' : ''
network = (type == default_network_type) ? '' : type
network = 'point-to-point' if type.to_s == 'p2p'
config_set('interface_ospf', 'network_type', @interface.name,
no_cmd, network)
end | ruby | def network_type=(type)
no_cmd = (type == default_network_type) ? 'no' : ''
network = (type == default_network_type) ? '' : type
network = 'point-to-point' if type.to_s == 'p2p'
config_set('interface_ospf', 'network_type', @interface.name,
no_cmd, network)
end | [
"def",
"network_type",
"=",
"(",
"type",
")",
"no_cmd",
"=",
"(",
"type",
"==",
"default_network_type",
")",
"?",
"'no'",
":",
"''",
"network",
"=",
"(",
"type",
"==",
"default_network_type",
")",
"?",
"''",
":",
"type",
"network",
"=",
"'point-to-point'",... | interface %s
%s ip ospf network %s | [
"interface",
"%s",
"%s",
"ip",
"ospf",
"network",
"%s"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface_ospf.rb#L281-L287 |
20,320 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface_ospf.rb | Cisco.InterfaceOspf.passive_interface= | def passive_interface=(enable)
fail TypeError unless enable == true || enable == false
config_set('interface_ospf', 'passive_interface', @interface.name,
enable ? '' : 'no')
end | ruby | def passive_interface=(enable)
fail TypeError unless enable == true || enable == false
config_set('interface_ospf', 'passive_interface', @interface.name,
enable ? '' : 'no')
end | [
"def",
"passive_interface",
"=",
"(",
"enable",
")",
"fail",
"TypeError",
"unless",
"enable",
"==",
"true",
"||",
"enable",
"==",
"false",
"config_set",
"(",
"'interface_ospf'",
",",
"'passive_interface'",
",",
"@interface",
".",
"name",
",",
"enable",
"?",
"'... | interface %s
%s ip ospf passive-interface | [
"interface",
"%s",
"%s",
"ip",
"ospf",
"passive",
"-",
"interface"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface_ospf.rb#L299-L303 |
20,321 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface_ospf.rb | Cisco.InterfaceOspf.priority= | def priority=(val)
no_cmd = (val == default_priority) ? 'no' : ''
pri = (val == default_priority) ? '' : val
config_set('interface_ospf', 'priority',
@interface.name, no_cmd, pri)
end | ruby | def priority=(val)
no_cmd = (val == default_priority) ? 'no' : ''
pri = (val == default_priority) ? '' : val
config_set('interface_ospf', 'priority',
@interface.name, no_cmd, pri)
end | [
"def",
"priority",
"=",
"(",
"val",
")",
"no_cmd",
"=",
"(",
"val",
"==",
"default_priority",
")",
"?",
"'no'",
":",
"''",
"pri",
"=",
"(",
"val",
"==",
"default_priority",
")",
"?",
"''",
":",
"val",
"config_set",
"(",
"'interface_ospf'",
",",
"'prior... | interface %s
ip ospf priority %d | [
"interface",
"%s",
"ip",
"ospf",
"priority",
"%d"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface_ospf.rb#L311-L316 |
20,322 | cisco/cisco-network-node-utils | lib/cisco_node_utils/interface_ospf.rb | Cisco.InterfaceOspf.transmit_delay= | def transmit_delay=(val)
no_cmd = (val == default_transmit_delay) ? 'no' : ''
delay = (val == default_transmit_delay) ? '' : val
config_set('interface_ospf', 'transmit_delay',
@interface.name, no_cmd, delay)
end | ruby | def transmit_delay=(val)
no_cmd = (val == default_transmit_delay) ? 'no' : ''
delay = (val == default_transmit_delay) ? '' : val
config_set('interface_ospf', 'transmit_delay',
@interface.name, no_cmd, delay)
end | [
"def",
"transmit_delay",
"=",
"(",
"val",
")",
"no_cmd",
"=",
"(",
"val",
"==",
"default_transmit_delay",
")",
"?",
"'no'",
":",
"''",
"delay",
"=",
"(",
"val",
"==",
"default_transmit_delay",
")",
"?",
"''",
":",
"val",
"config_set",
"(",
"'interface_ospf... | interface %s
ip ospf transmit-delay %d | [
"interface",
"%s",
"ip",
"ospf",
"transmit",
"-",
"delay",
"%d"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/interface_ospf.rb#L343-L348 |
20,323 | cisco/cisco-network-node-utils | lib/cisco_node_utils/bfd_global.rb | Cisco.BfdGlobal.destroy | def destroy
return unless Feature.bfd_enabled?
[:interval,
:ipv4_interval,
:ipv6_interval,
:fabricpath_interval,
:echo_interface,
:echo_rx_interval,
:ipv4_echo_rx_interval,
:ipv6_echo_rx_interval,
:fabricpath_vlan,
:slow_timer,
:ipv4_slow... | ruby | def destroy
return unless Feature.bfd_enabled?
[:interval,
:ipv4_interval,
:ipv6_interval,
:fabricpath_interval,
:echo_interface,
:echo_rx_interval,
:ipv4_echo_rx_interval,
:ipv6_echo_rx_interval,
:fabricpath_vlan,
:slow_timer,
:ipv4_slow... | [
"def",
"destroy",
"return",
"unless",
"Feature",
".",
"bfd_enabled?",
"[",
":interval",
",",
":ipv4_interval",
",",
":ipv6_interval",
",",
":fabricpath_interval",
",",
":echo_interface",
",",
":echo_rx_interval",
",",
":ipv4_echo_rx_interval",
",",
":ipv6_echo_rx_interval... | Reset everything back to default | [
"Reset",
"everything",
"back",
"to",
"default"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/bfd_global.rb#L34-L55 |
20,324 | cisco/cisco-network-node-utils | lib/cisco_node_utils/vtp.rb | Cisco.Vtp.domain= | def domain=(d)
d = d.to_s
fail ArgumentError unless d.length.between?(1, MAX_VTP_DOMAIN_NAME_SIZE)
config_set('vtp', 'domain', domain: d)
end | ruby | def domain=(d)
d = d.to_s
fail ArgumentError unless d.length.between?(1, MAX_VTP_DOMAIN_NAME_SIZE)
config_set('vtp', 'domain', domain: d)
end | [
"def",
"domain",
"=",
"(",
"d",
")",
"d",
"=",
"d",
".",
"to_s",
"fail",
"ArgumentError",
"unless",
"d",
".",
"length",
".",
"between?",
"(",
"1",
",",
"MAX_VTP_DOMAIN_NAME_SIZE",
")",
"config_set",
"(",
"'vtp'",
",",
"'domain'",
",",
"domain",
":",
"d... | Set vtp domain name | [
"Set",
"vtp",
"domain",
"name"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/vtp.rb#L55-L59 |
20,325 | cisco/cisco-network-node-utils | lib/cisco_node_utils/vtp.rb | Cisco.Vtp.password | def password
# Unfortunately nxapi returns "\\" when the password is not set
password = config_get('vtp', 'password') if Feature.vtp_enabled?
return '' if password.nil? || password == '\\'
password
rescue Cisco::RequestNotSupported => e
# Certain platforms generate a Cisco::RequestNotS... | ruby | def password
# Unfortunately nxapi returns "\\" when the password is not set
password = config_get('vtp', 'password') if Feature.vtp_enabled?
return '' if password.nil? || password == '\\'
password
rescue Cisco::RequestNotSupported => e
# Certain platforms generate a Cisco::RequestNotS... | [
"def",
"password",
"# Unfortunately nxapi returns \"\\\\\" when the password is not set",
"password",
"=",
"config_get",
"(",
"'vtp'",
",",
"'password'",
")",
"if",
"Feature",
".",
"vtp_enabled?",
"return",
"''",
"if",
"password",
".",
"nil?",
"||",
"password",
"==",
... | Get vtp password | [
"Get",
"vtp",
"password"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/vtp.rb#L62-L72 |
20,326 | cisco/cisco-network-node-utils | lib/cisco_node_utils/vtp.rb | Cisco.Vtp.password= | def password=(password)
fail TypeError if password.nil?
fail TypeError unless password.is_a? String
fail ArgumentError if password.length > MAX_VTP_PASSWORD_SIZE
Feature.vtp_enable
state = (password == default_password) ? 'no' : ''
config_set('vtp', 'password', state: state, password... | ruby | def password=(password)
fail TypeError if password.nil?
fail TypeError unless password.is_a? String
fail ArgumentError if password.length > MAX_VTP_PASSWORD_SIZE
Feature.vtp_enable
state = (password == default_password) ? 'no' : ''
config_set('vtp', 'password', state: state, password... | [
"def",
"password",
"=",
"(",
"password",
")",
"fail",
"TypeError",
"if",
"password",
".",
"nil?",
"fail",
"TypeError",
"unless",
"password",
".",
"is_a?",
"String",
"fail",
"ArgumentError",
"if",
"password",
".",
"length",
">",
"MAX_VTP_PASSWORD_SIZE",
"Feature"... | Set vtp password | [
"Set",
"vtp",
"password"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/vtp.rb#L75-L82 |
20,327 | cisco/cisco-network-node-utils | lib/cisco_node_utils/vtp.rb | Cisco.Vtp.filename= | def filename=(uri)
fail TypeError if uri.nil?
Feature.vtp_enable
uri = uri.to_s
state = uri.empty? ? 'no' : ''
config_set('vtp', 'filename', state: state, uri: uri)
end | ruby | def filename=(uri)
fail TypeError if uri.nil?
Feature.vtp_enable
uri = uri.to_s
state = uri.empty? ? 'no' : ''
config_set('vtp', 'filename', state: state, uri: uri)
end | [
"def",
"filename",
"=",
"(",
"uri",
")",
"fail",
"TypeError",
"if",
"uri",
".",
"nil?",
"Feature",
".",
"vtp_enable",
"uri",
"=",
"uri",
".",
"to_s",
"state",
"=",
"uri",
".",
"empty?",
"?",
"'no'",
":",
"''",
"config_set",
"(",
"'vtp'",
",",
"'filen... | Set vtp filename | [
"Set",
"vtp",
"filename"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/vtp.rb#L96-L102 |
20,328 | cisco/cisco-network-node-utils | lib/cisco_node_utils/bgp.rb | Cisco.RouterBgp.graceful_restart= | def graceful_restart=(enable)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'graceful_restart', 'set',
'graceful_restart is not ' \
'configurable ' \
... | ruby | def graceful_restart=(enable)
if platform == :ios_xr && @vrf != 'default'
fail Cisco::UnsupportedError.new('bgp', 'graceful_restart', 'set',
'graceful_restart is not ' \
'configurable ' \
... | [
"def",
"graceful_restart",
"=",
"(",
"enable",
")",
"if",
"platform",
"==",
":ios_xr",
"&&",
"@vrf",
"!=",
"'default'",
"fail",
"Cisco",
"::",
"UnsupportedError",
".",
"new",
"(",
"'bgp'",
",",
"'graceful_restart'",
",",
"'set'",
",",
"'graceful_restart is not '... | Graceful Restart Setters | [
"Graceful",
"Restart",
"Setters"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/bgp.rb#L632-L642 |
20,329 | cisco/cisco-network-node-utils | lib/cisco_node_utils/bgp.rb | Cisco.RouterBgp.timer_bgp_keepalive_hold_set | def timer_bgp_keepalive_hold_set(keepalive, hold)
if keepalive == default_timer_bgp_keepalive &&
hold == default_timer_bgp_holdtime
@set_args[:state] = 'no'
@set_args[:keepalive] = keepalive
@set_args[:hold] = hold
else
@set_args[:state] = ''
@set_args[:keepa... | ruby | def timer_bgp_keepalive_hold_set(keepalive, hold)
if keepalive == default_timer_bgp_keepalive &&
hold == default_timer_bgp_holdtime
@set_args[:state] = 'no'
@set_args[:keepalive] = keepalive
@set_args[:hold] = hold
else
@set_args[:state] = ''
@set_args[:keepa... | [
"def",
"timer_bgp_keepalive_hold_set",
"(",
"keepalive",
",",
"hold",
")",
"if",
"keepalive",
"==",
"default_timer_bgp_keepalive",
"&&",
"hold",
"==",
"default_timer_bgp_holdtime",
"@set_args",
"[",
":state",
"]",
"=",
"'no'",
"@set_args",
"[",
":keepalive",
"]",
"=... | BGP Timers Setters | [
"BGP",
"Timers",
"Setters"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/bgp.rb#L933-L946 |
20,330 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.match_community | def match_community
str = config_get('route_map', 'match_community', @get_args)
if str.empty?
val = default_match_community
else
val = str.split
val.delete('exact-match')
end
val
end | ruby | def match_community
str = config_get('route_map', 'match_community', @get_args)
if str.empty?
val = default_match_community
else
val = str.split
val.delete('exact-match')
end
val
end | [
"def",
"match_community",
"str",
"=",
"config_get",
"(",
"'route_map'",
",",
"'match_community'",
",",
"@get_args",
")",
"if",
"str",
".",
"empty?",
"val",
"=",
"default_match_community",
"else",
"val",
"=",
"str",
".",
"split",
"val",
".",
"delete",
"(",
"'... | match community public private exact-match | [
"match",
"community",
"public",
"private",
"exact",
"-",
"match"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L156-L165 |
20,331 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.match_metric | def match_metric
str = config_get('route_map', 'match_metric', @get_args)
return default_match_metric if str.empty?
rarr = []
larr = []
metrics = str.split
deviation = false
metrics.each do |metric|
deviation = true if metric == '+-'
if !larr.empty? && !deviatio... | ruby | def match_metric
str = config_get('route_map', 'match_metric', @get_args)
return default_match_metric if str.empty?
rarr = []
larr = []
metrics = str.split
deviation = false
metrics.each do |metric|
deviation = true if metric == '+-'
if !larr.empty? && !deviatio... | [
"def",
"match_metric",
"str",
"=",
"config_get",
"(",
"'route_map'",
",",
"'match_metric'",
",",
"@get_args",
")",
"return",
"default_match_metric",
"if",
"str",
".",
"empty?",
"rarr",
"=",
"[",
"]",
"larr",
"=",
"[",
"]",
"metrics",
"=",
"str",
".",
"spli... | match metric 1 8 224 +- 9 23 5 +- 8 6 | [
"match",
"metric",
"1",
"8",
"224",
"+",
"-",
"9",
"23",
"5",
"+",
"-",
"8",
"6"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L847-L876 |
20,332 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.match_ospf_area | def match_ospf_area
str = config_get('route_map', 'match_ospf_area', @get_args)
return if str.nil?
str.empty? ? default_match_ospf_area : str.split
end | ruby | def match_ospf_area
str = config_get('route_map', 'match_ospf_area', @get_args)
return if str.nil?
str.empty? ? default_match_ospf_area : str.split
end | [
"def",
"match_ospf_area",
"str",
"=",
"config_get",
"(",
"'route_map'",
",",
"'match_ospf_area'",
",",
"@get_args",
")",
"return",
"if",
"str",
".",
"nil?",
"str",
".",
"empty?",
"?",
"default_match_ospf_area",
":",
"str",
".",
"split",
"end"
] | match ospf-area 10 7 | [
"match",
"ospf",
"-",
"area",
"10",
"7"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1107-L1111 |
20,333 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.match_mac_list | def match_mac_list
str = config_get('route_map', 'match_mac_list', @get_args)
return if str.nil?
str.empty? ? default_match_mac_list : str.split
end | ruby | def match_mac_list
str = config_get('route_map', 'match_mac_list', @get_args)
return if str.nil?
str.empty? ? default_match_mac_list : str.split
end | [
"def",
"match_mac_list",
"str",
"=",
"config_get",
"(",
"'route_map'",
",",
"'match_mac_list'",
",",
"@get_args",
")",
"return",
"if",
"str",
".",
"nil?",
"str",
".",
"empty?",
"?",
"default_match_mac_list",
":",
"str",
".",
"split",
"end"
] | match mac-list m1 m2 | [
"match",
"mac",
"-",
"list",
"m1",
"m2"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1139-L1143 |
20,334 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.match_evpn_route_type_get | def match_evpn_route_type_get
arr = config_get('route_map', 'match_evpn_route_type', @get_args)
return nil if arr.nil?
hash = {}
hash[:type1] = false
hash[:type3] = false
hash[:type4] = false
hash[:type5] = false
hash[:type6] = false
hash[:type_all] = false
ha... | ruby | def match_evpn_route_type_get
arr = config_get('route_map', 'match_evpn_route_type', @get_args)
return nil if arr.nil?
hash = {}
hash[:type1] = false
hash[:type3] = false
hash[:type4] = false
hash[:type5] = false
hash[:type6] = false
hash[:type_all] = false
ha... | [
"def",
"match_evpn_route_type_get",
"arr",
"=",
"config_get",
"(",
"'route_map'",
",",
"'match_evpn_route_type'",
",",
"@get_args",
")",
"return",
"nil",
"if",
"arr",
".",
"nil?",
"hash",
"=",
"{",
"}",
"hash",
"[",
":type1",
"]",
"=",
"false",
"hash",
"[",
... | match evpn route-type 1
match evpn route-type 2 all
match evpn route-type 2 mac-ip
match evpn route-type 2 mac-only
match evpn route-type 3 etc. | [
"match",
"evpn",
"route",
"-",
"type",
"1",
"match",
"evpn",
"route",
"-",
"type",
"2",
"all",
"match",
"evpn",
"route",
"-",
"type",
"2",
"mac",
"-",
"ip",
"match",
"evpn",
"route",
"-",
"type",
"2",
"mac",
"-",
"only",
"match",
"evpn",
"route",
"... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1214-L1238 |
20,335 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_metric_get | def set_metric_get
hash = {}
hash[:additive] = false
hash[:bandwidth] = false
hash[:delay] = false
hash[:reliability] = false
hash[:effective_bandwidth] = false
hash[:mtu] = false
str = config_get('route_map', 'set_metric', @get_args)
return hash if str.nil?
a... | ruby | def set_metric_get
hash = {}
hash[:additive] = false
hash[:bandwidth] = false
hash[:delay] = false
hash[:reliability] = false
hash[:effective_bandwidth] = false
hash[:mtu] = false
str = config_get('route_map', 'set_metric', @get_args)
return hash if str.nil?
a... | [
"def",
"set_metric_get",
"hash",
"=",
"{",
"}",
"hash",
"[",
":additive",
"]",
"=",
"false",
"hash",
"[",
":bandwidth",
"]",
"=",
"false",
"hash",
"[",
":delay",
"]",
"=",
"false",
"hash",
"[",
":reliability",
"]",
"=",
"false",
"hash",
"[",
":effectiv... | set metric 44 55 66 77 88
set metric +33 | [
"set",
"metric",
"44",
"55",
"66",
"77",
"88",
"set",
"metric",
"+",
"33"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1556-L1575 |
20,336 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_dampening_get | def set_dampening_get
hash = {}
hash[:half_life] = false
hash[:reuse] = false
hash[:suppress] = false
hash[:max] = false
str = config_get('route_map', 'set_dampening', @get_args)
return hash if str.nil?
arr = str.split
hash[:half_life] = arr[0].to_i
hash[:reus... | ruby | def set_dampening_get
hash = {}
hash[:half_life] = false
hash[:reuse] = false
hash[:suppress] = false
hash[:max] = false
str = config_get('route_map', 'set_dampening', @get_args)
return hash if str.nil?
arr = str.split
hash[:half_life] = arr[0].to_i
hash[:reus... | [
"def",
"set_dampening_get",
"hash",
"=",
"{",
"}",
"hash",
"[",
":half_life",
"]",
"=",
"false",
"hash",
"[",
":reuse",
"]",
"=",
"false",
"hash",
"[",
":suppress",
"]",
"=",
"false",
"hash",
"[",
":max",
"]",
"=",
"false",
"str",
"=",
"config_get",
... | set dampening 6 22 44 55 | [
"set",
"dampening",
"6",
"22",
"44",
"55"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1648-L1662 |
20,337 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_as_path_prepend | def set_as_path_prepend
arr = []
match = config_get('route_map', 'set_as_path_prepend', @get_args)
if arr
match.each do |line|
next if line.include?('last-as')
arr = line.strip.split
end
end
arr
end | ruby | def set_as_path_prepend
arr = []
match = config_get('route_map', 'set_as_path_prepend', @get_args)
if arr
match.each do |line|
next if line.include?('last-as')
arr = line.strip.split
end
end
arr
end | [
"def",
"set_as_path_prepend",
"arr",
"=",
"[",
"]",
"match",
"=",
"config_get",
"(",
"'route_map'",
",",
"'set_as_path_prepend'",
",",
"@get_args",
")",
"if",
"arr",
"match",
".",
"each",
"do",
"|",
"line",
"|",
"next",
"if",
"line",
".",
"include?",
"(",
... | set as-path prepend 55.77 44 33.5
set as-path prepend last-as 1 | [
"set",
"as",
"-",
"path",
"prepend",
"55",
".",
"77",
"44",
"33",
".",
"5",
"set",
"as",
"-",
"path",
"prepend",
"last",
"-",
"as",
"1"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1794-L1804 |
20,338 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_ipv4_default_next_hop | def set_ipv4_default_next_hop
str = config_get('route_map', 'set_ipv4_default_next_hop', @get_args)
return if str.nil?
if str.empty?
val = default_set_ipv4_default_next_hop
else
val = str.split
val.delete('load-share')
end
val
end | ruby | def set_ipv4_default_next_hop
str = config_get('route_map', 'set_ipv4_default_next_hop', @get_args)
return if str.nil?
if str.empty?
val = default_set_ipv4_default_next_hop
else
val = str.split
val.delete('load-share')
end
val
end | [
"def",
"set_ipv4_default_next_hop",
"str",
"=",
"config_get",
"(",
"'route_map'",
",",
"'set_ipv4_default_next_hop'",
",",
"@get_args",
")",
"return",
"if",
"str",
".",
"nil?",
"if",
"str",
".",
"empty?",
"val",
"=",
"default_set_ipv4_default_next_hop",
"else",
"val... | set ip default next-hop 1.1.1.1 2.2.2.2 3.3.3.3 | [
"set",
"ip",
"default",
"next",
"-",
"hop",
"1",
".",
"1",
".",
"1",
".",
"1",
"2",
".",
"2",
".",
"2",
".",
"2",
"3",
".",
"3",
".",
"3",
".",
"3"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1870-L1880 |
20,339 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_ipv4_next_hop | def set_ipv4_next_hop
arr = config_get('route_map', 'set_ipv4_next_hop', @get_args)
val = default_set_ipv4_next_hop
arr.each do |str|
next if str.empty?
next if str.include?('peer-address')
next if str.include?('unchanged')
next if str.include?('redist-unchanged')
... | ruby | def set_ipv4_next_hop
arr = config_get('route_map', 'set_ipv4_next_hop', @get_args)
val = default_set_ipv4_next_hop
arr.each do |str|
next if str.empty?
next if str.include?('peer-address')
next if str.include?('unchanged')
next if str.include?('redist-unchanged')
... | [
"def",
"set_ipv4_next_hop",
"arr",
"=",
"config_get",
"(",
"'route_map'",
",",
"'set_ipv4_next_hop'",
",",
"@get_args",
")",
"val",
"=",
"default_set_ipv4_next_hop",
"arr",
".",
"each",
"do",
"|",
"str",
"|",
"next",
"if",
"str",
".",
"empty?",
"next",
"if",
... | set ip next-hop 1.1.1.1 2.2.2.2 3.3.3.3 | [
"set",
"ip",
"next",
"-",
"hop",
"1",
".",
"1",
".",
"1",
".",
"1",
"2",
".",
"2",
".",
"2",
".",
"2",
"3",
".",
"3",
".",
"3",
".",
"3"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1922-L1934 |
20,340 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_ipv4_next_hop_load_share | def set_ipv4_next_hop_load_share
arr = config_get('route_map', 'set_ipv4_next_hop', @get_args)
val = default_set_ipv4_next_hop_load_share
arr.each do |str|
next if str.empty?
return true if str.include?('load-share')
end
val
end | ruby | def set_ipv4_next_hop_load_share
arr = config_get('route_map', 'set_ipv4_next_hop', @get_args)
val = default_set_ipv4_next_hop_load_share
arr.each do |str|
next if str.empty?
return true if str.include?('load-share')
end
val
end | [
"def",
"set_ipv4_next_hop_load_share",
"arr",
"=",
"config_get",
"(",
"'route_map'",
",",
"'set_ipv4_next_hop'",
",",
"@get_args",
")",
"val",
"=",
"default_set_ipv4_next_hop_load_share",
"arr",
".",
"each",
"do",
"|",
"str",
"|",
"next",
"if",
"str",
".",
"empty?... | set ip next-hop 1.1.1.1 2.2.2.2 3.3.3.3 load-share
set ip next-hop load-share | [
"set",
"ip",
"next",
"-",
"hop",
"1",
".",
"1",
".",
"1",
".",
"1",
"2",
".",
"2",
".",
"2",
".",
"2",
"3",
".",
"3",
".",
"3",
".",
"3",
"load",
"-",
"share",
"set",
"ip",
"next",
"-",
"hop",
"load",
"-",
"share"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L1963-L1971 |
20,341 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_ipv6_default_next_hop | def set_ipv6_default_next_hop
str = config_get('route_map', 'set_ipv6_default_next_hop', @get_args)
return if str.nil?
if str.empty?
val = default_set_ipv6_default_next_hop
else
val = str.split
val.delete('load-share')
end
val
end | ruby | def set_ipv6_default_next_hop
str = config_get('route_map', 'set_ipv6_default_next_hop', @get_args)
return if str.nil?
if str.empty?
val = default_set_ipv6_default_next_hop
else
val = str.split
val.delete('load-share')
end
val
end | [
"def",
"set_ipv6_default_next_hop",
"str",
"=",
"config_get",
"(",
"'route_map'",
",",
"'set_ipv6_default_next_hop'",
",",
"@get_args",
")",
"return",
"if",
"str",
".",
"nil?",
"if",
"str",
".",
"empty?",
"val",
"=",
"default_set_ipv6_default_next_hop",
"else",
"val... | set ipv6 default next-hop 1.1.1.1 2.2.2.2 3.3.3.3 | [
"set",
"ipv6",
"default",
"next",
"-",
"hop",
"1",
".",
"1",
".",
"1",
".",
"1",
"2",
".",
"2",
".",
"2",
".",
"2",
"3",
".",
"3",
".",
"3",
".",
"3"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L2057-L2067 |
20,342 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_ipv6_next_hop | def set_ipv6_next_hop
arr = config_get('route_map', 'set_ipv6_next_hop', @get_args)
val = default_set_ipv6_next_hop
arr.each do |str|
next if str.empty?
next if str.include?('peer-address')
next if str.include?('unchanged')
next if str.include?('redist-unchanged')
... | ruby | def set_ipv6_next_hop
arr = config_get('route_map', 'set_ipv6_next_hop', @get_args)
val = default_set_ipv6_next_hop
arr.each do |str|
next if str.empty?
next if str.include?('peer-address')
next if str.include?('unchanged')
next if str.include?('redist-unchanged')
... | [
"def",
"set_ipv6_next_hop",
"arr",
"=",
"config_get",
"(",
"'route_map'",
",",
"'set_ipv6_next_hop'",
",",
"@get_args",
")",
"val",
"=",
"default_set_ipv6_next_hop",
"arr",
".",
"each",
"do",
"|",
"str",
"|",
"next",
"if",
"str",
".",
"empty?",
"next",
"if",
... | set ipv6 next-hop 1.1.1.1 2.2.2.2 3.3.3.3 | [
"set",
"ipv6",
"next",
"-",
"hop",
"1",
".",
"1",
".",
"1",
".",
"1",
"2",
".",
"2",
".",
"2",
".",
"2",
"3",
".",
"3",
".",
"3",
".",
"3"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L2109-L2121 |
20,343 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_ipv6_next_hop_load_share | def set_ipv6_next_hop_load_share
arr = config_get('route_map', 'set_ipv6_next_hop', @get_args)
val = default_set_ipv6_next_hop_load_share
arr.each do |str|
next if str.empty?
return true if str.include?('load-share')
end
val
end | ruby | def set_ipv6_next_hop_load_share
arr = config_get('route_map', 'set_ipv6_next_hop', @get_args)
val = default_set_ipv6_next_hop_load_share
arr.each do |str|
next if str.empty?
return true if str.include?('load-share')
end
val
end | [
"def",
"set_ipv6_next_hop_load_share",
"arr",
"=",
"config_get",
"(",
"'route_map'",
",",
"'set_ipv6_next_hop'",
",",
"@get_args",
")",
"val",
"=",
"default_set_ipv6_next_hop_load_share",
"arr",
".",
"each",
"do",
"|",
"str",
"|",
"next",
"if",
"str",
".",
"empty?... | set ipv6 default next-hop 1.1.1.1 2.2.2.2 3.3.3.3 load-share
set ipv6 default next-hop load-share | [
"set",
"ipv6",
"default",
"next",
"-",
"hop",
"1",
".",
"1",
".",
"1",
".",
"1",
"2",
".",
"2",
".",
"2",
".",
"2",
"3",
".",
"3",
".",
"3",
".",
"3",
"load",
"-",
"share",
"set",
"ipv6",
"default",
"next",
"-",
"hop",
"load",
"-",
"share"
... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L2150-L2158 |
20,344 | cisco/cisco-network-node-utils | lib/cisco_node_utils/route_map.rb | Cisco.RouteMap.set_extcommunity_cost_set | def set_extcommunity_cost_set(igp, pre)
str = ''
# reset first
if set_extcommunity_cost_device
cpre = set_extcommunity_cost_pre_bestpath
cigp = set_extcommunity_cost_igp
cpre.each do |id, val|
str.concat('pre-bestpath ' + id.to_s + ' ' + val.to_s + ' ')
end
... | ruby | def set_extcommunity_cost_set(igp, pre)
str = ''
# reset first
if set_extcommunity_cost_device
cpre = set_extcommunity_cost_pre_bestpath
cigp = set_extcommunity_cost_igp
cpre.each do |id, val|
str.concat('pre-bestpath ' + id.to_s + ' ' + val.to_s + ' ')
end
... | [
"def",
"set_extcommunity_cost_set",
"(",
"igp",
",",
"pre",
")",
"str",
"=",
"''",
"# reset first",
"if",
"set_extcommunity_cost_device",
"cpre",
"=",
"set_extcommunity_cost_pre_bestpath",
"cigp",
"=",
"set_extcommunity_cost_igp",
"cpre",
".",
"each",
"do",
"|",
"id",... | set extcommunity cost igp 0 22 igp 3 23
set extcommunity cost pre-bestpath 1 222 pre-bestpath 2 54
set extcommunity cost pre-bestpath 1 222 pre-bestpath 2 54 igp 0 22 | [
"set",
"extcommunity",
"cost",
"igp",
"0",
"22",
"igp",
"3",
"23",
"set",
"extcommunity",
"cost",
"pre",
"-",
"bestpath",
"1",
"222",
"pre",
"-",
"bestpath",
"2",
"54",
"set",
"extcommunity",
"cost",
"pre",
"-",
"bestpath",
"1",
"222",
"pre",
"-",
"bes... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/route_map.rb#L2475-L2500 |
20,345 | cisco/cisco-network-node-utils | lib/cisco_node_utils/overlay_global.rb | Cisco.OverlayGlobal.anycast_gateway_mac | def anycast_gateway_mac
mac = config_get('overlay_global', 'anycast_gateway_mac')
mac.nil? || mac.empty? ? default_anycast_gateway_mac : mac.downcase
end | ruby | def anycast_gateway_mac
mac = config_get('overlay_global', 'anycast_gateway_mac')
mac.nil? || mac.empty? ? default_anycast_gateway_mac : mac.downcase
end | [
"def",
"anycast_gateway_mac",
"mac",
"=",
"config_get",
"(",
"'overlay_global'",
",",
"'anycast_gateway_mac'",
")",
"mac",
".",
"nil?",
"||",
"mac",
".",
"empty?",
"?",
"default_anycast_gateway_mac",
":",
"mac",
".",
"downcase",
"end"
] | anycast-gateway-mac | [
"anycast",
"-",
"gateway",
"-",
"mac"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/overlay_global.rb#L118-L121 |
20,346 | cisco/cisco-network-node-utils | lib/cisco_node_utils/tacacs_server.rb | Cisco.TacacsServer.encryption_key_set | def encryption_key_set(enctype, password)
password = Utils.add_quotes(password)
# if enctype is TACACS_SERVER_ENC_UNKNOWN, we will unset the key
if enctype == TACACS_SERVER_ENC_UNKNOWN
# if current encryption type is not TACACS_SERVER_ENC_UNKNOWN, we
# need to unset it. Otherwise the b... | ruby | def encryption_key_set(enctype, password)
password = Utils.add_quotes(password)
# if enctype is TACACS_SERVER_ENC_UNKNOWN, we will unset the key
if enctype == TACACS_SERVER_ENC_UNKNOWN
# if current encryption type is not TACACS_SERVER_ENC_UNKNOWN, we
# need to unset it. Otherwise the b... | [
"def",
"encryption_key_set",
"(",
"enctype",
",",
"password",
")",
"password",
"=",
"Utils",
".",
"add_quotes",
"(",
"password",
")",
"# if enctype is TACACS_SERVER_ENC_UNKNOWN, we will unset the key",
"if",
"enctype",
"==",
"TACACS_SERVER_ENC_UNKNOWN",
"# if current encrypti... | Set encryption type and password | [
"Set",
"encryption",
"type",
"and",
"password"
] | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/tacacs_server.rb#L155-L171 |
20,347 | cisco/cisco-network-node-utils | lib/cisco_node_utils/itd_service.rb | Cisco.ItdService.ingress_interface= | def ingress_interface=(list)
ingress_interface_cleanup
@set_args[:state] = ''
list.each do |intf, next_hop|
@set_args[:interface] = intf
@set_args[:next] = ''
@set_args[:nhop] = ''
unless next_hop == '' || next_hop == 'default'
@set_args[:next] = 'next-hop'
... | ruby | def ingress_interface=(list)
ingress_interface_cleanup
@set_args[:state] = ''
list.each do |intf, next_hop|
@set_args[:interface] = intf
@set_args[:next] = ''
@set_args[:nhop] = ''
unless next_hop == '' || next_hop == 'default'
@set_args[:next] = 'next-hop'
... | [
"def",
"ingress_interface",
"=",
"(",
"list",
")",
"ingress_interface_cleanup",
"@set_args",
"[",
":state",
"]",
"=",
"''",
"list",
".",
"each",
"do",
"|",
"intf",
",",
"next_hop",
"|",
"@set_args",
"[",
":interface",
"]",
"=",
"intf",
"@set_args",
"[",
":... | only one next-hop is allowed per interface but
due to nxos issues, it allows more than one;
so the workaround is to clean up the current ingress
intf and configure all of them again | [
"only",
"one",
"next",
"-",
"hop",
"is",
"allowed",
"per",
"interface",
"but",
"due",
"to",
"nxos",
"issues",
"it",
"allows",
"more",
"than",
"one",
";",
"so",
"the",
"workaround",
"is",
"to",
"clean",
"up",
"the",
"current",
"ingress",
"intf",
"and",
... | a617a9ef9d6bd18f35f2e2f2591033e1ddd46145 | https://github.com/cisco/cisco-network-node-utils/blob/a617a9ef9d6bd18f35f2e2f2591033e1ddd46145/lib/cisco_node_utils/itd_service.rb#L199-L213 |
20,348 | emancu/toml-rb | lib/toml-rb/keygroup.rb | TomlRB.Keygroup.ensure_key_not_defined | def ensure_key_not_defined(visited_keys)
fail ValueOverwriteError.new(full_key) if visited_keys.include?(full_key)
visited_keys << full_key
end | ruby | def ensure_key_not_defined(visited_keys)
fail ValueOverwriteError.new(full_key) if visited_keys.include?(full_key)
visited_keys << full_key
end | [
"def",
"ensure_key_not_defined",
"(",
"visited_keys",
")",
"fail",
"ValueOverwriteError",
".",
"new",
"(",
"full_key",
")",
"if",
"visited_keys",
".",
"include?",
"(",
"full_key",
")",
"visited_keys",
"<<",
"full_key",
"end"
] | Fail if the key was already defined with a ValueOverwriteError | [
"Fail",
"if",
"the",
"key",
"was",
"already",
"defined",
"with",
"a",
"ValueOverwriteError"
] | 1b649547ed1cc1855b11eb7880c1ad03b8ab52e9 | https://github.com/emancu/toml-rb/blob/1b649547ed1cc1855b11eb7880c1ad03b8ab52e9/lib/toml-rb/keygroup.rb#L21-L24 |
20,349 | samnissen/watir-screenshot-stitch | lib/watir-screenshot-stitch.rb | Watir.Screenshot.save_stitch | def save_stitch(path, opts = {})
return @browser.screenshot.save(path) if base64_capable?
@options = opts
@path = path
calculate_dimensions
return self.save(@path) if (one_shot? || bug_shot?)
build_canvas
gather_slices
stitch_together
@combined_screenshot.write @... | ruby | def save_stitch(path, opts = {})
return @browser.screenshot.save(path) if base64_capable?
@options = opts
@path = path
calculate_dimensions
return self.save(@path) if (one_shot? || bug_shot?)
build_canvas
gather_slices
stitch_together
@combined_screenshot.write @... | [
"def",
"save_stitch",
"(",
"path",
",",
"opts",
"=",
"{",
"}",
")",
"return",
"@browser",
".",
"screenshot",
".",
"save",
"(",
"path",
")",
"if",
"base64_capable?",
"@options",
"=",
"opts",
"@path",
"=",
"path",
"calculate_dimensions",
"return",
"self",
".... | Represents stitched together screenshot and writes to file.
@example
opts = {:page_height_limit => 5000}
browser.screenshot.save_stitch("path/abc.png", browser, opts)
@param [String] path
@deprecated
@param [Watir::Browser] browser
@param [Hash] opts | [
"Represents",
"stitched",
"together",
"screenshot",
"and",
"writes",
"to",
"file",
"."
] | 4cb9ac14ec974751b185391f6832bfb7e205f531 | https://github.com/samnissen/watir-screenshot-stitch/blob/4cb9ac14ec974751b185391f6832bfb7e205f531/lib/watir-screenshot-stitch.rb#L57-L70 |
20,350 | samnissen/watir-screenshot-stitch | lib/watir-screenshot-stitch.rb | Watir.Screenshot.base64_canvas | def base64_canvas
return self.base64 if base64_capable?
output = nil
return self.base64 if one_shot? || bug_shot?
@browser.execute_script html2canvas_payload
@browser.execute_script h2c_activator
@browser.wait_until(timeout: MAXIMUM_SCREENSHOT_GENERATION_WAIT_TIME) {
outpu... | ruby | def base64_canvas
return self.base64 if base64_capable?
output = nil
return self.base64 if one_shot? || bug_shot?
@browser.execute_script html2canvas_payload
@browser.execute_script h2c_activator
@browser.wait_until(timeout: MAXIMUM_SCREENSHOT_GENERATION_WAIT_TIME) {
outpu... | [
"def",
"base64_canvas",
"return",
"self",
".",
"base64",
"if",
"base64_capable?",
"output",
"=",
"nil",
"return",
"self",
".",
"base64",
"if",
"one_shot?",
"||",
"bug_shot?",
"@browser",
".",
"execute_script",
"html2canvas_payload",
"@browser",
".",
"execute_script"... | Employs html2canvas to produce a Base64 encoded string
of a full page screenshot.
@example
browser.screenshot.base64_canvas(browser)
#=> '7HWJ43tZDscPleeUuPW6HhN3x+z7vU/lufmH0qNTtTum94IBWMT46evImci1vnFGT'
@deprecated
@param [Watir::Browser] browser
@return [String] | [
"Employs",
"html2canvas",
"to",
"produce",
"a",
"Base64",
"encoded",
"string",
"of",
"a",
"full",
"page",
"screenshot",
"."
] | 4cb9ac14ec974751b185391f6832bfb7e205f531 | https://github.com/samnissen/watir-screenshot-stitch/blob/4cb9ac14ec974751b185391f6832bfb7e205f531/lib/watir-screenshot-stitch.rb#L86-L102 |
20,351 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.setup_zk | def setup_zk
@zk = ZK.new(@zkservers) if @zkservers
@zk.register(redis_nodes_path) { |event| handle_zk_event(event) }
if @safe_mode
@zk.on_expired_session { purge_clients }
end
@zk.on_connected { @zk.stat(redis_nodes_path, :watch => true) }
@zk.stat(redis_nodes_path, :watch =... | ruby | def setup_zk
@zk = ZK.new(@zkservers) if @zkservers
@zk.register(redis_nodes_path) { |event| handle_zk_event(event) }
if @safe_mode
@zk.on_expired_session { purge_clients }
end
@zk.on_connected { @zk.stat(redis_nodes_path, :watch => true) }
@zk.stat(redis_nodes_path, :watch =... | [
"def",
"setup_zk",
"@zk",
"=",
"ZK",
".",
"new",
"(",
"@zkservers",
")",
"if",
"@zkservers",
"@zk",
".",
"register",
"(",
"redis_nodes_path",
")",
"{",
"|",
"event",
"|",
"handle_zk_event",
"(",
"event",
")",
"}",
"if",
"@safe_mode",
"@zk",
".",
"on_expi... | Sets up the underlying ZooKeeper connection. | [
"Sets",
"up",
"the",
"underlying",
"ZooKeeper",
"connection",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L188-L197 |
20,352 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.handle_zk_event | def handle_zk_event(event)
update_znode_timestamp
if event.node_created? || event.node_changed?
build_clients
elsif event.node_deleted?
purge_clients
@zk.stat(redis_nodes_path, :watch => true)
else
logger.error("Unknown ZK node event: #{event.inspect}")
end
... | ruby | def handle_zk_event(event)
update_znode_timestamp
if event.node_created? || event.node_changed?
build_clients
elsif event.node_deleted?
purge_clients
@zk.stat(redis_nodes_path, :watch => true)
else
logger.error("Unknown ZK node event: #{event.inspect}")
end
... | [
"def",
"handle_zk_event",
"(",
"event",
")",
"update_znode_timestamp",
"if",
"event",
".",
"node_created?",
"||",
"event",
".",
"node_changed?",
"build_clients",
"elsif",
"event",
".",
"node_deleted?",
"purge_clients",
"@zk",
".",
"stat",
"(",
"redis_nodes_path",
",... | Handles a ZK event.
@param [ZK::Event] event the ZK event to handle | [
"Handles",
"a",
"ZK",
"event",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L202-L214 |
20,353 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.dispatch | def dispatch(method, *args, &block)
if @safe_mode && !recently_heard_from_node_manager?
build_clients
end
verify_supported!(method)
tries = 0
begin
client_for(method).send(method, *args, &block)
rescue *CONNECTIVITY_ERRORS => ex
logger.error("Error while hand... | ruby | def dispatch(method, *args, &block)
if @safe_mode && !recently_heard_from_node_manager?
build_clients
end
verify_supported!(method)
tries = 0
begin
client_for(method).send(method, *args, &block)
rescue *CONNECTIVITY_ERRORS => ex
logger.error("Error while hand... | [
"def",
"dispatch",
"(",
"method",
",",
"*",
"args",
",",
"&",
"block",
")",
"if",
"@safe_mode",
"&&",
"!",
"recently_heard_from_node_manager?",
"build_clients",
"end",
"verify_supported!",
"(",
"method",
")",
"tries",
"=",
"0",
"begin",
"client_for",
"(",
"met... | Dispatches a redis operation to a master or slave.
@param [Symbol] method the method to dispatch
@param [Array] args the arguments to pass to the method
@param [Proc] block an optional block to pass to the method
@return [Object] the result of dispatching the command | [
"Dispatches",
"a",
"redis",
"operation",
"to",
"a",
"master",
"or",
"slave",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L230-L254 |
20,354 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.fetch_nodes | def fetch_nodes
data = @zk.get(redis_nodes_path, :watch => true).first
nodes = symbolize_keys(decode(data))
logger.debug("Fetched nodes: #{nodes.inspect}")
nodes
rescue Zookeeper::Exceptions::InheritedConnectionError, ZK::Exceptions::InterruptedSession => ex
logger.debug { "Caught #{e... | ruby | def fetch_nodes
data = @zk.get(redis_nodes_path, :watch => true).first
nodes = symbolize_keys(decode(data))
logger.debug("Fetched nodes: #{nodes.inspect}")
nodes
rescue Zookeeper::Exceptions::InheritedConnectionError, ZK::Exceptions::InterruptedSession => ex
logger.debug { "Caught #{e... | [
"def",
"fetch_nodes",
"data",
"=",
"@zk",
".",
"get",
"(",
"redis_nodes_path",
",",
":watch",
"=>",
"true",
")",
".",
"first",
"nodes",
"=",
"symbolize_keys",
"(",
"decode",
"(",
"data",
")",
")",
"logger",
".",
"debug",
"(",
"\"Fetched nodes: #{nodes.inspec... | Fetches the known redis nodes from ZooKeeper.
@return [Hash] the known master/slave redis servers | [
"Fetches",
"the",
"known",
"redis",
"nodes",
"from",
"ZooKeeper",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L322-L336 |
20,355 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.new_clients_for | def new_clients_for(*nodes)
nodes.map do |node|
host, port = node.split(':')
opts = {:host => host, :port => port}
opts.update(:db => @db) if @db
opts.update(:password => @password) if @password
client = Redis.new(@redis_client_options.merge(opts))
if @namespace
... | ruby | def new_clients_for(*nodes)
nodes.map do |node|
host, port = node.split(':')
opts = {:host => host, :port => port}
opts.update(:db => @db) if @db
opts.update(:password => @password) if @password
client = Redis.new(@redis_client_options.merge(opts))
if @namespace
... | [
"def",
"new_clients_for",
"(",
"*",
"nodes",
")",
"nodes",
".",
"map",
"do",
"|",
"node",
"|",
"host",
",",
"port",
"=",
"node",
".",
"split",
"(",
"':'",
")",
"opts",
"=",
"{",
":host",
"=>",
"host",
",",
":port",
"=>",
"port",
"}",
"opts",
".",... | Builds new Redis clients for the specified nodes.
@param [Array<String>] nodes the array of redis host:port pairs
@return [Array<Redis>] the array of corresponding Redis clients | [
"Builds",
"new",
"Redis",
"clients",
"for",
"the",
"specified",
"nodes",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L342-L355 |
20,356 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.verify_role! | def verify_role!(node, role)
current_role = node.info['role']
if current_role.to_sym != role
raise InvalidNodeRoleError.new(address_for(node), role, current_role)
end
role
end | ruby | def verify_role!(node, role)
current_role = node.info['role']
if current_role.to_sym != role
raise InvalidNodeRoleError.new(address_for(node), role, current_role)
end
role
end | [
"def",
"verify_role!",
"(",
"node",
",",
"role",
")",
"current_role",
"=",
"node",
".",
"info",
"[",
"'role'",
"]",
"if",
"current_role",
".",
"to_sym",
"!=",
"role",
"raise",
"InvalidNodeRoleError",
".",
"new",
"(",
"address_for",
"(",
"node",
")",
",",
... | Verifies the actual role for a redis node.
@param [Redis] node the redis node to check
@param [Symbol] role the role to verify
@return [Symbol] the verified role
@raise [InvalidNodeRoleError] if the role is invalid | [
"Verifies",
"the",
"actual",
"role",
"for",
"a",
"redis",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L374-L380 |
20,357 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.nodes_changed? | def nodes_changed?(new_nodes)
return true if address_for(@master) != new_nodes[:master]
return true if different?(addresses_for(@slaves), new_nodes[:slaves])
false
end | ruby | def nodes_changed?(new_nodes)
return true if address_for(@master) != new_nodes[:master]
return true if different?(addresses_for(@slaves), new_nodes[:slaves])
false
end | [
"def",
"nodes_changed?",
"(",
"new_nodes",
")",
"return",
"true",
"if",
"address_for",
"(",
"@master",
")",
"!=",
"new_nodes",
"[",
":master",
"]",
"return",
"true",
"if",
"different?",
"(",
"addresses_for",
"(",
"@slaves",
")",
",",
"new_nodes",
"[",
":slav... | Determines if the currently known redis servers is different
from the nodes returned by ZooKeeper.
@param [Array<String>] new_nodes the new redis nodes
@return [Boolean] true if nodes are different, false otherwise | [
"Determines",
"if",
"the",
"currently",
"known",
"redis",
"servers",
"is",
"different",
"from",
"the",
"nodes",
"returned",
"by",
"ZooKeeper",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L413-L417 |
20,358 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.client_for | def client_for(method)
stack = Thread.current[@current_client_key] ||= []
client = if stack.last
stack.last
elsif @master_only
master
elsif REDIS_READ_OPS.include?(method)
slave
else
master
end
stack << client
client
end | ruby | def client_for(method)
stack = Thread.current[@current_client_key] ||= []
client = if stack.last
stack.last
elsif @master_only
master
elsif REDIS_READ_OPS.include?(method)
slave
else
master
end
stack << client
client
end | [
"def",
"client_for",
"(",
"method",
")",
"stack",
"=",
"Thread",
".",
"current",
"[",
"@current_client_key",
"]",
"||=",
"[",
"]",
"client",
"=",
"if",
"stack",
".",
"last",
"stack",
".",
"last",
"elsif",
"@master_only",
"master",
"elsif",
"REDIS_READ_OPS",
... | Acquires a client to use for the specified operation.
@param [Symbol] method the method for which to retrieve a client
@return [Redis] a redis client to use
@note
This method stores a stack of clients used to handle the case
where the same RedisFailover::Client instance is referenced by
nested blocks (e.g.... | [
"Acquires",
"a",
"client",
"to",
"use",
"for",
"the",
"specified",
"operation",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L464-L478 |
20,359 | ryanlecompte/redis_failover | lib/redis_failover/client.rb | RedisFailover.Client.parse_options | def parse_options(options)
@zk, @zkservers = options.values_at(:zk, :zkservers)
if [@zk, @zkservers].all? || [@zk, @zkservers].none?
raise ArgumentError, 'must specify :zk or :zkservers'
end
@root_znode = options.fetch(:znode_path, Util::DEFAULT_ROOT_ZNODE_PATH)
@namespace = optio... | ruby | def parse_options(options)
@zk, @zkservers = options.values_at(:zk, :zkservers)
if [@zk, @zkservers].all? || [@zk, @zkservers].none?
raise ArgumentError, 'must specify :zk or :zkservers'
end
@root_znode = options.fetch(:znode_path, Util::DEFAULT_ROOT_ZNODE_PATH)
@namespace = optio... | [
"def",
"parse_options",
"(",
"options",
")",
"@zk",
",",
"@zkservers",
"=",
"options",
".",
"values_at",
"(",
":zk",
",",
":zkservers",
")",
"if",
"[",
"@zk",
",",
"@zkservers",
"]",
".",
"all?",
"||",
"[",
"@zk",
",",
"@zkservers",
"]",
".",
"none?",
... | Parses the configuration operations.
@param [Hash] options the configuration options | [
"Parses",
"the",
"configuration",
"operations",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/client.rb#L491-L510 |
20,360 | ryanlecompte/redis_failover | lib/redis_failover/node.rb | RedisFailover.Node.make_slave! | def make_slave!(node)
perform_operation do |redis|
unless slave_of?(node)
redis.slaveof(node.host, node.port)
logger.info("#{self} is now a slave of #{node}")
wakeup
end
end
end | ruby | def make_slave!(node)
perform_operation do |redis|
unless slave_of?(node)
redis.slaveof(node.host, node.port)
logger.info("#{self} is now a slave of #{node}")
wakeup
end
end
end | [
"def",
"make_slave!",
"(",
"node",
")",
"perform_operation",
"do",
"|",
"redis",
"|",
"unless",
"slave_of?",
"(",
"node",
")",
"redis",
".",
"slaveof",
"(",
"node",
".",
"host",
",",
"node",
".",
"port",
")",
"logger",
".",
"info",
"(",
"\"#{self} is now... | Makes this node a slave of the given node.
@param [Node] node the node of which to become a slave | [
"Makes",
"this",
"node",
"a",
"slave",
"of",
"the",
"given",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node.rb#L80-L88 |
20,361 | ryanlecompte/redis_failover | lib/redis_failover/node.rb | RedisFailover.Node.perform_operation | def perform_operation
redis = nil
Timeout.timeout(MAX_OP_WAIT_TIME) do
redis = new_client
yield redis
end
rescue Exception => ex
raise NodeUnavailableError, "#{ex.class}: #{ex.message}", ex.backtrace
ensure
if redis
begin
redis.client.disconnect
... | ruby | def perform_operation
redis = nil
Timeout.timeout(MAX_OP_WAIT_TIME) do
redis = new_client
yield redis
end
rescue Exception => ex
raise NodeUnavailableError, "#{ex.class}: #{ex.message}", ex.backtrace
ensure
if redis
begin
redis.client.disconnect
... | [
"def",
"perform_operation",
"redis",
"=",
"nil",
"Timeout",
".",
"timeout",
"(",
"MAX_OP_WAIT_TIME",
")",
"do",
"redis",
"=",
"new_client",
"yield",
"redis",
"end",
"rescue",
"Exception",
"=>",
"ex",
"raise",
"NodeUnavailableError",
",",
"\"#{ex.class}: #{ex.message... | Safely performs a redis operation within a given timeout window.
@yield [Redis] the redis client to use for the operation
@raise [NodeUnavailableError] if node is currently unreachable | [
"Safely",
"performs",
"a",
"redis",
"operation",
"within",
"a",
"given",
"timeout",
"window",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node.rb#L172-L188 |
20,362 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.setup_zk | def setup_zk
unless @zk
@zk = ZK.new("#{@options[:zkservers]}#{@options[:chroot] || ''}")
@zk.register(manual_failover_path) do |event|
handle_manual_failover_update(event)
end
@zk.on_connected { @zk.stat(manual_failover_path, :watch => true) }
end
create_pat... | ruby | def setup_zk
unless @zk
@zk = ZK.new("#{@options[:zkservers]}#{@options[:chroot] || ''}")
@zk.register(manual_failover_path) do |event|
handle_manual_failover_update(event)
end
@zk.on_connected { @zk.stat(manual_failover_path, :watch => true) }
end
create_pat... | [
"def",
"setup_zk",
"unless",
"@zk",
"@zk",
"=",
"ZK",
".",
"new",
"(",
"\"#{@options[:zkservers]}#{@options[:chroot] || ''}\"",
")",
"@zk",
".",
"register",
"(",
"manual_failover_path",
")",
"do",
"|",
"event",
"|",
"handle_manual_failover_update",
"(",
"event",
")"... | Configures the ZooKeeper client. | [
"Configures",
"the",
"ZooKeeper",
"client",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L110-L122 |
20,363 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.handle_unavailable | def handle_unavailable(node, snapshots)
# no-op if we already know about this node
return if @unavailable.include?(node)
logger.info("Handling unavailable node: #{node}")
@unavailable << node
# find a new master if this node was a master
if node == @master
logger.info("Demot... | ruby | def handle_unavailable(node, snapshots)
# no-op if we already know about this node
return if @unavailable.include?(node)
logger.info("Handling unavailable node: #{node}")
@unavailable << node
# find a new master if this node was a master
if node == @master
logger.info("Demot... | [
"def",
"handle_unavailable",
"(",
"node",
",",
"snapshots",
")",
"# no-op if we already know about this node",
"return",
"if",
"@unavailable",
".",
"include?",
"(",
"node",
")",
"logger",
".",
"info",
"(",
"\"Handling unavailable node: #{node}\"",
")",
"@unavailable",
"... | Handles an unavailable node.
@param [Node] node the unavailable node
@param [Hash<Node, NodeSnapshot>] snapshots the current set of snapshots | [
"Handles",
"an",
"unavailable",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L128-L141 |
20,364 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.handle_available | def handle_available(node, snapshots)
reconcile(node)
# no-op if we already know about this node
return if @master == node || (@master && @slaves.include?(node))
logger.info("Handling available node: #{node}")
if @master
# master already exists, make a slave
node.make_sla... | ruby | def handle_available(node, snapshots)
reconcile(node)
# no-op if we already know about this node
return if @master == node || (@master && @slaves.include?(node))
logger.info("Handling available node: #{node}")
if @master
# master already exists, make a slave
node.make_sla... | [
"def",
"handle_available",
"(",
"node",
",",
"snapshots",
")",
"reconcile",
"(",
"node",
")",
"# no-op if we already know about this node",
"return",
"if",
"@master",
"==",
"node",
"||",
"(",
"@master",
"&&",
"@slaves",
".",
"include?",
"(",
"node",
")",
")",
... | Handles an available node.
@param [Node] node the available node
@param [Hash<Node, NodeSnapshot>] snapshots the current set of snapshots | [
"Handles",
"an",
"available",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L147-L164 |
20,365 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.handle_syncing | def handle_syncing(node, snapshots)
reconcile(node)
if node.syncing_with_master? && node.prohibits_stale_reads?
logger.info("Node #{node} not ready yet, still syncing with master.")
force_unavailable_slave(node)
else
# otherwise, we can use this node
handle_available(n... | ruby | def handle_syncing(node, snapshots)
reconcile(node)
if node.syncing_with_master? && node.prohibits_stale_reads?
logger.info("Node #{node} not ready yet, still syncing with master.")
force_unavailable_slave(node)
else
# otherwise, we can use this node
handle_available(n... | [
"def",
"handle_syncing",
"(",
"node",
",",
"snapshots",
")",
"reconcile",
"(",
"node",
")",
"if",
"node",
".",
"syncing_with_master?",
"&&",
"node",
".",
"prohibits_stale_reads?",
"logger",
".",
"info",
"(",
"\"Node #{node} not ready yet, still syncing with master.\"",
... | Handles a node that is currently syncing.
@param [Node] node the syncing node
@param [Hash<Node, NodeSnapshot>] snapshots the current set of snapshots | [
"Handles",
"a",
"node",
"that",
"is",
"currently",
"syncing",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L170-L180 |
20,366 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.handle_manual_failover | def handle_manual_failover(node, snapshots)
# no-op if node to be failed over is already master
return if @master == node
logger.info("Handling manual failover")
# ensure we can talk to the node
node.ping
# make current master a slave, and promote new master
@slaves << @maste... | ruby | def handle_manual_failover(node, snapshots)
# no-op if node to be failed over is already master
return if @master == node
logger.info("Handling manual failover")
# ensure we can talk to the node
node.ping
# make current master a slave, and promote new master
@slaves << @maste... | [
"def",
"handle_manual_failover",
"(",
"node",
",",
"snapshots",
")",
"# no-op if node to be failed over is already master",
"return",
"if",
"@master",
"==",
"node",
"logger",
".",
"info",
"(",
"\"Handling manual failover\"",
")",
"# ensure we can talk to the node",
"node",
... | Handles a manual failover request to the given node.
@param [Node] node the candidate node for failover
@param [Hash<Node, NodeSnapshot>] snapshots the current set of snapshots | [
"Handles",
"a",
"manual",
"failover",
"request",
"to",
"the",
"given",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L186-L198 |
20,367 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.promote_new_master | def promote_new_master(snapshots, node = nil)
delete_path(redis_nodes_path)
@master = nil
# make a specific node or selected candidate the new master
candidate = node || failover_strategy_candidate(snapshots)
if candidate.nil?
logger.error('Failed to promote a new master, no cand... | ruby | def promote_new_master(snapshots, node = nil)
delete_path(redis_nodes_path)
@master = nil
# make a specific node or selected candidate the new master
candidate = node || failover_strategy_candidate(snapshots)
if candidate.nil?
logger.error('Failed to promote a new master, no cand... | [
"def",
"promote_new_master",
"(",
"snapshots",
",",
"node",
"=",
"nil",
")",
"delete_path",
"(",
"redis_nodes_path",
")",
"@master",
"=",
"nil",
"# make a specific node or selected candidate the new master",
"candidate",
"=",
"node",
"||",
"failover_strategy_candidate",
"... | Promotes a new master.
@param [Hash<Node, NodeSnapshot>] snapshots the current set of snapshots
@param [Node] node the optional node to promote | [
"Promotes",
"a",
"new",
"master",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L204-L223 |
20,368 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.find_existing_master | def find_existing_master
if data = @zk.get(redis_nodes_path).first
nodes = symbolize_keys(decode(data))
master = node_from(nodes[:master])
logger.info("Master from existing znode config: #{master || 'none'}")
# Check for case where a node previously thought to be the master was
... | ruby | def find_existing_master
if data = @zk.get(redis_nodes_path).first
nodes = symbolize_keys(decode(data))
master = node_from(nodes[:master])
logger.info("Master from existing znode config: #{master || 'none'}")
# Check for case where a node previously thought to be the master was
... | [
"def",
"find_existing_master",
"if",
"data",
"=",
"@zk",
".",
"get",
"(",
"redis_nodes_path",
")",
".",
"first",
"nodes",
"=",
"symbolize_keys",
"(",
"decode",
"(",
"data",
")",
")",
"master",
"=",
"node_from",
"(",
"nodes",
"[",
":master",
"]",
")",
"lo... | Seeds the initial node master from an existing znode config. | [
"Seeds",
"the",
"initial",
"node",
"master",
"from",
"an",
"existing",
"znode",
"config",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L254-L275 |
20,369 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.node_from | def node_from(node_string)
return if node_string.nil?
host, port = node_string.split(':', 2)
Node.new(:host => host, :port => port, :password => @options[:password])
end | ruby | def node_from(node_string)
return if node_string.nil?
host, port = node_string.split(':', 2)
Node.new(:host => host, :port => port, :password => @options[:password])
end | [
"def",
"node_from",
"(",
"node_string",
")",
"return",
"if",
"node_string",
".",
"nil?",
"host",
",",
"port",
"=",
"node_string",
".",
"split",
"(",
"':'",
",",
"2",
")",
"Node",
".",
"new",
"(",
":host",
"=>",
"host",
",",
":port",
"=>",
"port",
","... | Creates a Node instance from a string.
@param [String] node_string a string representation of a node (e.g., host:port)
@return [Node] the Node representation | [
"Creates",
"a",
"Node",
"instance",
"from",
"a",
"string",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L281-L285 |
20,370 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.guess_master | def guess_master(nodes)
master_nodes = nodes.select { |node| node.master? }
raise NoMasterError if master_nodes.empty?
raise MultipleMastersError.new(master_nodes) if master_nodes.size > 1
master_nodes.first
end | ruby | def guess_master(nodes)
master_nodes = nodes.select { |node| node.master? }
raise NoMasterError if master_nodes.empty?
raise MultipleMastersError.new(master_nodes) if master_nodes.size > 1
master_nodes.first
end | [
"def",
"guess_master",
"(",
"nodes",
")",
"master_nodes",
"=",
"nodes",
".",
"select",
"{",
"|",
"node",
"|",
"node",
".",
"master?",
"}",
"raise",
"NoMasterError",
"if",
"master_nodes",
".",
"empty?",
"raise",
"MultipleMastersError",
".",
"new",
"(",
"maste... | Searches for the master node.
@param [Array<Node>] nodes the nodes to search
@return [Node] the found master node, nil if not found | [
"Searches",
"for",
"the",
"master",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L302-L307 |
20,371 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.redirect_slaves_to | def redirect_slaves_to(node)
@slaves.dup.each do |slave|
begin
slave.make_slave!(node)
rescue NodeUnavailableError
logger.info("Failed to redirect unreachable slave #{slave} to #{node}")
force_unavailable_slave(slave)
end
end
end | ruby | def redirect_slaves_to(node)
@slaves.dup.each do |slave|
begin
slave.make_slave!(node)
rescue NodeUnavailableError
logger.info("Failed to redirect unreachable slave #{slave} to #{node}")
force_unavailable_slave(slave)
end
end
end | [
"def",
"redirect_slaves_to",
"(",
"node",
")",
"@slaves",
".",
"dup",
".",
"each",
"do",
"|",
"slave",
"|",
"begin",
"slave",
".",
"make_slave!",
"(",
"node",
")",
"rescue",
"NodeUnavailableError",
"logger",
".",
"info",
"(",
"\"Failed to redirect unreachable sl... | Redirects all slaves to the specified node.
@param [Node] node the node to which slaves are redirected | [
"Redirects",
"all",
"slaves",
"to",
"the",
"specified",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L312-L321 |
20,372 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.reconcile | def reconcile(node)
return if @master == node && node.master?
return if @master && node.slave_of?(@master)
logger.info("Reconciling node #{node}")
if @master == node && !node.master?
# we think the node is a master, but the node doesn't
node.make_master!
return
end... | ruby | def reconcile(node)
return if @master == node && node.master?
return if @master && node.slave_of?(@master)
logger.info("Reconciling node #{node}")
if @master == node && !node.master?
# we think the node is a master, but the node doesn't
node.make_master!
return
end... | [
"def",
"reconcile",
"(",
"node",
")",
"return",
"if",
"@master",
"==",
"node",
"&&",
"node",
".",
"master?",
"return",
"if",
"@master",
"&&",
"node",
".",
"slave_of?",
"(",
"@master",
")",
"logger",
".",
"info",
"(",
"\"Reconciling node #{node}\"",
")",
"i... | It's possible that a newly available node may have been restarted
and completely lost its dynamically set run-time role by the node
manager. This method ensures that the node resumes its role as
determined by the manager.
@param [Node] node the node to reconcile | [
"It",
"s",
"possible",
"that",
"a",
"newly",
"available",
"node",
"may",
"have",
"been",
"restarted",
"and",
"completely",
"lost",
"its",
"dynamically",
"set",
"run",
"-",
"time",
"role",
"by",
"the",
"node",
"manager",
".",
"This",
"method",
"ensures",
"t... | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L337-L352 |
20,373 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.delete_path | def delete_path(path)
@zk.delete(path)
logger.info("Deleted ZK node #{path}")
rescue ZK::Exceptions::NoNode => ex
logger.info("Tried to delete missing znode: #{ex.inspect}")
end | ruby | def delete_path(path)
@zk.delete(path)
logger.info("Deleted ZK node #{path}")
rescue ZK::Exceptions::NoNode => ex
logger.info("Tried to delete missing znode: #{ex.inspect}")
end | [
"def",
"delete_path",
"(",
"path",
")",
"@zk",
".",
"delete",
"(",
"path",
")",
"logger",
".",
"info",
"(",
"\"Deleted ZK node #{path}\"",
")",
"rescue",
"ZK",
"::",
"Exceptions",
"::",
"NoNode",
"=>",
"ex",
"logger",
".",
"info",
"(",
"\"Tried to delete mis... | Deletes the znode path containing the redis nodes.
@param [String] path the znode path to delete | [
"Deletes",
"the",
"znode",
"path",
"containing",
"the",
"redis",
"nodes",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L375-L380 |
20,374 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.create_path | def create_path(path, options = {})
unless @zk.exists?(path)
@zk.create(path,
options[:initial_value],
:ephemeral => options.fetch(:ephemeral, false))
logger.info("Created ZK node #{path}")
end
rescue ZK::Exceptions::NodeExists
# best effort
end | ruby | def create_path(path, options = {})
unless @zk.exists?(path)
@zk.create(path,
options[:initial_value],
:ephemeral => options.fetch(:ephemeral, false))
logger.info("Created ZK node #{path}")
end
rescue ZK::Exceptions::NodeExists
# best effort
end | [
"def",
"create_path",
"(",
"path",
",",
"options",
"=",
"{",
"}",
")",
"unless",
"@zk",
".",
"exists?",
"(",
"path",
")",
"@zk",
".",
"create",
"(",
"path",
",",
"options",
"[",
":initial_value",
"]",
",",
":ephemeral",
"=>",
"options",
".",
"fetch",
... | Creates a znode path.
@param [String] path the znode path to create
@param [Hash] options the options used to create the path
@option options [String] :initial_value an initial value for the znode
@option options [Boolean] :ephemeral true if node is ephemeral, false otherwise | [
"Creates",
"a",
"znode",
"path",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L388-L397 |
20,375 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.write_state | def write_state(path, value, options = {})
create_path(path, options.merge(:initial_value => value))
@zk.set(path, value)
end | ruby | def write_state(path, value, options = {})
create_path(path, options.merge(:initial_value => value))
@zk.set(path, value)
end | [
"def",
"write_state",
"(",
"path",
",",
"value",
",",
"options",
"=",
"{",
"}",
")",
"create_path",
"(",
"path",
",",
"options",
".",
"merge",
"(",
":initial_value",
"=>",
"value",
")",
")",
"@zk",
".",
"set",
"(",
"path",
",",
"value",
")",
"end"
] | Writes state to a particular znode path.
@param [String] path the znode path that should be written to
@param [String] value the value to write to the znode
@param [Hash] options the default options to be used when creating the node
@note the path will be created if it doesn't exist | [
"Writes",
"state",
"to",
"a",
"particular",
"znode",
"path",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L405-L408 |
20,376 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.handle_manual_failover_update | def handle_manual_failover_update(event)
if event.node_created? || event.node_changed?
perform_manual_failover
end
rescue => ex
logger.error("Error scheduling a manual failover: #{ex.inspect}")
logger.error(ex.backtrace.join("\n"))
ensure
@zk.stat(manual_failover_path, :wat... | ruby | def handle_manual_failover_update(event)
if event.node_created? || event.node_changed?
perform_manual_failover
end
rescue => ex
logger.error("Error scheduling a manual failover: #{ex.inspect}")
logger.error(ex.backtrace.join("\n"))
ensure
@zk.stat(manual_failover_path, :wat... | [
"def",
"handle_manual_failover_update",
"(",
"event",
")",
"if",
"event",
".",
"node_created?",
"||",
"event",
".",
"node_changed?",
"perform_manual_failover",
"end",
"rescue",
"=>",
"ex",
"logger",
".",
"error",
"(",
"\"Error scheduling a manual failover: #{ex.inspect}\"... | Handles a manual failover znode update.
@param [ZK::Event] event the ZK event to handle | [
"Handles",
"a",
"manual",
"failover",
"znode",
"update",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L413-L422 |
20,377 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.update_master_state | def update_master_state(node, snapshots)
state = @node_strategy.determine_state(node, snapshots)
case state
when :unavailable
handle_unavailable(node, snapshots)
when :available
if node.syncing_with_master?
handle_syncing(node, snapshots)
else
handle_a... | ruby | def update_master_state(node, snapshots)
state = @node_strategy.determine_state(node, snapshots)
case state
when :unavailable
handle_unavailable(node, snapshots)
when :available
if node.syncing_with_master?
handle_syncing(node, snapshots)
else
handle_a... | [
"def",
"update_master_state",
"(",
"node",
",",
"snapshots",
")",
"state",
"=",
"@node_strategy",
".",
"determine_state",
"(",
"node",
",",
"snapshots",
")",
"case",
"state",
"when",
":unavailable",
"handle_unavailable",
"(",
"node",
",",
"snapshots",
")",
"when... | Used to update the master node manager state. These states are only handled if
this node manager instance is serving as the master manager.
@param [Node] node the node to handle
@param [Hash<Node, NodeSnapshot>] snapshots the current set of snapshots | [
"Used",
"to",
"update",
"the",
"master",
"node",
"manager",
"state",
".",
"These",
"states",
"are",
"only",
"handled",
"if",
"this",
"node",
"manager",
"instance",
"is",
"serving",
"as",
"the",
"master",
"manager",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L482-L501 |
20,378 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.update_current_state | def update_current_state(node, state, latency = nil)
old_unavailable = @monitored_unavailable.dup
old_available = @monitored_available.dup
case state
when :unavailable
unless @monitored_unavailable.include?(node)
@monitored_unavailable << node
@monitored_available.de... | ruby | def update_current_state(node, state, latency = nil)
old_unavailable = @monitored_unavailable.dup
old_available = @monitored_available.dup
case state
when :unavailable
unless @monitored_unavailable.include?(node)
@monitored_unavailable << node
@monitored_available.de... | [
"def",
"update_current_state",
"(",
"node",
",",
"state",
",",
"latency",
"=",
"nil",
")",
"old_unavailable",
"=",
"@monitored_unavailable",
".",
"dup",
"old_available",
"=",
"@monitored_available",
".",
"dup",
"case",
"state",
"when",
":unavailable",
"unless",
"@... | Updates the current view of the world for this particular node
manager instance. All node managers write this state regardless
of whether they are the master manager or not.
@param [Node] node the node to handle
@param [Symbol] state the node state
@param [Integer] latency an optional latency | [
"Updates",
"the",
"current",
"view",
"of",
"the",
"world",
"for",
"this",
"particular",
"node",
"manager",
"instance",
".",
"All",
"node",
"managers",
"write",
"this",
"state",
"regardless",
"of",
"whether",
"they",
"are",
"the",
"master",
"manager",
"or",
"... | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L510-L536 |
20,379 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.current_node_snapshots | def current_node_snapshots
nodes = {}
snapshots = Hash.new { |h, k| h[k] = NodeSnapshot.new(k) }
fetch_node_manager_states.each do |node_manager, states|
available, unavailable = states.values_at(:available, :unavailable)
available.each do |node_string, latency|
node = nodes[... | ruby | def current_node_snapshots
nodes = {}
snapshots = Hash.new { |h, k| h[k] = NodeSnapshot.new(k) }
fetch_node_manager_states.each do |node_manager, states|
available, unavailable = states.values_at(:available, :unavailable)
available.each do |node_string, latency|
node = nodes[... | [
"def",
"current_node_snapshots",
"nodes",
"=",
"{",
"}",
"snapshots",
"=",
"Hash",
".",
"new",
"{",
"|",
"h",
",",
"k",
"|",
"h",
"[",
"k",
"]",
"=",
"NodeSnapshot",
".",
"new",
"(",
"k",
")",
"}",
"fetch_node_manager_states",
".",
"each",
"do",
"|",... | Builds current snapshots of nodes across all running node managers.
@return [Hash<Node, NodeSnapshot>] the snapshots for all nodes | [
"Builds",
"current",
"snapshots",
"of",
"nodes",
"across",
"all",
"running",
"node",
"managers",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L561-L577 |
20,380 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.wait_until_master | def wait_until_master
logger.info('Waiting to become master Node Manager ...')
with_lock do
@master_manager = true
logger.info('Acquired master Node Manager lock.')
logger.info("Configured node strategy #{@node_strategy.class}")
logger.info("Configured failover strategy #{@f... | ruby | def wait_until_master
logger.info('Waiting to become master Node Manager ...')
with_lock do
@master_manager = true
logger.info('Acquired master Node Manager lock.')
logger.info("Configured node strategy #{@node_strategy.class}")
logger.info("Configured failover strategy #{@f... | [
"def",
"wait_until_master",
"logger",
".",
"info",
"(",
"'Waiting to become master Node Manager ...'",
")",
"with_lock",
"do",
"@master_manager",
"=",
"true",
"logger",
".",
"info",
"(",
"'Acquired master Node Manager lock.'",
")",
"logger",
".",
"info",
"(",
"\"Configu... | Waits until this node manager becomes the master. | [
"Waits",
"until",
"this",
"node",
"manager",
"becomes",
"the",
"master",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L580-L591 |
20,381 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.manage_nodes | def manage_nodes
# Re-discover nodes, since the state of the world may have been changed
# by the time we've become the primary node manager.
discover_nodes
# ensure that slaves are correctly pointing to this master
redirect_slaves_to(@master)
# Periodically update master config st... | ruby | def manage_nodes
# Re-discover nodes, since the state of the world may have been changed
# by the time we've become the primary node manager.
discover_nodes
# ensure that slaves are correctly pointing to this master
redirect_slaves_to(@master)
# Periodically update master config st... | [
"def",
"manage_nodes",
"# Re-discover nodes, since the state of the world may have been changed",
"# by the time we've become the primary node manager.",
"discover_nodes",
"# ensure that slaves are correctly pointing to this master",
"redirect_slaves_to",
"(",
"@master",
")",
"# Periodically upd... | Manages the redis nodes by periodically processing snapshots. | [
"Manages",
"the",
"redis",
"nodes",
"by",
"periodically",
"processing",
"snapshots",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L594-L625 |
20,382 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.with_lock | def with_lock
@zk_lock ||= @zk.locker(current_lock_path)
begin
@zk_lock.lock!(true)
rescue Exception
# handle shutdown case
running? ? raise : return
end
if running?
@zk_lock.assert!
yield
end
ensure
if @zk_lock
begin
... | ruby | def with_lock
@zk_lock ||= @zk.locker(current_lock_path)
begin
@zk_lock.lock!(true)
rescue Exception
# handle shutdown case
running? ? raise : return
end
if running?
@zk_lock.assert!
yield
end
ensure
if @zk_lock
begin
... | [
"def",
"with_lock",
"@zk_lock",
"||=",
"@zk",
".",
"locker",
"(",
"current_lock_path",
")",
"begin",
"@zk_lock",
".",
"lock!",
"(",
"true",
")",
"rescue",
"Exception",
"# handle shutdown case",
"running?",
"?",
"raise",
":",
"return",
"end",
"if",
"running?",
... | Executes a block wrapped in a ZK exclusive lock. | [
"Executes",
"a",
"block",
"wrapped",
"in",
"a",
"ZK",
"exclusive",
"lock",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L638-L660 |
20,383 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.perform_manual_failover | def perform_manual_failover
@lock.synchronize do
return unless running? && @master_manager && @zk_lock
@zk_lock.assert!
new_master = @zk.get(manual_failover_path, :watch => true).first
return unless new_master && new_master.size > 0
logger.info("Received manual failover req... | ruby | def perform_manual_failover
@lock.synchronize do
return unless running? && @master_manager && @zk_lock
@zk_lock.assert!
new_master = @zk.get(manual_failover_path, :watch => true).first
return unless new_master && new_master.size > 0
logger.info("Received manual failover req... | [
"def",
"perform_manual_failover",
"@lock",
".",
"synchronize",
"do",
"return",
"unless",
"running?",
"&&",
"@master_manager",
"&&",
"@zk_lock",
"@zk_lock",
".",
"assert!",
"new_master",
"=",
"@zk",
".",
"get",
"(",
"manual_failover_path",
",",
":watch",
"=>",
"tru... | Perform a manual failover to a redis node. | [
"Perform",
"a",
"manual",
"failover",
"to",
"a",
"redis",
"node",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L663-L690 |
20,384 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.ensure_sufficient_node_managers | def ensure_sufficient_node_managers(snapshots)
currently_sufficient = true
snapshots.each do |node, snapshot|
node_managers = snapshot.node_managers
if node_managers.size < @required_node_managers
logger.error("Not enough Node Managers in snapshot for node #{node}. " +
... | ruby | def ensure_sufficient_node_managers(snapshots)
currently_sufficient = true
snapshots.each do |node, snapshot|
node_managers = snapshot.node_managers
if node_managers.size < @required_node_managers
logger.error("Not enough Node Managers in snapshot for node #{node}. " +
... | [
"def",
"ensure_sufficient_node_managers",
"(",
"snapshots",
")",
"currently_sufficient",
"=",
"true",
"snapshots",
".",
"each",
"do",
"|",
"node",
",",
"snapshot",
"|",
"node_managers",
"=",
"snapshot",
".",
"node_managers",
"if",
"node_managers",
".",
"size",
"<"... | Determines if each snapshot has a sufficient number of node managers.
@param [Hash<Node, Snapshot>] snapshots the current snapshots
@return [Boolean] true if sufficient, false otherwise | [
"Determines",
"if",
"each",
"snapshot",
"has",
"a",
"sufficient",
"number",
"of",
"node",
"managers",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L706-L724 |
20,385 | ryanlecompte/redis_failover | lib/redis_failover/node_manager.rb | RedisFailover.NodeManager.failover_strategy_candidate | def failover_strategy_candidate(snapshots)
# only include nodes that this master Node Manager can see
filtered_snapshots = snapshots.select do |node, snapshot|
snapshot.viewable_by?(manager_id)
end
logger.info('Attempting to find candidate from snapshots:')
logger.info("\n" + filt... | ruby | def failover_strategy_candidate(snapshots)
# only include nodes that this master Node Manager can see
filtered_snapshots = snapshots.select do |node, snapshot|
snapshot.viewable_by?(manager_id)
end
logger.info('Attempting to find candidate from snapshots:')
logger.info("\n" + filt... | [
"def",
"failover_strategy_candidate",
"(",
"snapshots",
")",
"# only include nodes that this master Node Manager can see",
"filtered_snapshots",
"=",
"snapshots",
".",
"select",
"do",
"|",
"node",
",",
"snapshot",
"|",
"snapshot",
".",
"viewable_by?",
"(",
"manager_id",
"... | Invokes the configured failover strategy.
@param [Hash<Node, NodeSnapshot>] snapshots the node snapshots
@return [Node] a failover candidate | [
"Invokes",
"the",
"configured",
"failover",
"strategy",
"."
] | be1208240b9b817fb0288edc7535e3f445f767cd | https://github.com/ryanlecompte/redis_failover/blob/be1208240b9b817fb0288edc7535e3f445f767cd/lib/redis_failover/node_manager.rb#L730-L739 |
20,386 | larskanis/pkcs11 | lib/pkcs11/library.rb | PKCS11.Library.C_Initialize | def C_Initialize(args=nil)
case args
when Hash
pargs = CK_C_INITIALIZE_ARGS.new
args.each{|k,v| pargs.send("#{k}=", v) }
else
pargs = args
end
unwrapped_C_Initialize(pargs)
end | ruby | def C_Initialize(args=nil)
case args
when Hash
pargs = CK_C_INITIALIZE_ARGS.new
args.each{|k,v| pargs.send("#{k}=", v) }
else
pargs = args
end
unwrapped_C_Initialize(pargs)
end | [
"def",
"C_Initialize",
"(",
"args",
"=",
"nil",
")",
"case",
"args",
"when",
"Hash",
"pargs",
"=",
"CK_C_INITIALIZE_ARGS",
".",
"new",
"args",
".",
"each",
"{",
"|",
"k",
",",
"v",
"|",
"pargs",
".",
"send",
"(",
"\"#{k}=\"",
",",
"v",
")",
"}",
"e... | Initialize a pkcs11 dynamic library.
@param [Hash, CK_C_INITIALIZE_ARGS] args A Hash or CK_C_INITIALIZE_ARGS instance with load params. | [
"Initialize",
"a",
"pkcs11",
"dynamic",
"library",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/library.rb#L49-L58 |
20,387 | larskanis/pkcs11 | lib/pkcs11/library.rb | PKCS11.Library.C_GetSlotList | def C_GetSlotList(tokenPresent=false)
slots = unwrapped_C_GetSlotList(tokenPresent)
slots.map{|slot|
Slot.new self, slot
}
end | ruby | def C_GetSlotList(tokenPresent=false)
slots = unwrapped_C_GetSlotList(tokenPresent)
slots.map{|slot|
Slot.new self, slot
}
end | [
"def",
"C_GetSlotList",
"(",
"tokenPresent",
"=",
"false",
")",
"slots",
"=",
"unwrapped_C_GetSlotList",
"(",
"tokenPresent",
")",
"slots",
".",
"map",
"{",
"|",
"slot",
"|",
"Slot",
".",
"new",
"self",
",",
"slot",
"}",
"end"
] | Obtain an array of Slot objects in the system.
@param [true, false] tokenPresent indicates whether the list
obtained includes only those slots with a token present (true), or
all slots (false);
@return [Array<Slot>] | [
"Obtain",
"an",
"array",
"of",
"Slot",
"objects",
"in",
"the",
"system",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/library.rb#L76-L81 |
20,388 | larskanis/pkcs11 | lib/pkcs11/session.rb | PKCS11.Session.C_FindObjects | def C_FindObjects(max_count)
objs = @pk.C_FindObjects(@sess, max_count)
objs.map{|obj| Object.new @pk, @sess, obj }
end | ruby | def C_FindObjects(max_count)
objs = @pk.C_FindObjects(@sess, max_count)
objs.map{|obj| Object.new @pk, @sess, obj }
end | [
"def",
"C_FindObjects",
"(",
"max_count",
")",
"objs",
"=",
"@pk",
".",
"C_FindObjects",
"(",
"@sess",
",",
"max_count",
")",
"objs",
".",
"map",
"{",
"|",
"obj",
"|",
"Object",
".",
"new",
"@pk",
",",
"@sess",
",",
"obj",
"}",
"end"
] | Continues a search for token and session objects that match a template,
obtaining additional object handles.
See {Session#find_objects} for convenience
@return [Array<PKCS11::Object>] Returns an array of Object instances. | [
"Continues",
"a",
"search",
"for",
"token",
"and",
"session",
"objects",
"that",
"match",
"a",
"template",
"obtaining",
"additional",
"object",
"handles",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/session.rb#L91-L94 |
20,389 | larskanis/pkcs11 | lib/pkcs11/session.rb | PKCS11.Session.C_GenerateKey | def C_GenerateKey(mechanism, template={})
obj = @pk.C_GenerateKey(@sess, to_mechanism(mechanism), to_attributes(template))
Object.new @pk, @sess, obj
end | ruby | def C_GenerateKey(mechanism, template={})
obj = @pk.C_GenerateKey(@sess, to_mechanism(mechanism), to_attributes(template))
Object.new @pk, @sess, obj
end | [
"def",
"C_GenerateKey",
"(",
"mechanism",
",",
"template",
"=",
"{",
"}",
")",
"obj",
"=",
"@pk",
".",
"C_GenerateKey",
"(",
"@sess",
",",
"to_mechanism",
"(",
"mechanism",
")",
",",
"to_attributes",
"(",
"template",
")",
")",
"Object",
".",
"new",
"@pk"... | Generates a secret key Object or set of domain parameters, creating a new
Object.
@param [Hash, Symbol, Integer, PKCS11::CK_MECHANISM] mechanism used mechanism
@param [Hash] template Attributes of the key to create.
@return [PKCS11::Object] key Object of the new created key.
@example generate 112 bit DES key
... | [
"Generates",
"a",
"secret",
"key",
"Object",
"or",
"set",
"of",
"domain",
"parameters",
"creating",
"a",
"new",
"Object",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/session.rb#L653-L656 |
20,390 | larskanis/pkcs11 | lib/pkcs11/session.rb | PKCS11.Session.C_DeriveKey | def C_DeriveKey(mechanism, base_key, template={})
obj = @pk.C_DeriveKey(@sess, to_mechanism(mechanism), base_key, to_attributes(template))
Object.new @pk, @sess, obj
end | ruby | def C_DeriveKey(mechanism, base_key, template={})
obj = @pk.C_DeriveKey(@sess, to_mechanism(mechanism), base_key, to_attributes(template))
Object.new @pk, @sess, obj
end | [
"def",
"C_DeriveKey",
"(",
"mechanism",
",",
"base_key",
",",
"template",
"=",
"{",
"}",
")",
"obj",
"=",
"@pk",
".",
"C_DeriveKey",
"(",
"@sess",
",",
"to_mechanism",
"(",
"mechanism",
")",
",",
"base_key",
",",
"to_attributes",
"(",
"template",
")",
")... | Derives a key from a base key, creating a new key object.
@param [Hash, Symbol, Integer, PKCS11::CK_MECHANISM] mechanism used mechanism
@param [PKCS11::Object] base_key key to derive
@param [Hash] template Attributes of the object to create.
@return [PKCS11::Object] key object of the new created key.
@example... | [
"Derives",
"a",
"key",
"from",
"a",
"base",
"key",
"creating",
"a",
"new",
"key",
"object",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/session.rb#L718-L721 |
20,391 | larskanis/pkcs11 | lib/pkcs11/slot.rb | PKCS11.Slot.C_OpenSession | def C_OpenSession(flags=CKF_SERIAL_SESSION)
nr = @pk.C_OpenSession(@slot, flags)
sess = Session.new @pk, nr
if block_given?
begin
yield sess
ensure
sess.close
end
else
sess
end
end | ruby | def C_OpenSession(flags=CKF_SERIAL_SESSION)
nr = @pk.C_OpenSession(@slot, flags)
sess = Session.new @pk, nr
if block_given?
begin
yield sess
ensure
sess.close
end
else
sess
end
end | [
"def",
"C_OpenSession",
"(",
"flags",
"=",
"CKF_SERIAL_SESSION",
")",
"nr",
"=",
"@pk",
".",
"C_OpenSession",
"(",
"@slot",
",",
"flags",
")",
"sess",
"=",
"Session",
".",
"new",
"@pk",
",",
"nr",
"if",
"block_given?",
"begin",
"yield",
"sess",
"ensure",
... | Opens a Session between an application and a token in a particular slot.
@param [Integer] flags indicates the type of session. Default is read-only,
use <tt>CKF_SERIAL_SESSION | CKF_RW_SESSION</tt> for read-write session.
* If called with block, yields the block with the session and closes the session
... | [
"Opens",
"a",
"Session",
"between",
"an",
"application",
"and",
"a",
"token",
"in",
"a",
"particular",
"slot",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/slot.rb#L79-L91 |
20,392 | larskanis/pkcs11 | lib/pkcs11/object.rb | PKCS11.Object.[] | def [](*attributes)
attrs = C_GetAttributeValue( attributes.flatten )
if attrs.length>1 || attributes.first.kind_of?(Array)
attrs.map(&:value)
else
attrs.first.value unless attrs.empty?
end
end | ruby | def [](*attributes)
attrs = C_GetAttributeValue( attributes.flatten )
if attrs.length>1 || attributes.first.kind_of?(Array)
attrs.map(&:value)
else
attrs.first.value unless attrs.empty?
end
end | [
"def",
"[]",
"(",
"*",
"attributes",
")",
"attrs",
"=",
"C_GetAttributeValue",
"(",
"attributes",
".",
"flatten",
")",
"if",
"attrs",
".",
"length",
">",
"1",
"||",
"attributes",
".",
"first",
".",
"kind_of?",
"(",
"Array",
")",
"attrs",
".",
"map",
"(... | Get the value of one or several attributes of the object.
@param [String, Symbol, Integer, Array] attribute can be String or Symbol
of the attribute(s) constant or the attribute(s) number as Integer.
@return [String, Integer, Boolean, Array, nil] the attribute value as String,
Integer or true/false ... | [
"Get",
"the",
"value",
"of",
"one",
"or",
"several",
"attributes",
"of",
"the",
"object",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/object.rb#L48-L55 |
20,393 | larskanis/pkcs11 | lib/pkcs11/object.rb | PKCS11.Object.[]= | def []=(*attributes)
values = attributes.pop
values = [values] unless values.kind_of?(Array)
raise ArgumentError, "different number of attributes to set (#{attributes.length}) and given values (#{values.length})" unless attributes.length == values.length
map = values.each.with_index.inject({}){|... | ruby | def []=(*attributes)
values = attributes.pop
values = [values] unless values.kind_of?(Array)
raise ArgumentError, "different number of attributes to set (#{attributes.length}) and given values (#{values.length})" unless attributes.length == values.length
map = values.each.with_index.inject({}){|... | [
"def",
"[]=",
"(",
"*",
"attributes",
")",
"values",
"=",
"attributes",
".",
"pop",
"values",
"=",
"[",
"values",
"]",
"unless",
"values",
".",
"kind_of?",
"(",
"Array",
")",
"raise",
"ArgumentError",
",",
"\"different number of attributes to set (#{attributes.len... | Modifies the value of one or several attributes of the object.
@param [String, Symbol, Integer] attribute can be String or Symbol of the attribute constant
or the attribute value as Integer.
@param [String, Integer, Boolean, Array, nil] value value(s) the attribute(s) will be set to.
Following value... | [
"Modifies",
"the",
"value",
"of",
"one",
"or",
"several",
"attributes",
"of",
"the",
"object",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/object.rb#L76-L82 |
20,394 | larskanis/pkcs11 | lib/pkcs11/object.rb | PKCS11.Object.C_GetAttributeValue | def C_GetAttributeValue(*template)
case template.length
when 0
return @pk.vendor_all_attribute_names.map{|attr|
begin
attributes(@pk.vendor_const_get(attr))
rescue PKCS11::Error
end
}.flatten.compact
when 1
template = ... | ruby | def C_GetAttributeValue(*template)
case template.length
when 0
return @pk.vendor_all_attribute_names.map{|attr|
begin
attributes(@pk.vendor_const_get(attr))
rescue PKCS11::Error
end
}.flatten.compact
when 1
template = ... | [
"def",
"C_GetAttributeValue",
"(",
"*",
"template",
")",
"case",
"template",
".",
"length",
"when",
"0",
"return",
"@pk",
".",
"vendor_all_attribute_names",
".",
"map",
"{",
"|",
"attr",
"|",
"begin",
"attributes",
"(",
"@pk",
".",
"vendor_const_get",
"(",
"... | Obtains the value of one or more attributes of the object in a single call.
@param [Array<String, Symbol, Integer>, Hash, String, Integer] attribute attribute names
whose values should be returned
Without params all known attributes are tried to read from the Object.
This is significant slower then naming the ... | [
"Obtains",
"the",
"value",
"of",
"one",
"or",
"more",
"attributes",
"of",
"the",
"object",
"in",
"a",
"single",
"call",
"."
] | 4f39c54a932face8b3d87c157d8d56469c43c6bc | https://github.com/larskanis/pkcs11/blob/4f39c54a932face8b3d87c157d8d56469c43c6bc/lib/pkcs11/object.rb#L109-L123 |
20,395 | mailin-api/sendinblue-ruby-gem | lib/sendinblue.rb | Sendinblue.Mailin.get_campaigns_v2 | def get_campaigns_v2(data)
if data['type'] == "" and data['status'] == "" and data['page'] == "" and data['page_limit'] == ""
return self.get("campaign/detailsv2/","")
else
return self.get("campaign/detailsv2/type/" + data['type'] + "/status/" + data['status'] + "/page/" + data['page'].to_s + "/page_limit/"... | ruby | def get_campaigns_v2(data)
if data['type'] == "" and data['status'] == "" and data['page'] == "" and data['page_limit'] == ""
return self.get("campaign/detailsv2/","")
else
return self.get("campaign/detailsv2/type/" + data['type'] + "/status/" + data['status'] + "/page/" + data['page'].to_s + "/page_limit/"... | [
"def",
"get_campaigns_v2",
"(",
"data",
")",
"if",
"data",
"[",
"'type'",
"]",
"==",
"\"\"",
"and",
"data",
"[",
"'status'",
"]",
"==",
"\"\"",
"and",
"data",
"[",
"'page'",
"]",
"==",
"\"\"",
"and",
"data",
"[",
"'page_limit'",
"]",
"==",
"\"\"",
"r... | Get all campaigns detail.
@param {Array} data contains php array with key value pair.
@options data {String} type: Type of campaign. Possible values – classic, trigger, sms, template ( case sensitive ) [Optional]
@options data {String} status: Status of campaign. Possible values – draft, sent, archive, queued, suspe... | [
"Get",
"all",
"campaigns",
"detail",
"."
] | 670d38921c9893e653fab07dc5b9ecfb86628460 | https://github.com/mailin-api/sendinblue-ruby-gem/blob/670d38921c9893e653fab07dc5b9ecfb86628460/lib/sendinblue.rb#L169-L175 |
20,396 | podio/podio-rb | lib/podio/client.rb | Podio.Client.authenticate_with_auth_code | def authenticate_with_auth_code(authorization_code, redirect_uri)
response = @oauth_connection.post do |req|
req.url '/oauth/token'
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = {:grant_type => 'authorization_code', :client_id => api_key, :client_secret => ap... | ruby | def authenticate_with_auth_code(authorization_code, redirect_uri)
response = @oauth_connection.post do |req|
req.url '/oauth/token'
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = {:grant_type => 'authorization_code', :client_id => api_key, :client_secret => ap... | [
"def",
"authenticate_with_auth_code",
"(",
"authorization_code",
",",
"redirect_uri",
")",
"response",
"=",
"@oauth_connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"'/oauth/token'",
"req",
".",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'ap... | sign in as a user using the server side flow | [
"sign",
"in",
"as",
"a",
"user",
"using",
"the",
"server",
"side",
"flow"
] | 66137e685a494bc188ced542ae8e872d14b90a74 | https://github.com/podio/podio-rb/blob/66137e685a494bc188ced542ae8e872d14b90a74/lib/podio/client.rb#L43-L53 |
20,397 | podio/podio-rb | lib/podio/client.rb | Podio.Client.authenticate_with_credentials | def authenticate_with_credentials(username, password, offering_id=nil)
body = {:grant_type => 'password', :client_id => api_key, :client_secret => api_secret, :username => username, :password => password}
body[:offering_id] = offering_id if offering_id.present?
response = @oauth_connection.post do |r... | ruby | def authenticate_with_credentials(username, password, offering_id=nil)
body = {:grant_type => 'password', :client_id => api_key, :client_secret => api_secret, :username => username, :password => password}
body[:offering_id] = offering_id if offering_id.present?
response = @oauth_connection.post do |r... | [
"def",
"authenticate_with_credentials",
"(",
"username",
",",
"password",
",",
"offering_id",
"=",
"nil",
")",
"body",
"=",
"{",
":grant_type",
"=>",
"'password'",
",",
":client_id",
"=>",
"api_key",
",",
":client_secret",
"=>",
"api_secret",
",",
":username",
"... | Sign in as a user using credentials | [
"Sign",
"in",
"as",
"a",
"user",
"using",
"credentials"
] | 66137e685a494bc188ced542ae8e872d14b90a74 | https://github.com/podio/podio-rb/blob/66137e685a494bc188ced542ae8e872d14b90a74/lib/podio/client.rb#L56-L69 |
20,398 | podio/podio-rb | lib/podio/client.rb | Podio.Client.authenticate_with_app | def authenticate_with_app(app_id, app_token)
response = @oauth_connection.post do |req|
req.url '/oauth/token'
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = {:grant_type => 'app', :client_id => api_key, :client_secret => api_secret, :app_id => app_id, :app_to... | ruby | def authenticate_with_app(app_id, app_token)
response = @oauth_connection.post do |req|
req.url '/oauth/token'
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = {:grant_type => 'app', :client_id => api_key, :client_secret => api_secret, :app_id => app_id, :app_to... | [
"def",
"authenticate_with_app",
"(",
"app_id",
",",
"app_token",
")",
"response",
"=",
"@oauth_connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"'/oauth/token'",
"req",
".",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/x-www-form-... | Sign in as an app | [
"Sign",
"in",
"as",
"an",
"app"
] | 66137e685a494bc188ced542ae8e872d14b90a74 | https://github.com/podio/podio-rb/blob/66137e685a494bc188ced542ae8e872d14b90a74/lib/podio/client.rb#L72-L82 |
20,399 | podio/podio-rb | lib/podio/client.rb | Podio.Client.authenticate_with_transfer_token | def authenticate_with_transfer_token(transfer_token)
response = @oauth_connection.post do |req|
req.url '/oauth/token'
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = {:grant_type => 'transfer_token', :client_id => api_key, :client_secret => api_secret, :transf... | ruby | def authenticate_with_transfer_token(transfer_token)
response = @oauth_connection.post do |req|
req.url '/oauth/token'
req.headers['Content-Type'] = 'application/x-www-form-urlencoded'
req.body = {:grant_type => 'transfer_token', :client_id => api_key, :client_secret => api_secret, :transf... | [
"def",
"authenticate_with_transfer_token",
"(",
"transfer_token",
")",
"response",
"=",
"@oauth_connection",
".",
"post",
"do",
"|",
"req",
"|",
"req",
".",
"url",
"'/oauth/token'",
"req",
".",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/x-www-form-url... | Sign in with an transfer token, only available for Podio | [
"Sign",
"in",
"with",
"an",
"transfer",
"token",
"only",
"available",
"for",
"Podio"
] | 66137e685a494bc188ced542ae8e872d14b90a74 | https://github.com/podio/podio-rb/blob/66137e685a494bc188ced542ae8e872d14b90a74/lib/podio/client.rb#L85-L95 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.