_id stringlengths 2 6 | title stringlengths 9 130 | partition stringclasses 3
values | text stringlengths 66 10.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q1200 | Lex.Linter.validate_tokens | train | def validate_tokens(lexer)
if lexer.lex_tokens.empty?
complain("No token list defined")
end
if !lexer.lex_tokens.respond_to?(:to_ary)
complain("Tokens must be a list or enumerable")
end
terminals = []
lexer.lex_tokens.each do |token|
if !identifier?(token)
... | ruby | {
"resource": ""
} |
q1201 | Lex.Linter.validate_states | train | def validate_states(lexer)
if !lexer.state_info.respond_to?(:each_pair)
complain("States must be defined as a hash")
end
lexer.state_info.each do |state_name, state_type|
if ![:inclusive, :exclusive].include?(state_type)
complain("State type for state #{state_name}" \
... | ruby | {
"resource": ""
} |
q1202 | Scorched.Response.body= | train | def body=(value)
value = [] if !value || value == ''
super(value.respond_to?(:each) ? value : [value.to_s])
end | ruby | {
"resource": ""
} |
q1203 | Scorched.Response.finish | train | def finish(*args, &block)
self['Content-Type'] ||= 'text/html;charset=utf-8'
@block = block if block
if [204, 205, 304].include?(status.to_i)
header.delete "Content-Type"
header.delete "Content-Length"
close
[status.to_i, header, []]
else
[status.to_i, hea... | ruby | {
"resource": ""
} |
q1204 | Scorched.Controller.try_matches | train | def try_matches
eligable_matches.each do |match,idx|
request.breadcrumb << match
catch(:pass) {
dispatch(match)
return true
}
request.breadcrumb.pop # Current match passed, so pop the breadcrumb before the next iteration.
end
response.status = (!matc... | ruby | {
"resource": ""
} |
q1205 | Scorched.Controller.dispatch | train | def dispatch(match)
@_dispatched = true
target = match.mapping[:target]
response.merge! begin
if Proc === target
instance_exec(&target)
else
target.call(env.merge(
'SCRIPT_NAME' => request.matched_path.chomp('/'),
'PATH_INFO' => request.unmat... | ruby | {
"resource": ""
} |
q1206 | Scorched.Controller.matches | train | def matches
@_matches ||= begin
to_match = request.unmatched_path
to_match = to_match.chomp('/') if config[:strip_trailing_slash] == :ignore && to_match =~ %r{./$}
mappings.map { |mapping|
mapping[:pattern].match(to_match) do |match_data|
if match_data.pre_match == ''... | ruby | {
"resource": ""
} |
q1207 | Scorched.Controller.eligable_matches | train | def eligable_matches
@_eligable_matches ||= begin
matches.select { |m| m.failed_condition.nil? }.each_with_index.sort_by do |m,idx|
priority = m.mapping[:priority] || 0
media_type_rank = [*m.mapping[:conditions][:media_type]].map { |type|
env['scorched.accept'][:accept].ran... | ruby | {
"resource": ""
} |
q1208 | Scorched.Controller.check_for_failed_condition | train | def check_for_failed_condition(conds)
failed = (conds || []).find { |c, v| !check_condition?(c, v) }
if failed
failed[0] = failed[0][0..-2].to_sym if failed[0][-1] == '!'
end
failed
end | ruby | {
"resource": ""
} |
q1209 | Scorched.Controller.check_condition? | train | def check_condition?(c, v)
c = c[0..-2].to_sym if invert = (c[-1] == '!')
raise Error, "The condition `#{c}` either does not exist, or is not an instance of Proc" unless Proc === self.conditions[c]
retval = instance_exec(v, &self.conditions[c])
invert ? !retval : !!retval
end | ruby | {
"resource": ""
} |
q1210 | Scorched.Controller.redirect | train | def redirect(url, status: (env['HTTP_VERSION'] == 'HTTP/1.1') ? 303 : 302, halt: true)
response['Location'] = absolute(url)
response.status = status
self.halt if halt
end | ruby | {
"resource": ""
} |
q1211 | Scorched.Controller.flash | train | def flash(key = :flash)
raise Error, "Flash session data cannot be used without a valid Rack session" unless session
flash_hash = env['scorched.flash'] ||= {}
flash_hash[key] ||= {}
session[key] ||= {}
unless session[key].methods(false).include? :[]=
session[key].define_singleton_m... | ruby | {
"resource": ""
} |
q1212 | Scorched.Controller.run_filters | train | def run_filters(type)
halted = false
tracker = env['scorched.executed_filters'] ||= {before: Set.new, after: Set.new}
filters[type].reject { |f| tracker[type].include?(f) }.each do |f|
unless check_for_failed_condition(f[:conditions]) || (halted && !f[:force])
tracker[type] << f
... | ruby | {
"resource": ""
} |
q1213 | Scorched.Request.unescaped_path | train | def unescaped_path
path_info.split(/(%25|%2F)/i).each_slice(2).map { |v, m| URI.unescape(v) << (m || '') }.join('')
end | ruby | {
"resource": ""
} |
q1214 | SoftLayer.Server.reboot! | train | def reboot!(reboot_technique = :default_reboot)
case reboot_technique
when :default_reboot
self.service.rebootDefault
when :os_reboot
self.service.rebootSoft
when :power_cycle
self.service.rebootHard
else
raise ArgumentError, "Unrecognized reboot technique i... | ruby | {
"resource": ""
} |
q1215 | SoftLayer.Server.notes= | train | def notes=(new_notes)
raise ArgumentError, "The new notes cannot be nil" unless new_notes
edit_template = {
"notes" => new_notes
}
self.service.editObject(edit_template)
self.refresh_details()
end | ruby | {
"resource": ""
} |
q1216 | SoftLayer.Server.set_hostname! | train | def set_hostname!(new_hostname)
raise ArgumentError, "The new hostname cannot be nil" unless new_hostname
raise ArgumentError, "The new hostname cannot be empty" if new_hostname.empty?
edit_template = {
"hostname" => new_hostname
}
self.service.editObject(edit_template)
sel... | ruby | {
"resource": ""
} |
q1217 | SoftLayer.Server.set_domain! | train | def set_domain!(new_domain)
raise ArgumentError, "The new hostname cannot be nil" unless new_domain
raise ArgumentError, "The new hostname cannot be empty" if new_domain.empty?
edit_template = {
"domain" => new_domain
}
self.service.editObject(edit_template)
self.refresh_de... | ruby | {
"resource": ""
} |
q1218 | SoftLayer.Server.change_port_speed | train | def change_port_speed(new_speed, public = true)
if public
self.service.setPublicNetworkInterfaceSpeed(new_speed)
else
self.service.setPrivateNetworkInterfaceSpeed(new_speed)
end
self.refresh_details()
self
end | ruby | {
"resource": ""
} |
q1219 | SoftLayer.Server.reload_os! | train | def reload_os!(token = '', provisioning_script_uri = nil, ssh_keys = nil)
configuration = {}
configuration['customProvisionScriptUri'] = provisioning_script_uri if provisioning_script_uri
configuration['sshKeyIds'] = ssh_keys if ssh_keys
self.service.reloadOperatingSystem(token, configuration)... | ruby | {
"resource": ""
} |
q1220 | Drone.Plugin.parse | train | def parse
self.result ||= Payload.new.tap do |payload|
PayloadRepresenter.new(
payload
).from_json(
input
)
end
rescue MultiJson::ParseError
raise InvalidJsonError
end | ruby | {
"resource": ""
} |
q1221 | SoftLayer.APIParameterFilter.object_filter | train | def object_filter(filter)
raise ArgumentError, "object_filter expects an instance of SoftLayer::ObjectFilter" if filter.nil? || !filter.kind_of?(SoftLayer::ObjectFilter)
# we create a new object in case the user wants to store off the
# filter chain and reuse it later
APIParameterFilter.new(self.target... | ruby | {
"resource": ""
} |
q1222 | SoftLayer.VirtualServerUpgradeOrder.verify | train | def verify()
if has_order_items?
order_template = order_object
order_template = yield order_object if block_given?
@virtual_server.softlayer_client[:Product_Order].verifyOrder(order_template)
end
end | ruby | {
"resource": ""
} |
q1223 | SoftLayer.VirtualServerUpgradeOrder.place_order! | train | def place_order!()
if has_order_items?
order_template = order_object
order_template = yield order_object if block_given?
@virtual_server.softlayer_client[:Product_Order].placeOrder(order_template)
end
end | ruby | {
"resource": ""
} |
q1224 | SoftLayer.VirtualServerUpgradeOrder._item_prices_in_category | train | def _item_prices_in_category(which_category)
@virtual_server.upgrade_options.select { |item_price| item_price['categories'].find { |category| category['categoryCode'] == which_category } }
end | ruby | {
"resource": ""
} |
q1225 | SoftLayer.VirtualServerUpgradeOrder._item_price_with_capacity | train | def _item_price_with_capacity(which_category, capacity)
_item_prices_in_category(which_category).find { |item_price| item_price['item']['capacity'].to_i == capacity}
end | ruby | {
"resource": ""
} |
q1226 | SoftLayer.VirtualServerUpgradeOrder.order_object | train | def order_object
prices = []
cores_price_item = @cores ? _item_price_with_capacity("guest_core", @cores) : nil
ram_price_item = @ram ? _item_price_with_capacity("ram", @ram) : nil
max_port_speed_price_item = @max_port_speed ? _item_price_with_capacity("port_speed", @max_port_speed) : nil
... | ruby | {
"resource": ""
} |
q1227 | SoftLayer.NetworkStorage.assign_credential | train | def assign_credential(username)
raise ArgumentError, "The username cannot be nil" unless username
raise ArgumentError, "The username cannot be empty" if username.empty?
self.service.assignCredential(username.to_s)
@credentials = nil
end | ruby | {
"resource": ""
} |
q1228 | SoftLayer.NetworkStorage.password= | train | def password=(password)
raise ArgumentError, "The new password cannot be nil" unless password
raise ArgumentError, "The new password cannot be empty" if password.empty?
self.service.editObject({ "password" => password.to_s })
self.refresh_details()
end | ruby | {
"resource": ""
} |
q1229 | SoftLayer.NetworkStorage.remove_credential | train | def remove_credential(username)
raise ArgumentError, "The username cannot be nil" unless username
raise ArgumentError, "The username cannot be empty" if username.empty?
self.service.removeCredential(username.to_s)
@credentials = nil
end | ruby | {
"resource": ""
} |
q1230 | SoftLayer.NetworkStorage.softlayer_properties | train | def softlayer_properties(object_mask = nil)
my_service = self.service
if(object_mask)
my_service = my_service.object_mask(object_mask)
else
my_service = my_service.object_mask(self.class.default_object_mask)
end
my_service.getObject()
end | ruby | {
"resource": ""
} |
q1231 | SoftLayer.NetworkStorage.update_credential_password | train | def update_credential_password(username, password)
raise ArgumentError, "The new password cannot be nil" unless password
raise ArgumentError, "The new username cannot be nil" unless username
raise ArgumentError, "The new password cannot be empty" if password.empty?
raise ArgumentError, "The ... | ruby | {
"resource": ""
} |
q1232 | SoftLayer.ProductPackage.items_with_description | train | def items_with_description(expected_description)
filter = ObjectFilter.new { |filter| filter.accept("items.description").when_it is(expected_description) }
items_data = self.service.object_filter(filter).getItems()
items_data.collect do |item_data|
first_price = item_data['prices'][0]
... | ruby | {
"resource": ""
} |
q1233 | SoftLayer.ImageTemplate.available_datacenters | train | def available_datacenters
datacenters_data = self.service.getStorageLocations()
datacenters_data.collect { |datacenter_data| SoftLayer::Datacenter.datacenter_named(datacenter_data['name']) }
end | ruby | {
"resource": ""
} |
q1234 | SoftLayer.ImageTemplate.shared_with_accounts= | train | def shared_with_accounts= (account_id_list)
already_sharing_with = self.shared_with_accounts
accounts_to_add = account_id_list.select { |account_id| !already_sharing_with.include?(account_id) }
# Note, using the network API, it is possible to "unshare" an image template
# with the account that... | ruby | {
"resource": ""
} |
q1235 | SoftLayer.ImageTemplate.wait_until_ready | train | def wait_until_ready(max_trials, seconds_between_tries = 2)
# pessimistically assume the server is not ready
num_trials = 0
begin
self.refresh_details()
parent_ready = !(has_sl_property? :transactionId) || (self[:transactionId] == "")
children_ready = (nil == self['children'].... | ruby | {
"resource": ""
} |
q1236 | SoftLayer.ServerFirewallOrder.verify | train | def verify()
order_template = firewall_order_template
order_template = yield order_template if block_given?
server.softlayer_client[:Product_Order].verifyOrder(order_template)
end | ruby | {
"resource": ""
} |
q1237 | SoftLayer.VLANFirewall.cancel! | train | def cancel!(notes = nil)
user = self.softlayer_client[:Account].object_mask("mask[id,account.id]").getCurrentUser
notes = "Cancelled by a call to #{__method__} in the softlayer_api gem" if notes == nil || notes == ""
cancellation_request = {
'accountId' => user['account']['id'],
'user... | ruby | {
"resource": ""
} |
q1238 | SoftLayer.VLANFirewall.change_rules_bypass! | train | def change_rules_bypass!(bypass_symbol)
change_object = {
"firewallContextAccessControlListId" => rules_ACL_id(),
"rules" => self.rules
}
case bypass_symbol
when :apply_firewall_rules
change_object['bypassFlag'] = false
self.softlayer_client[:Network_Firewall_Upd... | ruby | {
"resource": ""
} |
q1239 | SoftLayer.VLANFirewall.change_routing_bypass! | train | def change_routing_bypass!(routing_symbol)
vlan_firewall_id = self['networkVlanFirewall']['id']
raise "Could not identify the device for a VLAN firewall" if !vlan_firewall_id
case routing_symbol
when :route_through_firewall
self.softlayer_client[:Network_Vlan_Firewall].object_with_id(v... | ruby | {
"resource": ""
} |
q1240 | SoftLayer.VLANFirewall.rules_ACL_id | train | def rules_ACL_id
outside_interface_data = self['firewallInterfaces'].find { |interface_data| interface_data['name'] == 'outside' }
incoming_ACL = outside_interface_data['firewallContextAccessControlLists'].find { |firewallACL_data| firewallACL_data['direction'] == 'in' } if outside_interface_data
if ... | ruby | {
"resource": ""
} |
q1241 | SoftLayer.VirtualServerOrder.place_order! | train | def place_order!()
order_template = virtual_guest_template
order_template = yield order_template if block_given?
virtual_server_hash = @softlayer_client[:Virtual_Guest].createObject(order_template)
SoftLayer::VirtualServer.server_with_id(virtual_server_hash['id'], :client => @softlayer_client) ... | ruby | {
"resource": ""
} |
q1242 | SoftLayer.Software.delete_user_password! | train | def delete_user_password!(username)
user_password = self.passwords.select { |sw_pw| sw_pw.username == username.to_s }
unless user_password.empty?
softlayer_client[:Software_Component_Password].object_with_id(user_password.first['id']).deleteObject
@passwords = nil
end
end | ruby | {
"resource": ""
} |
q1243 | Danger.DangerTodoist.print_todos_table | train | def print_todos_table
find_todos if @todos.nil?
return if @todos.empty?
markdown("#### Todos left in files")
@todos
.group_by(&:file)
.each { |file, todos| print_todos_per_file(file, todos) }
end | ruby | {
"resource": ""
} |
q1244 | SoftLayer.VirtualServerOrder_Package.virtual_server_order | train | def virtual_server_order
product_order = {
'packageId' => @package.id,
'useHourlyPricing' => !!@hourly,
'virtualGuests' => [{
'domain' => @domain,
'hostname' => @hostname
}]
}... | ruby | {
"resource": ""
} |
q1245 | SoftLayer.VirtualServer.capture_image | train | def capture_image(image_name, include_attached_storage = false, image_notes = '')
image_notes = '' if !image_notes
image_name = 'Captured Image' if !image_name
disk_filter = lambda { |disk| disk['device'] == '0' }
disk_filter = lambda { |disk| disk['device'] != '1' } if include_attached_storage... | ruby | {
"resource": ""
} |
q1246 | SoftLayer.VirtualServer.wait_until_ready | train | def wait_until_ready(max_trials, wait_for_transactions = false, seconds_between_tries = 2)
# pessimistically assume the server is not ready
num_trials = 0
begin
self.refresh_details()
has_os_reload = has_sl_property? :lastOperatingSystemReload
has_active_transaction = has_sl_p... | ruby | {
"resource": ""
} |
q1247 | SoftLayer.Account.find_vlan_with_number | train | def find_vlan_with_number(vlan_number)
filter = SoftLayer::ObjectFilter.new() { |filter|
filter.accept('networkVlans.vlanNumber').when_it is vlan_number
}
vlan_data = self.service.object_mask("mask[id,vlanNumber,primaryRouter,networkSpace]").object_filter(filter).getNetworkVlans
return ... | ruby | {
"resource": ""
} |
q1248 | SoftLayer.Client.service_named | train | def service_named(service_name, service_options = {})
raise ArgumentError,"Please provide a service name" if service_name.nil? || service_name.empty?
# Strip whitespace from service_name and ensure that it starts with "SoftLayer_".
# If it does not, then add the prefix.
full_name = service_name... | ruby | {
"resource": ""
} |
q1249 | SoftLayer.Service.call_softlayer_api_with_params | train | def call_softlayer_api_with_params(method_name, parameters, args)
additional_headers = {};
# The client knows about authentication, so ask him for the auth headers
authentication_headers = self.client.authentication_headers
additional_headers.merge!(authentication_headers)
if parameters ... | ruby | {
"resource": ""
} |
q1250 | ILO_SDK.BiosHelper.set_bios_settings | train | def set_bios_settings(options, system_id = 1)
r = response_handler(rest_patch("/redfish/v1/Systems/#{system_id}/bios/Settings/", body: options))
@logger.warn(r) if r['error']
true
end | ruby | {
"resource": ""
} |
q1251 | ILO_SDK.BiosHelper.set_uefi_shell_startup | train | def set_uefi_shell_startup(uefi_shell_startup, uefi_shell_startup_location, uefi_shell_startup_url)
new_action = {
'UefiShellStartup' => uefi_shell_startup,
'UefiShellStartupLocation' => uefi_shell_startup_location,
'UefiShellStartupUrl' => uefi_shell_startup_url
}
response = r... | ruby | {
"resource": ""
} |
q1252 | ILO_SDK.BiosHelper.get_bios_dhcp | train | def get_bios_dhcp
response = rest_get('/redfish/v1/Systems/1/bios/Settings/')
bios = response_handler(response)
{
'Dhcpv4' => bios['Dhcpv4'],
'Ipv4Address' => bios['Ipv4Address'],
'Ipv4Gateway' => bios['Ipv4Gateway'],
'Ipv4PrimaryDNS' => bios['Ipv4PrimaryDNS'],
... | ruby | {
"resource": ""
} |
q1253 | ILO_SDK.BiosHelper.set_bios_dhcp | train | def set_bios_dhcp(dhcpv4, ipv4_address = '', ipv4_gateway = '', ipv4_primary_dns = '', ipv4_secondary_dns = '', ipv4_subnet_mask = '')
new_action = {
'Dhcpv4' => dhcpv4,
'Ipv4Address' => ipv4_address,
'Ipv4Gateway' => ipv4_gateway,
'Ipv4PrimaryDNS' => ipv4_primary_dns,
'Ipv... | ruby | {
"resource": ""
} |
q1254 | ILO_SDK.BiosHelper.set_url_boot_file | train | def set_url_boot_file(url_boot_file)
new_action = { 'UrlBootFile' => url_boot_file }
response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1255 | ILO_SDK.BiosHelper.set_bios_service | train | def set_bios_service(name, email)
new_action = {
'ServiceName' => name,
'ServiceEmail' => email
}
response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1256 | ILO_SDK.LogEntryHelper.clear_logs | train | def clear_logs(log_type)
new_action = { 'Action' => 'ClearLog' }
response = rest_post(uri_for_log_type(log_type), body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1257 | ILO_SDK.LogEntryHelper.get_logs | train | def get_logs(severity_level, duration, log_type)
response = rest_get("#{uri_for_log_type(log_type)}Entries/")
entries = response_handler(response)['Items']
start_time = Time.now.utc - (duration * 3600)
if severity_level.nil?
entries.select { |e| Time.parse(e['Created']) > start_time }
... | ruby | {
"resource": ""
} |
q1258 | ILO_SDK.ComputerDetailsHelper.get_computer_details | train | def get_computer_details
general_computer_details = get_general_computer_details
computer_network_details = get_computer_network_details
array_controller_details = get_array_controller_details
general_computer_details.merge(computer_network_details).merge(array_controller_details)
end | ruby | {
"resource": ""
} |
q1259 | ILO_SDK.ComputerDetailsHelper.get_general_computer_details | train | def get_general_computer_details
response = rest_get('/redfish/v1/Systems/1/')
details = response_handler(response)
{
'GeneralDetails' => {
'manufacturer' => details['Manufacturer'],
'model' => details['Model'],
'AssetTag' => details['AssetTag'],
'bios_v... | ruby | {
"resource": ""
} |
q1260 | ILO_SDK.ComputerDetailsHelper.get_computer_network_details | train | def get_computer_network_details
network_adapters = []
response = rest_get('/redfish/v1/Systems/1/NetworkAdapters/')
networks = response_handler(response)['links']['Member']
networks.each do |network|
response = rest_get(network['href'])
detail = response_handler(response)
... | ruby | {
"resource": ""
} |
q1261 | ILO_SDK.FirmwareUpdateHelper.set_fw_upgrade | train | def set_fw_upgrade(uri, tpm_override_flag = true)
new_action = { 'Action' => 'InstallFromURI', 'FirmwareURI' => uri, 'TPMOverrideFlag' => tpm_override_flag }
response = rest_post('/redfish/v1/Managers/1/UpdateService/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1262 | Sprockets.Helpers.asset_path | train | def asset_path(source, options = {})
uri = URI.parse(source)
return source if uri.absolute?
options[:prefix] = Sprockets::Helpers.prefix unless options[:prefix]
if Helpers.debug || options[:debug]
options[:manifest] = false
options[:digest] = false
options[:asset_host] ... | ruby | {
"resource": ""
} |
q1263 | ILO_SDK.ChassisHelper.get_power_metrics | train | def get_power_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
power_metrics_uri = response_handler(rest_get(chassis_uri))['links']['PowerMetrics']['href']
response = rest_get(power_metrics_uri)
metrics = response_hand... | ruby | {
"resource": ""
} |
q1264 | ILO_SDK.ChassisHelper.get_thermal_metrics | train | def get_thermal_metrics
chassis = rest_get('/redfish/v1/Chassis/')
chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
thermal_metrics_uri = response_handler(rest_get(chassis_uri))['links']['ThermalMetrics']['href']
response = rest_get(thermal_metrics_uri)
temperatures = ... | ruby | {
"resource": ""
} |
q1265 | ILO_SDK.DateTimeHelper.set_time_zone | train | def set_time_zone(time_zone)
time_response = rest_get('/redfish/v1/Managers/1/DateTime/')
new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone }
new_action = { 'TimeZone' => { 'Index' => new_time_zone[0]['Index'] } }
response = rest_pa... | ruby | {
"resource": ""
} |
q1266 | ILO_SDK.DateTimeHelper.set_ntp | train | def set_ntp(use_ntp)
new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } }
response = rest_patch('/redfish/v1/Managers/1/EthernetInterfaces/1/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1267 | ILO_SDK.DateTimeHelper.set_ntp_servers | train | def set_ntp_servers(ntp_servers)
new_action = { 'StaticNTPServers' => ntp_servers }
response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1268 | ILO_SDK.Cli.output | train | def output(data = {}, indent = 0)
case @options['format']
when 'json'
puts JSON.pretty_generate(data)
when 'yaml'
puts data.to_yaml
else
# rubocop:disable Metrics/BlockNesting
if data.class == Hash
data.each do |k, v|
if v.class == Hash || v.... | ruby | {
"resource": ""
} |
q1269 | ILO_SDK.BootSettingsHelper.set_boot_order | train | def set_boot_order(boot_order)
new_action = { 'PersistentBootConfigOrder' => boot_order }
response = rest_patch('/redfish/v1/systems/1/bios/Boot/Settings/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1270 | ILO_SDK.BootSettingsHelper.set_temporary_boot_order | train | def set_temporary_boot_order(boot_target)
response = rest_get('/redfish/v1/Systems/1/')
boottargets = response_handler(response)['Boot']['BootSourceOverrideSupported']
unless boottargets.include? boot_target
raise "BootSourceOverrideTarget value - #{boot_target} is not supported. Valid values ... | ruby | {
"resource": ""
} |
q1271 | ILO_SDK.ServiceRootHelper.get_schema | train | def get_schema(schema_prefix)
response = rest_get('/redfish/v1/Schemas/')
schemas = response_handler(response)['Items']
schema = schemas.select { |s| s['Schema'].start_with?(schema_prefix) }
raise "NO schema found with this schema prefix : #{schema_prefix}" if schema.empty?
info = []
... | ruby | {
"resource": ""
} |
q1272 | ILO_SDK.ServiceRootHelper.get_registry | train | def get_registry(registry_prefix)
response = rest_get('/redfish/v1/Registries/')
registries = response_handler(response)['Items']
registry = registries.select { |reg| reg['Schema'].start_with?(registry_prefix) }
info = []
registry.each do |reg|
response = rest_get(reg['Location'][0... | ruby | {
"resource": ""
} |
q1273 | ILO_SDK.ManagerNetworkProtocolHelper.set_timeout | train | def set_timeout(timeout)
new_action = { 'SessionTimeoutMinutes' => timeout }
response = rest_patch('/redfish/v1/Managers/1/NetworkService/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1274 | ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dhcp | train | def set_ilo_ipv4_dhcp(manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => {
'Enabled' => true,
'UseDNSServers' => true,
'UseDomainName' => true,
'UseGateway' => true,
'UseNTPServer... | ruby | {
"resource": ""
} |
q1275 | ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_static | train | def set_ilo_ipv4_static(ip:, netmask:, gateway: '0.0.0.0', manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } },
'IPv4Addresses' => [
'Address' => ip, 'SubnetMask' => netmask, 'Gateway' => gateway
]
}
respons... | ruby | {
"resource": ""
} |
q1276 | ILO_SDK.EthernetInterfaceHelper.set_ilo_ipv4_dns_servers | train | def set_ilo_ipv4_dns_servers(dns_servers:, manager_id: 1, ethernet_interface: 1)
new_action = {
'Oem' => {
'Hp' => {
'DHCPv4' => { 'UseDNSServers' => false },
'IPv4' => { 'DNSServers' => dns_servers }
}
}
}
response = rest_patch("/redfish/v1/... | ruby | {
"resource": ""
} |
q1277 | ILO_SDK.EthernetInterfaceHelper.set_ilo_hostname | train | def set_ilo_hostname(hostname:, domain_name: nil, manager_id: 1, ethernet_interface: 1)
new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } }
new_action['Oem']['Hp'].merge!('DHCPv4' => {}, 'DHCPv6' => {}) if domain_name
new_action['Oem']['Hp']['DHCPv4']['UseDomainName'] = false if domain_na... | ruby | {
"resource": ""
} |
q1278 | ILO_SDK.Rest.rest_api | train | def rest_api(type, path, options = {})
raise InvalidRequest, 'Must specify path' unless path
raise InvalidRequest, 'Must specify type' unless type
@logger.debug "Making :#{type} rest call to #{@host}#{path}"
uri = URI.parse(URI.escape("#{@host}#{path}"))
http = @disable_proxy ? Net::HTTP.... | ruby | {
"resource": ""
} |
q1279 | ILO_SDK.Rest.response_handler | train | def response_handler(response)
case response.code.to_i
when RESPONSE_CODE_OK # Synchronous read/query
begin
return JSON.parse(response.body)
rescue JSON::ParserError => e
@logger.warn "Failed to parse JSON response. #{e}"
return response.body
end
w... | ruby | {
"resource": ""
} |
q1280 | ILO_SDK.ManagerAccountHelper.get_account_privileges | train | def get_account_privileges(username)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
accounts.each do |account|
if account['Oem']['Hp']['LoginName'] == username
return account['Oem']['Hp']['Privileges']
end
end
... | ruby | {
"resource": ""
} |
q1281 | ILO_SDK.ManagerAccountHelper.set_account_privileges | train | def set_account_privileges(username, privileges)
response = rest_get('/redfish/v1/AccountService/Accounts/')
accounts = response_handler(response)['Items']
id = '0'
accounts.each do |account|
if account['Oem']['Hp']['LoginName'] == username
id = account['Id']
break
... | ruby | {
"resource": ""
} |
q1282 | ILO_SDK.HttpsCertHelper.get_certificate | train | def get_certificate
uri = URI.parse(URI.escape(@host))
options = { use_ssl: true, verify_mode: OpenSSL::SSL::VERIFY_NONE }
Net::HTTP.start(uri.host, uri.port, options) do |http|
http.peer_cert
end
end | ruby | {
"resource": ""
} |
q1283 | ILO_SDK.HttpsCertHelper.generate_csr | train | def generate_csr(country, state, city, org_name, org_unit, common_name)
new_action = {
'Action' => 'GenerateCSR',
'Country' => country,
'State' => state,
'City' => city,
'OrgName' => org_name,
'OrgUnit' => org_unit,
'CommonName' => common_name
}
... | ruby | {
"resource": ""
} |
q1284 | ILO_SDK.SecureBootHelper.set_uefi_secure_boot | train | def set_uefi_secure_boot(secure_boot_enable)
new_action = { 'SecureBootEnable' => secure_boot_enable }
response = rest_patch('/redfish/v1/Systems/1/SecureBoot/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1285 | ILO_SDK.PowerHelper.set_power_state | train | def set_power_state(state)
new_action = { 'Action' => 'Reset', 'ResetType' => state }
response = rest_post('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1286 | ILO_SDK.SNMPServiceHelper.set_snmp | train | def set_snmp(snmp_mode, snmp_alerts)
new_action = { 'Mode' => snmp_mode, 'AlertsEnabled' => snmp_alerts }
response = rest_patch('/redfish/v1/Managers/1/SnmpService/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1287 | ILO_SDK.VirtualMediaHelper.get_virtual_media | train | def get_virtual_media
response = rest_get('/redfish/v1/Managers/1/VirtualMedia/')
media = {}
response_handler(response)['links']['Member'].each do |vm|
response = rest_get(vm['href'])
virtual_media = response_handler(response)
media[virtual_media['Id']] = {
'Image' =>... | ruby | {
"resource": ""
} |
q1288 | ILO_SDK.VirtualMediaHelper.insert_virtual_media | train | def insert_virtual_media(id, image)
new_action = {
'Action' => 'InsertVirtualMedia',
'Target' => '/Oem/Hp',
'Image' => image
}
response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1289 | ILO_SDK.VirtualMediaHelper.eject_virtual_media | train | def eject_virtual_media(id)
new_action = {
'Action' => 'EjectVirtualMedia',
'Target' => '/Oem/Hp'
}
response = rest_post("/redfish/v1/Managers/1/VirtualMedia/#{id}/", body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1290 | ILO_SDK.ComputerSystemHelper.set_asset_tag | train | def set_asset_tag(asset_tag)
@logger.warn '[Deprecated] `set_asset_tag` is deprecated. Please use `set_system_settings(AssetTag: <tag>)` instead.'
new_action = { 'AssetTag' => asset_tag }
response = rest_patch('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
true
... | ruby | {
"resource": ""
} |
q1291 | ILO_SDK.ComputerSystemHelper.set_indicator_led | train | def set_indicator_led(state)
@logger.warn '[Deprecated] `set_indicator_led` is deprecated. Please use `set_system_settings(IndicatorLED: <state>)` instead.'
new_action = { 'IndicatorLED' => state }
response = rest_patch('/redfish/v1/Systems/1/', body: new_action)
response_handler(response)
... | ruby | {
"resource": ""
} |
q1292 | ILO_SDK.AccountServiceHelper.userhref | train | def userhref(uri, username)
response = rest_get(uri)
items = response_handler(response)['Items']
items.each do |it|
return it['links']['self']['href'] if it['UserName'] == username
end
end | ruby | {
"resource": ""
} |
q1293 | ILO_SDK.AccountServiceHelper.create_user | train | def create_user(username, password)
new_action = { 'UserName' => username, 'Password' => password, 'Oem' => { 'Hp' => { 'LoginName' => username } } }
response = rest_post('/redfish/v1/AccountService/Accounts/', body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1294 | ILO_SDK.AccountServiceHelper.change_password | train | def change_password(username, password)
new_action = { 'Password' => password }
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response = rest_patch(userhref, body: new_action)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1295 | ILO_SDK.AccountServiceHelper.delete_user | train | def delete_user(username)
userhref = userhref('/redfish/v1/AccountService/Accounts/', username)
response = rest_delete(userhref)
response_handler(response)
true
end | ruby | {
"resource": ""
} |
q1296 | Proxmox.Proxmox.templates | train | def templates
data = http_action_get "nodes/#{@node}/storage/local/content"
template_list = {}
data.each do |ve|
name = ve['volid'].gsub(%r{local:vztmpl\/(.*).tar.gz}, '\1')
template_list[name] = ve
end
template_list
end | ruby | {
"resource": ""
} |
q1297 | Proxmox.Proxmox.openvz_get | train | def openvz_get
data = http_action_get "nodes/#{@node}/openvz"
ve_list = {}
data.each do |ve|
ve_list[ve['vmid']] = ve
end
ve_list
end | ruby | {
"resource": ""
} |
q1298 | Proxmox.Proxmox.openvz_post | train | def openvz_post(ostemplate, vmid, config = {})
config['vmid'] = vmid
config['ostemplate'] = "local%3Avztmpl%2F#{ostemplate}.tar.gz"
vm_definition = config.to_a.map { |v| v.join '=' }.join '&'
http_action_post("nodes/#{@node}/openvz", vm_definition)
end | ruby | {
"resource": ""
} |
q1299 | Proxmox.Proxmox.create_ticket | train | def create_ticket
post_param = { username: @username, realm: @realm, password: @password }
@site['access/ticket'].post post_param do |response, _request, _result, &_block|
if response.code == 200
extract_ticket response
else
@connection_status = 'error'
end
... | ruby | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.